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

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


        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();
        assert(sortSpec instanceof ColumnReference);
        assertEquals("abc", ((ColumnReference)sortSpec).getTypeQueryName());
        assertEquals("def", ((ColumnReference)sortSpec).getPropertyQueryName());
    }
View Full Code Here


    public void simpleSortTest2() throws Exception {
        String statement = "SELECT * FROM MyType ORDER BY def DESC";       
        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        List<SortSpec> orderBys = walker.queryObj.getOrderBys();
        assertTrue(1 == orderBys.size());
        SortSpec sp = orderBys.get(0);
        assertFalse(sp.isAscending());
        CmisSelector sortSpec = sp.getSelector();
        assert(sortSpec instanceof ColumnReference);
        assertNull(((ColumnReference)sortSpec).getTypeQueryName());
        assertEquals("def", ((ColumnReference)sortSpec).getPropertyQueryName());
    }
View Full Code Here

            LOG.warn("ORDER BY has more than one sort criterium, all but the first are ignored.");
        class ResultComparator implements Comparator<StoredObject> {

            @SuppressWarnings("unchecked")
            public int compare(StoredObject so1, StoredObject so2) {
                SortSpec s = orderBy.get(0);
                CmisSelector sel = s.getSelector();
                int result;
               
                if (sel instanceof ColumnReference) {
                    String propId = ((ColumnReference)sel).getPropertyId();
                    Object propVal1 = so1.getProperties().get(propId).getFirstValue();
                    Object propVal2 = so2.getProperties().get(propId).getFirstValue();
                    if (propVal1 == null && propVal2 == null)
                        result = 0;
                    else if (propVal1 == null)
                        result = -1;
                    else if (propVal2 == null)
                        result = 1;
                    else
                        result = ((Comparable)propVal1).compareTo(propVal2);                   
                } else {
                    String funcName = ((FunctionReference)sel).getName();
                    // evaluate function here, currently ignore
                    result = 0;
                }
                if (!s.isAscending())
                    result = -result;
                return result;
            }
        }
View Full Code Here

            LOG.warn("ORDER BY has more than one sort criterium, all but the first are ignored.");
        class ResultComparator implements Comparator<StoredObject> {

            @SuppressWarnings("unchecked")
            public int compare(StoredObject so1, StoredObject so2) {
                SortSpec s = orderBy.get(0);
                CmisSelector sel = s.getSelector();
                int result;
               
                if (sel instanceof ColumnReference) {
                    String propId = ((ColumnReference)sel).getPropertyId();
                    Object propVal1 = so1.getProperties().get(propId).getFirstValue();
                    Object propVal2 = so2.getProperties().get(propId).getFirstValue();
                    if (propVal1 == null && propVal2 == null)
                        result = 0;
                    else if (propVal1 == null)
                        result = -1;
                    else if (propVal2 == null)
                        result = 1;
                    else
                        result = ((Comparable)propVal1).compareTo(propVal2);                   
                } else {
                    String funcName = ((FunctionReference)sel).getName();
                    // evaluate function here, currently ignore
                    result = 0;
                }
                if (!s.isAscending())
                    result = -result;
                return result;
            }
View Full Code Here

        }
        class ResultComparator implements Comparator<StoredObject> {

            @SuppressWarnings("unchecked")
            public int compare(StoredObject so1, StoredObject so2) {
                SortSpec s = orderBy.get(0);
                CmisSelector sel = s.getSelector();
                int result;

                if (sel instanceof ColumnReference) {
                    String propId = ((ColumnReference) sel).getPropertyId();
                    Object propVal1 = so1.getProperties().get(propId).getFirstValue();
                    Object propVal2 = so2.getProperties().get(propId).getFirstValue();
                    if (propVal1 == null && propVal2 == null) {
                        result = 0;
                    } else if (propVal1 == null) {
                        result = -1;
                    } else if (propVal2 == null) {
                        result = 1;
                    } else {
                        result = ((Comparable<Object>) propVal1).compareTo(propVal2);
                    }
                } else {
                    // String funcName = ((FunctionReference) sel).getName();
                    // evaluate function here, currently ignore
                    result = 0;
                }
                if (!s.isAscending()) {
                    result = -result;
                }
                return result;
            }
        }
View Full Code Here

        }
        class ResultComparator implements Comparator<StoredObject> {

            @SuppressWarnings("unchecked")
            public int compare(StoredObject so1, StoredObject so2) {
                SortSpec s = orderBy.get(0);
                CmisSelector sel = s.getSelector();
                int result;

                if (sel instanceof ColumnReference) {
                    String propId = ((ColumnReference) sel).getPropertyId();
                    Object propVal1 = so1.getProperties().get(propId).getFirstValue();
                    Object propVal2 = so2.getProperties().get(propId).getFirstValue();
                    if (propVal1 == null && propVal2 == null) {
                        result = 0;
                    } else if (propVal1 == null) {
                        result = -1;
                    } else if (propVal2 == null) {
                        result = 1;
                    } else {
                        result = ((Comparable<Object>) propVal1).compareTo(propVal2);
                    }
                } else {
                    // String funcName = ((FunctionReference) sel).getName();
                    // evaluate function here, currently ignore
                    result = 0;
                }
                if (!s.isAscending()) {
                    result = -result;
                }
                return result;
            }
View Full Code Here

        assertNotNull(walker);

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

        SortSpec sp = orderBys.get(0);
        assertTrue(sp.isAscending());

        CmisSelector sortSpec = sp.getSelector();
        assert(sortSpec instanceof ColumnReference);
        assertEquals("abc", ((ColumnReference)sortSpec).getQualifier());
        assertEquals("def", ((ColumnReference)sortSpec).getPropertyQueryName());
    }
View Full Code Here

        assertNotNull(walker);

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

        SortSpec sp = orderBys.get(0);
        assertFalse(sp.isAscending());

        CmisSelector sortSpec = sp.getSelector();
        assert(sortSpec instanceof ColumnReference);
        assertNull(((ColumnReference)sortSpec).getQualifier());
        assertEquals("def", ((ColumnReference)sortSpec).getPropertyQueryName());
    }
View Full Code Here

            LOG.warn("ORDER BY has more than one sort criterium, all but the first are ignored.");
        class ResultComparator implements Comparator<StoredObject> {

            @SuppressWarnings("unchecked")
            public int compare(StoredObject so1, StoredObject so2) {
                SortSpec s = orderBy.get(0);
                CmisSelector sel = s.getSelector();
                int result;

                if (sel instanceof ColumnReference) {
                    String propId = ((ColumnReference) sel).getPropertyId();
                    Object propVal1 = so1.getProperties().get(propId).getFirstValue();
                    Object propVal2 = so2.getProperties().get(propId).getFirstValue();
                    if (propVal1 == null && propVal2 == null)
                        result = 0;
                    else if (propVal1 == null)
                        result = -1;
                    else if (propVal2 == null)
                        result = 1;
                    else
                        result = ((Comparable<Object>) propVal1).compareTo(propVal2);
                } else {
                    // String funcName = ((FunctionReference) sel).getName();
                    // evaluate function here, currently ignore
                    result = 0;
                }
                if (!s.isAscending())
                    result = -result;
                return result;
            }
        }
View Full Code Here

            LOG.warn("ORDER BY has more than one sort criterium, all but the first are ignored.");
        class ResultComparator implements Comparator<StoredObject> {

            @SuppressWarnings("unchecked")
            public int compare(StoredObject so1, StoredObject so2) {
                SortSpec s = orderBy.get(0);
                CmisSelector sel = s.getSelector();
                int result;

                if (sel instanceof ColumnReference) {
                    String propId = ((ColumnReference) sel).getPropertyId();
                    Object propVal1 = so1.getProperties().get(propId).getFirstValue();
                    Object propVal2 = so2.getProperties().get(propId).getFirstValue();
                    if (propVal1 == null && propVal2 == null)
                        result = 0;
                    else if (propVal1 == null)
                        result = -1;
                    else if (propVal2 == null)
                        result = 1;
                    else
                        result = ((Comparable<Object>) propVal1).compareTo(propVal2);
                } else {
                    // String funcName = ((FunctionReference) sel).getName();
                    // evaluate function here, currently ignore
                    result = 0;
                }
                if (!s.isAscending())
                    result = -result;
                return result;
            }
View Full Code Here

TOP

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

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.