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());
}
}
}
}
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;
}
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));
}
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());
}
}
}
}
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;
}
Aggregations