当前位置: 首页>>代码示例>>Java>>正文


Java PluginRegistry.getPluginId方法代码示例

本文整理汇总了Java中org.pentaho.di.core.plugins.PluginRegistry.getPluginId方法的典型用法代码示例。如果您正苦于以下问题:Java PluginRegistry.getPluginId方法的具体用法?Java PluginRegistry.getPluginId怎么用?Java PluginRegistry.getPluginId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.core.plugins.PluginRegistry的用法示例。


在下文中一共展示了PluginRegistry.getPluginId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generatePreviewTransformation

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public static final TransMeta generatePreviewTransformation(VariableSpace parent, StepMetaInterface oneMeta, String oneStepname)
{
    PluginRegistry registry = PluginRegistry.getInstance();

    TransMeta previewMeta = new TransMeta(parent);
    // The following operation resets the internal variables!
    //
    previewMeta.setName(parent==null ? "Preview transformation" : parent.toString());
    
    // At it to the first step.
    StepMeta one = new StepMeta(registry.getPluginId(StepPluginType.class, oneMeta), oneStepname, oneMeta);
    one.setLocation(50,50);
    one.setDraw(true);
    previewMeta.addStep(one);
    
    DummyTransMeta twoMeta = new DummyTransMeta();
    StepMeta two = new StepMeta(registry.getPluginId(StepPluginType.class, twoMeta), "dummy", twoMeta); //$NON-NLS-1$
    two.setLocation(250,50);
    two.setDraw(true);
    previewMeta.addStep(two);
    
    TransHopMeta hop = new TransHopMeta(one, two);
    previewMeta.addTransHop(hop);
    
    return previewMeta;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:27,代码来源:TransPreviewFactory.java

示例2: createTransformationMeta

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
/**
 * 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, (StepMetaInterface) gpLoadMeta);
   transMeta.addStep(gpLoadStepMeta);

   return transMeta;
}
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:33,代码来源:GPLoadTests.java

示例3: createRowGeneratorStep

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
/**
 * 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 = (Const.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;
  }
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:33,代码来源:JsonOutputTest.java

示例4: setUp

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
@Before
public void setUp() {
  TransMeta transMeta = new TransMeta();
  transMeta.setName( "delete1" );

  Map<String, String> vars = new HashMap<String, String>();
  vars.put( "max.sz", "10" );
  transMeta.injectVariables( vars );

  umi = new InsertUpdateMeta();
  ud = new InsertUpdateData();

  PluginRegistry plugReg = PluginRegistry.getInstance();
  String deletePid = plugReg.getPluginId( StepPluginType.class, umi );

  stepMeta = new StepMeta( deletePid, "delete", umi );
  Trans trans = new Trans( transMeta );
  transMeta.addStep( stepMeta );
  upd = new InsertUpdate( stepMeta, ud, 1, transMeta, trans );
  upd.copyVariablesFrom( transMeta );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:22,代码来源:InsertUpdateMetaTest.java

示例5: generatePreviewTransformation

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public static final TransMeta generatePreviewTransformation( VariableSpace parent, StepMetaInterface oneMeta,
  String oneStepname ) {
  PluginRegistry registry = PluginRegistry.getInstance();

  TransMeta previewMeta = new TransMeta( parent );
  // The following operation resets the internal variables!
  //
  previewMeta.setName( parent == null ? "Preview transformation" : parent.toString() );

  // At it to the first step.
  StepMeta one = new StepMeta( registry.getPluginId( StepPluginType.class, oneMeta ), oneStepname, oneMeta );
  one.setLocation( 50, 50 );
  one.setDraw( true );
  previewMeta.addStep( one );

  DummyTransMeta twoMeta = new DummyTransMeta();
  StepMeta two = new StepMeta( registry.getPluginId( StepPluginType.class, twoMeta ), "dummy", twoMeta );
  two.setLocation( 250, 50 );
  two.setDraw( true );
  previewMeta.addStep( two );

  TransHopMeta hop = new TransHopMeta( one, two );
  previewMeta.addTransHop( hop );

  return previewMeta;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:27,代码来源:TransPreviewFactory.java

示例6: createFastJsonInputStep

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
private StepMeta createFastJsonInputStep(String name, PluginRegistry registry, boolean ignoreMissingPath,
                                         boolean defaultPathLeafToNull) {
    FastJsonInputMeta fjim = new FastJsonInputMeta();
    fjim.setInFields(true);
    fjim.setFieldValue("json_data");
    fjim.setRemoveSourceField(true);
    fjim.setIgnoreMissingPath(ignoreMissingPath);
    fjim.setDefaultPathLeafToNull(defaultPathLeafToNull);

    FastJsonInputField if1 = new FastJsonInputField("id");
    if1.setPath("$.[*].id");
    if1.setType(ValueMeta.TYPE_INTEGER);
    if1.setTrimType(FastJsonInputField.TYPE_TRIM_NONE);

    FastJsonInputField if2 = new FastJsonInputField("first_name");
    if2.setPath("$.[*].first_name");
    if2.setType(ValueMeta.TYPE_STRING);
    if2.setTrimType(FastJsonInputField.TYPE_TRIM_NONE);

    FastJsonInputField if3 = new FastJsonInputField("last_name");
    if3.setPath("$.[*].last_name");
    if3.setType(ValueMeta.TYPE_STRING);
    if3.setTrimType(FastJsonInputField.TYPE_TRIM_NONE);

    FastJsonInputField if4 = new FastJsonInputField("city");
    if4.setPath("$.[*].city");
    if4.setType(ValueMeta.TYPE_STRING);
    if4.setTrimType(FastJsonInputField.TYPE_TRIM_NONE);

    FastJsonInputField[] inputFields = new FastJsonInputField[4];
    inputFields[0] = if1;
    inputFields[1] = if2;
    inputFields[2] = if3;
    inputFields[3] = if4;
    fjim.setInputFields(inputFields);

    String fjiPid = registry.getPluginId(StepPluginType.class, fjim);

    return new StepMeta(fjiPid, name, fjim);
}
 
开发者ID:etdube,项目名称:pdi-fastjsoninput-plugin,代码行数:41,代码来源:FastJsonInputTest.java

示例7: createInjectorStep

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
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;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:15,代码来源:CsvInputBase.java

示例8: buildRowGeneratorStep

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
/**
 * Builds a {@link org.pentaho.di.trans.steps.rowgenerator.RowGenerator} Step 
 * with a single String field.
 *
 * @param registry
 *          Plugin Registry.
 * @param stepName
 *          Name to use for step
 * @return {@link StepMeta} for a Row Generator step.
 */
private StepMeta buildRowGeneratorStep( PluginRegistry registry, String stepName ) {
  RowGeneratorMeta rm = new RowGeneratorMeta();

  // Set the information of the row generator.
  String rowGeneratorPid = registry.getPluginId( StepPluginType.class, rm );
  StepMeta rowGeneratorStep = new StepMeta( rowGeneratorPid, stepName, rm );

  String[] fieldName = { "string" };
  String[] type = { "String" };
  String[] value = { "string_value" };
  String[] fieldFormat = { "" };
  String[] group = { "" };
  String[] decimal = { "" };
  String[] currency = { "", };
  int[] intDummies = { -1, -1, -1 };
  boolean[] setEmptystring = { false, false, false };

  rm.setDefault();
  rm.setFieldName( fieldName );
  rm.setFieldType( type );
  rm.setValue( value );
  rm.setFieldLength( intDummies );
  rm.setFieldPrecision( intDummies );
  rm.setRowLimit( "1" );
  rm.setFieldFormat( fieldFormat );
  rm.setGroup( group );
  rm.setDecimal( decimal );
  rm.setCurrency( currency );
  rm.setEmptyString( setEmptystring );

  return rowGeneratorStep;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:43,代码来源:MappingIT.java

示例9: createDummyStep

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
/**
 * Creates a dummy
 *
 * @param name
 * @param pluginRegistry
 * @return StepMata
 */
public static synchronized StepMeta createDummyStep( String name, PluginRegistry pluginRegistry ) {
  DummyTransMeta dummyTransMeta = new DummyTransMeta();
  String dummyPid = pluginRegistry.getPluginId( StepPluginType.class, dummyTransMeta );
  StepMeta dummyStep = new StepMeta( dummyPid, name, dummyTransMeta );

  return dummyStep;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:15,代码来源:TestUtilities.java

示例10: TransformTest

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public TransformTest( int id ) throws Exception {
	this.id = id;
	KettleEnvironment.init();
	PluginRegistry registry = PluginRegistry.getInstance();

	tm = new TransMeta();
	tm.setName( "TransformTest Transformation " + this.id );

	// Credit Card Generator
	RandomCCNumberGeneratorMeta ccardMeta = new RandomCCNumberGeneratorMeta();
	String ccardId = registry.getPluginId( StepPluginType.class, ccardMeta );
	String ccardName = "Generate Random Credit Cards";
	StepMeta ccardStep = new StepMeta( ccardId, ccardName, ccardMeta );

	ccardMeta.setCardLengthFieldName( "Card length" );
	ccardMeta.setCardNumberFieldName( "Card number" );
	ccardMeta.setCardTypeFieldName( "Card type" );
	ccardMeta.allocate( 1 );
	ccardMeta.setFieldCCType( new String[]{ "American Express" } );
	//http://jira.pentaho.com/browse/PDI-13299
	ccardMeta.getFieldCCLength()[0] = "15";
	ccardMeta.getFieldCCSize()[0] = "10";
	tm.addStep( ccardStep );

	WriteToLogMeta writeLogMeta = new WriteToLogMeta();
	writeLogMeta.setDefault();
	String writeLogId = registry.getPluginId( StepPluginType.class, writeLogMeta );
	String writeLogName = "Write to Log";
	StepMeta writeLogStep = new StepMeta( writeLogId, writeLogName, writeLogMeta );
	tm.addStep( writeLogStep );

	// Hops
	TransHopMeta hopCCardWriteLog = new TransHopMeta( ccardStep, writeLogStep );
	tm.addTransHop( hopCCardWriteLog );

	// Make pretty for Spoon
	ccardStep.setLocation(100, 50);
	writeLogStep.setLocation(200, 50);

	ccardStep.setDraw(true);
	writeLogStep.setDraw(true);
}
 
开发者ID:matthewtckr,项目名称:pdi_examples,代码行数:43,代码来源:TransformTest.java

示例11: setUp

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {

	KettleEnvironment.init();

	/* SET UP TRANSFORMATION */

	// Create a new transformation...
	TransMeta transMeta = new TransMeta();
	transMeta.setName("insert/update test");

	// Add the database connections
	for (int i = 0; i < databasesXML.length; i++) {
		DatabaseMeta databaseMeta = new DatabaseMeta(databasesXML[i]);
		transMeta.addDatabase(databaseMeta);
	}

	DatabaseMeta dbInfo = transMeta.findDatabase("db");

	/* SET UP DATABASE */
	// Create target table
	db = new Database(transMeta, dbInfo);
	db.connect();

	String source = db.getCreateTableStatement(TARGET_TABLE, getTargetTableRowMeta(), null, false, null, true);
	db.execStatement(source);

	// populate target table
	for (String sql : insertStatement) {
		db.execStatement(sql);
	}

	/* SET UP TRANSFORMATION STEPS */

	PluginRegistry registry = PluginRegistry.getInstance();

	// 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, (StepMetaInterface) im);
	transMeta.addStep(injectorStep);

	// create the update step...
	String updateStepName = "insert/update [" + TARGET_TABLE + "]";
	insupd = new InsertUpdateMeta();
	insupd.setDatabaseMeta(transMeta.findDatabase("db"));
	insupd.setTableName(TARGET_TABLE);
	
	insupd.setUpdateLookup(new String[] { "VALUE" , "ROW_ORDER"});
	insupd.setUpdateStream(new String[] { "VALUE" , "ROW_ORDER"});
	insupd.setUpdate(new Boolean[] { true, false });

	String fromid = registry.getPluginId(StepPluginType.class, insupd);
	StepMeta updateStep = new StepMeta(fromid, updateStepName, (StepMetaInterface) insupd);
	updateStep.setDescription("insert/update data in table [" + TARGET_TABLE + "] on database [" + dbInfo + "]");
	transMeta.addStep(updateStep);

	TransHopMeta hi = new TransHopMeta(injectorStep, updateStep);
	transMeta.addTransHop(hi);

	/* PREPARE TRANSFORMATION EXECUTION */

	trans = new Trans(transMeta);
	trans.prepareExecution(null);

	StepInterface si = trans.getStepInterface(updateStepName, 0);
	rc = new RowStepCollector();
	si.addRowListener(rc);

	rp = trans.addRowProducer(injectorStepName, 0);

}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:76,代码来源:InsertUpdateTest.java

示例12: testInfoStreams_single

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
/**
 * Tests that info steps are correctly identified via StepMetaInterface.getStepIOMeta()
 */
public void testInfoStreams_single() throws Exception {
  KettleEnvironment.init();
  PluginRegistry registry = PluginRegistry.getInstance();

  //
  // Create a new transformation with a row generator that feeds a Mapping (Sub-Transformation) Step
  //
  TransMeta transMeta = new TransMeta();
  transMeta.setName("Mapping Info Test"); //$NON-NLS-1$
  StepMeta rowGenerator = buildRowGeneratorStep(registry, "Generate Rows"); //$NON-NLS-1$
  transMeta.addStep(rowGenerator);

  String mappingName = "mapping"; //$NON-NLS-1$
  MappingMeta mappingMeta = new MappingMeta();
  mappingMeta.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
  mappingMeta.setFileName("test-src/org/pentaho/di/trans/steps/mapping/subtrans.ktr"); //$NON-NLS-1$
  String mappingInputStepName = "input"; //$NON-NLS-1$
  mappingMeta
      .setInputMappings(Collections.singletonList(createMappingDef(rowGenerator.getName(), mappingInputStepName, "string", "a"))); //$NON-NLS-1$ //$NON-NLS-2$
  String mappingPid = registry.getPluginId(StepPluginType.class, mappingMeta);
  StepMeta mapping = new StepMeta(mappingPid, mappingName, mappingMeta);
  transMeta.addStep(mapping);

  TransHopMeta hopGeneratorToMapping = new TransHopMeta(rowGenerator, mapping);
  transMeta.addTransHop(hopGeneratorToMapping);

  Trans trans = new Trans(transMeta);
  trans.prepareExecution(null);

  // Mimic how a transformation is loaded and initialized from TransMeta.loadXML() or KettleDatabaseRepositoryTransDelegate.loadTransformation()
  // so the StepMeta references are wired up in the MappingMeta properly
  // (Copied from TransMeta.loadXML())
  for (int i = 0; i < transMeta.nrSteps(); i++) {
    StepMeta stepMeta = transMeta.getStep(i);
    StepMetaInterface sii = stepMeta.getStepMetaInterface();
    if (sii != null)
      sii.searchInfoAndTargetSteps(transMeta.getSteps());
  }

  // Verify the transformation was configured properly
  assertEquals("Transformation not initialized properly", 2, transMeta.nrSteps()); //$NON-NLS-1$

  StepMeta meta = transMeta.getStep(1);
  assertTrue("Transformation not initialized properly", meta.getStepMetaInterface() instanceof MappingMeta); //$NON-NLS-1$

  MappingMeta loadedMappingMeta = (MappingMeta) meta.getStepMetaInterface();
  assertEquals("Expected a single input mapping definition", 1, loadedMappingMeta.getInputMappings().size()); //$NON-NLS-1$

  StepIOMetaInterface ioMeta = loadedMappingMeta.getStepIOMeta();
  assertEquals("Expected a single Info Stream", 1, ioMeta.getInfoStreams().size()); //$NON-NLS-1$
  assertEquals("Expected a single Info Step", 1, loadedMappingMeta.getInfoSteps().length); //$NON-NLS-1$

  // Verify the transformation can be executed
  StepInterface si = trans.getStepInterface(mappingName, 0);
  RowStepCollector rc = new RowStepCollector();
  si.addRowListener(rc);

  trans.startThreads();
  trans.waitUntilFinished();

  assertEquals(1, rc.getRowsRead().size());
  assertEquals(1, rc.getRowsWritten().size());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:67,代码来源:MappingTest.java

示例13: testCaseInsensitiveNoPreviousSort

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
public void testCaseInsensitiveNoPreviousSort() throws Exception {
  KettleEnvironment.init();

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

  PluginRegistry registry = PluginRegistry.getInstance();

  //
  // 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 );

  //
  // Create a unique rows step
  //
  String uniqueRowsStepname = "unique rows step";
  UniqueRowsMeta urm = new UniqueRowsMeta();
  urm.setCompareFields( new String[] { "KEY" } );
  urm.setCaseInsensitive( new boolean[] { true } );

  String uniqueRowsStepPid = registry.getPluginId( StepPluginType.class, urm );
  StepMeta uniqueRowsStep = new StepMeta( uniqueRowsStepPid, uniqueRowsStepname, urm );
  transMeta.addStep( uniqueRowsStep );

  transMeta.addTransHop( new TransHopMeta( injectorStep, uniqueRowsStep ) );

  //
  // Create a dummy step
  //
  String dummyStepname = "dummy step";
  DummyTransMeta dm = new DummyTransMeta();

  String dummyPid = registry.getPluginId( StepPluginType.class, dm );
  StepMeta dummyStep = new StepMeta( dummyPid, dummyStepname, dm );
  transMeta.addStep( dummyStep );

  transMeta.addTransHop( new TransHopMeta( uniqueRowsStep, dummyStep ) );

  // Now execute the transformation...
  Trans trans = new Trans( transMeta );

  trans.prepareExecution( null );

  StepInterface si = trans.getStepInterface( dummyStepname, 0 );
  RowStepCollector dummyRc = new RowStepCollector();
  si.addRowListener( dummyRc );

  RowProducer rp = trans.addRowProducer( injectorStepname, 0 );
  trans.startThreads();

  // add rows
  List<RowMetaAndData> inputList = createData();
  for ( RowMetaAndData rm : inputList ) {
    rp.putRow( rm.getRowMeta(), rm.getData() );
  }
  rp.finished();

  trans.waitUntilFinished();

  List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
  checkRows( createResultDataCaseInsensitiveNoPreviousSort(), resultRows );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:73,代码来源:UniqueRowsIT.java

示例14: createTextFileOutputStep

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
private StepMeta createTextFileOutputStep(String name, String textFileName, String compression, PluginRegistry registry) {
    
    // Create a Text File Output step
    String testFileOutputName = name;
    TextFileOutputMeta textFileOutputMeta = new TextFileOutputMeta();
    String textFileInputPid = registry.getPluginId(StepPluginType.class, textFileOutputMeta);
    StepMeta textFileOutputStep = new StepMeta(textFileInputPid, testFileOutputName, textFileOutputMeta);

    //  initialize the fields
    TextFileField[] fields = new TextFileField[3];
    for (int idx = 0; idx < fields.length; idx++) {
        fields[idx] = new TextFileField();
    }

    //  populate the fields
    //  it is important that the setPosition(int)
    //  is invoked with the correct position as
    //  we are testing the reading of a delimited file.
    fields[0].setName("id");
    fields[0].setType(ValueMetaInterface.TYPE_INTEGER);
    fields[0].setFormat("");
    fields[0].setLength(-1);
    fields[0].setPrecision(-1);
    fields[0].setCurrencySymbol("");
    fields[0].setDecimalSymbol("");
    fields[0].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);

    fields[1].setName("city");
    fields[1].setType(ValueMetaInterface.TYPE_STRING);
    fields[1].setFormat("");
    fields[1].setLength(-1);
    fields[1].setPrecision(-1);
    fields[1].setCurrencySymbol("");
    fields[1].setDecimalSymbol("");
    fields[1].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);


    fields[2].setName("state");
    fields[2].setType(ValueMetaInterface.TYPE_STRING);
    fields[2].setFormat("");
    fields[2].setLength(-1);
    fields[2].setPrecision(-1);
    fields[2].setCurrencySymbol("");
    fields[2].setDecimalSymbol("");
    fields[2].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    
    //  call this to allocate the number of fields
    textFileOutputMeta.allocate(3);
    textFileOutputMeta.setOutputFields(fields);
    
    //  set meta properties- these were determined by running Spoon
    //  and setting up the transformation we are setting up here.
    //  i.e. - the dialog told me what I had to set to avoid
    //  NPEs during the transformation.
    
    //  We need a file name so we will generate a temp file       
    textFileOutputMeta.setFileName(textFileName);
    textFileOutputMeta.setFileNameInField(false);
    textFileOutputMeta.setExtension(EXTENSION);
    textFileOutputMeta.setEnclosure("\"");
    textFileOutputMeta.setFileCompression(compression);        
    textFileOutputMeta.setSeparator(SEPARATOR); 
    textFileOutputMeta.setFileFormat(TestUtilities.getFileFormat());
    textFileOutputMeta.setAddToResultFiles(false);
    textFileOutputMeta.setNewline(TestUtilities.getEndOfLineCharacters());
    textFileOutputMeta.setSeparator(";");
    textFileOutputMeta.setEnclosure("\"");

    return textFileOutputStep;
    
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:72,代码来源:TextFileOutputTests.java

示例15: testCombinationLookup

import org.pentaho.di.core.plugins.PluginRegistry; //导入方法依赖的package包/类
/**
 * Test case for Combination lookup/update.
 */
public void testCombinationLookup() throws Exception {
  //
  // Create a new transformation...
  //
  TransMeta transMeta = new TransMeta();
  transMeta.setName( "transname" );

  // Add the database connections
  for ( int i = 0; i < databasesXML.length; i++ ) {
    DatabaseMeta databaseMeta = new DatabaseMeta( databasesXML[i] );
    transMeta.addDatabase( databaseMeta );
  }

  DatabaseMeta lookupDBInfo = transMeta.findDatabase( "lookup" );

  // Execute our setup SQLs in the database.
  Database lookupDatabase = new Database( transMeta, lookupDBInfo );
  lookupDatabase.connect();
  createTables( lookupDatabase );
  createData( lookupDatabase );

  PluginRegistry registry = PluginRegistry.getInstance();

  //
  // create the source step...
  //
  String fromstepname = "read from [" + source_table + "]";
  TableInputMeta tii = new TableInputMeta();
  tii.setDatabaseMeta( transMeta.findDatabase( "lookup" ) );
  String selectSQL = "SELECT " + Const.CR;
  selectSQL += "DLR_CD, DLR_NM, DLR_DESC ";
  selectSQL += "FROM " + source_table + " ORDER BY ORDNO;";
  tii.setSQL( selectSQL );

  String fromstepid = registry.getPluginId( StepPluginType.class, tii );
  StepMeta fromstep = new StepMeta( fromstepid, fromstepname, tii );
  fromstep.setLocation( 150, 100 );
  fromstep.setDraw( true );
  fromstep.setDescription( "Reads information from table ["
    + source_table + "] on database [" + lookupDBInfo + "]" );
  transMeta.addStep( fromstep );

  //
  // create the combination lookup/update step...
  //
  String lookupstepname = "lookup from [lookup]";
  CombinationLookupMeta clm = new CombinationLookupMeta();
  String[] lookupKey = { "DLR_CD" };
  clm.setTablename( target_table );
  clm.setKeyField( lookupKey );
  clm.setKeyLookup( lookupKey );
  clm.setTechnicalKeyField( "ID" );
  clm.setTechKeyCreation( CombinationLookupMeta.CREATION_METHOD_TABLEMAX );
  clm.setDatabaseMeta( lookupDBInfo );

  String lookupstepid = registry.getPluginId( StepPluginType.class, clm );
  StepMeta lookupstep = new StepMeta( lookupstepid, lookupstepname, clm );
  lookupstep.setDescription( "Looks up information from table [lookup] on database [" + lookupDBInfo + "]" );
  transMeta.addStep( lookupstep );

  TransHopMeta hi = new TransHopMeta( fromstep, lookupstep );
  transMeta.addTransHop( hi );

  // Now execute the transformation...
  Trans trans = new Trans( transMeta );
  trans.execute( null );

  trans.waitUntilFinished();

  checkResults( lookupDatabase );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:75,代码来源:CombinationLookupIT.java


注:本文中的org.pentaho.di.core.plugins.PluginRegistry.getPluginId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。