Java Code Examples for org.pentaho.di.core.row.RowMetaInterface#mergeRowMeta()

The following examples show how to use org.pentaho.di.core.row.RowMetaInterface#mergeRowMeta() . 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 Project: pentaho-kettle   File: MergeRowsMeta.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  // We don't have any input fields here in "r" as they are all info fields.
  // So we just merge in the info fields.
  //
  if ( info != null ) {
    boolean found = false;
    for ( int i = 0; i < info.length && !found; i++ ) {
      if ( info[i] != null ) {
        r.mergeRowMeta( info[i], name );
        found = true;
      }
    }
  }

  if ( Utils.isEmpty( flagField ) ) {
    throw new KettleStepException( BaseMessages.getString( PKG, "MergeRowsMeta.Exception.FlagFieldNotSpecified" ) );
  }
  ValueMetaInterface flagFieldValue = new ValueMetaString( flagField );
  flagFieldValue.setOrigin( name );
  r.addValueMeta( flagFieldValue );

}
 
Example 2
@Override
public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
    VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  // We don't have any input fields here in "r" as they are all info fields.
  // So we just merge in the info fields.
  //
  if ( info != null ) {
    for ( int i = 0; i < info.length; i++ ) {
      if ( info[i] != null ) {
        r.mergeRowMeta( info[i] );
      }
    }
  }

  for ( int i = 0; i < r.size(); i++ ) {
    r.getValueMeta( i ).setOrigin( name );
  }
  return;
}
 
Example 3
Source Project: pentaho-kettle   File: MergeJoinMeta.java    License: Apache License 2.0 6 votes vote down vote up
public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
                       VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  // We don't have any input fields here in "r" as they are all info fields.
  // So we just merge in the info fields.
  //
  if ( info != null ) {
    for ( int i = 0; i < info.length; i++ ) {
      if ( info[i] != null ) {
        r.mergeRowMeta( info[i], name );
      }
    }
  }

  for ( int i = 0; i < r.size(); i++ ) {
    ValueMetaInterface vmi = r.getValueMeta( i );
    if ( vmi != null && Utils.isEmpty( vmi.getName() ) ) {
      vmi.setOrigin( name );
    }
  }
  return;
}
 
Example 4
Source Project: pentaho-kettle   File: RowGeneratorMeta.java    License: Apache License 2.0 6 votes vote down vote up
public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  try {
    List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
    RowMetaAndData rowMetaAndData = RowGenerator.buildRow( this, remarks, origin );
    if ( !remarks.isEmpty() ) {
      StringBuilder stringRemarks = new StringBuilder();
      for ( CheckResultInterface remark : remarks ) {
        stringRemarks.append( remark.toString() ).append( Const.CR );
      }
      throw new KettleStepException( stringRemarks.toString() );
    }

    for ( ValueMetaInterface valueMeta : rowMetaAndData.getRowMeta().getValueMetaList() ) {
      valueMeta.setOrigin( origin );
    }

    row.mergeRowMeta( rowMetaAndData.getRowMeta() );
  } catch ( Exception e ) {
    throw new KettleStepException( e );
  }
}
 
Example 5
Source Project: pentaho-kettle   File: ExecSQLRowMeta.java    License: Apache License 2.0 5 votes vote down vote up
public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  RowMetaAndData add =
    ExecSQL.getResultRow( new Result(), getUpdateField(), getInsertField(), getDeleteField(), getReadField() );

  r.mergeRowMeta( add.getRowMeta() );
}
 
Example 6
Source Project: pentaho-kettle   File: JoinRows.java    License: Apache License 2.0 5 votes vote down vote up
private RowMetaInterface createOutputRowMeta( RowMetaInterface[] fileRowMeta ) {
  RowMetaInterface outputRowMeta = new RowMeta();
  for ( int i = 0; i < data.fileRowMeta.length; i++ ) {
    outputRowMeta.mergeRowMeta( data.fileRowMeta[i], meta.getName() );
  }
  return outputRowMeta;
}
 
Example 7
Source Project: pentaho-kettle   File: ExecSQLMeta.java    License: Apache License 2.0 5 votes vote down vote up
public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  RowMetaAndData add =
    ExecSQL.getResultRow( new Result(), getUpdateField(), getInsertField(), getDeleteField(), getReadField() );

  r.mergeRowMeta( add.getRowMeta() );
}
 
Example 8
Source Project: pentaho-kettle   File: AppendMeta.java    License: Apache License 2.0 5 votes vote down vote up
public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  // We don't have any input fields here in "r" as they are all info fields.
  // So we just take the info fields.
  //
  if ( info != null ) {
    if ( info.length > 0 && info[0] != null ) {
      r.mergeRowMeta( info[0] );
    }
  }
}
 
Example 9
Source Project: pentaho-kettle   File: GetVariableMeta.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
    VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  // Determine the maximum length...
  //
  int length = -1;
  for ( int i = 0; i < fieldDefinitions.length; i++ ) {
    String variableString = fieldDefinitions[i].getVariableString();
    if ( variableString != null ) {
      String string = space.environmentSubstitute( variableString );
      if ( string.length() > length ) {
        length = string.length();
      }
    }
  }

  RowMetaInterface row = new RowMeta();
  for ( int i = 0; i < fieldDefinitions.length; i++ ) {
    ValueMetaInterface v;
    try {
      v = ValueMetaFactory.createValueMeta( fieldDefinitions[i].getFieldName(), fieldDefinitions[i].getFieldType() );
    } catch ( KettlePluginException e ) {
      throw new KettleStepException( e );
    }
    int fieldLength = fieldDefinitions[i].getFieldLength();
    if ( fieldLength < 0 ) {
      v.setLength( length );
    } else {
      v.setLength( fieldLength );
    }
    int fieldPrecision = fieldDefinitions[i].getFieldPrecision();
    if ( fieldPrecision >= 0 ) {
      v.setPrecision( fieldPrecision );
    }
    v.setConversionMask( fieldDefinitions[i].getFieldFormat() );
    v.setGroupingSymbol( fieldDefinitions[i].getGroup() );
    v.setDecimalSymbol( fieldDefinitions[i].getDecimal() );
    v.setCurrencySymbol( fieldDefinitions[i].getCurrency() );
    v.setTrimType( fieldDefinitions[i].getTrimType() );
    v.setOrigin( name );

    row.addValueMeta( v );
  }

  inputRowMeta.mergeRowMeta( row, name );
}