use of javax.jcr.query.qom.Column in project jackrabbit by apache.
the class SQL2PathEscapingTest method testGetChildrenApiStatement.
/**
* the statement behind the api should be consistent, and return a similar
* query. in our case it should escape the paths that have spaces in them by
* enclosing them in single quotes
*
* @throws Exception
*/
public void testGetChildrenApiStatement() 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(executeSQL2Query(qom.getStatement()), 2);
}
use of javax.jcr.query.qom.Column in project jackrabbit by apache.
the class Parser method createQueryObjectModel.
/**
* Parse a JCR-SQL2 query and return the query object model
*
* @param query the query string
* @return the query object model
* @throws RepositoryException if parsing failed
*/
public QueryObjectModel createQueryObjectModel(String query) throws RepositoryException {
initialize(query);
selectors = new ArrayList<Selector>();
expected = new ArrayList<String>();
bindVariables = new HashMap<String, BindVariableValue>();
read();
read("SELECT");
int columnParseIndex = parseIndex;
ArrayList<ColumnOrWildcard> list = parseColumns();
read("FROM");
Source source = parseSource();
Column[] columnArray = resolveColumns(columnParseIndex, list);
Constraint constraint = null;
if (readIf("WHERE")) {
constraint = parseConstraint();
}
Ordering[] orderings = null;
if (readIf("ORDER")) {
read("BY");
orderings = parseOrder();
}
if (currentToken.length() > 0) {
throw getSyntaxError("<end>");
}
return factory.createQuery(source, constraint, orderings, columnArray);
}
use of javax.jcr.query.qom.Column in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testColumnWithSelector.
/**
* Test case for {@link QueryObjectModelFactory#column(String, String, String)}
*/
public void testColumnWithSelector() throws RepositoryException {
Column col = qf.column(SELECTOR_NAME1, propertyName1, COLUMN_NAME);
assertEquals("Wrong selector name", SELECTOR_NAME1, col.getSelectorName());
assertEquals("Wrong property name", propertyName1, col.getPropertyName());
assertEquals("Wrong column name", COLUMN_NAME, col.getColumnName());
}
use of javax.jcr.query.qom.Column in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testCreateQueryWithConstraintOrderingAndColumn.
public void testCreateQueryWithConstraintOrderingAndColumn() throws RepositoryException {
Selector selector = qf.selector(testNodeType, SELECTOR_NAME1);
PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
Ordering ordering = qf.ascending(propValue);
Column column = qf.column(SELECTOR_NAME1, propertyName1, propertyName1);
QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, new Column[] { column });
assertTrue("Not a selector source", qom.getSource() instanceof Selector);
assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
assertEquals("Wrong size of orderings", 1, qom.getOrderings().length);
assertEquals("Wrong size of columns", 1, qom.getColumns().length);
}
use of javax.jcr.query.qom.Column in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testCreateQueryFromSourceWithConstraintOrderingAndColumn.
public void testCreateQueryFromSourceWithConstraintOrderingAndColumn() throws RepositoryException {
Source selector = qf.selector(testNodeType, SELECTOR_NAME1);
PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
Ordering ordering = qf.ascending(propValue);
Column column = qf.column(SELECTOR_NAME1, propertyName1, propertyName1);
QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, new Column[] { column });
assertTrue("Not a selector source", qom.getSource() instanceof Selector);
assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
assertEquals("Wrong size of orderings", 1, qom.getOrderings().length);
assertEquals("Wrong size of columns", 1, qom.getColumns().length);
}
Aggregations