public static StepInjectionMetaEntry findEntry( List<StepInjectionMetaEntry> entries, String key ) { for ( StepInjectionMetaEntry entry : entries ) { if ( entry.getKey().equals( key ) ) { return entry; } } return null; }
@Override public void handleEvent( Event arg0 ) { System.out.println( entry.getKey() + " - " + entry.getDescription() ); } } );
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; }
/** * 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; }
Object cmp = cmpEntry.getValue(); if ( ref != null && cmp == null ) { throw new KettleException( "Reference key '" + refEntry.getKey() + "': value is not null while the compare value is null" ); throw new KettleException( "Reference key '" + refEntry.getKey() + "': value is null while the compare value is not null" ); throw new KettleException( "Reference key '" + refEntry.getKey() + "': reference value '" + ref + "' is not equal to '" + cmp + "'" );
private static void assertInjected( List<StepInjectionMetaEntry> fields, List<StepInjectionMetaEntry> toBeInjected ) { Map<String, StepInjectionMetaEntry> map = new HashMap<String, StepInjectionMetaEntry>( fields.size() ); for ( StepInjectionMetaEntry field : fields ) { map.put( field.getKey(), field ); } for ( StepInjectionMetaEntry entry : toBeInjected ) { StepInjectionMetaEntry field = map.get( entry.getKey() ); assertNotNull( entry.getKey(), field ); Object value = field.getValue(); if ( value == null ) { assertNull( entry.getKey(), entry.getValue() ); } else { assertEquals( entry.getKey(), entry.getValue(), value ); } } }
public void injectStepMetadataEntries( List<StepInjectionMetaEntry> metadata ) { for ( StepInjectionMetaEntry entry : metadata ) { KettleAttributeInterface attr = findAttribute( entry.getKey() ); if ( entry.getKey().equals( "SCHEMA" ) ) { schemaName = (String) entry.getValue(); } else if ( entry.getKey().equals( "TABLE" ) ) { tableName = (String) entry.getValue(); } else if ( entry.getKey().equals( "LOGFILE" ) ) { logFile = (String) entry.getValue(); } else if ( entry.getKey().equals( "FIELD_SEPARATOR" ) ) { fieldSeparator = (String) entry.getValue(); } else if ( entry.getKey().equals( "FIELD_ENCLOSURE" ) ) { fieldEnclosure = (String) entry.getValue(); } else if ( entry.getKey().equals( "NULL_REPRESENTATION" ) ) { setNULLrepresentation( (String) entry.getValue() ); } else if ( entry.getKey().equals( "ENCODING" ) ) { encoding = (String) entry.getValue(); } else if ( entry.getKey().equals( "BUFFER_SIZE" ) ) { bufferSize = (String) entry.getValue(); } else if ( entry.getKey().equals( "TRUNCATE" ) ) { truncate = (Boolean) entry.getValue(); } else if ( entry.getKey().equals( "FULLY_QUOTE_SQL" ) ) { fullyQuoteSQL = (Boolean) entry.getValue(); } else { KettleAttributeInterface fieldAttr = findAttribute( fieldAttribute.getKey() );
public void injectStepMetadataEntries( List<StepInjectionMetaEntry> metadata ) { for ( StepInjectionMetaEntry entry : metadata ) { KettleAttributeInterface attr = findAttribute( entry.getKey() ); if ( entry.getKey().equals( "SCHEMA" ) ) { schemaName = (String) entry.getValue(); } else if ( entry.getKey().equals( "TABLE" ) ) { tableName = (String) entry.getValue(); } else if ( entry.getKey().equals( "LOADACTION" ) ) { loadAction = (String) entry.getValue(); } else if ( entry.getKey().equals( "DBNAMEOVERRIDE" ) ) { dbNameOverride = (String) entry.getValue(); } else if ( entry.getKey().equals( "ENCLOSURE" ) ) { enclosure = (String) entry.getValue(); } else if ( entry.getKey().equals( "DELIMITER" ) ) { delimiter = (String) entry.getValue(); } else if ( entry.getKey().equals( "STOPONERROR" ) ) { stopOnError = (Boolean) entry.getValue(); } else { KettleAttributeInterface fieldAttr = findAttribute( fieldAttribute.getKey() );
@Test public void extractingAll() throws Exception { TextFileInputMetaInjection injection = new TextFileInputMetaInjection( new TextFileInputMeta() ); List<StepInjectionMetaEntry> metadata = injection.getStepInjectionMetadataEntries(); List<StepInjectionMetaEntry> extracted = injection.extractStepMetadataEntries(); assertEquals( metadata.size(), extracted.size() ); for ( StepInjectionMetaEntry metaEntry : metadata ) { assertNotNull( metaEntry.getKey(), StepInjectionUtil.findEntry( extracted, metaEntry.getKey() ) ); } }
Entry fieldsEntry = Entry.findEntry( lookFields.getKey() ); if ( fieldsEntry != null ) { if ( fieldsEntry == Entry.FIELDS ) { for ( StepInjectionMetaEntry lookField : lookFields.getDetails() ) { Entry fieldEntry = Entry.findEntry( lookField.getKey() ); if ( fieldEntry != null ) { if ( fieldEntry == Entry.FIELD ) { Entry metaEntry = Entry.findEntry( entry.getKey() ); if ( metaEntry != null ) { Object value = entry.getValue();
if ( entry.getValueType() != ValueMetaInterface.TYPE_NONE ) { TreeItem entryItem = new TreeItem( stepItem, SWT.NONE ); entryItem.setText( entry.getKey() ); entryItem.setText( 1, entry.getDescription() ); TargetStepAttribute target = new TargetStepAttribute( stepMeta.getName(), entry.getKey(), false ); treeItemTargetMap.put( entryItem, target ); listsItem.setText( entry.getKey() ); listsItem.setText( 1, entry.getDescription() ); StepInjectionMetaEntry listEntry = entry.getDetails().get( 0 ); treeItem.setText( me.getKey() ); treeItem.setText( 1, me.getDescription() ); TargetStepAttribute target = new TargetStepAttribute( stepMeta.getName(), me.getKey(), true ); treeItemTargetMap.put( treeItem, target );
@Test public void testTopLevelMetadataEntries() { try { List<StepInjectionMetaEntry> entries = stepMeta.getStepMetaInjectionInterface().getStepInjectionMetadataEntries(); String masterKeys = "FIELDS"; for ( StepInjectionMetaEntry entry : entries ) { String key = entry.getKey(); assertTrue( masterKeys.contains( key ) ); masterKeys = masterKeys.replace( key, "" ); } assertTrue( masterKeys.trim().length() == 0 ); } catch ( KettleException e ) { fail( e.getMessage() ); } }
@Test public void testTopLevelMetadataEntries() { try { List<StepInjectionMetaEntry> entries = loader.getStepMeta().getStepMetaInterface().getStepMetaInjectionInterface().getStepInjectionMetadataEntries(); String masterKeys = "SCHEMA TABLE LOADACTION STOPONERROR DELIMITER ENCLOSURE DBNAMEOVERRIDE MAPPINGS "; for ( StepInjectionMetaEntry entry : entries ) { String key = entry.getKey(); assertTrue( masterKeys.contains( key ) ); masterKeys = masterKeys.replace( key, "" ); } assertTrue( masterKeys.trim().length() == 0 ); } catch ( KettleException e ) { fail( e.getMessage() ); } }
@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 testTopLevelMetadataEntries() { try { List<StepInjectionMetaEntry> entries = loader.getStepMeta().getStepMetaInterface().getStepMetaInjectionInterface().getStepInjectionMetadataEntries(); String masterKeys = "SCHEMA TABLE LOGFILE FIELD_SEPARATOR FIELD_ENCLOSURE NULL_REPRESENTATION ENCODING TRUNCATE " + "FULLY_QUOTE_SQL BUFFER_SIZE MAPPINGS "; for ( StepInjectionMetaEntry entry : entries ) { String key = entry.getKey(); assertTrue( masterKeys.contains( key ) ); masterKeys = masterKeys.replace( key, "" ); } assertTrue( masterKeys.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() ); } }
entry.setValueType( lm.findAttribute( entry.getKey() ).getType() ); switch ( entry.getValueType() ) { case ValueMetaInterface.TYPE_STRING: entry.setValue( "new_".concat( entry.getKey() ) ); break; case ValueMetaInterface.TYPE_BOOLEAN: switch ( childEntry.getValueType() ) { case ValueMetaInterface.TYPE_STRING: childEntry.setValue( "new_".concat( childEntry.getKey() ) ); break; case ValueMetaInterface.TYPE_BOOLEAN:
switch ( entry.getValueType() ) { case ValueMetaInterface.TYPE_STRING: entry.setValue( "new_".concat( entry.getKey() ) ); break; case ValueMetaInterface.TYPE_BOOLEAN: switch ( childEntry.getValueType() ) { case ValueMetaInterface.TYPE_STRING: childEntry.setValue( "new_".concat( childEntry.getKey() ) ); break; case ValueMetaInterface.TYPE_BOOLEAN: