use of org.activityinfo.store.query.shared.NullFormSupervisor in project activityinfo by bedatadriven.
the class DateFunctionQueryTest method testToday.
@Test
public void testToday() {
TestingStorageProvider catalog = new TestingStorageProvider();
IntakeForm intakeForm = catalog.getIntakeForm();
ColumnSetBuilder builder = new ColumnSetBuilder(catalog, new NullFormScanCache(), new NullFormSupervisor());
QueryModel queryModel = new QueryModel(intakeForm.getFormId());
queryModel.selectExpr("TODAY()").as("today");
queryModel.selectExpr("YEARFRAC(TODAY(), DOB)").as("age");
queryModel.selectExpr("DOB").as("dob");
ColumnSet columnSet = builder.build(queryModel);
ColumnView today = columnSet.getColumnView("today");
ColumnView age = columnSet.getColumnView("age");
ColumnView dob = columnSet.getColumnView("dob");
for (int i = 0; i < columnSet.getNumRows(); i++) {
if (dob.getString(i) != null) {
double ageInYears = age.getDouble(i);
System.out.println(dob.get(i) + " " + ageInYears);
if (Double.isNaN(ageInYears)) {
throw new AssertionError();
}
}
}
System.out.println(age);
}
use of org.activityinfo.store.query.shared.NullFormSupervisor 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));
}
use of org.activityinfo.store.query.shared.NullFormSupervisor 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();
}
use of org.activityinfo.store.query.shared.NullFormSupervisor in project activityinfo by bedatadriven.
the class ActivityInfoClientAsyncStub method queryTableColumns.
@Override
public Promise<ColumnSet> queryTableColumns(QueryModel query) {
try {
FormStorageProvider catalog = newCatalog();
ColumnSetBuilder builder = new ColumnSetBuilder(catalog, new NullFormSupervisor());
return Promise.resolved(builder.build(query));
} catch (Exception e) {
return Promise.rejected(e);
}
}
use of org.activityinfo.store.query.shared.NullFormSupervisor in project activityinfo by bedatadriven.
the class GetSitesHandler method initialiseHandler.
private void initialiseHandler(GetSites command, User user) {
catalog = catalogProvider.get();
if (catalog != null) {
this.command = command;
builder = new ColumnSetBuilder(catalog, new AppEngineFormScanCache(), new FormSupervisorAdapter(catalog, user.getId()));
linkedBuilder = new ColumnSetBuilder(catalog, new AppEngineFormScanCache(), new NullFormSupervisor());
batchFormTreeBuilder = new BatchingFormTreeBuilder(catalog);
batch = builder.createNewBatch();
linkedBatch = linkedBuilder.createNewBatch();
selfLinkedActivities = Maps.newHashMap();
sortInfo = command.getSortInfo();
offset = command.getOffset();
limit = command.getLimit();
totalResultLength = 0;
} else {
throw new CommandException("Could not retrieve form catalog");
}
}
Aggregations