@Test public void testSearchConditionCase() { String dummyStepname = "Output"; DummyTransMeta dummyMeta = new DummyTransMeta(); String dummyStepPid = PluginRegistry.getInstance().getPluginId( StepPluginType.class, dummyMeta ); StepMeta dummyStep = new StepMeta( dummyStepPid, dummyStepname, dummyMeta ); List<StringSearchResult> stringList = new ArrayList<StringSearchResult>(); StringSearcher.findMetaData( dummyStep, 0, stringList, dummyMeta, 0 ); int checkCount = 0; String aResult = null; for ( int i = 0; i < stringList.size(); i++ ) { aResult = stringList.get( i ).toString(); if ( aResult.endsWith( "Dummy (stepid)" ) ) { checkCount++; } else if ( aResult.endsWith( "Output (name)" ) ) { checkCount++; } if ( checkCount == 2 ) { break; } } assertEquals( 2, checkCount ); FilterRowsMeta filterRowsMeta = new FilterRowsMeta(); Condition condition = new Condition(); condition.setNegated( false ); condition.setLeftValuename( "wibble_t" ); condition.setRightValuename( "wobble_s" ); condition.setFunction( org.pentaho.di.core.Condition.FUNC_EQUAL ); filterRowsMeta.setDefault(); filterRowsMeta.setCondition( condition ); String filterRowsPluginPid = PluginRegistry.getInstance().getPluginId( StepPluginType.class, filterRowsMeta ); StepMeta filterRowsStep = new StepMeta( filterRowsPluginPid, "Filter Rows", filterRowsMeta ); stringList.clear(); StringSearcher.findMetaData( filterRowsStep, 0, stringList, filterRowsMeta, 0 ); checkCount = 0; for ( int i = 0; i < stringList.size(); i++ ) { aResult = stringList.get( i ).toString(); if ( aResult.endsWith( "FilterRows (stepid)" ) ) { checkCount++; } else if ( aResult.endsWith( "Filter Rows (name)" ) ) { checkCount++; } if ( checkCount == 2 ) { break; } } assertEquals( 2, checkCount ); }
public static final void findMetaData( Object object, int level, List<StringSearchResult> stringList, Object parentObject, Object grandParentObject ) { if ( ( object == null ) || level > 5 ) { return; } PluginRegistry registry = PluginRegistry.getInstance(); if ( stepPluginPackages == null ) { stepPluginPackages = registry.getPluginPackages( StepPluginType.class ); } if ( jobEntryPluginPackages == null ) { jobEntryPluginPackages = registry.getPluginPackages( JobEntryPluginType.class ); } Class<? extends Object> baseClass = object.getClass(); Field[] fields = baseClass.getDeclaredFields(); for ( int i = 0; i < fields.length; i++ ) { Field field = fields[i]; boolean processThisOne = true; if ( ( field.getModifiers() & Modifier.FINAL ) > 0 ) { processThisOne = false; } if ( ( field.getModifiers() & Modifier.STATIC ) > 0 ) { processThisOne = false; } boolean sanctionedPackage = false; String fieldToString = field.toString(); if ( fieldToString.indexOf( LOCAL_PACKAGE ) >= 0 ) { sanctionedPackage = true; } for ( int x = 0; x < JAVA_PACKAGES.length && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( JAVA_PACKAGES[x] ) >= 0 ) { sanctionedPackage = true; } } for ( int x = 0; x < stepPluginPackages.size() && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( stepPluginPackages.get( x ) ) >= 0 ) { sanctionedPackage = true; } } for ( int x = 0; x < jobEntryPluginPackages.size() && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( jobEntryPluginPackages.get( x ) ) >= 0 ) { sanctionedPackage = true; } } if ( !sanctionedPackage ) { processThisOne = false; } if ( processThisOne ) { try { Object obj = field.get( object ); if ( obj != null ) { stringSearchInObject( obj, level, stringList, parentObject, grandParentObject, field ); } } catch ( IllegalAccessException e ) { try { Method method = findMethod( baseClass, field.getName() ); if ( method != null ) { Object string = method.invoke( object, (Object[]) null ); if ( string != null ) { stringSearchInObject( string, level, stringList, parentObject, grandParentObject, field ); } } } catch ( Throwable ex ) { } } } } }
StringSearcher { public static final void findMetaData( Object object, int level, List<StringSearchResult> stringList, Object parentObject, Object grandParentObject ) { if ( ( object == null ) || level > 5 ) { return; } PluginRegistry registry = PluginRegistry.getInstance(); if ( stepPluginPackages == null ) { stepPluginPackages = registry.getPluginPackages( StepPluginType.class ); } if ( jobEntryPluginPackages == null ) { jobEntryPluginPackages = registry.getPluginPackages( JobEntryPluginType.class ); } Class<? extends Object> baseClass = object.getClass(); Field[] fields = baseClass.getDeclaredFields(); for ( int i = 0; i < fields.length; i++ ) { Field field = fields[i]; boolean processThisOne = true; if ( ( field.getModifiers() & Modifier.FINAL ) > 0 ) { processThisOne = false; } if ( ( field.getModifiers() & Modifier.STATIC ) > 0 ) { processThisOne = false; } boolean sanctionedPackage = false; String fieldToString = field.toString(); if ( fieldToString.indexOf( LOCAL_PACKAGE ) >= 0 ) { sanctionedPackage = true; } for ( int x = 0; x < JAVA_PACKAGES.length && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( JAVA_PACKAGES[x] ) >= 0 ) { sanctionedPackage = true; } } for ( int x = 0; x < stepPluginPackages.size() && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( stepPluginPackages.get( x ) ) >= 0 ) { sanctionedPackage = true; } } for ( int x = 0; x < jobEntryPluginPackages.size() && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( jobEntryPluginPackages.get( x ) ) >= 0 ) { sanctionedPackage = true; } } if ( !sanctionedPackage ) { processThisOne = false; } if ( processThisOne ) { try { Object obj = field.get( object ); if ( obj != null ) { stringSearchInObject( obj, level, stringList, parentObject, grandParentObject, field ); } } catch ( IllegalAccessException e ) { try { Method method = findMethod( baseClass, field.getName() ); if ( method != null ) { Object string = method.invoke( object, (Object[]) null ); if ( string != null ) { stringSearchInObject( string, level, stringList, parentObject, grandParentObject, field ); } } } catch ( Throwable ex ) { } } } } } }
StringSearcher { public static final void findMetaData( Object object, int level, List<StringSearchResult> stringList, Object parentObject, Object grandParentObject ) { if ( ( object == null ) || level > 5 ) { return; } PluginRegistry registry = PluginRegistry.getInstance(); if ( stepPluginPackages == null ) { stepPluginPackages = registry.getPluginPackages( StepPluginType.class ); } if ( jobEntryPluginPackages == null ) { jobEntryPluginPackages = registry.getPluginPackages( JobEntryPluginType.class ); } Class<? extends Object> baseClass = object.getClass(); Field[] fields = baseClass.getDeclaredFields(); for ( int i = 0; i < fields.length; i++ ) { Field field = fields[i]; boolean processThisOne = true; if ( ( field.getModifiers() & Modifier.FINAL ) > 0 ) { processThisOne = false; } if ( ( field.getModifiers() & Modifier.STATIC ) > 0 ) { processThisOne = false; } boolean sanctionedPackage = false; String fieldToString = field.toString(); if ( fieldToString.indexOf( LOCAL_PACKAGE ) >= 0 ) { sanctionedPackage = true; } for ( int x = 0; x < JAVA_PACKAGES.length && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( JAVA_PACKAGES[x] ) >= 0 ) { sanctionedPackage = true; } } for ( int x = 0; x < stepPluginPackages.size() && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( stepPluginPackages.get( x ) ) >= 0 ) { sanctionedPackage = true; } } for ( int x = 0; x < jobEntryPluginPackages.size() && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( jobEntryPluginPackages.get( x ) ) >= 0 ) { sanctionedPackage = true; } } if ( !sanctionedPackage ) { processThisOne = false; } if ( processThisOne ) { try { Object obj = field.get( object ); if ( obj != null ) { stringSearchInObject( obj, level, stringList, parentObject, grandParentObject, field ); } } catch ( IllegalAccessException e ) { try { Method method = findMethod( baseClass, field.getName() ); if ( method != null ) { Object string = method.invoke( object, (Object[]) null ); if ( string != null ) { stringSearchInObject( string, level, stringList, parentObject, grandParentObject, field ); } } } catch ( Throwable ex ) { } } } } }  }
StringSearcher { public static final void findMetaData( Object object, int level, List<StringSearchResult> stringList, Object parentObject, Object grandParentObject ) { if ( ( object == null ) || level > 5 ) { return; } PluginRegistry registry = PluginRegistry.getInstance(); if ( stepPluginPackages == null ) { stepPluginPackages = registry.getPluginPackages( StepPluginType.class ); } if ( jobEntryPluginPackages == null ) { jobEntryPluginPackages = registry.getPluginPackages( JobEntryPluginType.class ); } Class<? extends Object> baseClass = object.getClass(); Field[] fields = baseClass.getDeclaredFields(); for ( int i = 0; i < fields.length; i++ ) { Field field = fields[i]; boolean processThisOne = true; if ( ( field.getModifiers() & Modifier.FINAL ) > 0 ) { processThisOne = false; } if ( ( field.getModifiers() & Modifier.STATIC ) > 0 ) { processThisOne = false; } boolean sanctionedPackage = false; String fieldToString = field.toString(); if ( fieldToString.indexOf( LOCAL_PACKAGE ) >= 0 ) { sanctionedPackage = true; } for ( int x = 0; x < JAVA_PACKAGES.length && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( JAVA_PACKAGES[x] ) >= 0 ) { sanctionedPackage = true; } } for ( int x = 0; x < stepPluginPackages.size() && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( stepPluginPackages.get( x ) ) >= 0 ) { sanctionedPackage = true; } } for ( int x = 0; x < jobEntryPluginPackages.size() && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( jobEntryPluginPackages.get( x ) ) >= 0 ) { sanctionedPackage = true; } } if ( !sanctionedPackage ) { processThisOne = false; } if ( processThisOne ) { try { Object obj = field.get( object ); if ( obj != null ) { stringSearchInObject( obj, level, stringList, parentObject, grandParentObject, field ); } } catch ( IllegalAccessException e ) { try { Method method = findMethod( baseClass, field.getName() ); if ( method != null ) { Object string = method.invoke( object, (Object[]) null ); if ( string != null ) { stringSearchInObject( string, level, stringList, parentObject, grandParentObject, field ); } } } catch ( Throwable ex ) { } } } } }  static final void findMetaData( Object object, int level, List<StringSearchResult> stringList,
    Object parentObject, Object grandParentObject ); static final String constructGetter( String name ); static final String constructIsGetter( String name ); }
StringSearcher { public static final void findMetaData( Object object, int level, List<StringSearchResult> stringList, Object parentObject, Object grandParentObject ) { if ( ( object == null ) || level > 5 ) { return; } PluginRegistry registry = PluginRegistry.getInstance(); if ( stepPluginPackages == null ) { stepPluginPackages = registry.getPluginPackages( StepPluginType.class ); } if ( jobEntryPluginPackages == null ) { jobEntryPluginPackages = registry.getPluginPackages( JobEntryPluginType.class ); } Class<? extends Object> baseClass = object.getClass(); Field[] fields = baseClass.getDeclaredFields(); for ( int i = 0; i < fields.length; i++ ) { Field field = fields[i]; boolean processThisOne = true; if ( ( field.getModifiers() & Modifier.FINAL ) > 0 ) { processThisOne = false; } if ( ( field.getModifiers() & Modifier.STATIC ) > 0 ) { processThisOne = false; } boolean sanctionedPackage = false; String fieldToString = field.toString(); if ( fieldToString.indexOf( LOCAL_PACKAGE ) >= 0 ) { sanctionedPackage = true; } for ( int x = 0; x < JAVA_PACKAGES.length && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( JAVA_PACKAGES[x] ) >= 0 ) { sanctionedPackage = true; } } for ( int x = 0; x < stepPluginPackages.size() && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( stepPluginPackages.get( x ) ) >= 0 ) { sanctionedPackage = true; } } for ( int x = 0; x < jobEntryPluginPackages.size() && !sanctionedPackage; x++ ) { if ( fieldToString.indexOf( jobEntryPluginPackages.get( x ) ) >= 0 ) { sanctionedPackage = true; } } if ( !sanctionedPackage ) { processThisOne = false; } if ( processThisOne ) { try { Object obj = field.get( object ); if ( obj != null ) { stringSearchInObject( obj, level, stringList, parentObject, grandParentObject, field ); } } catch ( IllegalAccessException e ) { try { Method method = findMethod( baseClass, field.getName() ); if ( method != null ) { Object string = method.invoke( object, (Object[]) null ); if ( string != null ) { stringSearchInObject( string, level, stringList, parentObject, grandParentObject, field ); } } } catch ( Throwable ex ) { } } } } }  static final void findMetaData( Object object, int level, List<StringSearchResult> stringList,
    Object parentObject, Object grandParentObject ); static final String constructGetter( String name ); static final String constructIsGetter( String name );  }