Search in sources :

Example 16 with ColumnSetBuilder

use of org.activityinfo.store.query.server.ColumnSetBuilder 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 17 with ColumnSetBuilder

use of org.activityinfo.store.query.server.ColumnSetBuilder 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);
    }
}
Also used : FormStorageProvider(org.activityinfo.store.spi.FormStorageProvider) ColumnSetBuilder(org.activityinfo.store.query.server.ColumnSetBuilder) NullFormSupervisor(org.activityinfo.store.query.shared.NullFormSupervisor)

Example 18 with ColumnSetBuilder

use of org.activityinfo.store.query.server.ColumnSetBuilder in project activityinfo by bedatadriven.

the class QueryEvaluatorTest method circularReference.

@Test
public void circularReference() throws Exception {
    final FormClass formClass = new FormClass(ResourceId.valueOf("XYZ"));
    formClass.addField(ResourceId.valueOf("FA")).setCode("A").setLabel("Field A").setType(new CalculatedFieldType("B"));
    formClass.addField(ResourceId.valueOf("FB")).setCode("B").setLabel("Field B").setType(new CalculatedFieldType("A"));
    FormStorageProviderStub catalog = new FormStorageProviderStub();
    catalog.addForm(formClass).withRowCount(10);
    ColumnSetBuilder builder = new ColumnSetBuilder(catalog, new NullFormScanCache(), new NullFormSupervisor());
    FormScanBatch batch = builder.createNewBatch();
    QueryEvaluator evaluator = new QueryEvaluator(FilterLevel.BASE, catalog.getTree(formClass.getId()), batch);
    Slot<ColumnView> a = evaluator.evaluateExpression(new SymbolNode("A"));
    Slot<ColumnView> aPlusOne = evaluator.evaluateExpression(FormulaParser.parse("A+1"));
    builder.execute(batch);
    assertThat(a.get().numRows(), equalTo(10));
    assertThat(a.get().getString(0), nullValue());
    assertThat(aPlusOne.get().getString(0), nullValue());
    assertThat(aPlusOne.get().getDouble(0), equalTo(1d));
}
Also used : ColumnSetBuilder(org.activityinfo.store.query.server.ColumnSetBuilder) SymbolNode(org.activityinfo.model.formula.SymbolNode) CalculatedFieldType(org.activityinfo.model.type.expr.CalculatedFieldType) FormClass(org.activityinfo.model.form.FormClass) ColumnView(org.activityinfo.model.query.ColumnView) Test(org.junit.Test)

Example 19 with ColumnSetBuilder

use of org.activityinfo.store.query.server.ColumnSetBuilder 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");
    }
}
Also used : ColumnSetBuilder(org.activityinfo.store.query.server.ColumnSetBuilder) AppEngineFormScanCache(org.activityinfo.store.hrd.AppEngineFormScanCache) FormSupervisorAdapter(org.activityinfo.store.query.server.FormSupervisorAdapter) NullFormSupervisor(org.activityinfo.store.query.shared.NullFormSupervisor) CommandException(org.activityinfo.legacy.shared.exception.CommandException) BatchingFormTreeBuilder(org.activityinfo.store.spi.BatchingFormTreeBuilder)

Example 20 with ColumnSetBuilder

use of org.activityinfo.store.query.server.ColumnSetBuilder 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)20 NullFormSupervisor (org.activityinfo.store.query.shared.NullFormSupervisor)16 ColumnSet (org.activityinfo.model.query.ColumnSet)14 QueryModel (org.activityinfo.model.query.QueryModel)13 Test (org.junit.Test)11 ColumnView (org.activityinfo.model.query.ColumnView)8 NullFormScanCache (org.activityinfo.store.query.shared.NullFormScanCache)8 FormClass (org.activityinfo.model.form.FormClass)5 FormField (org.activityinfo.model.form.FormField)3 Quantity (org.activityinfo.model.type.number.Quantity)3 QuantityType (org.activityinfo.model.type.number.QuantityType)3 Charsets (com.google.common.base.Charsets)2 Operation (io.swagger.v3.oas.annotations.Operation)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 MediaType (javax.ws.rs.core.MediaType)2 Response (javax.ws.rs.core.Response)2 StreamingOutput (javax.ws.rs.core.StreamingOutput)2