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

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


    @Test
    public void simpleWhereTest() {
        String statement = "SELECT * FROM MyType WHERE MyProp1=123";

        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        assertNotNull(walker);

        List<CmisSelector> whereRefs = queryObj.getWhereReferences();
        Map<Integer, CmisSelector> colRefs = queryObj.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 == queryObj.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()));
//        assertTrue(traverseTreeAndFindNodeInColumnMap(tree, colRefs));
        traverseTreeAndFindNodeInColumnMap2(tree, colRefs);
View Full Code Here


    @Test
    public void simpleSortTest1() {
        String statement = "SELECT * FROM MyType ORDER BY abc.def ASC";

        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        assertNotNull(walker);

        List<SortSpec> orderBys = queryObj.getOrderBys();
        assertTrue(1 == orderBys.size());

View Full Code Here

    }

    @Test
    public void simpleSortTest2() {
        String statement = "SELECT * FROM MyType ORDER BY def DESC";
        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        assertNotNull(walker);

        List<SortSpec> orderBys = queryObj.getOrderBys();
        assertTrue(1 == orderBys.size());

View Full Code Here

    @Test
    public void doubleFromTest() {
        String statement = "SELECT * FROM MyType JOIN YourType WHERE a='1'";

        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        assertNotNull(walker);

        QueryObject from = queryObj;
        Map<String,String> types = from.getTypes();
        assertTrue(2 == types.size());
View Full Code Here

        return objList;
    }

    public void processQueryAndCatchExc(String statement) {
        QueryUtil queryUtil = new QueryUtil();
        CmisQueryWalker walker = queryUtil.traverseStatementAndCatchExc(statement, queryObj, null);
        whereTree = walker.getWherePredicateTree();
    }
View Full Code Here

        parserTree = (CommonTree) parsedStatement.getTree();           
        // printTree(tree);

        CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);
        nodes.setTokenStream(tokens);
        CmisQueryWalker walker = new CmisQueryWalker(nodes);
        return walker;
    }
View Full Code Here

        CmisQueryWalker walker = new CmisQueryWalker(nodes);
        return walker;
    }

    protected CmisQueryWalker traverseStatement(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
        CmisQueryWalker walker = getWalker(statement);
        walker.query(queryObj);
        String errMsg = walker.getErrorMessageString();
        if (null != errMsg) {
            fail("Walking of statement failed with error: \n   " + errMsg +
                    "\n   Statement was: " + statement);
        }
        walkerTree = (CommonTree) walker.getTreeNodeStream().getTreeSource();
        return walker;
    }
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);
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()));
//        assertTrue(traverseTreeAndFindNodeInColumnMap(tree, colRefs));
        traverseTreeAndFindNodeInColumnMap2(tree, colRefs);
View Full Code Here

   
    @Test
    public void simpleSortTest1() throws Exception {
        String statement = "SELECT * FROM MyType ORDER BY abc.def ASC";
       
        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        List<SortSpec> orderBys = walker.queryObj.getOrderBys();
        assertTrue(1 == orderBys.size());
        SortSpec sp = orderBys.get(0);
        assertTrue(sp.isAscending());
        CmisSelector sortSpec = sp.getSelector();
View Full Code Here

TOP

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

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.