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;
}
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"));
}
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);
}
}
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();
}
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));
}
Aggregations