當前位置: 首頁>>代碼示例>>Java>>正文


Java Trans.waitUntilFinished方法代碼示例

本文整理匯總了Java中org.pentaho.di.trans.Trans.waitUntilFinished方法的典型用法代碼示例。如果您正苦於以下問題:Java Trans.waitUntilFinished方法的具體用法?Java Trans.waitUntilFinished怎麽用?Java Trans.waitUntilFinished使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.pentaho.di.trans.Trans的用法示例。


在下文中一共展示了Trans.waitUntilFinished方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
/**
 * 1) create a new transformation <br>
 * 2) Express the transformation as XML file <br>
 * 3) Execute the transformation <br>
 * <br>
 * @param args
 */
public static void main(String[] args) throws Exception
{
	EnvUtil.environmentInit();
    
	// Init the logging...
	//
    LogWriter.getInstance("TransBuilderFilter.log", true, LogWriter.LOG_LEVEL_DETAILED);
    
    // Load the Kettle steps & plugins
	StepLoader.init();
    
    // The parameters we want, optionally this can be 
    String transformationName = "Filter test Transformation";
   
    TransMeta transMeta = buildFilterSample(transformationName);
    System.out.println(transMeta.getXML());
    
    // Now execute the transformation...
    Trans trans = new Trans(transMeta);
    trans.execute(null);
    trans.waitUntilFinished();
    
}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:31,代碼來源:TransBuilderFilter.java

示例2: runTransformationFromResource

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
public Trans runTransformationFromResource(String resource, List<TransVariable> listVaribale) {
    try {
        // load latest revision of the transformation
        // The TransMeta object is the programmatic representation of a transformation definition.
        TransMeta transMeta = new TransMeta(getClass().getResourceAsStream(resource), null, false, null, null);

        // Creating a transformation object which is the programmatic representation of a transformation 
        // A transformation object can be executed, report success, etc.
        Trans transformation = new Trans(transMeta);
        if (listVaribale != null) {
            for (TransVariable variable : listVaribale) {
                transformation.setVariable(variable.getName(), variable.getValue());
            }
        }

        // adjust the log level
        transformation.setLogLevel(LogLevel.BASIC);

        // starting the transformation, which will execute asynchronously
        transformation.execute(null);

        // waiting for the transformation to finish
        transformation.waitUntilFinished();

        return transformation;
    } catch (KettleException ex) {
        MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.syncerror"), ex);
        msg.show(this);
        return null;
    }
}
 
開發者ID:nordpos,項目名稱:nordpos,代碼行數:32,代碼來源:JPanelTransformation.java

示例3: executeTrans

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
protected void executeTrans(Trans trans) throws KettleException { 
   trans.prepareExecution(null);
   trans.startThreads();
   trans.waitUntilFinished();
}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:6,代碼來源:ExecuteTransServlet.java

示例4: executeTransformation

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
public Map<String, Object> executeTransformation(String ktrPath) {

		Map<String, Object> executionResult = new HashMap<String, Object>();

		try {
			KettleEnvironment.init();
			EnvUtil.environmentInit();

			TransMeta transMeta = new TransMeta(ktrPath);

			List<DatabaseMeta> dbMetaList = transMeta.getDatabases();

			for (DatabaseMeta dbMeta : dbMetaList) {
				if (dbMeta.getName().equals(this.connectionName)) {
					dbMeta.setHostname(this.dbHostName);
					dbMeta.setUsername(this.dbUerName);
					dbMeta.setPassword(this.dbPassword);
					dbMeta.setDBPort(this.dbPort);
					dbMeta.setDBName(this.dbName);
				}
			}

			Trans transformation = new Trans(transMeta);

			if (this.parameters != null) {
				for (Map.Entry<String, String> entry : this.parameters.entrySet()) {
					transformation.setParameterValue((String) entry.getKey(), (String) entry.getValue());
				}
			}

			transformation.execute(null);
			transformation.waitUntilFinished();

			for (StepMetaDataCombi combi : transformation.getSteps()) {

				StepDTO stepDTO = new StepDTO();

				stepDTO.setStepName(combi.step.getStepname());
				stepDTO.setLinesInput(Long.valueOf(combi.step.getLinesInput()));
				stepDTO.setLinesOutput(Long.valueOf(combi.step.getLinesOutput()));
				stepDTO.setLinesRead(Long.valueOf(combi.step.getLinesRead()));
				stepDTO.setLinesRejected(Long.valueOf(combi.step.getLinesRejected()));
				stepDTO.setLinesUpdated(Long.valueOf(combi.step.getLinesUpdated()));

				stepDTO.setStepDestinationNameList(new ArrayList<String>());

				for (RowSet rowSet : combi.step.getOutputRowSets()) {
					stepDTO.getStepDestinationNameList().add(rowSet.getDestinationStepName());
				}

				this.getStepDTOList().add(stepDTO);
			}

			if (transformation.getErrors() > 0) {
				System.out.println("Erroruting Transformation");

				executionResult.put("transformationExecuted", false);
				return executionResult;
			} else {

				executionResult.put("transformationExecuted", true);
				return executionResult;
			}
		} catch (Exception e) {
			e.printStackTrace();

			executionResult.put("transformationExecuted", false);
			return executionResult;
		}
	}
 
開發者ID:rodrifmed,項目名稱:pentaho-data-integration,代碼行數:71,代碼來源:TransformationManager.java

示例5: test

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
/**
 * Runs the transformation with the below input parameters
 * @param inputData JSON string
 * @param ignoreMissingPath boolean
 * @param defaultPathLeafToNull boolean
 * @return Transformation Results
 */
private List<RowMetaAndData> test(String inputData, boolean ignoreMissingPath, boolean defaultPathLeafToNull)
        throws Exception {
    KettleEnvironment.init();

    // Create a new transformation
    TransMeta transMeta = new TransMeta();
    transMeta.setName("testFastJsonInput");
    PluginRegistry registry = PluginRegistry.getInstance();

    // Create Injector
    String injectorStepName = "injector step";
    StepMeta injectorStep = TestUtilities.createInjectorStep(injectorStepName, registry);
    transMeta.addStep(injectorStep);

    // Create a FastJsonInput step
    String fastJsonInputName = "FastJsonInput step";
    StepMeta fastJsonInputStep = createFastJsonInputStep(fastJsonInputName, registry, ignoreMissingPath,
            defaultPathLeafToNull);
    transMeta.addStep(fastJsonInputStep);

    // TransHopMeta between injector step and FastJsonInput
    TransHopMeta injector_hop_fjis = new TransHopMeta(injectorStep, fastJsonInputStep);
    transMeta.addTransHop(injector_hop_fjis);

    // Create a dummy step
    String dummyStepName = "dummy step";
    StepMeta dummyStep = TestUtilities.createDummyStep(dummyStepName, registry);
    transMeta.addStep(dummyStep);

    // TransHopMeta between FastJsonInput and Dummy
    TransHopMeta fjis_hop_dummy = new TransHopMeta(fastJsonInputStep, dummyStep);
    transMeta.addTransHop(fjis_hop_dummy);

    // Execute the transformation
    Trans trans = new Trans(transMeta);
    trans.prepareExecution(null);

    // Create a row collector and add it to the dummy step interface
    StepInterface si = trans.getStepInterface(dummyStepName, 0);
    RowStepCollector dummyRowCollector = new RowStepCollector();
    si.addRowListener(dummyRowCollector);

    // Create a row producer
    RowProducer rowProducer = trans.addRowProducer(injectorStepName, 0);
    trans.startThreads();

    // create the rows
    List<RowMetaAndData> inputList = createInputData(inputData);
    for (RowMetaAndData rowMetaAndData : inputList) {
        rowProducer.putRow(rowMetaAndData.getRowMeta(), rowMetaAndData.getData());
    }
    rowProducer.finished();

    trans.waitUntilFinished();

    return dummyRowCollector.getRowsWritten();
}
 
開發者ID:etdube,項目名稱:pdi-fastjsoninput-plugin,代碼行數:65,代碼來源:FastJsonInputTest.java

示例6: testCombinationLookup

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
/**
* Test case for Combination lookup/update.
*/
  public void testCombinationLookup() throws Exception
  {
      EnvUtil.environmentInit();
      try
      {
          //
          // 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(lookupDBInfo);
          lookupDatabase.connect();
          createTables(lookupDatabase);
          createData(lookupDatabase);

          StepLoader steploader = StepLoader.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 = steploader.getStepPluginID(tii);
          StepMeta fromstep = new StepMeta(fromstepid, fromstepname, (StepMetaInterface) 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 = steploader.getStepPluginID(clm);
          StepMeta lookupstep = new StepMeta(lookupstepid, lookupstepname, (StepMetaInterface) 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);
      }    	
      finally {}    
  }
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:81,代碼來源:CombinationLookupTest.java

示例7: testInjector

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
/**
* Test case for injector step... also a show case on how
* to use injector.
*/
  public void testInjector() throws Exception
  {
      EnvUtil.environmentInit();

      //
      // Create a new transformation...
      //
      TransMeta transMeta = new TransMeta();
      transMeta.setName("injectortest");
  	
      StepLoader steploader = StepLoader.getInstance();            

      // 
      // create an injector step...
      //
      String injectorStepname = "injector step";
      InjectorMeta im = new InjectorMeta();
      
      // Set the information of the injector.
              
      String injectorPid = steploader.getStepPluginID(im);
      StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
      transMeta.addStep(injectorStep);

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

      String dummyPid = steploader.getStepPluginID(dm);
      StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
      transMeta.addStep(dummyStep);                              

      TransHopMeta hi = new TransHopMeta(injectorStep, dummyStep);
      transMeta.addTransHop(hi);
              
      // Now execute the transformation...
      Trans trans = new Trans(transMeta);

      trans.prepareExecution(null);
              
      StepInterface si = trans.getStepInterface(dummyStepname, 0);
      RowStepCollector rc = new RowStepCollector();
      si.addRowListener(rc);
      
      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 = rc.getRowsWritten();
      checkRows(resultRows, inputList);
  }
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:67,代碼來源:InjectorTest.java

示例8: testCaseSensitiveNoPreviousSort

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
public void testCaseSensitiveNoPreviousSort() throws Exception
{
    EnvUtil.environmentInit();

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

    // 
    // create an injector step...
    //
    String injectorStepname = "injector step";
    InjectorMeta im = new InjectorMeta();
    
    // Set the information of the injector.                
    String injectorPid = steploader.getStepPluginID(im);
    StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)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[] {false});

    String uniqueRowsStepPid = steploader.getStepPluginID(urm);
    StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
    transMeta.addStep(uniqueRowsStep);            

    transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));        
    
    // 
    // Create a dummy step
    //
    String dummyStepname = "dummy step";            
    DummyTransMeta dm = new DummyTransMeta();

    String dummyPid = steploader.getStepPluginID(dm);
    StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)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(createResultDataCaseSensitiveNoPreviousSort(), resultRows);
}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:75,代碼來源:UniqueRowsTest.java

示例9: testCaseInsensitiveNoPreviousSort

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
public void testCaseInsensitiveNoPreviousSort() throws Exception
{
    EnvUtil.environmentInit();

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

    // 
    // create an injector step...
    //
    String injectorStepname = "injector step";
    InjectorMeta im = new InjectorMeta();
    
    // Set the information of the injector.                
    String injectorPid = steploader.getStepPluginID(im);
    StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)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 = steploader.getStepPluginID(urm);
    StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
    transMeta.addStep(uniqueRowsStep);            

    transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));        
    
    // 
    // Create a dummy step
    //
    String dummyStepname = "dummy step";            
    DummyTransMeta dm = new DummyTransMeta();

    String dummyPid = steploader.getStepPluginID(dm);
    StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)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:icholy,項目名稱:geokettle-2.0,代碼行數:75,代碼來源:UniqueRowsTest.java

示例10: testRowGenerator

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
/**
* Test case for Row Generator step.
*/
  public void testRowGenerator() throws Exception
  {
      EnvUtil.environmentInit();

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

      // 
      // create a row generator step...
      //
      String rowGeneratorStepname = "row generator step";
      RowGeneratorMeta rm = new RowGeneratorMeta();
      
      // Set the information of the row generator.                
      String rowGeneratorPid = steploader.getStepPluginID(rm);
      StepMeta rowGeneratorStep = new StepMeta(rowGeneratorPid, rowGeneratorStepname, (StepMetaInterface)rm);
      transMeta.addStep(rowGeneratorStep);
      
      //
      // Do the following specs 3 times.
      //
      String fieldName[]   = { "string", "boolean", "integer" };
      String type[]        = { "String", "Boolean", "Integer" };
      String value[]       = { "string_value", "true", "20"   };
      String fieldFormat[] = { "", "", ""  };
      String group[]       = { "", "", ""  };
      String decimal[]     = { "", "", ""  };
      int    intDummies[]  = { -1, -1, -1 };
              
      rm.setDefault();
      rm.setFieldName(fieldName);
      rm.setFieldType(type);
      rm.setValue(value);
      rm.setFieldLength(intDummies);
      rm.setFieldPrecision(intDummies);        
      rm.setRowLimit("3");
      rm.setFieldFormat(fieldFormat);
      rm.setGroup(group);
      rm.setDecimal(decimal);

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

      String dummyPid = steploader.getStepPluginID(dm);
      StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
      transMeta.addStep(dummyStep);                              

      TransHopMeta hi = new TransHopMeta(rowGeneratorStep, dummyStep);
      transMeta.addTransHop(hi);
              
      // Now execute the transformation...
      Trans trans = new Trans(transMeta);

      trans.prepareExecution(null);
              
      StepInterface si = trans.getStepInterface(dummyStepname, 0);
      RowStepCollector rc = new RowStepCollector();
      si.addRowListener(rc);
      
      trans.startThreads();        
      trans.waitUntilFinished();   
      
      List<RowMetaAndData> checkList = createData();
      List<RowMetaAndData> resultRows = rc.getRowsWritten();
      checkRows(resultRows, checkList);
  }
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:78,代碼來源:RowGeneratorTest.java

示例11: runEngine

import org.pentaho.di.trans.Trans; //導入方法依賴的package包/類
public boolean runEngine(boolean printDescription) throws KettleException
  {
  	System.gc();
  	
      if (StepLoader.getInstance().getPluginList().size()==0) StepLoader.init();

      transMeta = new TransMeta(filename);
      transMeta.setVariable("NR_OF_ROWS", Long.toString(records));
      if (printDescription) printTransDescription();

      // Replace the TARGET database connection settings with the one provided
      if (targetDatabaseMeta!=null)
      {
          transMeta.addOrReplaceDatabase(targetDatabaseMeta);
      }
      
      // OK, now run this transFormation.
      Trans trans = new Trans(transMeta);
      
      try {
      	trans.prepareExecution(null);
      }
      catch (Exception e) {
      	LogWriter.getInstance().logError(trans.getName(), "Error preparing / initializing transformation", e);
      	return false;
}
      
      if (!Const.isEmpty(rowListenerStep))
      {
          BaseStep baseStep = trans.findRunThread(rowListenerStep);
          if (baseStep!=null)
          {
              baseStep.addRowListener(rowListener);
          }
      }
      
      long startTime = System.currentTimeMillis();
      
      trans.startThreads();
      
      trans.waitUntilFinished();
      
      long stopTime = System.currentTimeMillis();

      result = trans.getResult();
      
      runTime = (double)(stopTime - startTime) / 1000;
      speed = (double)records / (runTime);
      
      printStats("V3 results", records, runTime, speed);
      
      return true;
  }
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:54,代碼來源:TimedTransRunner.java


注:本文中的org.pentaho.di.trans.Trans.waitUntilFinished方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。