public BeanInjectionInfo( Class<?> clazz ) { LOG.logDebug( "Collect bean injection info for " + clazz ); try { this.clazz = clazz; clazzAnnotation = clazz.getAnnotation( InjectionSupported.class ); if ( clazzAnnotation == null ) { throw new RuntimeException( "Injection not supported in " + clazz ); } Group gr0 = new Group( "" ); groupsList.add( gr0 ); groupsMap.put( gr0.getName(), gr0 ); for ( String group : clazzAnnotation.groups() ) { Group gr = new Group( group ); groupsList.add( gr ); groupsMap.put( gr.getName(), gr ); } for ( String p : clazzAnnotation.hide() ) { hideProperties.add( p ); } BeanLevelInfo root = new BeanLevelInfo(); root.leafClass = clazz; root.init( this ); properties = Collections.unmodifiableMap( properties ); groupsList = Collections.unmodifiableList( groupsList ); groupsMap = null; } catch ( Throwable ex ) { LOG.logError( "Error bean injection info collection for " + clazz + ": " + ex.getMessage(), ex ); throw ex; } }
@Test public void testInjectionDescription() throws Exception { BeanInjectionInfo ri = new BeanInjectionInfo( MetaBeanLevel1.class ); assertEquals( 3, ri.getGroups().size() ); assertEquals( "", ri.getGroups().get( 0 ).getName() ); assertEquals( "FILENAME_LINES", ri.getGroups().get( 1 ).getName() ); assertEquals( "FILENAME_LINES2", ri.getGroups().get( 2 ).getName() ); assertTrue( ri.getProperties().containsKey( "SEPARATOR" ) ); assertTrue( ri.getProperties().containsKey( "FILENAME" ) ); assertTrue( ri.getProperties().containsKey( "BASE" ) ); assertTrue( ri.getProperties().containsKey( "FIRST" ) ); assertEquals( "FILENAME_LINES", ri.getProperties().get( "FILENAME" ).getGroupName() ); assertEquals( "!DESCRIPTION!", ri.getDescription( "DESCRIPTION" ) ); }
private void processNewMDIDescription( StepMeta stepMeta, TreeItem stepItem, StepMetaInterface metaInterface ) { BeanInjectionInfo stepInjectionInfo = new BeanInjectionInfo( metaInterface.getClass() ); for ( BeanInjectionInfo.Group gr : stepInjectionInfo.getGroups() ) { boolean rootGroup = StringUtils.isEmpty( gr.getName() ); TreeItem groupItem; if ( !rootGroup ) { groupItem = new TreeItem( stepItem, SWT.NONE ); groupItem.setText( gr.getName() ); groupItem.setText( 1, gr.getDescription() ); } else { groupItem = null; } for ( BeanInjectionInfo.Property property : gr.getGroupProperties() ) { TreeItem treeItem = new TreeItem( rootGroup ? stepItem : groupItem, SWT.NONE ); treeItem.setText( property.getName() ); treeItem.setText( 1, property.getDescription() ); TargetStepAttribute target = new TargetStepAttribute( stepMeta.getName(), property.getName(), !rootGroup ); treeItemTargetMap.put( treeItem, target ); SourceStepField source = targetSourceMapping.get( target ); if ( source != null ) { treeItem.setText( 2, Const.NVL( source.getStepname() == null ? CONST_VALUE : source.getStepname(), "" ) ); treeItem.setText( 3, Const.NVL( source.getField(), "" ) ); } } } }