use of javax.jcr.query.qom.Or 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.Or in project jackrabbit by apache.
the class QOMFormatter method append.
private void append(Not constraint) throws RepositoryException {
append("NOT ");
Constraint c = constraint.getConstraint();
boolean paren = c instanceof And || c instanceof Or;
if (paren) {
append("(");
}
append(c);
if (paren) {
append(")");
}
}
use of javax.jcr.query.qom.Or 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.Or in project jackrabbit by apache.
the class LuceneQueryFactory method addBooleanConstraint.
protected void addBooleanConstraint(BooleanQuery query, Constraint constraint, Occur occur, Map<String, NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException {
if (occur == MUST && constraint instanceof And) {
And and = (And) constraint;
addBooleanConstraint(query, and.getConstraint1(), occur, selectorMap, searcher);
addBooleanConstraint(query, and.getConstraint2(), occur, selectorMap, searcher);
} else if (occur == SHOULD && constraint instanceof Or) {
Or or = (Or) constraint;
addBooleanConstraint(query, or.getConstraint1(), occur, selectorMap, searcher);
addBooleanConstraint(query, or.getConstraint2(), occur, selectorMap, searcher);
} else {
query.add(create(constraint, selectorMap, searcher), occur);
}
}
use of javax.jcr.query.qom.Or in project jackrabbit-oak by apache.
the class QomTest method or.
@Test
public void or() throws RepositoryException {
Constraint c0 = f.propertyExistence("x", "c0");
Constraint c1 = f.propertyExistence("x", "c1");
Or or = f.or(c0, c1);
assertEquals(or.getConstraint1(), c0);
assertEquals(or.getConstraint2(), c1);
assertEquals("([x].[c0] IS NOT NULL) OR ([x].[c1] IS NOT NULL)", or.toString());
}
Aggregations