org.pentaho.di.core.plugins.PluginRegistry Java Examples

The following examples show how to use org.pentaho.di.core.plugins.PluginRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XBaseInputMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.init( false );
  List<String> attributes =
      Arrays.asList( "dbfFileName", "rowLimit", "rowNrAdded", "rowNrField", "acceptingFilenames", "acceptingField",
          "acceptingStepName", "includeFilename", "filenameField", "charactersetName" );

  Map<String, String> getterMap = new HashMap<String, String>();
  getterMap.put( "includeFilename", "includeFilename" );

  Map<String, String> setterMap = new HashMap<String, String>();

  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
      new LoadSaveTester( testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap );
}
 
Example #2
Source File: JoinRowsMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.init( false );
  List<String> attributes =
      Arrays.asList( "directory", "prefix", "cacheSize", "mainStepname", "condition" );

  Map<String, String> getterMap = new HashMap<String, String>();
  Map<String, String> setterMap = new HashMap<String, String>();

  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
  attrValidatorMap.put( "condition", new ConditionLoadSaveValidator() );

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
      new LoadSaveTester( testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap );
}
 
Example #3
Source File: CsvInputFileEncodingTransformIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
protected void setUp() throws Exception {
  super.setUp();
  KettleEnvironment.init();

  //
  // Create a new transformation...
  //
  transMeta = new TransMeta();
  transMeta.setName( "csvinput1" );

  registry = PluginRegistry.getInstance();

  fileName = writeInputFile();

  injectorStep = createInjectorStep( transMeta, registry );
  csvInputStep = createCsvInputStep( transMeta, registry, "\"", false );
}
 
Example #4
Source File: CompressionProviderFactory.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<CompressionProvider> getCompressionProviders() {
  Collection<CompressionProvider> providerClasses = new ArrayList<CompressionProvider>();

  List<PluginInterface> providers = getPlugins();
  if ( providers != null ) {
    for ( PluginInterface plugin : providers ) {
      try {
        providerClasses.add( PluginRegistry.getInstance().loadClass( plugin, CompressionProvider.class ) );
      } catch ( Exception e ) {
        // Do nothing here, if we can't load the provider, don't add it to the list
      }
    }
  }
  return providerClasses;
}
 
Example #5
Source File: RestInputIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public StepMeta createRestInputStep( TransMeta transMeta, PluginRegistry registry ) throws Exception {
  String inputName = "rest input step";
  RestMeta meta = new RestMeta();

  String inputPid = registry.getPluginId( StepPluginType.class, meta );
  StepMeta inputStep = new StepMeta( inputPid, inputName, meta );
  transMeta.addStep( inputStep );

  meta.setDefault();
  meta.setUrl( tester.createSocketConnector( true ) + "/context/simple/join" );
  meta.setMethod( "POST" );
  meta.setMatrixParameterField( new String[] { "pageSize" } );
  meta.setMatrixParameterName( new String[] { "limit" } );

  meta.setParameterField( new String[] { "name" } );
  meta.setParameterName( new String[] { "name" } );

  meta.setApplicationType( RestMeta.APPLICATION_TYPE_TEXT_PLAIN );
  meta.setFieldName( "result" );

  return inputStep;
}
 
Example #6
Source File: DatabaseJoinMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.init( false );
  List<String> attributes =
      Arrays.asList( "sql", "rowLimit", "outerJoin", "variableReplace", "databaseMeta", "parameterField", "parameterType" );

  Map<String, String> getterMap = new HashMap<String, String>();
  Map<String, String> setterMap = new HashMap<String, String>();

  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  attrValidatorMap.put( "parameterField", new ArrayLoadSaveValidator<String>( new StringLoadSaveValidator(), 5 ) );

  attrValidatorMap.put( "parameterType", new PrimitiveIntArrayLoadSaveValidator( new NonZeroIntLoadSaveValidator( 7 ), 5 ) );

  attrValidatorMap.put( "databaseMeta", new DatabaseMetaLoadSaveValidator() );

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
      new LoadSaveTester( testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(),
          getterMap, setterMap, attrValidatorMap, typeValidatorMap, this );
}
 
Example #7
Source File: JsonOutputTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a row generator step for this class..
 * 
 * @param name
 * @param registry
 * @return
 */
private StepMeta createRowGeneratorStep( String name, PluginRegistry registry ) {

  // Default the name if it is empty
  String testFileOutputName = ( Utils.isEmpty( name ) ? "generate rows" : name );

  // create the RowGenerator and Step Meta
  RowGeneratorMeta rowGeneratorMeta = new RowGeneratorMeta();
  String rowGeneratorPid = registry.getPluginId( StepPluginType.class, rowGeneratorMeta );
  StepMeta generateRowsStep = new StepMeta( rowGeneratorPid, testFileOutputName, rowGeneratorMeta );

  // Set the field names, types and values
  rowGeneratorMeta.setFieldName( new String[] { "Id", "State", "City" } );
  rowGeneratorMeta.setFieldType( new String[] { "Integer", "String", "String" } );
  rowGeneratorMeta.setValue( new String[] { "1", "Florida", "Orlando" } );
  rowGeneratorMeta.setFieldLength( new int[] { -1, -1, -1 } );
  rowGeneratorMeta.setFieldPrecision( new int[] { -1, -1, -1 } );
  rowGeneratorMeta.setGroup( new String[] { "", "", "" } );
  rowGeneratorMeta.setDecimal( new String[] { "", "", "" } );
  rowGeneratorMeta.setCurrency( new String[] { "", "", "" } );
  rowGeneratorMeta.setFieldFormat( new String[] { "", "", "" } );
  rowGeneratorMeta.setRowLimit( "10" );

  // return the step meta
  return generateRowsStep;
}
 
Example #8
Source File: JobExecutionConfiguration.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public Repository connectRepository( RepositoriesMeta repositoriesMeta, String repositoryName, String username, String password ) throws KettleException {
  RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( repositoryName );
  if ( repositoryMeta == null ) {
    log.logBasic( "I couldn't find the repository with name '" + repositoryName + "'" );
    return null;
  }

  Repository rep = PluginRegistry.getInstance().loadClass( RepositoryPluginType.class, repositoryMeta,
      Repository.class );
  rep.init( repositoryMeta );

  try {
    rep.connect( username, password );
    log.logBasic( "Connected to " + repositoryName + " as " + username );
    setRepository( rep );
    return rep;
  } catch ( Exception e ) {
    log.logBasic( "Unable to connect to the repository with name '" + repositoryName + "'" );
    return null;
  }
}
 
Example #9
Source File: SpoonJobDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private StepMeta getToStep( DatabaseMeta targetDbInfo, String table ) {
  String tostepname = BaseMessages.getString( PKG, "Spoon.RipDB.Monitor.ToStep.Name" ) + table + "]";
  TableOutputMeta toi = new TableOutputMeta();
  toi.setDatabaseMeta( targetDbInfo );
  toi.setTableName( table );
  toi.setCommitSize( 100 );
  toi.setTruncateTable( true );

  String tostepid = PluginRegistry.getInstance().getPluginId( StepPluginType.class, toi );
  StepMeta tostep = new StepMeta( tostepid, tostepname, toi );
  tostep.setLocation( 500, 100 );
  tostep.setDraw( true );
  tostep
    .setDescription( BaseMessages.getString( PKG, "Spoon.RipDB.Monitor.ToStep.Description1" )
      + table + BaseMessages.getString( PKG, "Spoon.RipDB.Monitor.ToStep.Description2" )
      + targetDbInfo + "]" );
  return tostep;
}
 
Example #10
Source File: StepPartitioningMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void createPartitioner( String method ) throws KettlePluginException {
  methodType = getMethodType( method );
  switch ( methodType ) {
    case PARTITIONING_METHOD_SPECIAL: {
      PluginRegistry registry = PluginRegistry.getInstance();
      PluginInterface plugin = registry.findPluginWithId( PartitionerPluginType.class, method );
      partitioner = (Partitioner) registry.loadClass( plugin );
      partitioner.setId( plugin.getIds()[0] );
      break;
    }
    case PARTITIONING_METHOD_NONE:
    default:
      partitioner = null;
  }
  if ( partitioner != null ) {
    partitioner.setMeta( this );
  }
}
 
Example #11
Source File: FixedInputMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.init( false );
  List<String> attributes =
      Arrays.asList( "filename", "headerPresent", "lineWidth", "bufferSize", "lazyConversionActive", "lineFeedPresent",
          "runningInParallel", "fileType", "addResultFile", "encoding", "fieldDefinition" );

  Map<String, String> getterMap = new HashMap<String, String>();
  Map<String, String> setterMap = new HashMap<String, String>();
  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
  attrValidatorMap.put( "fieldDefinition",
      new ArrayLoadSaveValidator<FixedFileInputField>( new FixedFileInputFieldLoadSaveValidator(), 5 ) );
  attrValidatorMap.put( "fileType", new IntLoadSaveValidator( FixedInputMeta.fileTypeDesc.length ) );

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
      new LoadSaveTester( testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(),
          getterMap, setterMap, attrValidatorMap, typeValidatorMap, this );
}
 
Example #12
Source File: ParGzipCsvInputMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.init( false );
  List<String> attributes =
      Arrays.asList( "filename", "filenameField", "includingFilename", "rowNumField", "headerPresent", "delimiter",
          "enclosure", "bufferSize", "lazyConversionActive", "addResultFile", "runningInParallel", "encoding",
          "inputFields" );

  Map<String, String> getterMap = new HashMap<String, String>();
  Map<String, String> setterMap = new HashMap<String, String>();

  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
  attrValidatorMap.put( "inputFields", new ArrayLoadSaveValidator<TextFileInputField>( new TextFileInputFieldValidator(), 5 ) );

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
      new LoadSaveTester( testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), getterMap,
          setterMap, attrValidatorMap, typeValidatorMap, this );
}
 
Example #13
Source File: MemoryGroupByMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.init( false );
  List<String> attributes =
      Arrays.asList( "alwaysGivingBackOneRow", "groupField", "aggregateField", "subjectField", "aggregateType", "valueField" );

  FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator =
      new ArrayLoadSaveValidator<String>( new StringLoadSaveValidator(), 5 );

  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
  attrValidatorMap.put( "groupField", stringArrayLoadSaveValidator );
  attrValidatorMap.put( "aggregateField", stringArrayLoadSaveValidator );
  attrValidatorMap.put( "subjectField", stringArrayLoadSaveValidator );
  attrValidatorMap.put( "valueField", stringArrayLoadSaveValidator );
  attrValidatorMap.put( "aggregateType", new PrimitiveIntArrayLoadSaveValidator(
      new IntLoadSaveValidator( MemoryGroupByMeta.typeGroupCode.length ), 5 ) );

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
      new LoadSaveTester<MemoryGroupByMeta>( testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(),
          new HashMap<String, String>(), new HashMap<String, String>(), attrValidatorMap, typeValidatorMap, this );
}
 
Example #14
Source File: SpoonStepsDelegateTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testDelStepsExtensionPointCancelDelete() throws Exception {
  PluginMockInterface pluginInterface = mock( PluginMockInterface.class );
  when( pluginInterface.getName() ).thenReturn( KettleExtensionPoint.TransBeforeDeleteSteps.id );
  when( pluginInterface.getMainType() ).thenReturn( (Class) ExtensionPointInterface.class );
  when( pluginInterface.getIds() ).thenReturn( new String[] { KettleExtensionPoint.TransBeforeDeleteSteps.id } );

  ExtensionPointInterface extensionPoint = mock( ExtensionPointInterface.class );
  when( pluginInterface.loadClass( ExtensionPointInterface.class ) ).thenReturn( extensionPoint );
  doThrow( KettleException.class ).when( extensionPoint )
      .callExtensionPoint( any( LogChannelInterface.class ), any( StepMeta[].class ) );

  PluginRegistry.addPluginType( ExtensionPointPluginType.getInstance() );
  PluginRegistry.getInstance().registerPlugin( ExtensionPointPluginType.class, pluginInterface );

  SpoonStepsDelegate delegate = mock( SpoonStepsDelegate.class );
  delegate.spoon = mock( Spoon.class );
  doCallRealMethod().when( delegate ).delSteps( any( TransMeta.class ), any( StepMeta[].class ) );

  TransMeta trans = mock( TransMeta.class );
  StepMeta[] steps = new StepMeta[] { mock( StepMeta.class ) };
  delegate.delSteps( trans, steps );

  verify( extensionPoint, times( 1 ) ).callExtensionPoint( any(), eq( steps ) );
}
 
Example #15
Source File: CsvInput2IT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Test case for Get XML Data step, very simple example.
 *
 * @throws Exception
 *           Upon any exception
 */
@Test
public void testCSVInput1() throws Exception {
  KettleEnvironment.init();

  //
  // Create a new transformation...
  //
  TransMeta transMeta = new TransMeta();
  transMeta.setName( "csvinput1" );

  PluginRegistry registry = PluginRegistry.getInstance();

  String fileName = writeInputFile();

  StepMeta injectorStep = createInjectorStep( transMeta, registry );
  StepMeta csvInputStep = createCsvInputStep( transMeta, registry, "\"", true );

  createAndTestTrans(
    registry, transMeta, injectorStep, csvInputStep, fileName, createTextFileInputFields().length );
}
 
Example #16
Source File: TableInputMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.init( false );
  List<String> attributes =
    Arrays.asList( "databaseMeta", "sQL", "rowLimit", "executeEachInputRow", "variableReplacementActive",
      "lazyConversionActive", "cachedRowMetaActive" );

  Map<String, String> getterMap = new HashMap<String, String>();
  Map<String, String> setterMap = new HashMap<String, String>();

  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
    new LoadSaveTester( testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap );
}
 
Example #17
Source File: RepositoriesHelper.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void loginToRepository() throws KettleException, KettleSecurityException {
  if ( model != null && model.getSelectedRepository() != null ) {
    RepositoryMeta repositoryMeta =
      input.getRepository( model.getRepositoryIndex( model.getSelectedRepository() ) );
    repository =
      PluginRegistry.getInstance().loadClass(
        RepositoryPluginType.class, repositoryMeta.getId(), Repository.class );
    repository.init( repositoryMeta );
    repository.connect( model.getUsername(), model.getPassword() );
    props.setLastRepository( repositoryMeta.getName() );
    props.setLastRepositoryLogin( model.getUsername() );
  } else {
    log.logDetailed( BaseMessages.getString( PKG, "RepositoryLogin.ErrorLoginToRepository" ) );
    throw new KettleException( BaseMessages.getString( PKG, "RepositoryLogin.ErrorLoginToRepository" ) );
  }
}
 
Example #18
Source File: HTTPMetaLoadSaveTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void testLoadSaveRoundTrip() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.init( false );
  List<String> attributes =
      Arrays.asList( "url", "urlInField", "urlField", "encoding", "httpLogin", "httpPassword", "proxyHost",
          "proxyPort", "socketTimeout", "connectionTimeout", "closeIdleConnectionsTime", "argumentField",
          "argumentParameter", "headerField", "headerParameter", "fieldName", "resultCodeFieldName",
          "responseTimeFieldName", "responseHeaderFieldName" );
  Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap =
      new HashMap<String, FieldLoadSaveValidator<?>>();

  //Arrays need to be consistent length
  FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator =
      new ArrayLoadSaveValidator<String>( new StringLoadSaveValidator(), 25 );
  fieldLoadSaveValidatorAttributeMap.put( "argumentField", stringArrayLoadSaveValidator );
  fieldLoadSaveValidatorAttributeMap.put( "argumentParameter", stringArrayLoadSaveValidator );
  fieldLoadSaveValidatorAttributeMap.put( "headerField", stringArrayLoadSaveValidator );
  fieldLoadSaveValidatorAttributeMap.put( "headerParameter", stringArrayLoadSaveValidator );

  loadSaveTester =
      new LoadSaveTester( HTTPMeta.class, attributes, new HashMap<String, String>(),
          new HashMap<String, String>(), fieldLoadSaveValidatorAttributeMap,
          new HashMap<String, FieldLoadSaveValidator<?>>() );

}
 
Example #19
Source File: GPLoadIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a transformation with a row generator step and hopped to a GPLoadStep with the passed name.
 * 
 * @param gpLoadStepname
 *          The name of the GPLoad step.
 * 
 * @throws KettleException
 */
public TransMeta createTransformationMeta( String gpLoadStepname ) throws Exception {

  // Create a new transformation...
  TransMeta transMeta = new TransMeta();
  transMeta.setName( "row generatortest" );

  // Add a database connection to the trans meta
  transMeta.addDatabase( new DatabaseMeta( GREENPLUM_DATABASE_CONNECTION ) );

  // get a reference to the plugin registry
  PluginRegistry registry = PluginRegistry.getInstance();
  if ( registry == null ) {
    throw new Exception( "Plugin registry is null.  Make sure that the Kettle environment was initialized." );
  }

  // create the GPLoad step
  GPLoadMeta gpLoadMeta = new GPLoadMeta();
  String dummyPid = registry.getPluginId( StepPluginType.class, gpLoadMeta );
  StepMeta gpLoadStepMeta = new StepMeta( dummyPid, gpLoadStepname, gpLoadMeta );
  transMeta.addStep( gpLoadStepMeta );

  return transMeta;
}
 
Example #20
Source File: DeleteMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  PluginRegistry.init( false );
  List<String> attributes =
      Arrays.asList( "schemaName", "tableName", "commitSize", "databaseMeta", "keyStream", "keyLookup", "keyCondition", "keyStream2" );

  Map<String, String> getterMap = new HashMap<String, String>();
  Map<String, String> setterMap = new HashMap<String, String>();
  FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator =
      new ArrayLoadSaveValidator<String>( new StringLoadSaveValidator(), 5 );

  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
  attrValidatorMap.put( "keyStream", stringArrayLoadSaveValidator );
  attrValidatorMap.put( "keyLookup", stringArrayLoadSaveValidator );
  attrValidatorMap.put( "keyCondition", stringArrayLoadSaveValidator );
  attrValidatorMap.put( "keyStream2", stringArrayLoadSaveValidator );
  attrValidatorMap.put( "databaseMeta", new DatabaseMetaLoadSaveValidator() );

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
      new LoadSaveTester( testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(),
          getterMap, setterMap, attrValidatorMap, typeValidatorMap, this );
}
 
Example #21
Source File: MySQLBulkLoaderTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  TransMeta transMeta = new TransMeta();
  transMeta.setName( "MysqlBulkLoader" );

  Map<String, String> vars = new HashMap<String, String>();
  vars.put( "delim", "," );
  vars.put( "enclos", "'" );
  vars.put( "charset", "UTF8" );
  vars.put( "tbl", "sometable" );
  vars.put( "schema", "someschema" );
  transMeta.injectVariables( vars );
  MySQLDatabaseMeta mysql = new MySQLDatabaseMeta();
  mysql.setName( "MySQL" );
  DatabaseMeta dbMeta = new DatabaseMeta();
  dbMeta.setDatabaseInterface( mysql );
  dbMeta.setQuoteAllFields( true );
  lmeta = new MySQLBulkLoaderMeta();
  lmeta.setDelimiter( "${delim}" );
  lmeta.setEnclosure( "${enclos}" );
  lmeta.setEncoding( "${charset}" );
  lmeta.setTableName( "${tbl}" );
  lmeta.setSchemaName( "${schema}" );
  lmeta.setDatabaseMeta( dbMeta );
  ldata = new MySQLBulkLoaderData();
  PluginRegistry plugReg = PluginRegistry.getInstance();
  String mblPid = plugReg.getPluginId( StepPluginType.class, lmeta );
  smeta = new StepMeta( mblPid, "MySqlBulkLoader", lmeta );
  Trans trans = new Trans( transMeta );
  transMeta.addStep( smeta );
  lder = new MySQLBulkLoader( smeta, ldata, 1, transMeta, trans );
  lder.copyVariablesFrom( transMeta );
}
 
Example #22
Source File: PluginRegistryConcurrencyTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
  PluginRegistry registry = PluginRegistry.getInstance();
  for ( Map.Entry<Class<? extends PluginTypeInterface>, List<PluginInterface>> entry : plugins.entrySet() ) {
    Class<? extends PluginTypeInterface> type = entry.getKey();
    for ( PluginInterface plugin : entry.getValue() ) {
      registry.removePlugin( type, plugin );
    }
  }
}
 
Example #23
Source File: BaseStreamingDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private Image getImage() {
  PluginInterface plugin =
    PluginRegistry.getInstance().getPlugin( StepPluginType.class, stepMeta.getStepMetaInterface() );
  String id = plugin.getIds()[ 0 ];
  if ( id != null ) {
    return GUIResource.getInstance().getImagesSteps().get( id ).getAsBitmapForSize( shell.getDisplay(),
      ConstUI.LARGE_ICON_SIZE, ConstUI.LARGE_ICON_SIZE );
  }
  return null;
}
 
Example #24
Source File: SystemDataMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.init( false );
  List<String> attributes =
      Arrays.asList( "fieldName", "fieldType" );

  Map<String, String> getterMap = new HashMap<String, String>() {
    {
      put( "fieldName", "getFieldName" );
      put( "fieldType", "getFieldType" );
    }
  };
  Map<String, String> setterMap = new HashMap<String, String>() {
    {
      put( "fieldName", "setFieldName" );
      put( "fieldType", "setFieldType" );
    }
  };
  FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator =
      new ArrayLoadSaveValidator<String>( new StringLoadSaveValidator(), 5 );

  FieldLoadSaveValidator<SystemDataTypes[]> sdtArrayLoadSaveValidator =
      new ArrayLoadSaveValidator<SystemDataTypes>( new SystemDataTypesLoadSaveValidator(), 5 );

  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
  attrValidatorMap.put( "fieldName", stringArrayLoadSaveValidator );
  attrValidatorMap.put( "fieldType", sdtArrayLoadSaveValidator );

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
      new LoadSaveTester( testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(),
          getterMap, setterMap, attrValidatorMap, typeValidatorMap, this );
}
 
Example #25
Source File: BaseStreamStepMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws KettleException {
  PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() );
  PluginRegistry.init( false );
  String passwordEncoderPluginID =
    Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" );
  Encr.init( passwordEncoderPluginID );
}
 
Example #26
Source File: SalesforceConnectionTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpClass() throws KettleException {
  PluginRegistry.addPluginType( TwoWayPasswordEncoderPluginType.getInstance() );
  PluginRegistry.init();
  String passwordEncoderPluginID = Const.NVL( EnvUtil.getSystemProperty( Const.KETTLE_PASSWORD_ENCODER_PLUGIN ), "Kettle" );
  Encr.init( passwordEncoderPluginID );
}
 
Example #27
Source File: ValidatorMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setUpLoadSave() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.init( false );
  List<String> attributes =
      Arrays.asList( "validatingAll", "concatenatingErrors", "concatenationSeparator", "validations" );

  Map<String, String> getterMap = new HashMap<String, String>() {
    {
      put( "validatingAll", "isValidatingAll" );
      put( "concatenatingErrors", "isConcatenatingErrors" );
      put( "concatenationSeparator", "getConcatenationSeparator" );
      put( "validations", "getValidations" );
    }
  };
  Map<String, String> setterMap = new HashMap<String, String>() {
    {
      put( "validatingAll", "setValidatingAll" );
      put( "concatenatingErrors", "setConcatenatingErrors" );
      put( "concatenationSeparator", "setConcatenationSeparator" );
      put( "validations", "setValidations" );
    }
  };

  Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
  attrValidatorMap.put( "validations", new ListLoadSaveValidator<Validation>( new ValidationLoadSaveValidator(), 5 ) );

  Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();

  loadSaveTester =
      new LoadSaveTester( testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(),
          getterMap, setterMap, attrValidatorMap, typeValidatorMap, this );
}
 
Example #28
Source File: DatabaseMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Search for the right type of DatabaseInterface object and return it.
 *
 * @param databaseTypeDesc
 *          the type of DatabaseInterface to look for (id or description)
 * @return The requested DatabaseInterface
 *
 * @throws KettleDatabaseException
 *           when the type could not be found or referenced.
 */
private static final DatabaseInterface findDatabaseInterface( String databaseTypeDesc ) throws KettleDatabaseException {
  PluginRegistry registry = PluginRegistry.getInstance();
  PluginInterface plugin = registry.getPlugin( DatabasePluginType.class, databaseTypeDesc );
  if ( plugin == null ) {
    plugin = registry.findPluginWithName( DatabasePluginType.class, databaseTypeDesc );
  }

  if ( plugin == null ) {
    throw new KettleDatabaseException( "database type with plugin id ["
      + databaseTypeDesc + "] couldn't be found!" );
  }

  return getDatabaseInterfacesMap().get( plugin.getIds()[0] );
}
 
Example #29
Source File: CsvInputBase.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public StepMeta createInjectorStep( TransMeta transMeta, PluginRegistry registry ) {
  //
  // create an injector step...
  //
  String injectorStepname = "injector step";
  InjectorMeta im = new InjectorMeta();

  // Set the information of the injector.
  String injectorPid = registry.getPluginId( StepPluginType.class, im );
  StepMeta injectorStep = new StepMeta( injectorPid, injectorStepname, im );
  transMeta.addStep( injectorStep );

  return injectorStep;
}
 
Example #30
Source File: CsvInputBase.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public StepMeta createCsvInputStep( TransMeta transMeta, PluginRegistry registry, String enclosure,
  boolean headerPresent ) {
  //
  // Create a Csv Input step
  //
  String csvInputName = "csv input step";
  CsvInputMeta cim = new CsvInputMeta();

  String csvInputPid = registry.getPluginId( StepPluginType.class, cim );
  StepMeta csvInputStep = new StepMeta( csvInputPid, csvInputName, cim );
  transMeta.addStep( csvInputStep );

  TextFileInputField[] fields = createTextFileInputFields();

  cim.setIncludingFilename( true );
  cim.setFilename( "" );
  cim.setFilenameField( "filename" );
  cim.setDelimiter( ";" );
  cim.setEnclosure( enclosure );
  cim.setBufferSize( "50000" );
  cim.setLazyConversionActive( false );
  cim.setHeaderPresent( headerPresent );
  cim.setAddResultFile( false );
  cim.setIncludingFilename( true );
  cim.setRowNumField( "" );
  cim.setRunningInParallel( false );
  cim.setInputFields( fields );

  return csvInputStep;
}