private StepInjectionMetaEntry findDetailRootEntry( List<StepInjectionMetaEntry> metadataEntries, StepInjectionMetaEntry entry ) { for ( StepInjectionMetaEntry rowsEntry : metadataEntries ) { for ( StepInjectionMetaEntry rowEntry : rowsEntry.getDetails() ) { for ( StepInjectionMetaEntry detailEntry : rowEntry.getDetails() ) { if ( detailEntry.equals( entry ) ) { return rowsEntry; } } } } return null; }
private StepInjectionMetaEntry findMetaEntry( List<StepInjectionMetaEntry> metadataEntries, String attributeKey ) { for ( StepInjectionMetaEntry entry : metadataEntries ) { if ( entry.getKey().equals( attributeKey ) ) { return entry; } entry = findMetaEntry( entry.getDetails(), attributeKey ); if ( entry != null ) { return entry; } } return null; }
protected void addNestedStepMetaInjectionEntries( List<StepInjectionMetaEntry> list, StepMetaInjectionEnumEntry[] allEntries, StepMetaInjectionEnumEntry itemsEntry, StepMetaInjectionEnumEntry itemEntry ) { StepInjectionMetaEntry fieldsEntry = createStepMetaInjectionEntry( itemsEntry ); list.add( fieldsEntry ); StepInjectionMetaEntry fieldEntry = createStepMetaInjectionEntry( itemEntry ); fieldsEntry.getDetails().add( fieldEntry ); for ( StepMetaInjectionEnumEntry entry : allEntries ) { if ( entry.getParent() == itemEntry ) { fieldEntry.getDetails().add( createStepMetaInjectionEntry( entry ) ); } } }
/** * Find parent entry. * * @param entries the entries * @param key the key * @return the step injection meta entry */ protected StepInjectionMetaEntry findParentEntry( List<StepInjectionMetaEntry> entries, String key ) { for ( StepInjectionMetaEntry look : entries ) { if ( look.getKey().equals( key ) ) { return look; } StepInjectionMetaEntry check = findParentEntry( look.getDetails(), key ); if ( check != null ) { return check; } } return null; }
all.add( filesEntry ); StepInjectionMetaEntry fileEntry = StepInjectionUtil.getEntry( Entry.FILENAME_LINE ); filesEntry.getDetails().add( fileEntry ); List<StepInjectionMetaEntry> fileEntryDetails = fileEntry.getDetails(); for ( Entry entry : fileFieldsEntries ) { StepInjectionMetaEntry metaEntry = StepInjectionUtil.getEntry( entry ); all.add( fieldsEntry ); StepInjectionMetaEntry fieldEntry = StepInjectionUtil.getEntry( Entry.FIELD ); fieldsEntry.getDetails().add( fieldEntry ); List<StepInjectionMetaEntry> fieldEntryDetails = fieldEntry.getDetails(); for ( Entry entry : aggEntries ) { StepInjectionMetaEntry metaEntry = StepInjectionUtil.getEntry( entry );
@Override public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException { List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>(); StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry( "FIELDS", ValueMetaInterface.TYPE_NONE, "All the fields on the spreadsheets" ); all.add( fieldsEntry ); StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry( "FIELD", ValueMetaInterface.TYPE_NONE, "All the fields on the spreadsheets" ); fieldsEntry.getDetails().add( fieldEntry ); for ( Entry entry : Entry.values() ) { if ( entry.getValueType() != ValueMetaInterface.TYPE_NONE ) { StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); fieldEntry.getDetails().add( metaEntry ); } } return all; }
@Override public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException { List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>(); // The fields // StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry( Entry.EXPRESSION_FIELDS.name(), ValueMetaInterface.TYPE_NONE, Entry.EXPRESSION_FIELDS.description ); all.add( fieldsEntry ); StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry( Entry.EXPRESSION_FIELD.name(), ValueMetaInterface.TYPE_NONE, Entry.EXPRESSION_FIELD.description ); fieldsEntry.getDetails().add( fieldEntry ); Entry[] fieldsEntries = new Entry[] { Entry.NEW_FIELDNAME, Entry.JAVA_EXPRESSION, Entry.VALUE_TYPE, Entry.LENGTH, Entry.PRECISION, Entry.REPLACE_VALUE, }; for ( Entry entry : fieldsEntries ) { StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); fieldEntry.getDetails().add( metaEntry ); } return all; }
/** * Describe the metadata attributes that can be injected into this step metadata object. */ public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries( Class<?> PKG ) { List<StepInjectionMetaEntry> entries = new ArrayList<StepInjectionMetaEntry>(); for ( KettleAttributeInterface attr : attributes ) { if ( attr.getParent() == null ) { entries.add( createEntry( attr, PKG ) ); } else { StepInjectionMetaEntry entry = createEntry( attr, PKG ); StepInjectionMetaEntry parentEntry = findParentEntry( entries, attr.getParent().getKey() ); if ( parentEntry == null ) { throw new RuntimeException( "An error was detected in the step attributes' definition: the parent was not found for attribute " + attr ); } parentEntry.getDetails().add( entry ); } } return entries; }
@Override public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException { List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>(); StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry( "FIELDS", ValueMetaInterface.TYPE_NONE, BaseMessages.getString( PKG, "ExcelWriterMetaInjection.AllFields" ) ); all.add( fieldsEntry ); StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry( "FIELD", ValueMetaInterface.TYPE_NONE, BaseMessages.getString( PKG, "ExcelWriterMetaInjection.AllFields" ) ); fieldsEntry.getDetails().add( fieldEntry ); for ( Entry entry : Entry.values() ) { if ( entry.getValueType() != ValueMetaInterface.TYPE_NONE ) { StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); fieldEntry.getDetails().add( metaEntry ); } } return all; }
public List<StepInjectionMetaEntry> extractStepMetadataEntries() throws KettleException { List<StepInjectionMetaEntry> list = new ArrayList<StepInjectionMetaEntry>(); StepInjectionMetaEntry fieldsEntry = StepInjectionUtil.getEntry( Entry.EXPRESSION_FIELDS ); list.add( fieldsEntry ); for ( int i = 0; i < meta.getFormula().length; i++ ) { StepInjectionMetaEntry fieldEntry = StepInjectionUtil.getEntry( Entry.EXPRESSION_FIELD ); List<StepInjectionMetaEntry> details = fieldEntry.getDetails(); details.add( StepInjectionUtil.getEntry( Entry.NEW_FIELDNAME, meta.getFormula()[i].getFieldName() ) ); details.add( StepInjectionUtil.getEntry( Entry.JAVA_EXPRESSION, meta.getFormula()[i].getFormula() ) ); details.add( StepInjectionUtil.getEntry( Entry.VALUE_TYPE, ValueMetaFactory.getValueMetaName( meta.getFormula()[i].getValueType() ) ) ); details.add( StepInjectionUtil.getEntry( Entry.LENGTH, meta.getFormula()[i].getValueLength() ) ); details.add( StepInjectionUtil.getEntry( Entry.PRECISION, meta.getFormula()[i].getValuePrecision() ) ); details.add( StepInjectionUtil.getEntry( Entry.REPLACE_VALUE, meta.getFormula()[i].getReplaceField() ) ); fieldsEntry.getDetails().add( fieldEntry ); } return list; }
StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry( Entry.FIELD.name(), ValueMetaInterface.TYPE_NONE, Entry.FIELD.description ); fieldsEntry.getDetails().add( fieldEntry ); StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); fieldEntry.getDetails().add( metaEntry );
new StepInjectionMetaEntry( Entry.CONCAT_FIELD.name(), ValueMetaInterface.TYPE_NONE, Entry.CONCAT_FIELD.description ); fieldsEntry.getDetails().add( fieldEntry ); StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); fieldEntry.getDetails().add( metaEntry );
new StepInjectionMetaEntry( Entry.DATABASE_FIELD.name(), ValueMetaInterface.TYPE_NONE, Entry.DATABASE_FIELD.description ); fieldsEntry.getDetails().add( fieldEntry ); StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); fieldEntry.getDetails().add( metaEntry );
new StepInjectionMetaEntry( Entry.JSON_FIELD.name(), ValueMetaInterface.TYPE_NONE, Entry.JSON_FIELD.description ); fieldsEntry.getDetails().add( fieldEntry ); StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); fieldEntry.getDetails().add( metaEntry );
public List<StepInjectionMetaEntry> extractStepMetadataEntries() throws KettleException { List<StepInjectionMetaEntry> list = new ArrayList<StepInjectionMetaEntry>(); list.add( StepInjectionUtil.getEntry( Entry.TARGET_SCHEMA, meta.getSchemaName() ) ); list.add( StepInjectionUtil.getEntry( Entry.TARGET_TABLE, meta.getTableName() ) ); list.add( StepInjectionUtil.getEntry( Entry.COMMIT_SIZE, meta.getCommitSize() ) ); list.add( StepInjectionUtil.getEntry( Entry.TRUNCATE_TABLE, meta.truncateTable() ) ); list.add( StepInjectionUtil.getEntry( Entry.SPECIFY_DATABASE_FIELDS, meta.specifyFields() ) ); list.add( StepInjectionUtil.getEntry( Entry.IGNORE_INSERT_ERRORS, meta.ignoreErrors() ) ); list.add( StepInjectionUtil.getEntry( Entry.USE_BATCH_UPDATE, meta.useBatchUpdate() ) ); list.add( StepInjectionUtil.getEntry( Entry.PARTITION_OVER_TABLES, meta.isPartitioningEnabled() ) ); list.add( StepInjectionUtil.getEntry( Entry.PARTITIONING_FIELD, meta.getPartitioningField() ) ); list.add( StepInjectionUtil.getEntry( Entry.PARTITION_DATA_PER, meta.isPartitioningDaily() ? "DAY" : meta.isPartitioningMonthly() ? "MONTH" : "" ) ); list.add( StepInjectionUtil.getEntry( Entry.TABLE_NAME_DEFINED_IN_FIELD, meta.isTableNameInField() ) ); list.add( StepInjectionUtil.getEntry( Entry.TABLE_NAME_FIELD, meta.getTableNameField() ) ); list.add( StepInjectionUtil.getEntry( Entry.STORE_TABLE_NAME, meta.isTableNameInTable() ) ); list.add( StepInjectionUtil.getEntry( Entry.RETURN_AUTO_GENERATED_KEY, meta.isReturningGeneratedKeys() ) ); list.add( StepInjectionUtil.getEntry( Entry.AUTO_GENERATED_KEY_FIELD, meta.getGeneratedKeyField() ) ); StepInjectionMetaEntry fieldsEntry = StepInjectionUtil.getEntry( Entry.DATABASE_FIELDS ); list.add( fieldsEntry ); for ( int i = 0; i < meta.getFieldDatabase().length; i++ ) { StepInjectionMetaEntry fieldEntry = StepInjectionUtil.getEntry( Entry.DATABASE_FIELD ); List<StepInjectionMetaEntry> details = fieldEntry.getDetails(); details.add( StepInjectionUtil.getEntry( Entry.DATABASE_FIELDNAME, meta.getFieldDatabase()[i] ) ); details.add( StepInjectionUtil.getEntry( Entry.STREAM_FIELDNAME, meta.getFieldStream()[i] ) ); fieldsEntry.getDetails().add( fieldEntry ); } return list; }
fieldsEntry.getDetails().add( fieldEntry ); StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); fieldEntry.getDetails().add( metaEntry ); sheetsEntry.getDetails().add( sheetEntry ); StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); sheetEntry.getDetails().add( metaEntry );
@Override public List<StepInjectionMetaEntry> getStepInjectionMetadataEntries() throws KettleException { List<StepInjectionMetaEntry> all = new ArrayList<StepInjectionMetaEntry>(); // Add the fields... // StepInjectionMetaEntry fieldsEntry = new StepInjectionMetaEntry( Entry.FIELDS.name(), Entry.FIELDS.getValueType(), Entry.FIELDS .getDescription() ); all.add( fieldsEntry ); StepInjectionMetaEntry fieldEntry = new StepInjectionMetaEntry( Entry.FIELD.name(), Entry.FIELD.getValueType(), Entry.FIELD.getDescription() ); fieldsEntry.getDetails().add( fieldEntry ); for ( Entry entry : Entry.values() ) { if ( entry.getParent() == Entry.FIELD ) { StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); fieldEntry.getDetails().add( metaEntry ); } else { if ( entry.getParent() == null && entry != Entry.FIELDS && entry != Entry.FIELD ) { StepInjectionMetaEntry metaEntry = new StepInjectionMetaEntry( entry.name(), entry.getValueType(), entry.getDescription() ); all.add( metaEntry ); } } } return all; }
@Test public void testChildLevelMetadataEntries() { try { List<StepInjectionMetaEntry> entries = stepMeta.getStepMetaInjectionInterface().getStepInjectionMetadataEntries(); String childKeys = "NAME TYPE FORMAT STYLECELL FIELDTITLE TITLESTYLE " + "FORMULA HYPERLINKFIELD CELLCOMMENT COMMENTAUTHOR"; StepInjectionMetaEntry mappingEntry = null; for ( StepInjectionMetaEntry entry : entries ) { String key = entry.getKey(); if ( key.equals( "FIELDS" ) ) { mappingEntry = entry; break; } } assertNotNull( mappingEntry ); List<StepInjectionMetaEntry> fieldAttributes = mappingEntry.getDetails().get( 0 ).getDetails(); for ( StepInjectionMetaEntry attribute : fieldAttributes ) { String key = attribute.getKey(); assertTrue( childKeys.contains( key ) ); childKeys = childKeys.replace( key, "" ); } assertTrue( childKeys.trim().length() == 0 ); } catch ( KettleException e ) { fail( e.getMessage() ); } }
@Test public void testChildLevelMetadataEntries() { try { List<StepInjectionMetaEntry> entries = loader.getStepMeta().getStepMetaInterface().getStepMetaInjectionInterface().getStepInjectionMetadataEntries(); String childKeys = "STREAMNAME FIELDNAME DATEMASK "; StepInjectionMetaEntry mappingEntry = null; for ( StepInjectionMetaEntry entry : entries ) { String key = entry.getKey(); if ( key.equals( "MAPPINGS" ) ) { mappingEntry = entry; break; } } assertNotNull( mappingEntry ); List<StepInjectionMetaEntry> fieldAttributes = mappingEntry.getDetails().get( 0 ).getDetails(); for ( StepInjectionMetaEntry attribute : fieldAttributes ) { String key = attribute.getKey(); assertTrue( childKeys.contains( key ) ); childKeys = childKeys.replace( key, "" ); } assertTrue( childKeys.trim().length() == 0 ); } catch ( KettleException e ) { fail( e.getMessage() ); } }
@Test public void testChildLevelMetadataEntries() { try { List<StepInjectionMetaEntry> entries = loader.getStepMeta().getStepMetaInterface().getStepMetaInjectionInterface().getStepInjectionMetadataEntries(); String childKeys = "STREAMNAME FIELDNAME FIELD_FORMAT_OK "; StepInjectionMetaEntry mappingEntry = null; for ( StepInjectionMetaEntry entry : entries ) { String key = entry.getKey(); if ( key.equals( "MAPPINGS" ) ) { mappingEntry = entry; break; } } assertNotNull( mappingEntry ); List<StepInjectionMetaEntry> fieldAttributes = mappingEntry.getDetails().get( 0 ).getDetails(); for ( StepInjectionMetaEntry attribute : fieldAttributes ) { String key = attribute.getKey(); assertTrue( childKeys.contains( key ) ); childKeys = childKeys.replace( key, "" ); } assertTrue( childKeys.trim().length() == 0 ); } catch ( KettleException e ) { fail( e.getMessage() ); } }