private void assignValueForProp( BeanInjectionInfo.Property beanInfoProp, StepMetaInterface stepMetaInterface, BeanInjector injector ) { List<Prop> props = groups.stream() .filter( group -> beanInfoProp.getGroupName().equals( group.name ) ) .flatMap( group -> group.props.stream() ) .filter( prop -> beanInfoProp.getName().equals( prop.name ) ) .collect( Collectors.toList() ); decryptVals( props ); props.forEach( entry -> injectVal( beanInfoProp, entry, stepMetaInterface, injector ) ); }
private void injectVal( BeanInjectionInfo.Property beanInfoProp, Prop prop, StepMetaInterface stepMetaInterface, BeanInjector injector ) { if ( prop.value == null || prop.value.size() == 0 ) { prop.value = singletonList( null ); } try { injector.setProperty( stepMetaInterface, beanInfoProp.getName(), prop.value.stream() .map( value -> { RowMetaAndData rmad = new RowMetaAndData(); rmad.addValue( new ValueMetaString( prop.getName() ), envSubs( value ) ); return rmad; } ).collect( Collectors.toList() ), beanInfoProp.getName() ); } catch ( KettleException e ) { throw new RuntimeException( e ); } }
@SuppressWarnings ( "unchecked" ) private List<Object> getPropVal( StepMetaInterface stepMeta, BeanInjector injector, BeanInjectionInfo.Property prop ) { try { List ret; Object o = injector.getPropVal( stepMeta, prop.getName() ); if ( o instanceof List ) { ret = (List<Object>) o; } else if ( o instanceof Object[] ) { ret = asList( (Object[]) o ); } else { ret = singletonList( o ); } return maybeEncrypt( prop.getName(), ret ); } catch ( Exception e ) { throw new RuntimeException( e ); } }
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(), "" ) ); } } } }
private Function<BeanInjectionInfo.Property, Prop> getProp( StepMetaInterface stepMeta, BeanInjector injector ) { return prop -> new Prop( prop.getName(), getPropVal( stepMeta, injector, prop ), prop.getGroupName() ); }