Search in sources :

Example 1 with SchemaImporterV3

use of org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3 in project activityinfo by bedatadriven.

the class DbEditor method onUIAction.

private void onUIAction(String actionId) {
    if (UIActions.SAVE.equals(actionId)) {
        save();
    } else if (UIActions.DELETE.equals(actionId)) {
        promptDeleteSelection();
    } else if (UIActions.IMPORT.equals(actionId)) {
        SchemaImportDialog dialog = new SchemaImportDialog(new SchemaImporterV2(service, db), new SchemaImporterV3(db.getId(), locator));
        dialog.show().then(() -> {
            refresh();
            return null;
        });
    } else if (UIActions.EDIT.equals(actionId)) {
        Optional<ResourceId> selectedFormId = getSelectedFormId();
        if (selectedFormId.isPresent()) {
            eventBus.fireEvent(new NavigationEvent(NavigationHandler.NAVIGATION_REQUESTED, new ResourcePlace(selectedFormId.get(), ResourcePage.DESIGN_PAGE_ID)));
        }
    } else if (UIActions.OPEN_TABLE.equals(actionId)) {
        Optional<ResourceId> selectedFormId = getSelectedFormId();
        if (selectedFormId.isPresent()) {
            App3.openNewTable(selectedFormId.get());
        }
    }
}
Also used : SchemaImporterV3(org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3) ResourcePlace(org.activityinfo.ui.client.page.resource.ResourcePlace) ResourceId(org.activityinfo.model.resource.ResourceId) SchemaImportDialog(org.activityinfo.ui.client.page.config.design.importer.SchemaImportDialog) SchemaImporterV2(org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV2)

Example 2 with SchemaImporterV3

use of org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3 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 3 with SchemaImporterV3

use of org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3 in project activityinfo by bedatadriven.

the class SchemaCsvWriterV3Test method missingReferences.

@Test
public void missingReferences() throws IOException {
    PastedTable pastedTable = readExportAsTable("malformed-ref.csv");
    System.out.println(pastedTable);
    SchemaImporterV3 importer = new SchemaImporterV3(database.getId(), null, null);
    assertTrue(importer.parseColumns(pastedTable));
    boolean success = importer.processRows();
    for (SafeHtml warning : importer.getWarnings()) {
        System.out.println(warning);
    }
    assertTrue("warnings emitted", importer.getWarnings().size() == 1);
    assertTrue("parsing failed", !success);
}
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) Test(org.junit.Test)

Example 4 with SchemaImporterV3

use of org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3 in project activityinfo by bedatadriven.

the class SchemaCsvWriterV3Test method missingFieldNames.

@Test
public void missingFieldNames() throws IOException {
    PastedTable pastedTable = readExportAsTable("malformed.csv");
    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("warnings emitted", importer.getWarnings().size() == 2);
    assertTrue("parsing failed", !success);
}
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) Test(org.junit.Test)

Aggregations

SchemaImporterV3 (org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3)4 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)3 PastedTable (org.activityinfo.ui.client.component.importDialog.model.source.PastedTable)3 Test (org.junit.Test)3 FormClass (org.activityinfo.model.form.FormClass)1 FormTreeBuilder (org.activityinfo.model.formTree.FormTreeBuilder)1 FormTreePrettyPrinter (org.activityinfo.model.formTree.FormTreePrettyPrinter)1 ResourceId (org.activityinfo.model.resource.ResourceId)1 SchemaImportDialog (org.activityinfo.ui.client.page.config.design.importer.SchemaImportDialog)1 SchemaImporterV2 (org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV2)1 ResourcePlace (org.activityinfo.ui.client.page.resource.ResourcePlace)1