use of javax.jcr.query.qom.Constraint in project jackrabbit by apache.
the class SQL2PathEscapingTest method testGetChildrenApiDirect.
/**
* will build a query directly via the api using a spaced path
*
* @throws Exception
*/
public void testGetChildrenApiDirect() throws Exception {
QueryObjectModelFactory qomf = qm.getQOMFactory();
Source source1 = qomf.selector(NodeType.NT_BASE, "selector");
Column[] columns = new Column[] { qomf.column("selector", null, null) };
Constraint constraint2 = qomf.childNode("selector", n1.getPath());
QueryObjectModel qom = qomf.createQuery(source1, constraint2, null, columns);
checkResult(qom.execute(), 2);
}
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