use of javax.jcr.query.qom.Not in project jackrabbit-oak by apache.
the class QomTest method not.
@Test
public void not() throws RepositoryException {
Constraint c = f.propertyExistence("x", "c0");
Not n = f.not(c);
assertEquals(c, n.getConstraint());
assertEquals("[x].[c0] IS NOT NULL", c.toString());
assertEquals("* IS NOT NULL", f.propertyExistence(null, null).toString());
assertEquals("[s].* IS NOT NULL", f.propertyExistence("s", null).toString());
assertEquals("[p] IS NOT NULL", f.propertyExistence(null, "p").toString());
assertEquals("[s].[p] IS NOT NULL", f.propertyExistence("s", "p").toString());
}
use of javax.jcr.query.qom.Not in project jackrabbit by apache.
the class QOMFormatter method append.
private void append(And constraint) throws RepositoryException {
String and = "";
for (Constraint c : Arrays.asList(constraint.getConstraint1(), constraint.getConstraint2())) {
append(and);
and = " AND ";
boolean paren = c instanceof Or || c instanceof Not;
if (paren) {
append("(");
}
append(c);
if (paren) {
append(")");
}
}
}
use of javax.jcr.query.qom.Not in project jackrabbit by apache.
the class ConstraintSplitter method split.
private void split(ConstraintSplitInfo constraintSplitInfo, Constraint constraint) throws RepositoryException {
if (constraint instanceof Not) {
splitNot(constraintSplitInfo, (Not) constraint);
} else if (constraint instanceof And) {
And and = (And) constraint;
split(constraintSplitInfo, and.getConstraint1());
split(constraintSplitInfo, and.getConstraint2());
} else if (constraint instanceof Or) {
if (isReferencingBothSides(getSelectorNames(constraint))) {
Or or = (Or) constraint;
// the problem here is when you split an OR that has both condition sides referencing both join sides.
// it should split into 2 joins
constraintSplitInfo.splitOr();
split(constraintSplitInfo.getLeftInnerConstraints(), or.getConstraint1());
split(constraintSplitInfo.getRightInnerConstraints(), or.getConstraint2());
} else {
splitBySelectors(constraintSplitInfo, constraint, getSelectorNames(constraint));
}
} else {
splitBySelectors(constraintSplitInfo, constraint, getSelectorNames(constraint));
}
}
use of javax.jcr.query.qom.Not in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testNot.
/**
* Test case for {@link QueryObjectModelFactory#not(Constraint)}
*/
public void testNot() throws RepositoryException {
PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
Not not = qf.not(propExist);
assertTrue("Not a property existence constraint", not.getConstraint() instanceof PropertyExistence);
}
use of javax.jcr.query.qom.Not in project jackrabbit by apache.
the class LuceneQueryFactory method create.
protected Query create(Constraint constraint, Map<String, NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException {
if (constraint instanceof And) {
return getAndQuery((And) constraint, selectorMap, searcher);
} else if (constraint instanceof Or) {
return getOrQuery((Or) constraint, selectorMap, searcher);
} else if (constraint instanceof Not) {
return getNotQuery((Not) constraint, selectorMap, searcher);
} else if (constraint instanceof PropertyExistence) {
return getPropertyExistenceQuery((PropertyExistence) constraint);
} else if (constraint instanceof Comparison) {
Comparison c = (Comparison) constraint;
Transform left = new Transform(c.getOperand1());
return getComparisonQuery(left.operand, left.transform, c.getOperator(), c.getOperand2(), selectorMap);
} else if (constraint instanceof FullTextSearch) {
return getFullTextSearchQuery((FullTextSearch) constraint);
} else if (constraint instanceof SameNode) {
SameNode sn = (SameNode) constraint;
return getNodeIdQuery(UUID, sn.getPath());
} else if (constraint instanceof ChildNode) {
ChildNode cn = (ChildNode) constraint;
return getNodeIdQuery(PARENT, cn.getParentPath());
} else if (constraint instanceof DescendantNode) {
DescendantNode dn = (DescendantNode) constraint;
return getDescendantNodeQuery(dn, searcher);
} else {
throw new UnsupportedRepositoryOperationException("Unknown constraint type: " + constraint);
}
}
Aggregations