Search in sources :

Example 21 with MappingValueRename

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);
}
Also used : MappingValueRename(org.pentaho.di.trans.steps.mapping.MappingValueRename) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 22 with MappingValueRename

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"));
}
Also used : MappingValueRename(org.pentaho.di.trans.steps.mapping.MappingValueRename) Before(org.junit.Before)

Example 23 with MappingValueRename

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;
}
Also used : MappingValueRename(org.pentaho.di.trans.steps.mapping.MappingValueRename) ArrayList(java.util.ArrayList) SourceToTargetMapping(org.pentaho.di.core.SourceToTargetMapping)

Aggregations

MappingValueRename (org.pentaho.di.trans.steps.mapping.MappingValueRename)23 RowMeta (org.pentaho.di.core.row.RowMeta)7 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)7 ArrayList (java.util.ArrayList)6 KettleException (org.pentaho.di.core.exception.KettleException)6 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)6 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)5 MappingIODefinition (org.pentaho.di.trans.steps.mapping.MappingIODefinition)5 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 HashMap (java.util.HashMap)3 TableItem (org.eclipse.swt.widgets.TableItem)3 SourceToTargetMapping (org.pentaho.di.core.SourceToTargetMapping)3 List (java.util.List)2 CTabItem (org.eclipse.swt.custom.CTabItem)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 FormLayout (org.eclipse.swt.layout.FormLayout)2 Button (org.eclipse.swt.widgets.Button)2