Package com.socrata.model.soql

Examples of com.socrata.model.soql.OrderByClause


    public void testAddAllMethods() {
        SoqlQueryBuilder    builder = new SoqlQueryBuilder(ROBUST_QUERY);

        builder.addGroupByPhrases(Lists.newArrayList("Group2", "Group3"));
        builder.addSelectPhrases(Lists.newArrayList("Column2", "Column3"));
        builder.addOrderByPhrases(Lists.newArrayList(new OrderByClause(SortOrder.Descending, "Order2"),
                                                     new OrderByClause(SortOrder.Ascending, "Order3")));

        SoqlQuery   query = builder.build();
        assertEquals(3, query.groupByClause.size());
        assertEquals(3, query.selectClause.size());
        assertEquals(3, query.orderByClause.size());

        ListAssert.assertEquals(Lists.newArrayList("Group1", "Group2", "Group3"),
                                query.groupByClause);

        ListAssert.assertEquals(Lists.newArrayList("Column1", "Column2", "Column3"),
                                query.selectClause);

        ListAssert.assertEquals(Lists.newArrayList(new OrderByClause(SortOrder.Ascending, "Order1"),
                                                   new OrderByClause(SortOrder.Descending, "Order2"),
                                                   new OrderByClause(SortOrder.Ascending, "Order3")),
                                query.orderByClause);


    }
View Full Code Here


    public void testSetMethodsOnCollections() {
        SoqlQueryBuilder    builder = new SoqlQueryBuilder(ROBUST_QUERY);

        builder.setGroupByPhrase(Lists.newArrayList("Group2", "Group3"));
        builder.setSelectPhrase(Lists.newArrayList("Column2", "Column3"));
        builder.setOrderByPhrase(Lists.newArrayList(new OrderByClause(SortOrder.Descending, "Order2"),
                                                     new OrderByClause(SortOrder.Ascending, "Order3")));

        SoqlQuery   query = builder.build();
        assertEquals(2, query.groupByClause.size());
        assertEquals(2, query.selectClause.size());
        assertEquals(2, query.orderByClause.size());

        ListAssert.assertEquals(Lists.newArrayList("Group2", "Group3"),
                                query.groupByClause);

        ListAssert.assertEquals(Lists.newArrayList("Column2", "Column3"),
                                query.selectClause);

        ListAssert.assertEquals(Lists.newArrayList(new OrderByClause(SortOrder.Descending, "Order2"),
                                                   new OrderByClause(SortOrder.Ascending, "Order3")),
                                query.orderByClause);


    }
View Full Code Here

            TestCase.assertNotNull(loadedView);
            TestCase.assertEquals("published", loadedView.getPublicationStage());

            final Soda2Consumer consumer = new Soda2Consumer(connection);
            final SoqlQuery   sortQuery = new SoqlQueryBuilder()
                    .addOrderByPhrase(new OrderByClause(SortOrder.Ascending, "name"))
                    .build();
            List<NominationsWText> nominations = consumer.query(createdView.getId(), sortQuery, NominationsWText.LIST_TYPE);
            TestCase.assertEquals(2, nominations.size());
            TestCase.assertEquals("Kitty, Hello", nominations.get(0).getName());
            TestCase.assertEquals("Name, Test", nominations.get(1).getName());
View Full Code Here

        try {
            //
            //  Make sure data is added
            Soda2Consumer consumer = new Soda2Consumer(connection);
            SoqlQuery   sortQuery = new SoqlQueryBuilder()
                    .addOrderByPhrase(new OrderByClause(SortOrder.Ascending, "name"))
                    .build();
            List<NominationsWText> nominations = consumer.query(createdView.getId(), sortQuery, NominationsWText.LIST_TYPE);
            TestCase.assertEquals(2, nominations.size());
            TestCase.assertEquals("Kitty, Hello", nominations.get(0).getName());
            TestCase.assertEquals("Name, Test", nominations.get(1).getName());



            createdView.setResourceName(name);
            createdView = importer.updateDatasetInfo(createdView);

            consumer = new Soda2Consumer(connection);
            sortQuery = new SoqlQueryBuilder()
                    .addOrderByPhrase(new OrderByClause(SortOrder.Ascending, "name"))
                    .build();
            nominations = consumer.query(createdView.getId(), sortQuery, NominationsWText.LIST_TYPE);
            TestCase.assertEquals(2, nominations.size());
            TestCase.assertEquals("Kitty, Hello", nominations.get(0).getName());
            TestCase.assertEquals("Name, Test", nominations.get(1).getName());
View Full Code Here

            TestCase.assertNotNull(loadedView);
            TestCase.assertEquals("published", loadedView.getPublicationStage());

            final Soda2Consumer consumer = new Soda2Consumer(connection);
            final SoqlQuery   sortQuery = new SoqlQueryBuilder()
                    .addOrderByPhrase(new OrderByClause(SortOrder.Ascending, "name"))
                    .build();
            List<Nomination> nominations = consumer.query(createdView.getId(), sortQuery, Nomination.LIST_TYPE);
            TestCase.assertEquals(2, nominations.size());
            TestCase.assertEquals("Kitty, Hello", nominations.get(0).getName());
            TestCase.assertEquals("Name, Test", nominations.get(1).getName());
View Full Code Here

        try {
            importer.publish(createdView.getId());

            SoqlQuery   sortByNameQuery = new SoqlQueryBuilder(SoqlQuery.SELECT_ALL)
                    .addOrderByPhrase(new OrderByClause(SortOrder.Descending, "name"))
                    .build();

            //Validate
            List retVal =  consumer.query(createdView.getId(), sortByNameQuery, Soda2Consumer.HASH_RETURN_TYPE);
            TestCase.assertEquals(2, retVal.size());
View Full Code Here

        SoqlQuery   departmentOfStateQuery = new SoqlQueryBuilder()
                .addSelectPhrase("name")
                .addSelectPhrase("position")
                .addSelectPhrase("nomination_date")
                .setWhereClause("agency_name='Department of State'")
                .addOrderByPhrase(new OrderByClause(SortOrder.Descending, "position"))
                .build();
        nominations = consumer.query("nominationsCopy", departmentOfStateQuery, Nomination.LIST_TYPE);
        TestCase.assertTrue(nominations.size() > 0);
        System.out.println(nominations.size());
    }
View Full Code Here

TOP

Related Classes of com.socrata.model.soql.OrderByClause

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.