Search in sources :

Example 16 with PastedTable

use of org.activityinfo.ui.client.component.importDialog.model.source.PastedTable 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 17 with PastedTable

use of org.activityinfo.ui.client.component.importDialog.model.source.PastedTable 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)

Example 18 with PastedTable

use of org.activityinfo.ui.client.component.importDialog.model.source.PastedTable in project activityinfo by bedatadriven.

the class SchemaCsvWriterV3Test method readExportAsTable.

private PastedTable readExportAsTable(String resourceName) throws IOException {
    PastedTable table = new PastedTable(readExport(resourceName));
    table.parseAllRows();
    return table;
}
Also used : PastedTable(org.activityinfo.ui.client.component.importDialog.model.source.PastedTable)

Example 19 with PastedTable

use of org.activityinfo.ui.client.component.importDialog.model.source.PastedTable in project activityinfo by bedatadriven.

the class SchemaImportDialog method tryValidateImport.

private void tryValidateImport() {
    PastedTable source = new PastedTable(textArea.getText());
    if (source.getColumns().size() < 2 || source.getRows().size() <= 1) {
        onInputInvalid(I18N.CONSTANTS.invalidTableData());
        return;
    }
    if (importerV3.accept(source)) {
        importer = importerV3;
    } else {
        importer = importerV2;
    }
    if (!importer.parseColumns(source)) {
        onInputInvalid(I18N.MESSAGES.missingColumns(Joiner.on(", ").join(importer.getMissingColumns())));
        return;
    }
    if (importer.equals(importerV3)) {
        awaitValidation();
        importerV3.processRows(new AsyncCallback<Void>() {

            @Override
            public void onFailure(Throwable caught) {
                // invalid
                onInputInvalid(I18N.CONSTANTS.invalidReference());
            }

            @Override
            public void onSuccess(Void result) {
                // valid
                onInputValid();
            }
        });
    } else {
        importer.processRows();
        onInputValid();
    }
}
Also used : PastedTable(org.activityinfo.ui.client.component.importDialog.model.source.PastedTable)

Aggregations

PastedTable (org.activityinfo.ui.client.component.importDialog.model.source.PastedTable)19 Test (org.junit.Test)16 FormTree (org.activityinfo.model.formTree.FormTree)8 ImportModel (org.activityinfo.ui.client.component.importDialog.model.ImportModel)8 ValidatedRowTable (org.activityinfo.ui.client.component.importDialog.model.validation.ValidatedRowTable)5 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)3 SourceColumn (org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn)3 SchemaImporterV3 (org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3)3 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 GetSites (org.activityinfo.legacy.shared.command.GetSites)2 SiteResult (org.activityinfo.legacy.shared.command.result.SiteResult)2 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)2 ColumnSet (org.activityinfo.model.query.ColumnSet)2 QueryModel (org.activityinfo.model.query.QueryModel)2 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)1 Filter (org.activityinfo.legacy.shared.command.Filter)1 FormClass (org.activityinfo.model.form.FormClass)1 FieldPath (org.activityinfo.model.formTree.FieldPath)1 FormTreeBuilder (org.activityinfo.model.formTree.FormTreeBuilder)1 FormTreePrettyPrinter (org.activityinfo.model.formTree.FormTreePrettyPrinter)1