Package com.socrata.model.soql

Examples of com.socrata.model.soql.SoqlQuery


        this.limit = limit;
        return this;
    }

    public SoqlQuery build() {
        return new SoqlQuery(selectClause.isEmpty() ? null : selectClause,
                             whereClause,
                             groupByClause.isEmpty()? null : groupByClause,
                             havingClause,
                             orderByClause.isEmpty()? null : orderByClause,
                             fullTextSearchClause,
View Full Code Here


        Date d = new Date(112, 5, 20, 7, 0);

        Soda2Consumer   consumer = createConsumer();

        //  Run an equality filter on a floating timestamp
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ "=to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();
        final List<Nomination>  results = consumer.query(NOMINATION_DATA_SET, query, Nomination.LIST_TYPE);


        // Verify results against known values.
        final Set<String>       names = Sets.newHashSet("Masumoto, David", "Trottenberg, Polly Ellen");
        for (Nomination n: results) {
            TestCase.assertTrue(names.remove(n.getName()));
            TestCase.assertEquals(d, n.getNominationDate());
        }

        //  Check greater than floating timestamp
        SoqlQuery queryGreater = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ ">to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();
        final List<Nomination>  resultsGreater = consumer.query(NOMINATION_DATA_SET, queryGreater, Nomination.LIST_TYPE);


        //  Verify results all come after the test date
        for (Nomination n: resultsGreater) {
            TestCase.assertTrue(n.getNominationDate().after(d));
        }

        //  Check greater than floating timestamp
        SoqlQuery queryLesser = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ "<to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<Nomination>  resultsLesser = consumer.query(NOMINATION_DATA_SET, queryLesser, Nomination.LIST_TYPE);
View Full Code Here

        Soda2Consumer   consumer = createConsumer();

        //
        //  Check floating timestamp
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ "=to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  results = consumer.query(NOMINATION_DATA_SET, query, NominationWithJoda.LIST_TYPE);
        final Set<String>       names = Sets.newHashSet("Masumoto, David", "Trottenberg, Polly Ellen");

        for (NominationWithJoda n: results) {
            TestCase.assertTrue(names.remove(n.getName()));
            TestCase.assertTrue(n.getNominationDate().toDateTime(DateTimeZone.getDefault()).toDate().equals(d));
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryGreater = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ ">to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  resultsGreater = consumer.query(NOMINATION_DATA_SET, queryGreater, NominationWithJoda.LIST_TYPE);

        for (NominationWithJoda n: resultsGreater) {
            TestCase.assertTrue(n.getNominationDate().toDateTime(DateTimeZone.getDefault()).isAfter(d.getTime()));
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryLesser = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Nomination Date"+ "<to_floating_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  resultsLesser = consumer.query(NOMINATION_DATA_SET, queryLesser, NominationWithJoda.LIST_TYPE);
View Full Code Here

        Soda2Consumer   consumer = createConsumer();

        //
        //  Check floating timestamp
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ "=to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<Nomination>  results = consumer.query(NOMINATION_DATA_SET, query, Nomination.LIST_TYPE);
        final Set<String>       names = Sets.newHashSet("Masumoto, David", "Trottenberg, Polly Ellen");

        for (Nomination n: results) {
            TestCase.assertTrue(names.remove(n.getName()));
            TestCase.assertEquals(d, n.getNominationDate());
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryGreater = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ ">to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<Nomination>  resultsGreater = consumer.query(NOMINATION_DATA_SET, queryGreater, Nomination.LIST_TYPE);

        for (Nomination n: resultsGreater) {
            if (n.getConfirmationVoteDate() != null) {
                TestCase.assertTrue(d.before(n.getConfirmationVoteDate()));
            }
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryLesser = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ "<to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<Nomination>  resultsLesser = consumer.query(NOMINATION_DATA_SET, queryLesser, Nomination.LIST_TYPE);
View Full Code Here

        Soda2Consumer   consumer = createConsumer();

        //
        //  Check floating timestamp
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ "=to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  results = consumer.query(NOMINATION_DATA_SET, query, NominationWithJoda.LIST_TYPE);
        final Set<String>       names = Sets.newHashSet("Masumoto, David", "Trottenberg, Polly Ellen");

        for (NominationWithJoda n: results) {
            TestCase.assertTrue(names.remove(n.getName()));
            TestCase.assertEquals(d, n.getNominationDate().toDate());
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryGreater = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ ">to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  resultsGreater = consumer.query(NOMINATION_DATA_SET, queryGreater, NominationWithJoda.LIST_TYPE);

        for (NominationWithJoda n: resultsGreater) {
            if (n.getConfirmationVoteDate() != null) {
                TestCase.assertTrue(d.before(n.getConfirmationVoteDate().toDate()));
            }
        }

        //
        //  Check greater than floating timestamp
        SoqlQuery queryLesser = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression(ColumnUtil.getQueryName("Confirmation Vote"+ "<to_fixed_timestamp('2012-6-20T07:00:00Z')"))
                .build();

        final List<NominationWithJoda>  resultsLesser = consumer.query(NOMINATION_DATA_SET, queryLesser, NominationWithJoda.LIST_TYPE);
View Full Code Here

    private void executeSimpleQuery(final HttpLowLevel connection, final String dataset) throws LongRunningQueryException, SodaError, InterruptedException
    {

        //Create a query that should return a single result
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression("primary_naics=325510"))
                .build();

        final Soda2Consumer   soda2Consumer = new Soda2Consumer(connection);

        //
        //   Issue query as a full query
        final ClientResponse responseFullQuery = soda2Consumer.query(dataset, HttpLowLevel.JSON_TYPE, query.toString());
        final List<ToxinData> resultsFullQuery = responseFullQuery.getEntity(new GenericType<List<ToxinData>>() {});
        TestCase.assertEquals(6, resultsFullQuery.size());
        for (ToxinData toxinData : resultsFullQuery) {
            TestCase.assertEquals(325510L, toxinData.getPrimaryNAICS());
        }
View Full Code Here

    private void executeSimpleQuery(final HttpLowLevel connection, final String dataset) throws LongRunningQueryException, SodaError, InterruptedException
    {

        //Create a query that should return a single result
        SoqlQuery query = new SoqlQueryBuilder()
                .setWhereClause(new ConditionalExpression("primary_naics=325510"))
                .build();

        final Soda2Consumer soda2Consumer = new Soda2Consumer(connection);

        //
        //   Issue query as a full query
        final ClientResponse responseFullQuery = soda2Consumer.query(dataset, HttpLowLevel.JSON_TYPE, query.toString());
        final List<ToxinData> resultsFullQuery = responseFullQuery.getEntity(new GenericType<List<ToxinData>>() {});
        TestCase.assertEquals(6, resultsFullQuery.size());
        for (ToxinData toxinData : resultsFullQuery) {
            TestCase.assertEquals(325510L, toxinData.getPrimaryNAICS());
        }
View Full Code Here

        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"),
View Full Code Here

        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"),
View Full Code Here

        try {

            //
            //Verify the row we expect is really there.
            final SoqlQuery   lookupTestRow = new SoqlQueryBuilder()
                        .setWhereClause("id='8880962'")
                        .build();
            final List queryResults = producer.query(dataset.getId(), lookupTestRow, Soda2Producer.HASH_RETURN_TYPE);
            TestCase.assertEquals(1, queryResults.size());
View Full Code Here

TOP

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

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.