Package org.apache.chemistry.opencmis.server.support.query

Examples of org.apache.chemistry.opencmis.server.support.query.ColumnReference


        assertTrue(1 == types.size());
        List<CmisSelector> wheres = qo.getWhereReferences();
        assertTrue(1 == wheres.size());
        for (CmisSelector where : wheres) {
            assertTrue(where instanceof ColumnReference);
            ColumnReference colRef = ((ColumnReference) where);
            assertEquals(bookType, colRef.getTypeDefinition());
            assertTrue(colRef.getPropertyQueryName().equals(ISBN_PROP));
        }
    }
View Full Code Here


        QueryObject qo = walker.queryObj;
        List<CmisSelector> wheres = qo.getWhereReferences();
        assertTrue(1 == wheres.size());
        for (CmisSelector where : wheres) {
            assertTrue(where instanceof ColumnReference);
            ColumnReference colRef = ((ColumnReference) where);
            assertEquals(colRef.getTypeDefinition(), myType);
            assertTrue(colRef.getPropertyQueryName().equals(STRING_PROP));
        }
    }
View Full Code Here

        QueryObject qo = walker.queryObj;
        List<SortSpec> sorts = qo.getOrderBys();
        assertTrue(1 == sorts.size());
        for (SortSpec sort : sorts) {
            assertTrue(sort.getSelector() instanceof ColumnReference);
            ColumnReference colRef = ((ColumnReference) sort.getSelector());
            assertEquals(colRef.getTypeDefinition(), bookType);
            assertTrue(colRef.getPropertyQueryName().equals(TITLE_PROP));
        }
    }
View Full Code Here

        QueryObject qo = walker.queryObj;
        List<SortSpec> sorts = qo.getOrderBys();
        assertTrue(1 == sorts.size());
        for (SortSpec sort : sorts) {
            assertTrue(sort.getSelector() instanceof ColumnReference);
            ColumnReference colRef = ((ColumnReference) sort.getSelector());
            assertEquals(colRef.getTypeDefinition(), bookType);
            assertTrue(colRef.getPropertyQueryName().equals(AUTHOR_PROP));
        }
    }
View Full Code Here

        QueryObject qo = walker.queryObj;
        List<SortSpec> sorts = qo.getOrderBys();
        assertTrue(1 == sorts.size());
        for (SortSpec sort : sorts) {
            assertTrue(sort.getSelector() instanceof ColumnReference);
            ColumnReference colRef = ((ColumnReference) sort.getSelector());
            assertEquals(colRef.getTypeDefinition(), bookType);
            assertTrue(colRef.getPropertyQueryName().equals(AUTHOR_PROP));
        }
    }
View Full Code Here

        QueryObject qo = walker.queryObj;
        List<CmisSelector> joins = qo.getJoinReferences();
        assertTrue(2 == joins.size());
        for (CmisSelector join : joins) {
            assertTrue(join instanceof ColumnReference);
            ColumnReference colRef = ((ColumnReference) join);
            if (myType.equals(colRef.getTypeDefinition())) {
                assertTrue(colRef.getPropertyQueryName().equals(STRING_PROP));
            } else if (bookType.equals(colRef.getTypeDefinition())) {
                assertTrue(colRef.getPropertyQueryName().equals(TITLE_PROP));
            } else
                fail("Unexpected type in JOIN reference");
        }
    }
View Full Code Here

                return true;
        }
    }

    private boolean evalWhereInAny(StoredObject so, Tree node, Tree colNode, Tree listNode) {
        ColumnReference colRef = getColumnReference(colNode);
        TypeDefinition td = colRef.getTypeDefinition();
        PropertyDefinition<?> pd = td.getPropertyDefinitions().get(colRef.getPropertyId());
        PropertyData<?> lVal = so.getProperties().get(colRef.getPropertyId());
        List<Object> literals = onLiteralList(listNode);
        if (pd.getCardinality() != Cardinality.MULTI)
            throw new RuntimeException("Operator ANY...IN only is allowed on multi-value properties ");
        else if (lVal == null)
            return false;
View Full Code Here

    }

    private boolean evalWhereNotInAny(StoredObject so, Tree node, Tree colNode, Tree listNode) {
        // Note just return !evalWhereInAny(so, node, colNode, listNode) is wrong, because
        // then it evaluates to true for null values (not set properties).
        ColumnReference colRef = getColumnReference(colNode);
        TypeDefinition td = colRef.getTypeDefinition();
        PropertyDefinition<?> pd = td.getPropertyDefinitions().get(colRef.getPropertyId());
        PropertyData<?> lVal = so.getProperties().get(colRef.getPropertyId());
        List<Object> literals = onLiteralList(listNode);
        if (pd.getCardinality() != Cardinality.MULTI)
            throw new RuntimeException("Operator ANY...IN only is allowed on multi-value properties ");
        else if (lVal == null)
            return false;
View Full Code Here

            return true;
        }   
    }

    private boolean evalWhereEqAny(StoredObject so, Tree node, Tree literalNode, Tree colNode) {
        ColumnReference colRef = getColumnReference(colNode);
        TypeDefinition td = colRef.getTypeDefinition();
        PropertyDefinition<?> pd = td.getPropertyDefinitions().get(colRef.getPropertyId());
        PropertyData<?> lVal = so.getProperties().get(colRef.getPropertyId());
        Object literal = onLiteral(literalNode);
        if (pd.getCardinality() != Cardinality.MULTI)
            throw new RuntimeException("Operator = ANY only is allowed on multi-value properties ");
        else if (lVal == null)
            return false;
View Full Code Here

    private boolean evalWhereIsLike(StoredObject so, Tree node, Tree colNode, Tree StringNode) {
        Object rVal = onLiteral(StringNode);
        if (!(rVal instanceof String))
                throw new RuntimeException("LIKE operator requires String literal on right hand side.");
       
        ColumnReference colRef = getColumnReference(colNode);
        TypeDefinition td = colRef.getTypeDefinition();
        PropertyDefinition<?> pd = td.getPropertyDefinitions().get(colRef.getPropertyId());
        PropertyType propType = pd.getPropertyType();
        if (propType != PropertyType.STRING && propType != PropertyType.HTML &&  propType != PropertyType.ID &&
                propType != PropertyType.URI)
            throw new RuntimeException("Property type "+ propType.value() + " is not allowed FOR LIKE");
        if (pd.getCardinality() != Cardinality.SINGLE)
            throw new RuntimeException("LIKE is not allowed for multi-value properties ");
       
        String propVal = (String) so.getProperties().get(colRef.getPropertyId()).getFirstValue();
        String pattern = translatePattern((String) rVal); // SQL to Java regex syntax
        Pattern p = Pattern.compile(pattern);
        return p.matcher(propVal).matches();
    }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.server.support.query.ColumnReference

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.