use of org.pentaho.di.trans.steps.mapping.MappingValueRename in project pentaho-kettle by pentaho.
the class MappingInputMeta_GetFields_Test method alreadyRenamed.
private static Object[] alreadyRenamed() {
RowMeta inputRowMeta = createRowMeta("field1", "renamed");
List<MappingValueRename> renames = Collections.singletonList(new MappingValueRename("field2", "renamed"));
String[] fields = new String[] { "field1", "renamed" };
String[] expected = new String[] { "field1", "renamed" };
return createCaseData(inputRowMeta, renames, fields, expected);
}
use of org.pentaho.di.trans.steps.mapping.MappingValueRename in project pentaho-kettle by pentaho.
the class MappingUtilTest method setup.
@Before
public void setup() {
sourceFields = new ArrayList<>(Arrays.asList(new String[] { "source1", "source2", "source3" }));
targetFields = new ArrayList<>(Arrays.asList(new String[] { "target1", "target2" }));
mappingValues = new ArrayList<>();
mappingValues.add(new MappingValueRename("source1", "target2"));
mappingValues.add(new MappingValueRename("source3", "target1"));
}
use of org.pentaho.di.trans.steps.mapping.MappingValueRename in project pentaho-kettle by pentaho.
the class MappingUtil method getCurrentMappings.
public static List<SourceToTargetMapping> getCurrentMappings(List<String> sourceFields, List<String> targetFields, List<MappingValueRename> mappingValues) {
List<SourceToTargetMapping> sourceToTargetMapping = new ArrayList<>();
if (sourceFields == null || targetFields == null || mappingValues == null) {
return sourceToTargetMapping;
}
if (!mappingValues.isEmpty()) {
for (MappingValueRename mappingValue : mappingValues) {
String source = mappingValue.getSourceValueName();
String target = mappingValue.getTargetValueName();
int sourceIndex = sourceFields.indexOf(source);
int targetIndex = targetFields.indexOf(target);
sourceToTargetMapping.add(new SourceToTargetMapping(sourceIndex, targetIndex));
}
}
return sourceToTargetMapping;
}
Aggregations