@Test public void testGetFields() throws Exception { RowMeta extraFields = new RowMeta(); extraFields.addValueMeta( new ValueMetaString( "field1" ) ); DatabaseMeta dbMeta = mock( DatabaseMeta.class ); DimensionLookupMeta meta = spy( new DimensionLookupMeta() ); meta.setUpdate( false ); meta.setKeyField( null ); meta.setFieldLookup( new String[] { "field1" } ); meta.setFieldStream( new String[] { "" } ); meta.setDatabaseMeta( dbMeta ); doReturn( extraFields ).when( meta ).getDatabaseTableFields( (Database) anyObject(), anyString(), anyString() ); doReturn( mock( LogChannelInterface.class ) ).when( meta ).getLog(); RowMeta row = new RowMeta(); try { meta.getFields( row, "DimensionLookupMetaTest", new RowMeta[] { row }, null, null, null, null ); } catch ( Throwable e ) { Assert.assertTrue( e.getMessage().contains( BaseMessages.getString( DimensionLookupMeta.class, "DimensionLookupMeta.Error.NoTechnicalKeySpecified" ) ) ); } }
@Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { for ( ValueMetaInterface valueMeta : row.getValueMetaList() ) { valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); valueMeta.setTrimType( ValueMetaInterface.TRIM_TYPE_NONE ); } if ( Utils.isEmpty( keyField ) ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Error.NoTechnicalKeySpecified" ); logError( message ); throw new KettleStepException( message ); } ValueMetaInterface v = new ValueMetaInteger( keyField ); if ( keyRename != null && keyRename.length() > 0 ) { v.setName( keyRename ); } v.setLength( 9 ); v.setPrecision( 0 ); v.setOrigin( name ); row.addValueMeta( v ); if ( !update && fieldLookup.length > 0 ) { Database db = null; try { if ( databaseMeta != null ) { db = createDatabaseObject(); RowMetaInterface extraFields = getDatabaseTableFields( db, schemaName, tableName ); for ( int i = 0; i < fieldLookup.length; i++ ) { v = extraFields.searchValueMeta( fieldLookup[i] ); if ( v == null ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToFindReturnField", fieldLookup[i] ); logError( message ); throw new KettleStepException( message ); } if ( fieldStream[i] != null && fieldStream[i].length() > 0 ) { v.setName( fieldStream[i] ); } v.setOrigin( name ); row.addValueMeta( v ); } } else { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField" ); logError( message ); throw new KettleStepException( message ); } } catch ( Exception e ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField2" ); logError( message ); throw new KettleStepException( message, e ); } finally { if ( db != null ) { db.disconnect(); } } } }
DimensionLookupMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { @Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { for ( ValueMetaInterface valueMeta : row.getValueMetaList() ) { valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); valueMeta.setTrimType( ValueMetaInterface.TRIM_TYPE_NONE ); } if ( Utils.isEmpty( keyField ) ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Error.NoTechnicalKeySpecified" ); logError( message ); throw new KettleStepException( message ); } ValueMetaInterface v = new ValueMetaInteger( keyField ); if ( keyRename != null && keyRename.length() > 0 ) { v.setName( keyRename ); } v.setLength( 9 ); v.setPrecision( 0 ); v.setOrigin( name ); row.addValueMeta( v ); if ( !update && fieldLookup.length > 0 ) { Database db = null; try { if ( databaseMeta != null ) { db = createDatabaseObject(); RowMetaInterface extraFields = getDatabaseTableFields( db, schemaName, tableName ); for ( int i = 0; i < fieldLookup.length; i++ ) { v = extraFields.searchValueMeta( fieldLookup[i] ); if ( v == null ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToFindReturnField", fieldLookup[i] ); logError( message ); throw new KettleStepException( message ); } if ( fieldStream[i] != null && fieldStream[i].length() > 0 ) { v.setName( fieldStream[i] ); } v.setOrigin( name ); row.addValueMeta( v ); } } else { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField" ); logError( message ); throw new KettleStepException( message ); } } catch ( Exception e ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField2" ); logError( message ); throw new KettleStepException( message, e ); } finally { if ( db != null ) { db.disconnect(); } } } } }
DimensionLookupMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { @Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { for ( ValueMetaInterface valueMeta : row.getValueMetaList() ) { valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); valueMeta.setTrimType( ValueMetaInterface.TRIM_TYPE_NONE ); } if ( Utils.isEmpty( keyField ) ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Error.NoTechnicalKeySpecified" ); logError( message ); throw new KettleStepException( message ); } ValueMetaInterface v = new ValueMetaInteger( keyField ); if ( keyRename != null && keyRename.length() > 0 ) { v.setName( keyRename ); } v.setLength( 9 ); v.setPrecision( 0 ); v.setOrigin( name ); row.addValueMeta( v ); if ( !update && fieldLookup.length > 0 ) { Database db = null; try { if ( databaseMeta != null ) { db = createDatabaseObject(); RowMetaInterface extraFields = getDatabaseTableFields( db, schemaName, tableName ); for ( int i = 0; i < fieldLookup.length; i++ ) { v = extraFields.searchValueMeta( fieldLookup[i] ); if ( v == null ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToFindReturnField", fieldLookup[i] ); logError( message ); throw new KettleStepException( message ); } if ( fieldStream[i] != null && fieldStream[i].length() > 0 ) { v.setName( fieldStream[i] ); } v.setOrigin( name ); row.addValueMeta( v ); } } else { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField" ); logError( message ); throw new KettleStepException( message ); } } catch ( Exception e ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField2" ); logError( message ); throw new KettleStepException( message, e ); } finally { if ( db != null ) { db.disconnect(); } } } } DimensionLookupMeta(); }
DimensionLookupMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { @Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { for ( ValueMetaInterface valueMeta : row.getValueMetaList() ) { valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); valueMeta.setTrimType( ValueMetaInterface.TRIM_TYPE_NONE ); } if ( Utils.isEmpty( keyField ) ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Error.NoTechnicalKeySpecified" ); logError( message ); throw new KettleStepException( message ); } ValueMetaInterface v = new ValueMetaInteger( keyField ); if ( keyRename != null && keyRename.length() > 0 ) { v.setName( keyRename ); } v.setLength( 9 ); v.setPrecision( 0 ); v.setOrigin( name ); row.addValueMeta( v ); if ( !update && fieldLookup.length > 0 ) { Database db = null; try { if ( databaseMeta != null ) { db = createDatabaseObject(); RowMetaInterface extraFields = getDatabaseTableFields( db, schemaName, tableName ); for ( int i = 0; i < fieldLookup.length; i++ ) { v = extraFields.searchValueMeta( fieldLookup[i] ); if ( v == null ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToFindReturnField", fieldLookup[i] ); logError( message ); throw new KettleStepException( message ); } if ( fieldStream[i] != null && fieldStream[i].length() > 0 ) { v.setName( fieldStream[i] ); } v.setOrigin( name ); row.addValueMeta( v ); } } else { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField" ); logError( message ); throw new KettleStepException( message ); } } catch ( Exception e ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField2" ); logError( message ); throw new KettleStepException( message, e ); } finally { if ( db != null ) { db.disconnect(); } } } } DimensionLookupMeta(); @Override String getTableName(); void setTableName( String tablename ); @Override DatabaseMeta getDatabaseMeta(); void setDatabaseMeta( DatabaseMeta database ); @Injection( name = "CONNECTION_NAME" ) void setConnection( String connectionName ); boolean isUpdate(); void setUpdate( boolean update ); boolean isAutoIncrement(); void setAutoIncrement( boolean autoIncrement ); void setTechKeyCreation( String techKeyCreation ); String getTechKeyCreation(); int getCommitSize(); void setCommitSize( int commitSize ); String getDateField(); void setDateField( String dateField ); String getDateFrom(); void setDateFrom( String dateFrom ); String getDateTo(); void setDateTo( String dateTo ); String[] getFieldLookup(); void setFieldLookup( String[] fieldLookup ); String[] getFieldStream(); void setFieldStream( String[] fieldStream ); int[] getFieldUpdate(); void setFieldUpdate( int[] fieldUpdate ); int[] getReturnType(); void setReturnType( int[] returnType ); String getKeyField(); void setKeyField( String keyField ); String[] getKeyLookup(); void setKeyLookup( String[] keyLookup ); String getKeyRename(); void setKeyRename( String keyRename ); String[] getKeyStream(); void setKeyStream( String[] keyStream ); int getMaxYear(); void setMaxYear( int maxYear ); int getMinYear(); void setMinYear( int minYear ); String getSequenceName(); void setSequenceName( String sequenceName ); String getVersionField(); void setVersionField( String versionField ); void actualizeWithInjectedValues(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrkeys, int nrfields ); @Override Object clone(); static final int getUpdateType( boolean upd, String ty ); static final String getUpdateType( boolean upd, int t ); static final String getUpdateTypeCode( boolean upd, int t ); static final int getStartDateAlternative( String string ); static final String getStartDateAlternativeCode( int alternative ); static final String getStartDateAlternativeDesc( int alternative ); static final String[] getStartDateAlternativeCodes(); static final String[] getStartDateAlternativeDescriptions(); static final boolean isUpdateTypeWithoutArgument( boolean update, int type ); @Override void setDefault(); @Override void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep,
      VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); Date getMinDate(); Date getMaxDate(); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
      String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
      IMetaStore metaStore ); @Override RowMetaInterface getTableFields(); @Override SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
      Repository repository, IMetaStore metaStore ); @Override void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
      String[] input, String[] output, RowMetaInterface info, Repository repository, IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
      Trans trans ); @Override StepDataInterface getStepData(); @Override DatabaseMeta[] getUsedDatabaseConnections(); @Override String getSchemaName(); @Override String getMissingDatabaseConnectionInformationMessage(); void setSchemaName( String schemaName ); int getCacheSize(); void setCacheSize( int cacheSize ); boolean isUsingStartDateAlternative(); void setUsingStartDateAlternative( boolean usingStartDateAlternative ); int getStartDateAlternative(); void setStartDateAlternative( int startDateAlternative ); String getStartDateFieldName(); void setStartDateFieldName( String startDateFieldName ); boolean isPreloadingCache(); void setPreloadingCache( boolean preloadingCache ); boolean useBatchUpdate(); void setUseBatchUpdate( boolean useBatchUpdate ); @Override RowMeta getRowMeta( final StepDataInterface stepData ); @Override List<String> getDatabaseFields(); @Override List<String> getStreamFields(); void normalizeAllocationFields(); @AfterInjection void afterInjectionSynchronization(); }
DimensionLookupMeta extends BaseStepMeta implements StepMetaInterface, ProvidesModelerMeta { @Override public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { for ( ValueMetaInterface valueMeta : row.getValueMetaList() ) { valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); valueMeta.setTrimType( ValueMetaInterface.TRIM_TYPE_NONE ); } if ( Utils.isEmpty( keyField ) ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Error.NoTechnicalKeySpecified" ); logError( message ); throw new KettleStepException( message ); } ValueMetaInterface v = new ValueMetaInteger( keyField ); if ( keyRename != null && keyRename.length() > 0 ) { v.setName( keyRename ); } v.setLength( 9 ); v.setPrecision( 0 ); v.setOrigin( name ); row.addValueMeta( v ); if ( !update && fieldLookup.length > 0 ) { Database db = null; try { if ( databaseMeta != null ) { db = createDatabaseObject(); RowMetaInterface extraFields = getDatabaseTableFields( db, schemaName, tableName ); for ( int i = 0; i < fieldLookup.length; i++ ) { v = extraFields.searchValueMeta( fieldLookup[i] ); if ( v == null ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToFindReturnField", fieldLookup[i] ); logError( message ); throw new KettleStepException( message ); } if ( fieldStream[i] != null && fieldStream[i].length() > 0 ) { v.setName( fieldStream[i] ); } v.setOrigin( name ); row.addValueMeta( v ); } } else { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField" ); logError( message ); throw new KettleStepException( message ); } } catch ( Exception e ) { String message = BaseMessages.getString( PKG, "DimensionLookupMeta.Exception.UnableToRetrieveDataTypeOfReturnField2" ); logError( message ); throw new KettleStepException( message, e ); } finally { if ( db != null ) { db.disconnect(); } } } } DimensionLookupMeta(); @Override String getTableName(); void setTableName( String tablename ); @Override DatabaseMeta getDatabaseMeta(); void setDatabaseMeta( DatabaseMeta database ); @Injection( name = "CONNECTION_NAME" ) void setConnection( String connectionName ); boolean isUpdate(); void setUpdate( boolean update ); boolean isAutoIncrement(); void setAutoIncrement( boolean autoIncrement ); void setTechKeyCreation( String techKeyCreation ); String getTechKeyCreation(); int getCommitSize(); void setCommitSize( int commitSize ); String getDateField(); void setDateField( String dateField ); String getDateFrom(); void setDateFrom( String dateFrom ); String getDateTo(); void setDateTo( String dateTo ); String[] getFieldLookup(); void setFieldLookup( String[] fieldLookup ); String[] getFieldStream(); void setFieldStream( String[] fieldStream ); int[] getFieldUpdate(); void setFieldUpdate( int[] fieldUpdate ); int[] getReturnType(); void setReturnType( int[] returnType ); String getKeyField(); void setKeyField( String keyField ); String[] getKeyLookup(); void setKeyLookup( String[] keyLookup ); String getKeyRename(); void setKeyRename( String keyRename ); String[] getKeyStream(); void setKeyStream( String[] keyStream ); int getMaxYear(); void setMaxYear( int maxYear ); int getMinYear(); void setMinYear( int minYear ); String getSequenceName(); void setSequenceName( String sequenceName ); String getVersionField(); void setVersionField( String versionField ); void actualizeWithInjectedValues(); @Override void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrkeys, int nrfields ); @Override Object clone(); static final int getUpdateType( boolean upd, String ty ); static final String getUpdateType( boolean upd, int t ); static final String getUpdateTypeCode( boolean upd, int t ); static final int getStartDateAlternative( String string ); static final String getStartDateAlternativeCode( int alternative ); static final String getStartDateAlternativeDesc( int alternative ); static final String[] getStartDateAlternativeCodes(); static final String[] getStartDateAlternativeDescriptions(); static final boolean isUpdateTypeWithoutArgument( boolean update, int type ); @Override void setDefault(); @Override void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep,
      VariableSpace space, Repository repository, IMetaStore metaStore ); @Override String getXML(); @Override void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); Date getMinDate(); Date getMaxDate(); @Override void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
      String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
      IMetaStore metaStore ); @Override RowMetaInterface getTableFields(); @Override SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
      Repository repository, IMetaStore metaStore ); @Override void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
      String[] input, String[] output, RowMetaInterface info, Repository repository, IMetaStore metaStore ); @Override StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr,
      Trans trans ); @Override StepDataInterface getStepData(); @Override DatabaseMeta[] getUsedDatabaseConnections(); @Override String getSchemaName(); @Override String getMissingDatabaseConnectionInformationMessage(); void setSchemaName( String schemaName ); int getCacheSize(); void setCacheSize( int cacheSize ); boolean isUsingStartDateAlternative(); void setUsingStartDateAlternative( boolean usingStartDateAlternative ); int getStartDateAlternative(); void setStartDateAlternative( int startDateAlternative ); String getStartDateFieldName(); void setStartDateFieldName( String startDateFieldName ); boolean isPreloadingCache(); void setPreloadingCache( boolean preloadingCache ); boolean useBatchUpdate(); void setUseBatchUpdate( boolean useBatchUpdate ); @Override RowMeta getRowMeta( final StepDataInterface stepData ); @Override List<String> getDatabaseFields(); @Override List<String> getStreamFields(); void normalizeAllocationFields(); @AfterInjection void afterInjectionSynchronization(); static final int TYPE_UPDATE_DIM_INSERT; static final int TYPE_UPDATE_DIM_UPDATE; static final int TYPE_UPDATE_DIM_PUNCHTHROUGH; static final int TYPE_UPDATE_DATE_INSUP; static final int TYPE_UPDATE_DATE_INSERTED; static final int TYPE_UPDATE_DATE_UPDATED; static final int TYPE_UPDATE_LAST_VERSION; static final String[] typeDesc; static final String[] typeCodes; static final String[] typeDescLookup; static final int START_DATE_ALTERNATIVE_NONE; static final int START_DATE_ALTERNATIVE_SYSDATE; static final int START_DATE_ALTERNATIVE_START_OF_TRANS; static final int START_DATE_ALTERNATIVE_NULL; static final int START_DATE_ALTERNATIVE_COLUMN_VALUE; static String CREATION_METHOD_AUTOINC; static String CREATION_METHOD_SEQUENCE; static String CREATION_METHOD_TABLEMAX; }