Java Code Examples for org.pentaho.di.core.row.RowMetaInterface#removeValueMeta()
The following examples show how to use
org.pentaho.di.core.row.RowMetaInterface#removeValueMeta() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CombinationLookupMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { ValueMetaInterface v = new ValueMetaInteger( technicalKeyField ); v.setLength( 10 ); v.setPrecision( 0 ); v.setOrigin( origin ); row.addValueMeta( v ); if ( replaceFields ) { for ( int i = 0; i < keyField.length; i++ ) { int idx = row.indexOfValue( keyField[ i ] ); if ( idx >= 0 ) { row.removeValueMeta( idx ); } } } }
Example 2
Source File: SelectValuesMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getDeleteFields( RowMetaInterface inputRowMeta ) throws KettleStepException { if ( deleteName != null && deleteName.length > 0 ) { // DESELECT values from the stream... for ( int i = 0; i < deleteName.length; i++ ) { try { inputRowMeta.removeValueMeta( deleteName[i] ); } catch ( KettleValueException e ) { throw new KettleStepException( e ); } } } }
Example 3
Source File: FlattenerMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { // Remove the key value (there will be different entries for each output row) // if ( fieldName != null && fieldName.length() > 0 ) { int idx = row.indexOfValue( fieldName ); if ( idx < 0 ) { throw new KettleStepException( BaseMessages.getString( PKG, "FlattenerMeta.Exception.UnableToLocateFieldInInputFields", fieldName ) ); } ValueMetaInterface v = row.getValueMeta( idx ); row.removeValueMeta( idx ); for ( int i = 0; i < targetField.length; i++ ) { ValueMetaInterface value = v.clone(); value.setName( targetField[i] ); value.setOrigin( name ); row.addValueMeta( value ); } } else { throw new KettleStepException( BaseMessages.getString( PKG, "FlattenerMeta.Exception.FlattenFieldRequired" ) ); } }
Example 4
Source File: XMLJoinMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { ValueMetaInterface v = new ValueMeta( this.getValueXMLfield(), ValueMetaInterface.TYPE_STRING ); v.setOrigin( name ); TransMeta transMeta = (TransMeta) space; try { // Row should only include fields from the target and not the source. During the preview table generation // the fields from all previous steps (source and target) are included in the row so lets remove the // source fields. List<String> targetFieldNames = null; RowMetaInterface targetRowMeta = transMeta.getStepFields( transMeta.findStep( getTargetXMLstep() ), null, null ); if ( targetRowMeta != null ) { targetFieldNames = Arrays.asList( targetRowMeta.getFieldNames() ); } for ( String fieldName : transMeta.getStepFields( transMeta.findStep( getSourceXMLstep() ), null, null ).getFieldNames() ) { if ( targetFieldNames == null || !targetFieldNames.contains( fieldName ) ) { row.removeValueMeta( fieldName ); } } } catch ( KettleValueException e ) { // Pass } row.addValueMeta( v ); }
Example 5
Source File: GetXMLDataStepAnalyzer.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override protected Map<String, RowMetaInterface> getInputRowMetaInterfaces( GetXMLDataMeta meta ) { Map<String, RowMetaInterface> inputRows = getInputFields( meta ); if ( inputRows == null ) { inputRows = new HashMap<>(); } // Get some boolean flags from the meta for easier access boolean isInFields = meta.isInFields(); boolean isAFile = meta.getIsAFile(); boolean isAUrl = meta.isReadUrl(); // only add resource fields if we are NOT getting the xml or file from a field if ( !isInFields || isAFile || isAUrl ) { RowMetaInterface stepFields = getOutputFields( meta ); RowMetaInterface clone = stepFields.clone(); // if there are previous steps providing data, we should remove them from the set of "resource" fields for ( RowMetaInterface rowMetaInterface : inputRows.values() ) { for ( ValueMetaInterface valueMetaInterface : rowMetaInterface.getValueMetaList() ) { try { clone.removeValueMeta( valueMetaInterface.getName() ); } catch ( KettleValueException e ) { // could not find it in the output, skip it } } } inputRows.put( RESOURCE, clone ); } return inputRows; }
Example 6
Source File: ConcatFieldsMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { // do not call the super class from TextFileOutputMeta since it modifies the source meta data // see getFieldsModifyInput() instead // remove selected fields from the stream when true if ( removeSelectedFields ) { if ( getOutputFields().length > 0 ) { for ( int i = 0; i < getOutputFields().length; i++ ) { TextFileField field = getOutputFields()[ i ]; try { row.removeValueMeta( field.getName() ); } catch ( KettleValueException e ) { // just ignore exceptions since missing fields are handled in the ConcatFields class } } } else { // no output fields selected, take them all, remove them all row.clear(); } } // Check Target Field Name if ( Utils.isEmpty( targetFieldName ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "ConcatFieldsMeta.CheckResult.TargetFieldNameMissing" ) ); } // add targetFieldName ValueMetaInterface vValue = new ValueMetaString( targetFieldName ); vValue.setLength( targetFieldLength, 0 ); vValue.setOrigin( name ); if ( !Utils.isEmpty( getEncoding() ) ) { vValue.setStringEncoding( getEncoding() ); } row.addValueMeta( vValue ); }
Example 7
Source File: NormaliserMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { // Get a unique list of the occurrences of the type // List<String> norm_occ = new ArrayList<>(); List<String> field_occ = new ArrayList<>(); int maxlen = 0; for ( int i = 0; i < normaliserFields.length; i++ ) { if ( !norm_occ.contains( normaliserFields[i].getNorm() ) ) { norm_occ.add( normaliserFields[i].getNorm() ); field_occ.add( normaliserFields[i].getName() ); } if ( normaliserFields[i].getValue().length() > maxlen ) { maxlen = normaliserFields[i].getValue().length(); } } // Then add the type field! // ValueMetaInterface typefield_value = new ValueMetaString( typeField ); typefield_value.setOrigin( name ); typefield_value.setLength( maxlen ); row.addValueMeta( typefield_value ); // Loop over the distinct list of fieldNorm[i] // Add the new fields that need to be created. // Use the same data type as the original fieldname... // for ( int i = 0; i < norm_occ.size(); i++ ) { String normname = norm_occ.get( i ); String fieldname = field_occ.get( i ); ValueMetaInterface v = row.searchValueMeta( fieldname ); if ( v != null ) { v = v.clone(); } else { throw new KettleStepException( BaseMessages.getString( PKG, "NormaliserMeta.Exception.UnableToFindField", fieldname ) ); } v.setName( normname ); v.setOrigin( name ); row.addValueMeta( v ); } // Now remove all the normalized fields... // for ( int i = 0; i < normaliserFields.length; i++ ) { int idx = row.indexOfValue( normaliserFields[i].getName() ); if ( idx >= 0 ) { row.removeValueMeta( idx ); } } }