Search in sources :

Example 1 with MapExistingAction

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

the class ColumnActionSelector method updateTypeStyles.

public void updateTypeStyles(FieldTypeClass sourceType) {
    for (Map.Entry<ColumnAction, RadioButton> entry : buttons.entrySet()) {
        final ColumnAction columnAction = entry.getKey();
        if (columnAction instanceof MapExistingAction) {
            final ImportTarget target = ((MapExistingAction) columnAction).getTarget();
            final FieldTypeClass targetType = target.getFormField().getType().getTypeClass();
            final RadioButton button = entry.getValue();
            button.removeStyleName(ColumnMappingStyles.INSTANCE.typeNotMatched());
            button.removeStyleName(ColumnMappingStyles.INSTANCE.typeMatched());
            if (targetType == sourceType || (sourceType == FieldTypeClass.FREE_TEXT && targetType == FieldTypeClass.REFERENCE)) {
                button.addStyleName(ColumnMappingStyles.INSTANCE.typeMatched());
            } else {
                button.addStyleName(ColumnMappingStyles.INSTANCE.typeNotMatched());
            }
        }
    }
}
Also used : ColumnAction(org.activityinfo.ui.client.component.importDialog.model.ColumnAction) ImportTarget(org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget) FieldTypeClass(org.activityinfo.model.type.FieldTypeClass) MapExistingAction(org.activityinfo.ui.client.component.importDialog.model.MapExistingAction) RadioButton(org.activityinfo.ui.client.widget.RadioButton) Map(java.util.Map)

Example 2 with MapExistingAction

use of org.activityinfo.ui.client.component.importDialog.model.MapExistingAction 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 3 with MapExistingAction

use of org.activityinfo.ui.client.component.importDialog.model.MapExistingAction 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 4 with MapExistingAction

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

the class ColumnActionSelector method updateStyles.

public void updateStyles() {
    for (Map.Entry<ColumnAction, RadioButton> entry : buttons.entrySet()) {
        final ColumnAction columnAction = entry.getKey();
        if (columnAction instanceof MapExistingAction) {
            final ImportTarget target = ((MapExistingAction) columnAction).getTarget();
            final RadioButton button = entry.getValue();
            button.removeStyleName(ColumnMappingStyles.INSTANCE.stateBound());
            button.removeStyleName(ColumnMappingStyles.INSTANCE.stateUnset());
            if (!importModel.getMappedColumns(target.getFormField().getId()).isEmpty()) {
                button.addStyleName(ColumnMappingStyles.INSTANCE.stateBound());
            } else if (target.getFormField().isRequired()) {
                button.addStyleName(ColumnMappingStyles.INSTANCE.stateUnset());
            }
        }
    }
}
Also used : ColumnAction(org.activityinfo.ui.client.component.importDialog.model.ColumnAction) ImportTarget(org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget) MapExistingAction(org.activityinfo.ui.client.component.importDialog.model.MapExistingAction) RadioButton(org.activityinfo.ui.client.widget.RadioButton) Map(java.util.Map)

Example 5 with MapExistingAction

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

the class ImportPresenter method createMatchingColumnActions.

private List<MapExistingAction> createMatchingColumnActions() {
    final List<MapExistingAction> columnActions = Lists.newArrayList();
    final List<ImportTarget> importTargets = importer.getImportTargets();
    for (ImportTarget target : importTargets) {
        columnActions.add(new MapExistingAction(target));
    }
    return columnActions;
}
Also used : ImportTarget(org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget) MapExistingAction(org.activityinfo.ui.client.component.importDialog.model.MapExistingAction)

Aggregations

MapExistingAction (org.activityinfo.ui.client.component.importDialog.model.MapExistingAction)6 ImportTarget (org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget)4 ColumnAction (org.activityinfo.ui.client.component.importDialog.model.ColumnAction)3 Map (java.util.Map)2 RadioButton (org.activityinfo.ui.client.widget.RadioButton)2 FormField (org.activityinfo.model.form.FormField)1 FieldTypeClass (org.activityinfo.model.type.FieldTypeClass)1 SourceColumn (org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn)1 ColumnAccessor (org.activityinfo.ui.client.component.importDialog.model.strategy.ColumnAccessor)1 TargetSiteId (org.activityinfo.ui.client.component.importDialog.model.strategy.TargetSiteId)1