Search in sources :

Example 26 with FormTree

use of org.activityinfo.model.formTree.FormTree in project activityinfo by bedatadriven.

the class MySqlCatalogTest method queryFormTree.

private FormTree queryFormTree(ResourceId classId) {
    FormTreeBuilder builder = new FormTreeBuilder(catalog);
    FormTree formTree = builder.queryTree(classId);
    JsonValue formTreeObject = JsonFormTreeBuilder.toJson(formTree);
    formTree = JsonFormTreeBuilder.fromJson(formTreeObject);
    return formTree;
}
Also used : FormTree(org.activityinfo.model.formTree.FormTree) JsonValue(org.activityinfo.json.JsonValue) FormTreeBuilder(org.activityinfo.model.formTree.FormTreeBuilder) JsonFormTreeBuilder(org.activityinfo.model.formTree.JsonFormTreeBuilder)

Example 27 with FormTree

use of org.activityinfo.model.formTree.FormTree in project activityinfo by bedatadriven.

the class MySqlCatalogTest method testReportingPeriod.

@Test
public void testReportingPeriod() {
    FormTreeBuilder treeBuilder = new FormTreeBuilder(catalog);
    FormTree formTree = treeBuilder.queryTree(CuidAdapter.reportingPeriodFormClass(3));
    FormTreePrettyPrinter.print(formTree);
    query(CuidAdapter.reportingPeriodFormClass(3), "rate", "date1", "date2", "site.partner", "site.partner.label", "site.location.label");
    assertThat(column("date1"), hasValues("2009-01-01", "2009-02-01", "2009-03-01"));
}
Also used : FormTree(org.activityinfo.model.formTree.FormTree) FormTreeBuilder(org.activityinfo.model.formTree.FormTreeBuilder) JsonFormTreeBuilder(org.activityinfo.model.formTree.JsonFormTreeBuilder) Test(org.junit.Test)

Example 28 with FormTree

use of org.activityinfo.model.formTree.FormTree in project activityinfo by bedatadriven.

the class ColumnSetBuilder method enqueue.

public Slot<ColumnSet> enqueue(QueryModel queryModel, FormScanBatch batch) {
    ResourceId formId = queryModel.getRowSources().get(0).getRootFormId();
    FormTree tree = formTreeBuilder.queryTree(formId);
    if (tree.getRootState() == FormTree.State.VALID) {
        return enqueue(tree, queryModel, batch);
    } else {
        return emptySet(queryModel);
    }
}
Also used : FormTree(org.activityinfo.model.formTree.FormTree) ResourceId(org.activityinfo.model.resource.ResourceId)

Example 29 with FormTree

use of org.activityinfo.model.formTree.FormTree in project activityinfo by bedatadriven.

the class FormResource method getTreePrettyPrinted.

@GET
@NoCache
@Produces(MediaType.TEXT_PLAIN)
@Path("tree/pretty")
public String getTreePrettyPrinted() {
    FormTree tree = fetchTree();
    StringWriter stringWriter = new StringWriter();
    FormTreePrettyPrinter printer = new FormTreePrettyPrinter(new PrintWriter(stringWriter));
    printer.printTree(tree);
    return stringWriter.toString();
}
Also used : FormTree(org.activityinfo.model.formTree.FormTree) StringWriter(java.io.StringWriter) FormTreePrettyPrinter(org.activityinfo.model.formTree.FormTreePrettyPrinter) PrintWriter(java.io.PrintWriter)

Example 30 with FormTree

use of org.activityinfo.model.formTree.FormTree in project activityinfo by bedatadriven.

the class ImportSimpleTest method testExceptionHandling.

@Test
public void testExceptionHandling() throws IOException {
    FormTree formTree = assertResolves(locator.getFormTree(HOUSEHOLD_SURVEY_FORM_CLASS));
    importModel = new ImportModel(formTree);
    // Step 1: User pastes in data to import
    PastedTable source = new PastedTable(Resources.toString(getResource(getClass(), "qis.csv"), Charsets.UTF_8));
    importModel.setSource(source);
    importer = new Importer(locator, formTree, FieldImportStrategies.get(JvmConverterFactory.get()));
    importModel.setColumnAction(columnIndex("MEMBER_NO_ADULT_FEMALE"), target("NumAdultMale"));
    importModel.setColumnAction(columnIndex("MEMBER_NO_ADULT_FEMALE"), target("NumAdultFemale"));
    importModel.setColumnAction(columnIndex("_CREATION_DATE"), target("Start Date"));
    importModel.setColumnAction(columnIndex("_SUBMISSION_DATE"), target("End Date"));
    importModel.setColumnAction(columnIndex("district name"), target("District Name"));
    importModel.setColumnAction(columnIndex("upazila"), target("Upzilla Name"));
    // importModel.setColumnAction(columnIndex("Partner"), target("Partner Name"));
    Promise<Void> result = importer.persist(importModel);
    assertThat(result.getState(), equalTo(Promise.State.REJECTED));
}
Also used : FormTree(org.activityinfo.model.formTree.FormTree) PastedTable(org.activityinfo.ui.client.component.importDialog.model.source.PastedTable) ImportModel(org.activityinfo.ui.client.component.importDialog.model.ImportModel) Test(org.junit.Test)

Aggregations

FormTree (org.activityinfo.model.formTree.FormTree)55 Test (org.junit.Test)35 ResourceId (org.activityinfo.model.resource.ResourceId)12 FormTreeBuilder (org.activityinfo.model.formTree.FormTreeBuilder)10 FormClass (org.activityinfo.model.form.FormClass)9 ColumnSet (org.activityinfo.model.query.ColumnSet)9 QueryModel (org.activityinfo.model.query.QueryModel)8 ImportModel (org.activityinfo.ui.client.component.importDialog.model.ImportModel)8 PastedTable (org.activityinfo.ui.client.component.importDialog.model.source.PastedTable)8 FormField (org.activityinfo.model.form.FormField)7 RecordRef (org.activityinfo.model.type.RecordRef)7 LookupKeySet (org.activityinfo.model.formTree.LookupKeySet)6 FormulaNode (org.activityinfo.model.formula.FormulaNode)6 ReferenceType (org.activityinfo.model.type.ReferenceType)6 LookupKey (org.activityinfo.model.formTree.LookupKey)5 ValidatedRowTable (org.activityinfo.ui.client.component.importDialog.model.validation.ValidatedRowTable)5 Optional (com.google.common.base.Optional)4 ColumnView (org.activityinfo.model.query.ColumnView)4 Nullable (javax.annotation.Nullable)3 DimensionCategory (org.activityinfo.legacy.shared.reports.content.DimensionCategory)3