本文整理匯總了Java中org.pentaho.di.trans.Trans.setParameterValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Trans.setParameterValue方法的具體用法?Java Trans.setParameterValue怎麽用?Java Trans.setParameterValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.pentaho.di.trans.Trans
的用法示例。
在下文中一共展示了Trans.setParameterValue方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
}