Search in sources :

Example 6 with SourceColumn

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

the class ImportSimpleTest method assertMapping.

private void assertMapping(String sourceColumnLabel, String targetColumnLabel) {
    final SourceColumn sourceColumn = importModel.getSourceColumn(columnIndex(sourceColumnLabel));
    assertNotNull(sourceColumn);
    final MapExistingAction columnAction = (MapExistingAction) importModel.getColumnAction(sourceColumn);
    assertTrue(columnAction.getTarget().getLabel().equals(targetColumnLabel));
}
Also used : SourceColumn(org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn) MapExistingAction(org.activityinfo.ui.client.component.importDialog.model.MapExistingAction)

Example 7 with SourceColumn

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

the class PastedTableTest method nfiParsingPerformance.

@Test
public void nfiParsingPerformance() throws IOException {
    long start = System.currentTimeMillis();
    PastedTable pastedTable = new PastedTable(Resources.toString(getResource(getClass(), "nfi-import-test.csv"), Charsets.UTF_8));
    pastedTable.parseAllRows();
    final List<SourceColumn> columns = pastedTable.getColumns();
    final List<? extends SourceRow> rows = pastedTable.getRows();
    long end = System.currentTimeMillis();
    System.out.println("Done in " + (end - start) + "ms , rows count=" + rows.size() + ", columns count=" + columns.size());
}
Also used : PastedTable(org.activityinfo.ui.client.component.importDialog.model.source.PastedTable) SourceColumn(org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn) Test(org.junit.Test)

Example 8 with SourceColumn

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

the class RowParserTest method qisCsvColumns.

@Test
public void qisCsvColumns() throws IOException {
    PastedTable source = new PastedTable(Resources.toString(getResource(getClass(), "qis.csv"), Charsets.UTF_8));
    final List<SourceColumn> columns = source.getColumns();
    System.out.println(Joiner.on('\n').join(columns));
    assertThat(columns.size(), equalTo(47));
}
Also used : PastedTable(org.activityinfo.ui.client.component.importDialog.model.source.PastedTable) SourceColumn(org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn) Test(org.junit.Test)

Example 9 with SourceColumn

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

the class ColumnMappingGrid method refresh.

public void refresh() {
    while (this.getColumnCount() > 0) {
        this.removeColumn(0);
    }
    sourceColumns = model.getSource().getColumns();
    for (SourceColumn sourceColumn : sourceColumns) {
        GridColumn gridColumn = new GridColumn(sourceColumn);
        GridHeader gridHeader = new GridHeader(sourceColumn, headerCell, columnSelectionModel);
        addColumn(gridColumn, gridHeader);
        setColumnWidth(gridColumn, columnWidthInEm(sourceColumn.getHeader()), com.google.gwt.dom.client.Style.Unit.EM);
    }
    this.redrawHeaders();
    // show already parsed data (it can be only part of it, not all)
    this.setRowData(model.getSource().getRows());
    // update table if not all rows are parsed
    if (!model.getSource().parsedAllRows()) {
        // give some time to switch the page
        Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {

            @Override
            public boolean execute() {
                refreshWithNewlyParsedRows();
                return false;
            }
        }, // wait 2 seconds
        2000);
    }
}
Also used : Scheduler(com.google.gwt.core.client.Scheduler) SourceColumn(org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn)

Example 10 with SourceColumn

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

the class ColumnMappingPage method updateColumnMapping.

private void updateColumnMapping(ColumnAction action) {
    final SourceColumn removedColumn = importModel.setColumnBinding(action, getSelectedColumn());
    dataGrid.refreshColumnStyles(getSelectedColumn().getIndex());
    if (removedColumn != null) {
        dataGrid.refreshColumnStyles(removedColumn.getIndex());
    }
    fireStateChanged();
}
Also used : SourceColumn(org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn)

Aggregations

SourceColumn (org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn)10 Map (java.util.Map)3 PastedTable (org.activityinfo.ui.client.component.importDialog.model.source.PastedTable)3 Test (org.junit.Test)3 Cell (com.google.gwt.cell.client.Cell)1 Scheduler (com.google.gwt.core.client.Scheduler)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 TreeMap (java.util.TreeMap)1 ColumnAction (org.activityinfo.ui.client.component.importDialog.model.ColumnAction)1 MapExistingAction (org.activityinfo.ui.client.component.importDialog.model.MapExistingAction)1 SourceColumnAccessor (org.activityinfo.ui.client.component.importDialog.model.source.SourceColumnAccessor)1 ColumnAccessor (org.activityinfo.ui.client.component.importDialog.model.strategy.ColumnAccessor)1 ImportTarget (org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget)1 TargetSiteId (org.activityinfo.ui.client.component.importDialog.model.strategy.TargetSiteId)1