org.pentaho.di.core.row.value.ValueMetaFactory Java Examples
The following examples show how to use
org.pentaho.di.core.row.value.ValueMetaFactory.
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: DatabaseJoinMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void readData( Node stepnode, List<DatabaseMeta> databases ) throws KettleXMLException { try { String con = XMLHandler.getTagValue( stepnode, "connection" ); databaseMeta = DatabaseMeta.findDatabase( databases, con ); sql = XMLHandler.getTagValue( stepnode, "sql" ); outerJoin = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "outer_join" ) ); replacevars = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "replace_vars" ) ); rowLimit = Const.toInt( XMLHandler.getTagValue( stepnode, "rowlimit" ), 0 ); Node param = XMLHandler.getSubNode( stepnode, "parameter" ); int nrparam = XMLHandler.countNodes( param, "field" ); allocate( nrparam ); for ( int i = 0; i < nrparam; i++ ) { Node pnode = XMLHandler.getSubNodeByNr( param, "field", i ); parameterField[i] = XMLHandler.getTagValue( pnode, "name" ); String ptype = XMLHandler.getTagValue( pnode, "type" ); parameterType[i] = ValueMetaFactory.getIdForValueMeta( ptype ); } } catch ( Exception e ) { throw new KettleXMLException( BaseMessages .getString( PKG, "DatabaseJoinMeta.Exception.UnableToLoadStepInfo" ), e ); } }
Example #2
Source File: MappingInputMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { try { int nrfields = rep.countNrStepAttributes( id_step, "field_name" ); allocate( nrfields ); for ( int i = 0; i < nrfields; i++ ) { fieldName[ i ] = rep.getStepAttributeString( id_step, i, "field_name" ); fieldType[ i ] = ValueMetaFactory.getIdForValueMeta( rep.getStepAttributeString( id_step, i, "field_type" ) ); fieldLength[ i ] = (int) rep.getStepAttributeInteger( id_step, i, "field_length" ); fieldPrecision[ i ] = (int) rep.getStepAttributeInteger( id_step, i, "field_precision" ); } selectingAndSortingUnspecifiedFields = rep.getStepAttributeBoolean( id_step, "select_unspecified" ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "MappingInputMeta.Exception.UnexpectedErrorInReadingStepInfo" ), e ); } }
Example #3
Source File: RowsFromResultMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { try { int nrfields = rep.countNrStepAttributes( id_step, "field_name" ); allocate( nrfields ); for ( int i = 0; i < nrfields; i++ ) { fieldname[i] = rep.getStepAttributeString( id_step, i, "field_name" ); type[i] = ValueMetaFactory.getIdForValueMeta( rep.getStepAttributeString( id_step, i, "field_type" ) ); length[i] = (int) rep.getStepAttributeInteger( id_step, i, "field_length" ); precision[i] = (int) rep.getStepAttributeInteger( id_step, i, "field_precision" ); } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "RowsFromResultMeta.Exception.ErrorReadingStepInfoFromRepository" ), e ); } }
Example #4
Source File: InjectorMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { try { int nrfields = rep.countNrStepAttributes( id_step, "field_name" ); allocate( nrfields ); for ( int i = 0; i < nrfields; i++ ) { fieldname[i] = rep.getStepAttributeString( id_step, i, "field_name" ); type[i] = ValueMetaFactory.getIdForValueMeta( rep.getStepAttributeString( id_step, i, "field_type" ) ); length[i] = (int) rep.getStepAttributeInteger( id_step, i, "field_length" ); precision[i] = (int) rep.getStepAttributeInteger( id_step, i, "field_precision" ); } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "InjectorMeta.Exception.ErrorReadingStepInfoFromRepository" ), e ); } }
Example #5
Source File: GaInputStepMetaTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void testSerialization() throws KettleException { List<String> attributes = Arrays.asList( "OAuthServiceAccount", "GaAppName", "OAuthKeyFile", "GaProfileName", "GaProfileTableId", "GaCustomTableId", "UseCustomTableId", "StartDate", "EndDate", "Dimensions", "Metrics", "Filters", "Sort", "UseSegment", "UseCustomSegment", "CustomSegment", "SegmentId", "SegmentName", "SamplingLevel", "RowLimit", "FeedFieldType", "FeedField", "OutputField", "OutputType", "ConversionMask" ); Map<String, FieldLoadSaveValidator<?>> attributeMap = new HashMap<>(); Map<String, FieldLoadSaveValidator<?>> typeMap = new HashMap<>(); int maxValueCount = ValueMetaFactory.getAllValueMetaNames().length; attributeMap.put( "FeedField", new ArrayLoadSaveValidator<String>( new StringLoadSaveValidator(), 25 ) ); attributeMap.put( "FeedFieldType", new ArrayLoadSaveValidator<String>( new StringLoadSaveValidator(), 25 ) ); attributeMap.put( "OutputField", new ArrayLoadSaveValidator<String>( new StringLoadSaveValidator(), 25 ) ); attributeMap.put( "OutputType", new PrimitiveIntArrayLoadSaveValidator( new IntLoadSaveValidator( maxValueCount ), 25 ) ); attributeMap.put( "ConversionMask", new ArrayLoadSaveValidator<String>( new StringLoadSaveValidator(), 25 ) ); LoadSaveTester<GaInputStepMeta> tester = new LoadSaveTester<>( GaInputStepMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), attributeMap, typeMap ); tester.testSerialization(); }
Example #6
Source File: CPythonRowMetaInterfaceValidator.java From pentaho-cpython-plugin with Apache License 2.0 | 6 votes |
@Override public RowMetaInterface getTestObject() { int size = random.nextInt( 10 ) + 1; RowMetaInterface result = new RowMeta(); for ( int i = 0; i < size; i++ ) { try { ValueMetaInterface vm = ValueMetaFactory.createValueMeta( "field" + i, i % 2 == 0 ? ValueMetaInterface.TYPE_STRING : ValueMetaInterface.TYPE_NUMBER ); result.addValueMeta( vm ); } catch ( KettlePluginException e ) { throw new RuntimeException( e ); } } return result; }
Example #7
Source File: CalculatorMetaFunction.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public CalculatorMetaFunction( Node calcnode ) { fieldName = XMLHandler.getTagValue( calcnode, "field_name" ); calcType = getCalcFunctionType( XMLHandler.getTagValue( calcnode, "calc_type" ) ); fieldA = XMLHandler.getTagValue( calcnode, "field_a" ); fieldB = XMLHandler.getTagValue( calcnode, "field_b" ); fieldC = XMLHandler.getTagValue( calcnode, "field_c" ); valueType = ValueMetaFactory.getIdForValueMeta( XMLHandler.getTagValue( calcnode, "value_type" ) ); valueLength = Const.toInt( XMLHandler.getTagValue( calcnode, "value_length" ), -1 ); valuePrecision = Const.toInt( XMLHandler.getTagValue( calcnode, "value_precision" ), -1 ); removedFromResult = "Y".equalsIgnoreCase( XMLHandler.getTagValue( calcnode, "remove" ) ); conversionMask = XMLHandler.getTagValue( calcnode, "conversion_mask" ); decimalSymbol = XMLHandler.getTagValue( calcnode, "decimal_symbol" ); groupingSymbol = XMLHandler.getTagValue( calcnode, "grouping_symbol" ); currencySymbol = XMLHandler.getTagValue( calcnode, "currency_symbol" ); // Fix 2.x backward compatibility // The conversion mask was added in a certain revision. // Anything that we load from before then should get masks set to retain backward compatibility // if ( XMLHandler.getSubNode( calcnode, "conversion_mask" ) == null ) { fixBackwardCompatibility(); } }
Example #8
Source File: GetVariableDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void getInfo( GetVariableMeta input ) throws KettleException { stepname = wStepname.getText(); // return value // Table table = wFields.table; int count = wFields.nrNonEmpty(); input.allocate( count ); //CHECKSTYLE:Indentation:OFF for ( int i = 0; i < count; i++ ) { TableItem item = wFields.getNonEmpty( i ); FieldDefinition currentField = input.getFieldDefinitions()[i]; int index = 1; currentField.setFieldName( item.getText( index++ ) ); currentField.setVariableString( item.getText( index++ ) ); currentField.setFieldType( ValueMetaFactory.getIdForValueMeta( item.getText( index++ ) ) ); currentField.setFieldFormat( item.getText( index++ ) ); currentField.setFieldLength( Const.toInt( item.getText( index++ ), -1 ) ); currentField.setFieldPrecision( Const.toInt( item.getText( index++ ), -1 ) ); currentField.setCurrency( item.getText( index++ ) ); currentField.setDecimal( item.getText( index++ ) ); currentField.setGroup( item.getText( index++ ) ); currentField.setTrimType( ValueMetaString.getTrimTypeByDesc( item.getText( index++ ) ) ); } }
Example #9
Source File: TableView.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private String[] getComboValues( TableItem row, ColumnInfo colinfo ) { if ( colinfo.getType() == ColumnInfo.COLUMN_TYPE_FORMAT ) { int type = ValueMetaFactory.getIdForValueMeta( row.getText( colinfo.getFieldTypeColumn() ) ); switch ( type ) { case ValueMetaInterface.TYPE_DATE: return Const.getDateFormats(); case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: case ValueMetaInterface.TYPE_NUMBER: return Const.getNumberFormats(); case ValueMetaInterface.TYPE_STRING: return Const.getConversionFormats(); default: return new String[0]; } } return colinfo.getComboValues(); }
Example #10
Source File: MappingInputMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public String getXML() { StringBuilder retval = new StringBuilder( 300 ); retval.append( " <fields>" ).append( Const.CR ); for ( int i = 0; i < fieldName.length; i++ ) { if ( fieldName[ i ] != null && fieldName[ i ].length() != 0 ) { retval.append( " <field>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "name", fieldName[ i ] ) ); retval .append( " " ).append( XMLHandler.addTagValue( "type", ValueMetaFactory.getValueMetaName( fieldType[ i ] ) ) ); retval.append( " " ).append( XMLHandler.addTagValue( "length", fieldLength[ i ] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "precision", fieldPrecision[ i ] ) ); retval.append( " </field>" ).append( Const.CR ); } } retval.append( " " ).append( XMLHandler.addTagValue( "select_unspecified", selectingAndSortingUnspecifiedFields ) ); retval.append( " </fields>" ).append( Const.CR ); return retval.toString(); }
Example #11
Source File: FormulaMetaFunction.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public String getXML() { String xml = ""; xml += "<" + XML_TAG + ">"; xml += XMLHandler.addTagValue( "field_name", fieldName ); xml += XMLHandler.addTagValue( "formula_string", formula ); xml += XMLHandler.addTagValue( "value_type", ValueMetaFactory.getValueMetaName( valueType ) ); xml += XMLHandler.addTagValue( "value_length", valueLength ); xml += XMLHandler.addTagValue( "value_precision", valuePrecision ); xml += XMLHandler.addTagValue( "replace_field", replaceField ); xml += "</" + XML_TAG + ">"; return xml; }
Example #12
Source File: DataSetDialog.java From pentaho-pdi-dataset with Apache License 2.0 | 6 votes |
public void getData() { for ( DataSetGroup group : groups ) { wDataSetGroup.add( group.getName() ); } wName.setText( Const.NVL( dataSet.getName(), "" ) ); wDescription.setText( Const.NVL( dataSet.getDescription(), "" ) ); wDataSetGroup.setText( Const.NVL( dataSet.getGroup() == null ? null : dataSet.getGroup().getName(), "" ) ); wTableName.setText( Const.NVL( dataSet.getTableName(), "" ) ); for ( int i = 0; i < dataSet.getFields().size(); i++ ) { DataSetField field = dataSet.getFields().get( i ); int colnr = 1; wFieldMapping.setText( Const.NVL( field.getFieldName(), "" ), colnr++, i ); wFieldMapping.setText( Const.NVL( field.getColumnName(), "" ), colnr++, i ); wFieldMapping.setText( ValueMetaFactory.getValueMetaName( field.getType() ), colnr++, i ); wFieldMapping.setText( Const.NVL( field.getFormat(), ""), colnr++, i ); wFieldMapping.setText( field.getLength() >= 0 ? Integer.toString( field.getLength() ) : "", colnr++, i ); wFieldMapping.setText( field.getPrecision() >= 0 ? Integer.toString( field.getPrecision() ) : "", colnr++, i ); wFieldMapping.setText( Const.NVL( field.getComment(), "" ), colnr++, i ); } wName.setFocus(); }
Example #13
Source File: ExcelInputMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public RowMetaInterface getEmptyFields() { RowMetaInterface row = new RowMeta(); if ( field != null ) { for ( int i = 0; i < field.length; i++ ) { ValueMetaInterface v; try { v = ValueMetaFactory.createValueMeta( field[ i ].getName(), field[ i ].getType() ); } catch ( KettlePluginException e ) { v = new ValueMetaNone( field[ i ].getName() ); } row.addValueMeta( v ); } } return row; }
Example #14
Source File: RulesAccumulatorMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public void readRep( Repository rep, IMetaStore metaStore, ObjectId idStep, List<DatabaseMeta> _databases ) throws KettleException { int nrfields = rep.countNrStepAttributes( idStep, StorageKeys.COLUMN_NAME.toString() ); ValueMetaInterface vm = null; for ( int i = 0; i < nrfields; i++ ) { String name = rep.getStepAttributeString( idStep, i, StorageKeys.COLUMN_NAME.toString() ); int type = ValueMeta.getType( rep.getStepAttributeString( idStep, i, StorageKeys.COLUMN_TYPE.toString() ) ); vm = ValueMetaFactory.createValueMeta( name, type ); getRuleResultColumns().add( vm ); } setRuleFile( rep.getStepAttributeString( idStep, StorageKeys.RULE_FILE.toString() ) ); setRuleDefinition( rep.getStepAttributeString( idStep, StorageKeys.RULE_DEFINITION.toString() ) ); }
Example #15
Source File: MappingInputMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException { try { for ( int i = 0; i < fieldName.length; i++ ) { if ( fieldName[ i ] != null && fieldName[ i ].length() != 0 ) { rep.saveStepAttribute( id_transformation, id_step, i, "field_name", fieldName[ i ] ); rep.saveStepAttribute( id_transformation, id_step, i, "field_type", ValueMetaFactory.getValueMetaName( fieldType[ i ] ) ); rep.saveStepAttribute( id_transformation, id_step, i, "field_length", fieldLength[ i ] ); rep.saveStepAttribute( id_transformation, id_step, i, "field_precision", fieldPrecision[ i ] ); } } rep.saveStepAttribute( id_transformation, id_step, "select_unspecified", selectingAndSortingUnspecifiedFields ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "MappingInputMeta.Exception.UnableToSaveStepInfo" ) + id_step, e ); } }
Example #16
Source File: RegexEvalMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private ValueMetaInterface constructValueMeta( ValueMetaInterface sourceValueMeta, String fieldName, int i, String name ) throws KettlePluginException { int type = fieldType[i]; if ( type == ValueMetaInterface.TYPE_NONE ) { type = ValueMetaInterface.TYPE_STRING; } ValueMetaInterface v; if ( sourceValueMeta == null ) { v = ValueMetaFactory.createValueMeta( fieldName, type ); } else { v = ValueMetaFactory.cloneValueMeta( sourceValueMeta, type ); } v.setLength( fieldLength[i] ); v.setPrecision( fieldPrecision[i] ); v.setOrigin( name ); v.setConversionMask( fieldFormat[i] ); v.setDecimalSymbol( fieldDecimal[i] ); v.setGroupingSymbol( fieldGroup[i] ); v.setCurrencySymbol( fieldCurrency[i] ); v.setTrimType( fieldTrimType[i] ); return v; }
Example #17
Source File: ScriptValuesMetaMod.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException { try { rep.saveStepAttribute( id_transformation, id_step, 0, "compatible", compatible ); rep.saveStepAttribute( id_transformation, id_step, 0, "optimizationLevel", optimizationLevel ); for ( int i = 0; i < jsScripts.length; i++ ) { rep.saveStepAttribute( id_transformation, id_step, i, JSSCRIPT_TAG_NAME, jsScripts[i].getScriptName() ); rep.saveStepAttribute( id_transformation, id_step, i, JSSCRIPT_TAG_SCRIPT, jsScripts[i].getScript() ); rep.saveStepAttribute( id_transformation, id_step, i, JSSCRIPT_TAG_TYPE, jsScripts[i].getScriptType() ); } for ( int i = 0; i < fieldname.length; i++ ) { rep.saveStepAttribute( id_transformation, id_step, i, "field_name", fieldname[i] ); rep.saveStepAttribute( id_transformation, id_step, i, "field_rename", rename[i] ); rep.saveStepAttribute( id_transformation, id_step, i, "field_type", ValueMetaFactory.getValueMetaName( type[i] ) ); rep.saveStepAttribute( id_transformation, id_step, i, "field_length", length[i] ); rep.saveStepAttribute( id_transformation, id_step, i, "field_precision", precision[i] ); rep.saveStepAttribute( id_transformation, id_step, i, "field_replace", replace[i] ); } } catch ( Exception e ) { throw new KettleException( BaseMessages .getString( PKG, "ScriptValuesMetaMod.Exception.UnableToSaveStepInfo" ) + id_step, e ); } }
Example #18
Source File: DataGridMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public void getFields( RowMetaInterface rowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { for ( int i = 0; i < fieldName.length; i++ ) { try { if ( !Utils.isEmpty( fieldName[i] ) ) { int type = ValueMetaFactory.getIdForValueMeta( fieldType[i] ); if ( type == ValueMetaInterface.TYPE_NONE ) { type = ValueMetaInterface.TYPE_STRING; } ValueMetaInterface v = ValueMetaFactory.createValueMeta( fieldName[i], type ); v.setLength( fieldLength[i] ); v.setPrecision( fieldPrecision[i] ); v.setOrigin( name ); v.setConversionMask( fieldFormat[i] ); v.setCurrencySymbol( currency[i] ); v.setGroupingSymbol( group[i] ); v.setDecimalSymbol( decimal[i] ); rowMeta.addValueMeta( v ); } } catch ( Exception e ) { throw new KettleStepException( "Unable to create value of type " + fieldType[i], e ); } } }
Example #19
Source File: YamlInput.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (YamlInputMeta) smi; data = (YamlInputData) sdi; if ( super.init( smi, sdi ) ) { data.rownr = 1L; data.nrInputFields = meta.getInputFields().length; data.rowMeta = new RowMeta(); for ( int i = 0; i < data.nrInputFields; i++ ) { YamlInputField field = meta.getInputFields()[i]; String path = environmentSubstitute( field.getPath() ); try { ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( path, field.getType() ); valueMeta.setTrimType( field.getTrimType() ); data.rowMeta.addValueMeta( valueMeta ); } catch ( Exception e ) { log.logError( "Unable to create value meta", e ); return false; } } return true; } return false; }
Example #20
Source File: DatabaseJoinMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public RowMetaInterface getTableFields() { // Build a dummy parameter row... // RowMetaInterface param = new RowMeta(); for ( int i = 0; i < parameterField.length; i++ ) { ValueMetaInterface v; try { v = ValueMetaFactory.createValueMeta( parameterField[i], parameterType[i] ); } catch ( KettlePluginException e ) { v = new ValueMetaNone( parameterField[i] ); } param.addValueMeta( v ); } RowMetaInterface fields = null; if ( databaseMeta != null ) { Database db = new Database( loggingObject, databaseMeta ); databases = new Database[] { db }; // Keep track of this one for cancelQuery try { db.connect(); fields = db.getQueryFields( databaseMeta.environmentSubstitute( sql ), true, param, new Object[param.size()] ); } catch ( KettleDatabaseException dbe ) { logError( BaseMessages.getString( PKG, "DatabaseJoinMeta.Log.DatabaseErrorOccurred" ) + dbe.getMessage() ); } finally { db.disconnect(); } } return fields; }
Example #21
Source File: JaninoMetaFunction.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public JaninoMetaFunction( Repository rep, ObjectId id_step, int nr ) throws KettleException { fieldName = rep.getStepAttributeString( id_step, nr, "field_name" ); formula = rep.getStepAttributeString( id_step, nr, "formula_string" ); valueType = ValueMetaFactory.getIdForValueMeta( rep.getStepAttributeString( id_step, nr, "value_type" ) ); valueLength = (int) rep.getStepAttributeInteger( id_step, nr, "value_length" ); valuePrecision = (int) rep.getStepAttributeInteger( id_step, nr, "value_precision" ); replaceField = rep.getStepAttributeString( id_step, nr, "replace_field" ); }
Example #22
Source File: OpenERPObjectInputMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public RowMetaInterface getRowMeta() throws KettlePluginException { RowMetaInterface rowMeta = new RowMeta(); for ( FieldMapping map : this.getMappings() ) { rowMeta.addValueMeta( ValueMetaFactory.createValueMeta( map.target_field, map.target_field_type ) ); } return rowMeta; }
Example #23
Source File: JaninoMetaFunction.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public JaninoMetaFunction( Node calcnode ) { fieldName = XMLHandler.getTagValue( calcnode, "field_name" ); formula = XMLHandler.getTagValue( calcnode, "formula_string" ); valueType = ValueMetaFactory.getIdForValueMeta( XMLHandler.getTagValue( calcnode, "value_type" ) ); valueLength = Const.toInt( XMLHandler.getTagValue( calcnode, "value_length" ), -1 ); valuePrecision = Const.toInt( XMLHandler.getTagValue( calcnode, "value_precision" ), -1 ); replaceField = XMLHandler.getTagValue( calcnode, "replace_field" ); }
Example #24
Source File: DatabaseLookupMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public String getXML() { StringBuilder retval = new StringBuilder( 500 ); retval .append( " " ).append( XMLHandler.addTagValue( "connection", databaseMeta == null ? "" : databaseMeta.getName() ) ); retval.append( " " ).append( XMLHandler.addTagValue( "cache", cached ) ); retval.append( " " ).append( XMLHandler.addTagValue( "cache_load_all", loadingAllDataInCache ) ); retval.append( " " ).append( XMLHandler.addTagValue( "cache_size", cacheSize ) ); retval.append( " <lookup>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "schema", schemaName ) ); retval.append( " " ).append( XMLHandler.addTagValue( "table", tablename ) ); retval.append( " " ).append( XMLHandler.addTagValue( "orderby", orderByClause ) ); retval.append( " " ).append( XMLHandler.addTagValue( "fail_on_multiple", failingOnMultipleResults ) ); retval.append( " " ).append( XMLHandler.addTagValue( "eat_row_on_failure", eatingRowOnLookupFailure ) ); for ( int i = 0; i < streamKeyField1.length; i++ ) { retval.append( " <key>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "name", streamKeyField1[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "field", tableKeyField[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "condition", keyCondition[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "name2", streamKeyField2[i] ) ); retval.append( " </key>" ).append( Const.CR ); } for ( int i = 0; i < returnValueField.length; i++ ) { retval.append( " <value>" ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "name", returnValueField[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "rename", returnValueNewName[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "default", returnValueDefault[i] ) ); retval.append( " " ).append( XMLHandler.addTagValue( "type", ValueMetaFactory.getValueMetaName( returnValueDefaultType[i] ) ) ); retval.append( " </value>" ).append( Const.CR ); } retval.append( " </lookup>" ).append( Const.CR ); return retval.toString(); }
Example #25
Source File: ParGzipCsvInputMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void readData( Node stepnode ) throws KettleXMLException { try { filename = XMLHandler.getTagValue( stepnode, "filename" ); filenameField = XMLHandler.getTagValue( stepnode, "filename_field" ); rowNumField = XMLHandler.getTagValue( stepnode, "rownum_field" ); includingFilename = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "include_filename" ) ); delimiter = XMLHandler.getTagValue( stepnode, "separator" ); enclosure = XMLHandler.getTagValue( stepnode, "enclosure" ); bufferSize = XMLHandler.getTagValue( stepnode, "buffer_size" ); headerPresent = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "header" ) ); lazyConversionActive = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "lazy_conversion" ) ); isaddresult = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "add_filename_result" ) ); runningInParallel = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "parallel" ) ); encoding = XMLHandler.getTagValue( stepnode, "encoding" ); Node fields = XMLHandler.getSubNode( stepnode, "fields" ); int nrfields = XMLHandler.countNodes( fields, "field" ); allocate( nrfields ); for ( int i = 0; i < nrfields; i++ ) { inputFields[i] = new TextFileInputField(); Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i ); inputFields[i].setName( XMLHandler.getTagValue( fnode, "name" ) ); inputFields[i].setType( ValueMetaFactory.getIdForValueMeta( XMLHandler.getTagValue( fnode, "type" ) ) ); inputFields[i].setFormat( XMLHandler.getTagValue( fnode, "format" ) ); inputFields[i].setCurrencySymbol( XMLHandler.getTagValue( fnode, "currency" ) ); inputFields[i].setDecimalSymbol( XMLHandler.getTagValue( fnode, "decimal" ) ); inputFields[i].setGroupSymbol( XMLHandler.getTagValue( fnode, "group" ) ); inputFields[i].setLength( Const.toInt( XMLHandler.getTagValue( fnode, "length" ), -1 ) ); inputFields[i].setPrecision( Const.toInt( XMLHandler.getTagValue( fnode, "precision" ), -1 ) ); inputFields[i].setTrimType( ValueMetaString.getTrimTypeByCode( XMLHandler.getTagValue( fnode, "trim_type" ) ) ); } } catch ( Exception e ) { throw new KettleXMLException( "Unable to load step info from XML", e ); } }
Example #26
Source File: TransExecutorMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
protected void addFieldToRow( RowMetaInterface row, String fieldName, int type, int length, int precision ) throws KettleStepException { if ( !Utils.isEmpty( fieldName ) ) { try { ValueMetaInterface value = ValueMetaFactory.createValueMeta( fieldName, type, length, precision ); value.setOrigin( getParentStepMeta().getName() ); row.addValueMeta( value ); } catch ( KettlePluginException e ) { throw new KettleStepException( BaseMessages.getString( PKG, "TransExecutorMeta.ValueMetaInterfaceCreation", fieldName ), e ); } } }
Example #27
Source File: EditRowsDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void ok() { try { stringRowMeta = new RowMeta(); for ( ValueMetaInterface valueMeta : rowMeta.getValueMetaList() ) { ValueMetaInterface stringValueMeta = ValueMetaFactory.cloneValueMeta( valueMeta, ValueMetaInterface.TYPE_STRING ); stringRowMeta.addValueMeta( stringValueMeta ); } List<Object[]> list = new ArrayList<Object[]>(); // Now read all the rows in the dialog, including the empty rows... // for ( int i = 0; i < wFields.getItemCount(); i++ ) { TableItem item = wFields.getTable().getItem( i ); Object[] row = getRowForData( item, i + 1 ); list.add( row ); } outputList = list; dispose(); } catch ( Exception e ) { new ErrorDialog( shell, "Error", BaseMessages.getString( PKG, "EditRowsDialog.ErrorConvertingData" ), e ); } }
Example #28
Source File: GaInputStepMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException { try { rep.saveStepAttribute( id_transformation, id_step, "oauthServiceAccount", oauthServiceAccount ); rep.saveStepAttribute( id_transformation, id_step, "oauthKeyFile", oauthKeyFile ); rep.saveStepAttribute( id_transformation, id_step, "appName", gaAppName ); rep.saveStepAttribute( id_transformation, id_step, "profileName", gaProfileName ); rep.saveStepAttribute( id_transformation, id_step, "profileTableId", gaProfileTableId ); rep.saveStepAttribute( id_transformation, id_step, "customTableId", gaCustomTableId ); rep.saveStepAttribute( id_transformation, id_step, "useCustomTableId", useCustomTableId ); rep.saveStepAttribute( id_transformation, id_step, "startDate", startDate ); rep.saveStepAttribute( id_transformation, id_step, "endDate", endDate ); rep.saveStepAttribute( id_transformation, id_step, "dimensions", dimensions ); rep.saveStepAttribute( id_transformation, id_step, "metrics", metrics ); rep.saveStepAttribute( id_transformation, id_step, "filters", filters ); rep.saveStepAttribute( id_transformation, id_step, "sort", sort ); rep.saveStepAttribute( id_transformation, id_step, "useSegment", useSegment ); rep.saveStepAttribute( id_transformation, id_step, "useCustomSegment", useCustomSegment ); rep.saveStepAttribute( id_transformation, id_step, "customSegment", customSegment ); rep.saveStepAttribute( id_transformation, id_step, "segmentId", segmentId ); rep.saveStepAttribute( id_transformation, id_step, "segmentName", segmentName ); rep.saveStepAttribute( id_transformation, id_step, "samplingLevel", samplingLevel ); rep.saveStepAttribute( id_transformation, id_step, "rowLimit", rowLimit ); for ( int i = 0; i < feedField.length; i++ ) { rep.saveStepAttribute( id_transformation, id_step, i, "feedFieldType", feedFieldType[ i ] ); rep.saveStepAttribute( id_transformation, id_step, i, "feedField", feedField[ i ] ); rep.saveStepAttribute( id_transformation, id_step, i, "outField", outputField[ i ] ); rep.saveStepAttribute( id_transformation, id_step, i, "conversionMask", conversionMask[ i ] ); rep.saveStepAttribute( id_transformation, id_step, i, "type", ValueMetaFactory.getValueMetaName( outputType[ i ] ) ); } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "GoogleAnalytics.Error.UnableToSaveToRep" ) + id_step, e ); } }
Example #29
Source File: ScriptMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { try { String script = rep.getStepAttributeString( id_step, "script" ); // When in compatibility mode, we load the script, not the other tabs... // if ( !Utils.isEmpty( script ) ) { jsScripts = new ScriptValuesScript[1]; jsScripts[0] = new ScriptValuesScript( ScriptValuesScript.TRANSFORM_SCRIPT, "ScriptValue", script ); } else { int nrScripts = rep.countNrStepAttributes( id_step, JSSCRIPT_TAG_NAME ); jsScripts = new ScriptValuesScript[nrScripts]; for ( int i = 0; i < nrScripts; i++ ) { jsScripts[i] = new ScriptValuesScript( (int) rep.getStepAttributeInteger( id_step, i, JSSCRIPT_TAG_TYPE ), rep.getStepAttributeString( id_step, i, JSSCRIPT_TAG_NAME ), rep.getStepAttributeString( id_step, i, JSSCRIPT_TAG_SCRIPT ) ); } } int nrfields = rep.countNrStepAttributes( id_step, "field_name" ); allocate( nrfields ); for ( int i = 0; i < nrfields; i++ ) { fieldname[i] = rep.getStepAttributeString( id_step, i, "field_name" ); rename[i] = rep.getStepAttributeString( id_step, i, "field_rename" ); type[i] = ValueMetaFactory.getIdForValueMeta( rep.getStepAttributeString( id_step, i, "field_type" ) ); length[i] = (int) rep.getStepAttributeInteger( id_step, i, "field_length" ); precision[i] = (int) rep.getStepAttributeInteger( id_step, i, "field_precision" ); replace[i] = rep.getStepAttributeBoolean( id_step, i, "field_replace" ); } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "ScriptMeta.Exception.UnexpectedErrorInReadingStepInfo" ), e ); } }
Example #30
Source File: FormulaMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public FormulaMetaFunction getTestObject() { return new FormulaMetaFunction( UUID.randomUUID().toString(), UUID.randomUUID().toString(), new Random().nextInt( ValueMetaFactory.getAllValueMetaNames().length ), new Random().nextInt(), new Random().nextInt(), UUID.randomUUID().toString() ); }