Search in sources :

Example 1 with ColumnAccessor

use of org.activityinfo.ui.client.component.importDialog.model.strategy.ColumnAccessor in project activityinfo by bedatadriven.

the class ColumnMappingPage method collectNotMappedMandatoryColumns.

/**
 * @param mandatory if true - then only mandatory, if false then ALL
 * @return
 */
public List<ImportTarget> collectNotMappedMandatoryColumns(boolean mandatory) {
    List<ImportTarget> list = Lists.newArrayList();
    for (final MapExistingAction action : actions) {
        final FormField formField = action.getTarget().getFormField();
        if (mandatory && !formField.isRequired()) {
            continue;
        }
        final Map<TargetSiteId, ColumnAccessor> mappedColumns = importModel.getMappedColumns(formField.getId());
        if (mappedColumns.isEmpty()) {
            list.add(action.getTarget());
        }
    }
    return list;
}
Also used : ImportTarget(org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget) ColumnAccessor(org.activityinfo.ui.client.component.importDialog.model.strategy.ColumnAccessor) MapExistingAction(org.activityinfo.ui.client.component.importDialog.model.MapExistingAction) TargetSiteId(org.activityinfo.ui.client.component.importDialog.model.strategy.TargetSiteId) FormField(org.activityinfo.model.form.FormField)

Example 2 with ColumnAccessor

use of org.activityinfo.ui.client.component.importDialog.model.strategy.ColumnAccessor in project activityinfo by bedatadriven.

the class ImportModel method getMappedColumns.

public Map<TargetSiteId, ColumnAccessor> getMappedColumns(ResourceId fieldId) {
    Map<TargetSiteId, ColumnAccessor> mappings = Maps.newHashMap();
    for (Map.Entry<SourceColumn, MapExistingAction> entry : getMapExistingActions(fieldId).entrySet()) {
        TargetSiteId site = entry.getValue().getTarget().getSite();
        ColumnAccessor column = new SourceColumnAccessor(entry.getKey());
        mappings.put(site, column);
    }
    return mappings;
}
Also used : SourceColumnAccessor(org.activityinfo.ui.client.component.importDialog.model.source.SourceColumnAccessor) ColumnAccessor(org.activityinfo.ui.client.component.importDialog.model.strategy.ColumnAccessor) SourceColumnAccessor(org.activityinfo.ui.client.component.importDialog.model.source.SourceColumnAccessor) SourceColumn(org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn) TargetSiteId(org.activityinfo.ui.client.component.importDialog.model.strategy.TargetSiteId) Map(java.util.Map)

Example 3 with ColumnAccessor

use of org.activityinfo.ui.client.component.importDialog.model.strategy.ColumnAccessor in project activityinfo by bedatadriven.

the class ImportCommandExecutor method createImporters.

private List<FieldImporter> createImporters(final ImportModel model) {
    final List<FieldImporter> importers = Lists.newArrayList();
    for (Importer.TargetField field : fields) {
        Map<TargetSiteId, ColumnAccessor> mappedColumns = model.getMappedColumns(field.node.getFieldId());
        if (!mappedColumns.isEmpty()) {
            System.out.println(field + " => " + mappedColumns);
            FieldImporter importer = field.strategy.createImporter(field.node, mappedColumns, model);
            importers.add(importer);
        }
    }
    return importers;
}
Also used : FieldImporter(org.activityinfo.ui.client.component.importDialog.model.strategy.FieldImporter) ColumnAccessor(org.activityinfo.ui.client.component.importDialog.model.strategy.ColumnAccessor) TargetSiteId(org.activityinfo.ui.client.component.importDialog.model.strategy.TargetSiteId) FieldImporter(org.activityinfo.ui.client.component.importDialog.model.strategy.FieldImporter)

Aggregations

ColumnAccessor (org.activityinfo.ui.client.component.importDialog.model.strategy.ColumnAccessor)3 TargetSiteId (org.activityinfo.ui.client.component.importDialog.model.strategy.TargetSiteId)3 Map (java.util.Map)1 FormField (org.activityinfo.model.form.FormField)1 MapExistingAction (org.activityinfo.ui.client.component.importDialog.model.MapExistingAction)1 SourceColumn (org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn)1 SourceColumnAccessor (org.activityinfo.ui.client.component.importDialog.model.source.SourceColumnAccessor)1 FieldImporter (org.activityinfo.ui.client.component.importDialog.model.strategy.FieldImporter)1 ImportTarget (org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget)1