Package javax.jcr.query.qom

Examples of javax.jcr.query.qom.Constraint


        format(qom.getColumns());
        ws();
        sb.append("FROM");
        ws();
        format(qom.getSource());
        Constraint c = qom.getConstraint();
        if (c != null) {
            ws();
            sb.append("WHERE");
            ws();
            format(c);
View Full Code Here


    private void format(Not constraint)
            throws RepositoryException {
        sb.append("NOT");
        ws();
        Constraint c = constraint.getConstraint();
        boolean paren = c instanceof And || c instanceof Or;
        if (paren) {
            sb.append("(");
        }
        format(c);
View Full Code Here

    final String selectorName = "selector"; //$NON-NLS-1$

    // selector
    final Selector selector = fac.selector( "nt:base", selectorName ); //$NON-NLS-1$
    // constraint1
    Constraint origParentFolderPathConstraint =
        fac.comparison( fac.propertyValue( selectorName, pentahoJcrConstants.getPHO_ORIGPARENTFOLDERPATH() ),
            QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, fac.literal( session.getValueFactory().createValue(
                origParentFolderPath ) ) );
    // constraint2
    Constraint origNameConstraint = null;
    if ( StringUtils.hasLength( filter ) ) {
      String convertedFilter = filter.replace( '*', '%' );
      origNameConstraint =
          fac.comparison( fac.propertyValue( selectorName, pentahoJcrConstants.getPHO_ORIGNAME() ),
              QueryObjectModelConstants.JCR_OPERATOR_LIKE, fac.literal( session.getValueFactory().createValue(
                  convertedFilter ) ) );
    }
    // constraint3
    Constraint descendantNodeConstraint = fac.descendantNode( selectorName, trashNode.getPath() );
    // AND together constraints
    Constraint allConstraints = fac.and( descendantNodeConstraint, origParentFolderPathConstraint );
    if ( StringUtils.hasLength( filter ) ) {
      allConstraints = fac.and( allConstraints, origNameConstraint );
    }
    Query query = fac.createQuery( selector, allConstraints, null, null );
    QueryResult result =
View Full Code Here

        assertEquals("[nt:base]",
                f.selector(NodeType.NT_BASE, null).toString());
       
        Source source1 = f.selector(NodeType.NT_BASE, "selector");
        Column[] columns = new Column[] { f.column("selector", null, null) };
        Constraint constraint2 = f.childNode("selector", "/");
        QueryObjectModel qom = f.createQuery(source1, constraint2, null,
                columns);
        assertEquals("select [selector].* from " +
                "[nt:base] AS [selector] " +
                "where ISCHILDNODE([selector], [/])", qom.toString());
View Full Code Here

                "where ISCHILDNODE([selector], [/])", qom.toString());
    }

    @Test
    public void and() throws RepositoryException {
        Constraint c0 = f.propertyExistence("x", "c0");
        Constraint c1 = f.propertyExistence("x", "c1");
        And and = f.and(c0, c1);
        assertEquals(and.getConstraint1(), c0);
        assertEquals(and.getConstraint2(), c1);
        assertEquals("([x].[c0] IS NOT NULL) AND ([x].[c1] IS NOT NULL)", and.toString());
    }
View Full Code Here

        assertEquals("NAME()", f.nodeName(null).toString());
    }

    @Test
    public void not() throws RepositoryException {
        Constraint c = f.propertyExistence("x", "c0");
        Not n = f.not(c);
        assertEquals(c, n.getConstraint());
        assertEquals("[x].[c0] IS NOT NULL", c.toString());
       
        assertEquals("* IS NOT NULL", f.propertyExistence(null, null).toString());
        assertEquals("[s].* IS NOT NULL", f.propertyExistence("s", null).toString());
        assertEquals("[p] IS NOT NULL", f.propertyExistence(null, "p").toString());
        assertEquals("[s].[p] IS NOT NULL", f.propertyExistence("s", "p").toString());
View Full Code Here

        assertEquals("[s].[p] IS NOT NULL", f.propertyExistence("s", "p").toString());
    }

    @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());
    }
View Full Code Here

    @Test
    public void createQuery() throws RepositoryException {
        Selector s = f.selector("nodeTypeName", "x");
        BindVariableValue b = f.bindVariable("var");
        Constraint c = f.propertyExistence("x", "c");
        PropertyValue p = f.propertyValue("x", "propertyName");
        c = f.and(f.comparison(p, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, b), c);
        Ordering o = f.ascending(p);
        Column col = f.column("x", "propertyName", "columnName");
        Ordering[] ords = new Ordering[]{o};
View Full Code Here

        read("SELECT");
        ArrayList<ColumnOrWildcard> list = parseColumns();
        read("FROM");
        Source source = parseSource();
        Column[] columnArray = resolveColumns(list);
        Constraint constraint = null;
        if (readIf("WHERE")) {
            constraint = parseConstraint();
        }
        Ordering[] orderings = null;
        if (readIf("ORDER")) {
View Full Code Here

            return factory.equiJoinCondition(selector1, property1, selector2, readName());
        }
    }

    private Constraint parseConstraint() throws RepositoryException {
        Constraint a = parseAnd();
        while (readIf("OR")) {
            a = factory.or(a, parseAnd());
        }
        return a;
    }
View Full Code Here

TOP

Related Classes of javax.jcr.query.qom.Constraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.