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

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


   
    @Test
    public void simpleFromTest2() throws Exception {
        String statement = "SELECT * FROM MyType";       
        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        QueryObject from = walker.queryObj;
        Map<String,String> types = from.getTypes();
        assertTrue(1 == types.size());
        String key = types.keySet().iterator().next();
        assertEquals("MyType", key);
        assertEquals("MyType", types.get(key));
   
View Full Code Here


   
    @Test
    public void simpleFromTest3() throws Exception {
        String statement = "SELECT t2.aaa FROM MyType abc123";       
        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        QueryObject from = walker.queryObj;
        Map<String,String> types = from.getTypes();
        assertTrue(1 == types.size());
        String key = types.keySet().iterator().next();
        assertEquals("abc123", key);
        assertEquals("MyType", types.get(key));
    }
View Full Code Here

    @Test
    public void simpleWhereTest() throws Exception {
        String statement = "SELECT * FROM MyType WHERE MyProp1=123";
       
        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        QueryObject qo = walker.queryObj;
        List<CmisSelector> whereRefs = qo.getWhereReferences();
        Map<Integer, CmisSelector> colRefs = qo.getColumnReferences();
        assertTrue(1 == whereRefs.size());
        CmisSelector value = whereRefs.iterator().next();
        assertTrue(value instanceof ColumnReference);
        assertEquals("MyProp1", ((ColumnReference)value).getPropertyQueryName());
        // only "*" should be in select references
        assertTrue(1 == qo.getSelectReferences().size());

        CommonTree tree = (CommonTree) walker.getTreeNodeStream().getTreeSource();
       
        // System.out.println("simpleWhereTest printing Tree ...");
        // System.out.println("id in map: " + System.identityHashCode(whereRefs.keySet().iterator().next()));
View Full Code Here

    @Test
    public void doubleFromTest() throws Exception {
        String statement = "SELECT * FROM MyType JOIN YourType WHERE a='1'";
       
        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        QueryObject from = walker.queryObj;
        Map<String,String> types = from.getTypes();
        assertTrue(2 == types.size());
    }
View Full Code Here

        List<TypeDefinition> typeDefs = super.createTypes();
        for (TypeDefinition typeDef : typeDefs)
            tm.addTypeDefinition(typeDef);
       
        // initialize query object with type manager
        super.setUp(new QueryObject(tm, null));
    }
View Full Code Here

        verifyResolveSelect(statement);
    }

    private void verifyResolveSelect(String statement) throws Exception {
        CmisQueryWalker walker = traverseStatement(statement);
        QueryObject qo = walker.queryObj;
        Map<String,String> types = qo.getTypes();
        assertTrue(1 == types.size());
        List<CmisSelector> selects = qo.getSelectReferences();
        assertTrue(2 == selects.size());
        for (CmisSelector select : selects) {
            assertTrue(select instanceof ColumnReference);
            ColumnReference colRef = ((ColumnReference) select);
            assertEquals(bookType, colRef.getTypeDefinition());
View Full Code Here

    @Test
    public void resolveTypesWithTwoFromsQualified() throws Exception {
        String statement = "SELECT BookType.Title, MyDocType.MyStringProp FROM BookType JOIN MyDocType WHERE BookType.ISBN = '100'";
       
        CmisQueryWalker walker = traverseStatement(statement);
        QueryObject qo = walker.queryObj;
        Map<String,String> types = qo.getTypes();
        assertTrue(2 == types.size());
        List<CmisSelector> selects = qo.getSelectReferences();
        assertTrue(2 == selects.size());

        ColumnReference colRef = ((ColumnReference) selects.get(0));
        assertEquals(colRef.getTypeDefinition(), bookType);
        assertTrue(colRef.getPropertyQueryName().equals(TITLE_PROP));
View Full Code Here

    @Test
    public void resolveTypesWithTwoFromsUnqualified() throws Exception {
        String statement = "SELECT Title, MyStringProp FROM BookType JOIN MyDocType AS MyDocAlias WHERE BookType.ISBN = '100'";
       
        CmisQueryWalker walker = traverseStatement(statement);
        QueryObject qo = walker.queryObj;
        Map<String,String> types = qo.getTypes();
        assertTrue(2 == types.size());
        List<CmisSelector> selects = qo.getSelectReferences();
        assertTrue(2 == selects.size());

        ColumnReference colRef = ((ColumnReference) selects.get(0));
        assertEquals(colRef.getTypeDefinition(), bookType);
        assertTrue(colRef.getPropertyQueryName().equals(TITLE_PROP));
View Full Code Here

    @Test
    public void resolveTypesWithTwoFromsUniqueByQualifying() throws Exception {
        String statement = "SELECT MyDocType.MyStringProp FROM MyDocTypeCopy JOIN MyDocType";
       
        CmisQueryWalker walker = traverseStatement(statement);
        QueryObject qo = walker.queryObj;
        Map<String,String> types = qo.getTypes();
        assertTrue(2 == types.size());
        List<CmisSelector> selects = qo.getSelectReferences();
        assertTrue(1 == selects.size());
        ColumnReference colRef = ((ColumnReference) selects.get(0));
        assertEquals(myType, colRef.getTypeDefinition());
        assertTrue(colRef.getPropertyQueryName().equals(STRING_PROP));       
    }
View Full Code Here

    @Test
    public void resolveTypesTest11() throws Exception {
        String statement = "SELECT BookType.* FROM BookType WHERE ISBN = '100'";
        CmisQueryWalker walker = traverseStatement(statement);
        QueryObject qo = walker.queryObj;
        Map<String,String> types = qo.getTypes();
        assertTrue(1 == types.size());
        List<CmisSelector> selects = qo.getSelectReferences();
        assertTrue(1 == selects.size());
        ColumnReference colRef = ((ColumnReference) selects.get(0));
        assertTrue(colRef.getPropertyQueryName().equals("*"));       
        assertEquals(bookType, colRef.getTypeDefinition());
    }
View Full Code Here

TOP

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

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.