Search in sources :

Example 1 with ColumnMappingGuesser

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");
}
Also used : FormTree(org.activityinfo.model.formTree.FormTree) PastedTable(org.activityinfo.ui.client.component.importDialog.model.source.PastedTable) ColumnMappingGuesser(org.activityinfo.ui.client.component.importDialog.model.match.ColumnMappingGuesser) ImportModel(org.activityinfo.ui.client.component.importDialog.model.ImportModel) Test(org.junit.Test)

Example 2 with ColumnMappingGuesser

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();
        }
    });
}
Also used : Scheduler(com.google.gwt.core.client.Scheduler) ColumnMappingGuesser(org.activityinfo.ui.client.component.importDialog.model.match.ColumnMappingGuesser)

Aggregations

ColumnMappingGuesser (org.activityinfo.ui.client.component.importDialog.model.match.ColumnMappingGuesser)2 Scheduler (com.google.gwt.core.client.Scheduler)1 FormTree (org.activityinfo.model.formTree.FormTree)1 ImportModel (org.activityinfo.ui.client.component.importDialog.model.ImportModel)1 PastedTable (org.activityinfo.ui.client.component.importDialog.model.source.PastedTable)1 Test (org.junit.Test)1