Search in sources :

Example 1 with FormTreePrettyPrinter

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

the class SchemaCsvWriterV3Test method importSurveyForm.

@Test
public void importSurveyForm() {
    PastedTable pastedTable = new PastedTable(expectedSurveyExport);
    SchemaImporterV3 importer = new SchemaImporterV3(database.getId(), null, null);
    assertTrue("columns found", importer.parseColumns(pastedTable));
    boolean success = importer.processRows();
    for (SafeHtml warning : importer.getWarnings()) {
        System.out.println(warning);
    }
    assertTrue(success);
    List<FormClass> formClasses = importer.toSave();
    formClassProvider.addAll(formClasses);
    FormTreeBuilder treeBuilder = new FormTreeBuilder(formClassProvider);
    FormTreePrettyPrinter prettyPrinter = new FormTreePrettyPrinter();
    for (FormClass formClass : formClasses) {
        if (!formClass.isSubForm()) {
            prettyPrinter.printTree(treeBuilder.queryTree(formClass.getId()));
        }
    }
}
Also used : SchemaImporterV3(org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3) PastedTable(org.activityinfo.ui.client.component.importDialog.model.source.PastedTable) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) FormClass(org.activityinfo.model.form.FormClass) FormTreePrettyPrinter(org.activityinfo.model.formTree.FormTreePrettyPrinter) FormTreeBuilder(org.activityinfo.model.formTree.FormTreeBuilder) Test(org.junit.Test)

Example 2 with FormTreePrettyPrinter

use of org.activityinfo.model.formTree.FormTreePrettyPrinter 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 3 with FormTreePrettyPrinter

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

the class NodeMatcherTest method prettyPrintTree.

private void prettyPrintTree() {
    FormTreePrettyPrinter prettyPrinter = new FormTreePrettyPrinter();
    prettyPrinter.printTree(tree());
}
Also used : FormTreePrettyPrinter(org.activityinfo.model.formTree.FormTreePrettyPrinter)

Aggregations

FormTreePrettyPrinter (org.activityinfo.model.formTree.FormTreePrettyPrinter)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 FormClass (org.activityinfo.model.form.FormClass)1 FormTree (org.activityinfo.model.formTree.FormTree)1 FormTreeBuilder (org.activityinfo.model.formTree.FormTreeBuilder)1 PastedTable (org.activityinfo.ui.client.component.importDialog.model.source.PastedTable)1 SchemaImporterV3 (org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3)1 Test (org.junit.Test)1