use of javax.jcr.query.qom.Constraint 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());
}
use of javax.jcr.query.qom.Constraint 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.Constraint in project jackrabbit by apache.
the class QOMFormatter method format.
private String format() throws RepositoryException {
append("SELECT ");
append(qom.getColumns());
append(" FROM ");
append(qom.getSource());
Constraint c = qom.getConstraint();
if (c != null) {
append(" WHERE ");
append(c);
}
Ordering[] orderings = qom.getOrderings();
if (orderings.length > 0) {
append(" ORDER BY ");
append(orderings);
}
return sb.toString();
}
use of javax.jcr.query.qom.Constraint 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.Constraint in project jackrabbit by apache.
the class Parser method parseConditionFuntionIf.
private Constraint parseConditionFuntionIf(String functionName) throws RepositoryException {
Constraint c;
if ("CONTAINS".equalsIgnoreCase(functionName)) {
String name = readName();
if (readIf(".")) {
if (readIf("*")) {
read(",");
c = factory.fullTextSearch(name, null, parseStaticOperand());
} else {
String selector = name;
name = readName();
read(",");
c = factory.fullTextSearch(selector, name, parseStaticOperand());
}
} else {
read(",");
c = factory.fullTextSearch(getOnlySelectorName(name), name, parseStaticOperand());
}
} else if ("ISSAMENODE".equalsIgnoreCase(functionName)) {
String name = readName();
if (readIf(",")) {
c = factory.sameNode(name, readPath());
} else {
c = factory.sameNode(getOnlySelectorName(name), name);
}
} else if ("ISCHILDNODE".equalsIgnoreCase(functionName)) {
String name = readName();
if (readIf(",")) {
c = factory.childNode(name, readPath());
} else {
c = factory.childNode(getOnlySelectorName(name), name);
}
} else if ("ISDESCENDANTNODE".equalsIgnoreCase(functionName)) {
String name = readName();
if (readIf(",")) {
c = factory.descendantNode(name, readPath());
} else {
c = factory.descendantNode(getOnlySelectorName(name), name);
}
} else {
return null;
}
read(")");
return c;
}
Aggregations