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