use of org.activityinfo.ui.client.component.importDialog.model.match.ColumnMappingGuesser in project activityinfo by bedatadriven.
the class ImportSimpleTest method columnMappingGuesser.
@Test
public void columnMappingGuesser() throws IOException {
FormTree formTree = assertResolves(locator.getFormTree(HOUSEHOLD_SURVEY_FORM_CLASS));
FormTreePrettyPrinter.print(formTree);
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()));
dumpList("COLUMNS", source.getColumns());
dumpList("FIELDS", importer.getImportTargets());
// Step 2: Guesser guess mapping
final ColumnMappingGuesser guesser = new ColumnMappingGuesser(importModel, importer.getImportTargets());
guesser.guess();
assertMapping("Partner", "Partner Name");
assertMapping("district name", "District Name");
}
use of org.activityinfo.ui.client.component.importDialog.model.match.ColumnMappingGuesser in project activityinfo by bedatadriven.
the class ColumnMappingPage method start.
@Override
public void start() {
ColumnMappingGuesser guesser = new ColumnMappingGuesser(importModel, collectNotMappedMandatoryColumns(false));
guesser.guess();
dataGrid.refresh();
if (columnSelectionModel.getSelectedSet().isEmpty() || columnSelectionModel.getSelectedObject().getIndex() != 0) {
columnSelectionModel.setSelected(importModel.getSourceColumn(0), true);
}
onNextPage();
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
refreshGuessedColumns();
}
});
}
Aggregations