Search in sources :

Example 76 with QueryObjectModel

use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.

the class UpperLowerCaseTest method checkQueries.

// -------------------------------< internal >-------------------------------
private void checkQueries(DynamicOperand operand, boolean toUpper, String operator, String[] literals, int type, boolean[] matches) throws RepositoryException {
    for (int i = 0; i < literals.length; i++) {
        QueryObjectModel qom = createQuery(operand, toUpper, operator, vf.createValue(literals[i], type));
        checkQOM(qom, matches[i] ? new Node[] { node } : new Node[0]);
    }
}
Also used : Node(javax.jcr.Node) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Example 77 with QueryObjectModel

use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.

the class ParserTest method formatLiteral.

private void formatLiteral(String literal, String cast) throws Exception {
    String s = "SELECT TEST.* FROM TEST WHERE ID=" + literal;
    QueryObjectModel qom = parser.createQueryObjectModel(s);
    String s2 = QOMFormatter.format(qom);
    String cast2 = s2.substring(s2.indexOf('=') + 1).trim();
    assertEquals(cast, cast2);
    qom = parser.createQueryObjectModel(s);
    s2 = QOMFormatter.format(qom);
    cast2 = s2.substring(s2.indexOf('=') + 1).trim();
    assertEquals(cast, cast2);
}
Also used : QueryObjectModel(javax.jcr.query.qom.QueryObjectModel)

Example 78 with QueryObjectModel

use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.

the class ParserTest method testParseScript.

public void testParseScript() throws Exception {
    LineNumberReader reader = openScript("test.sql2.txt");
    while (true) {
        String line = reader.readLine();
        if (line == null) {
            break;
        }
        line = line.trim();
        if (line.length() == 0 || line.startsWith("#")) {
            continue;
        }
        // System.out.println(line);
        String query = line;
        try {
            QueryObjectModel qom = parser.createQueryObjectModel(line);
            String s = QOMFormatter.format(qom);
            qom = parser.createQueryObjectModel(s);
            String s2 = QOMFormatter.format(qom);
            assertEquals(s, s2);
            fuzz(line);
        } catch (Exception e) {
            line = reader.readLine();
            String message = e.getMessage();
            message = message.replace('\n', ' ');
            if (line == null || !line.startsWith("> exception")) {
                e.printStackTrace();
                assertTrue("Unexpected exception for query " + query + ": " + e, false);
            }
            assertEquals("Expected exception message: " + message, "> exception: " + message, line);
        }
    }
    reader.close();
}
Also used : QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) ItemExistsException(javax.jcr.ItemExistsException) ConstraintViolationException(javax.jcr.nodetype.ConstraintViolationException) PathNotFoundException(javax.jcr.PathNotFoundException) VersionException(javax.jcr.version.VersionException) RepositoryException(javax.jcr.RepositoryException) LockException(javax.jcr.lock.LockException) NamespaceException(javax.jcr.NamespaceException) ValueFormatException(javax.jcr.ValueFormatException) ItemNotFoundException(javax.jcr.ItemNotFoundException) UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) InvalidQueryException(javax.jcr.query.InvalidQueryException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LineNumberReader(java.io.LineNumberReader)

Aggregations

QueryObjectModel (javax.jcr.query.qom.QueryObjectModel)78 Value (javax.jcr.Value)18 Node (javax.jcr.Node)17 JoinCondition (javax.jcr.query.qom.JoinCondition)13 Selector (javax.jcr.query.qom.Selector)10 Query (javax.jcr.query.Query)8 RepositoryException (javax.jcr.RepositoryException)7 Column (javax.jcr.query.qom.Column)7 Ordering (javax.jcr.query.qom.Ordering)7 Source (javax.jcr.query.qom.Source)7 PropertyExistence (javax.jcr.query.qom.PropertyExistence)6 QueryResult (javax.jcr.query.QueryResult)5 RowIterator (javax.jcr.query.RowIterator)5 PropertyValue (javax.jcr.query.qom.PropertyValue)5 ArrayList (java.util.ArrayList)4 NodeType (javax.jcr.nodetype.NodeType)4 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)4 InvalidQueryException (javax.jcr.query.InvalidQueryException)4 Constraint (javax.jcr.query.qom.Constraint)4 NodeTypeIterator (javax.jcr.nodetype.NodeTypeIterator)3