Codota Logo
BeanInjector
Code IndexAdd Codota to your IDE (free)

How to use
BeanInjector
in
org.pentaho.di.core.injection.bean

Best Java code snippets using org.pentaho.di.core.injection.bean.BeanInjector (Showing top 20 results out of 315)

  • Common ways to obtain BeanInjector
private void myMethod () {
BeanInjector b =
  • Codota IconBeanInjectionInfo info;new BeanInjector(info)
  • Smart code suggestions by Codota
}
origin: pentaho/pentaho-kettle

BeanInjector injector = new BeanInjector( injectionInfo );
   if ( injector.hasProperty( targetStepMeta, target.getAttributeKey() ) ) {
    injector.setProperty( targetStepMeta, target.getAttributeKey(), null, source.getField() );
   } else {
origin: pentaho/pentaho-kettle

case ARRAY:
 Object existArray = data != null ? extendArray( s, obj, index + 1 ) : checkArray( s, obj, index );
 if ( existArray == null ) {
  next = createObject( s.leafClass, root );
  Array.set( existArray, index, next );
case LIST:
 List<Object> existList = data != null ? extendList( s, obj, index + 1 ) : checkList( s, obj, index );
 if ( existList == null ) {
  next = createObject( s.leafClass, root );
  existList.set( index, next );
  next = s.field.get( obj );
  if ( next == null ) {
   next = createObject( s.leafClass, root );
   s.field.set( obj, next );
  Object existArray = data != null ? extendArray( s, obj, index + 1 ) : checkArray( s, obj, index );
  if ( existArray == null ) {
  break;
 case LIST:
  List<Object> existList = data != null ? extendList( s, obj, index + 1 ) : checkList( s, obj, index );
  if ( existList == null ) {
origin: pentaho/pentaho-kettle

@SuppressWarnings ( "unchecked" )
private Object getPropVal( Object obj, String propName, Queue<BeanLevelInfo> beanInfos ) {
 BeanLevelInfo info = beanInfos.remove();
 if ( beanInfos.isEmpty() ) {
  return getObjFromBeanInfo( obj, info );
 }
 obj = getObjFromBeanInfo( obj, info );
 switch ( info.dim ) {
  case LIST:
   return ( (List) requireNonNull( obj ) ).stream()
    .map( o -> getPropVal( o, propName, newLinkedList( beanInfos ) ) )
    .collect( Collectors.toList() );
  case ARRAY:
   return Arrays.stream( (Object[]) requireNonNull( obj ) )
    .map( o -> getPropVal( o, propName, newLinkedList( beanInfos ) ) )
    .toArray( Object[]::new );
  case NONE:
   return getPropVal( obj, propName, beanInfos );
 }
 throw new IllegalStateException( "Unexpected value of BeanLevelInfo.dim " + info.dim );
}
origin: pentaho/pentaho-kettle

 setProperty( root, prop, 0, data != null ? data.get( 0 ) : null, dataName, dataValue );
} catch ( Exception ex ) {
 throw new KettleException( "Error inject property '" + propName + "' into " + root.getClass(), ex );
 if ( data != null ) {
  for ( int i = 0; i < data.size(); i++ ) {
   setProperty( root, prop, i, data.get( i ), dataName, dataValue );
   boolean found = setProperty( root, prop, i, null, null, dataValue );
   if ( !found ) {
    break;
origin: pentaho/pentaho-kettle

BeanInjector injector = new BeanInjector( injectionInfo );
    if ( injector.hasProperty( targetStepMeta, target.getAttributeKey() ) ) {
      injector.setProperty( targetStepMeta, target.getAttributeKey(), rows, source.getField() );
      wasInjection = true;
 injector.runPostInjectionProcessing( targetStepMeta );
origin: pentaho/pentaho-kettle

/**
 * Sets the properties of this StepMetaProps on {@param stepMetaInterface}
 * <p>
 * This method mutates the stepMeta, as opposed to returning a new instance, to match
 * more cleanly to Kettle's {@link StepMetaInterface#loadXML} design, which loads props into
 * an instance.
 */
public StepMetaInterface to( StepMetaInterface stepMetaInterface ) {
 BeanInjectionInfo info = new BeanInjectionInfo( stepMetaInterface.getClass() );
 BeanInjector injector = new BeanInjector( info );
 info.getProperties().values().forEach( property -> assignValueForProp( property, stepMetaInterface, injector ) );
 return stepMetaInterface;
}
origin: pentaho/pentaho-kettle

/**
 * Retrieves the raw prop value from root object.
 * <p>
 * The similar {@link #getProperty(Object, String)} method (also in this class )should be
 * revisited and possibly eliminated.  That version attempts to retrieve indexed prop
 * vals from lists/arrays, but doesn't provide a way to retrieve the list or array objects
 * themselves.
 */
public Object getPropVal( Object root, String propName ) {
 Queue<BeanLevelInfo> beanInfos =
  newLinkedList( Optional.ofNullable( info.getProperties().get( propName ) )
   .orElseThrow( () -> new IllegalArgumentException( "Property not found: " + propName ) )
   .path );
 beanInfos.remove();  // pop off root
 return getPropVal( root, propName, beanInfos );
}
origin: pentaho/pentaho-kettle

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 );
 }
}
origin: pentaho/pentaho-kettle

/**
 * Retuns an instance of this class with stepMeta properties mapped
 * to a list of {@link PropGroup}
 */
public static StepMetaProps from( StepMetaInterface stepMeta ) {
 StepMetaProps propMap = new StepMetaProps( stepMeta );
 propMap.stepMeta = stepMeta;
 // use metadata injection to extract properties
 BeanInjectionInfo info = new BeanInjectionInfo( stepMeta.getClass() );
 BeanInjector injector = new BeanInjector( info );
 propMap.populateGroups( stepMeta, info, injector );
 return propMap;
}
origin: pentaho/pentaho-kettle

@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 );
 }
}
origin: pentaho/pentaho-kettle

/**
 * Check enum property.
 */
protected void check( String propertyName, EnumGetter getter, Class<?> enumType ) throws KettleException {
 ValueMetaInterface valueMeta = new ValueMetaString( "f" );
 Object[] values = enumType.getEnumConstants();
 for ( Object v : values ) {
  injector.setProperty( meta, propertyName, setValue( valueMeta, v ), "f" );
  assertEquals( v, getter.get() );
 }
 try {
  injector.setProperty( meta, propertyName, setValue( valueMeta, "###" ), "f" );
  fail( "Should be passed to enum" );
 } catch ( KettleException ex ) {
 }
 skipPropertyTest( propertyName );
}
origin: pentaho/pentaho-kettle

private static BeanInjector buildBeanInjectorFor( Class<?> clazz ) {
 BeanInjectionInfo metaBeanInfo = new BeanInjectionInfo( clazz );
 return new BeanInjector( metaBeanInfo );
}
origin: pentaho/pentaho-kettle

/**
 * Check string-to-int property.
 */
protected void checkStringToInt( String propertyName, IntGetter getter, String[] codes, int[] ids )
 throws KettleException {
 if ( codes.length != ids.length ) {
  throw new RuntimeException( "Wrong codes/ids sizes" );
 }
 ValueMetaInterface valueMetaString = new ValueMetaString( "f" );
 for ( int i = 0; i < codes.length; i++ ) {
  injector.setProperty( meta, propertyName, setValue( valueMetaString, codes[i] ), "f" );
  assertEquals( ids[i], getter.get() );
 }
 skipPropertyTest( propertyName );
}
origin: pentaho/pentaho-kettle

protected void setup( T meta ) {
 KettleLogStore.init();
 this.meta = meta;
 info = new BeanInjectionInfo( meta.getClass() );
 injector = new BeanInjector( info );
 nonTestedProperties = new HashSet<>( info.getProperties().keySet() );
}
origin: pentaho/pentaho-kettle

/**
 * Check long property.
 */
protected void check( String propertyName, LongGetter getter ) throws KettleException {
 ValueMetaInterface valueMetaString = new ValueMetaString( "f" );
 injector.setProperty( meta, propertyName, setValue( valueMetaString, "1" ), "f" );
 assertEquals( 1, getter.get() );
 injector.setProperty( meta, propertyName, setValue( valueMetaString, "45" ), "f" );
 assertEquals( 45, getter.get() );
 ValueMetaInterface valueMetaInteger = new ValueMetaInteger( "f" );
 injector.setProperty( meta, propertyName, setValue( valueMetaInteger, 1234L ), "f" );
 assertEquals( 1234, getter.get() );
 injector.setProperty( meta, propertyName, setValue( valueMetaInteger, Long.MAX_VALUE ), "f" );
 assertEquals( Long.MAX_VALUE, getter.get() );
 skipPropertyTest( propertyName );
}
origin: pentaho/pentaho-kettle

/**
 * Check int property.
 */
protected void check( String propertyName, IntGetter getter ) throws KettleException {
 ValueMetaInterface valueMetaString = new ValueMetaString( "f" );
 injector.setProperty( meta, propertyName, setValue( valueMetaString, "1" ), "f" );
 assertEquals( 1, getter.get() );
 injector.setProperty( meta, propertyName, setValue( valueMetaString, "45" ), "f" );
 assertEquals( 45, getter.get() );
 ValueMetaInterface valueMetaInteger = new ValueMetaInteger( "f" );
 injector.setProperty( meta, propertyName, setValue( valueMetaInteger, 1234L ), "f" );
 assertEquals( 1234, getter.get() );
 injector.setProperty( meta, propertyName, setValue( valueMetaInteger, (long) Integer.MAX_VALUE ), "f" );
 assertEquals( Integer.MAX_VALUE, getter.get() );
 skipPropertyTest( propertyName );
}
origin: pentaho/pentaho-kettle

/**
 * Check boolean property.
 */
protected void check( String propertyName, BooleanGetter getter ) throws KettleException {
 ValueMetaInterface valueMetaString = new ValueMetaString( "f" );
 injector.setProperty( meta, propertyName, setValue( valueMetaString, "Y" ), "f" );
 assertEquals( true, getter.get() );
 injector.setProperty( meta, propertyName, setValue( valueMetaString, "N" ), "f" );
 assertEquals( false, getter.get() );
 ValueMetaInterface valueMetaBoolean = new ValueMetaBoolean( "f" );
 injector.setProperty( meta, propertyName, setValue( valueMetaBoolean, true ), "f" );
 assertEquals( true, getter.get() );
 injector.setProperty( meta, propertyName, setValue( valueMetaBoolean, false ), "f" );
 assertEquals( false, getter.get() );
 skipPropertyTest( propertyName );
}
origin: pentaho/pentaho-kettle

@Test
public void testInjectionSets() throws Exception {
 MetaBeanLevel1 obj = new MetaBeanLevel1();
 RowMeta meta = new RowMeta();
 meta.addValueMeta( new ValueMetaString( "f1" ) );
 meta.addValueMeta( new ValueMetaString( "f2" ) );
 meta.addValueMeta( new ValueMetaString( "fstrint" ) );
 meta.addValueMeta( new ValueMetaString( "fstrlong" ) );
 meta.addValueMeta( new ValueMetaString( "fstrboolean" ) ); // TODO STLOCALE
 List<RowMetaAndData> rows = new ArrayList<>();
 rows.add( new RowMetaAndData( meta, "<sep>", "/tmp/file.txt", "123", "1234567891213", "y" ) );
 rows.add( new RowMetaAndData( meta, "<sep>", "/tmp/file2.txt", "123", "1234567891213", "y" ) );
 BeanInjector inj = buildBeanInjectorFor( MetaBeanLevel1.class );
 inj.setProperty( obj, "SEPARATOR", rows, "f1" );
 inj.setProperty( obj, "FILENAME", rows, "f2" );
 inj.setProperty( obj, "FILENAME_ARRAY", rows, "f2" );
 inj.setProperty( obj, "FBOOLEAN", rows, "fstrboolean" );
 inj.setProperty( obj, "FINT", rows, "fstrint" );
 inj.setProperty( obj, "FLONG", rows, "fstrlong" );
 inj.setProperty( obj, "FIRST", rows, "fstrint" );
 assertEquals( "<sep>", obj.getSub().getSeparator() );
 assertEquals( "/tmp/file.txt", obj.getSub().getFiles()[0].getName() );
 assertTrue( obj.fboolean );
 assertEquals( 123, obj.fint );
 assertEquals( 1234567891213L, obj.flong );
 assertEquals( "123", obj.getSub().first() );
 assertArrayEquals( new String[] { "/tmp/file.txt", "/tmp/file2.txt" }, obj.getSub().getFilenames() );
}
origin: pentaho/pentaho-kettle

@Test
public void testInjectionConstant() throws Exception {
 MetaBeanLevel1 obj = new MetaBeanLevel1();
 BeanInjector inj = buildBeanInjectorFor( MetaBeanLevel1.class );
 inj.setProperty( obj, "SEPARATOR", null, "<sep>" );
 inj.setProperty( obj, "FINT", null, "123" );
 inj.setProperty( obj, "FLONG", null, "1234567891213" );
 inj.setProperty( obj, "FBOOLEAN", null, "true" );
 inj.setProperty( obj, "FILENAME", null, "f1" );
 inj.setProperty( obj, "FILENAME_ARRAY", null, "f2" );
 assertEquals( "<sep>", obj.getSub().getSeparator() );
 assertTrue( obj.fboolean );
 assertEquals( 123, obj.fint );
 assertEquals( 1234567891213L, obj.flong );
 assertNull( obj.getSub().getFiles() );
 assertNull( obj.getSub().getFilenames() );
 obj.getSub().files = new MetaBeanLevel3[] { new MetaBeanLevel3(), new MetaBeanLevel3() };
 obj.getSub().filenames = new String[] { "", "", "" };
 inj.setProperty( obj, "FILENAME", null, "f1" );
 inj.setProperty( obj, "FILENAME_ARRAY", null, "f2" );
 assertEquals( 2, obj.getSub().getFiles().length );
 assertEquals( "f1", obj.getSub().getFiles()[0].getName() );
 assertEquals( "f1", obj.getSub().getFiles()[1].getName() );
 assertArrayEquals( new String[] { "f2", "f2", "f2" }, obj.getSub().getFilenames() );
}
origin: pentaho/pentaho-kettle

/**
 * Check string property.
 */
protected void check( String propertyName, StringGetter getter, String... values ) throws KettleException {
 ValueMetaInterface valueMeta = new ValueMetaString( "f" );
 if ( values.length == 0 ) {
  values = new String[] { "v", "v2", null };
 }
 String correctValue = null;
 for ( String v : values ) {
  injector.setProperty( meta, propertyName, setValue( valueMeta, v ), "f" );
  if ( v != null ) {
   // only not-null values injected
   correctValue = v;
  }
  assertEquals( correctValue, getter.get() );
 }
 skipPropertyTest( propertyName );
}
org.pentaho.di.core.injection.beanBeanInjector

Javadoc

Engine for get/set metadata injection properties from bean.

Most used methods

  • <init>
  • setProperty
    Sets data from RowMetaAndData, or constant value from dataValue depends on 'data != null'.
  • checkArray
  • checkList
  • createObject
  • extendArray
  • extendList
  • getObjFromBeanInfo
  • getPropVal
  • hasProperty
  • runPostInjectionProcessing
  • runPostInjectionProcessing

Popular in Java

  • Parsing JSON documents to java classes using gson
  • onCreateOptionsMenu (Activity)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now