Search in sources :

Example 6 with NullFormScanCache

use of org.activityinfo.store.query.shared.NullFormScanCache in project activityinfo by bedatadriven.

the class EnumerationQueryTest method enumRefTests.

@Test
public void enumRefTests() {
    TestingStorageProvider catalog = new TestingStorageProvider();
    ColumnSetBuilder builder = new ColumnSetBuilder(catalog, new NullFormScanCache(), new NullFormSupervisor());
    IntakeForm intakeForm = catalog.getIntakeForm();
    QueryModel queryModel = new QueryModel(intakeForm.getFormId());
    queryModel.selectField(intakeForm.getNationalityFieldId()).as("nationality");
    queryModel.selectExpr(intakeForm.getNationalityFieldId() + "==" + "\"" + intakeForm.getPalestinianId() + "\"").as("palestinian");
    queryModel.selectExpr("\"" + intakeForm.getPalestinianId() + "\"" + "==" + intakeForm.getNationalityFieldId()).as("palestinianInverse");
    ColumnSet columnSet = builder.build(queryModel);
    ColumnView nationality = columnSet.getColumnView("nationality");
    ColumnView palestinian = columnSet.getColumnView("palestinian");
    ColumnView palestinianInverse = columnSet.getColumnView("palestinianInverse");
    // Correct Tests
    assertThat(nationality.get(1).toString(), equalTo(NAT_PAL));
    assertThat(Boolean.valueOf(palestinian.get(1).toString()), equalTo(true));
    assertThat(Boolean.valueOf(palestinianInverse.get(1).toString()), equalTo(true));
    // Incorrect Tests
    // Multiple selected values should return null
    assertThat(nationality.get(5), equalTo(null));
}
Also used : ColumnSetBuilder(org.activityinfo.store.query.server.ColumnSetBuilder) NullFormScanCache(org.activityinfo.store.query.shared.NullFormScanCache) ColumnView(org.activityinfo.model.query.ColumnView) EnumColumnView(org.activityinfo.model.query.EnumColumnView) ColumnSet(org.activityinfo.model.query.ColumnSet) NullFormSupervisor(org.activityinfo.store.query.shared.NullFormSupervisor) QueryModel(org.activityinfo.model.query.QueryModel) Test(org.junit.Test)

Example 7 with NullFormScanCache

use of org.activityinfo.store.query.shared.NullFormScanCache in project activityinfo by bedatadriven.

the class UnaryFunctionQueryTest method setup.

@Before
public void setup() {
    catalog = new TestingStorageProvider();
    builder = new ColumnSetBuilder(catalog, new NullFormScanCache(), new NullFormSupervisor());
    intakeForm = catalog.getIntakeForm();
}
Also used : ColumnSetBuilder(org.activityinfo.store.query.server.ColumnSetBuilder) NullFormScanCache(org.activityinfo.store.query.shared.NullFormScanCache) NullFormSupervisor(org.activityinfo.store.query.shared.NullFormSupervisor) Before(org.junit.Before)

Example 8 with NullFormScanCache

use of org.activityinfo.store.query.shared.NullFormScanCache in project activityinfo by bedatadriven.

the class AsyncClientStub method queryTableColumns.

@Override
public Promise<ColumnSet> queryTableColumns(QueryModel query) {
    if (!connected) {
        return offlineResult();
    }
    ColumnSetBuilder columnSetBuilder = new ColumnSetBuilder(storageProvider, new NullFormScanCache(), new NullFormSupervisor());
    ColumnSet columnSet = columnSetBuilder.build(query);
    return Promise.resolved(columnSet);
}
Also used : ColumnSetBuilder(org.activityinfo.store.query.server.ColumnSetBuilder) NullFormScanCache(org.activityinfo.store.query.shared.NullFormScanCache) ColumnSet(org.activityinfo.model.query.ColumnSet) NullFormSupervisor(org.activityinfo.store.query.shared.NullFormSupervisor)

Aggregations

ColumnSetBuilder (org.activityinfo.store.query.server.ColumnSetBuilder)8 NullFormScanCache (org.activityinfo.store.query.shared.NullFormScanCache)8 NullFormSupervisor (org.activityinfo.store.query.shared.NullFormSupervisor)8 ColumnSet (org.activityinfo.model.query.ColumnSet)7 ColumnView (org.activityinfo.model.query.ColumnView)6 QueryModel (org.activityinfo.model.query.QueryModel)6 Test (org.junit.Test)6 EnumColumnView (org.activityinfo.model.query.EnumColumnView)2 Before (org.junit.Before)1