use of org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters in project pentaho-kettle by pentaho.
the class TransExecutorDialog method collectInformation.
private void collectInformation() {
// The parameters...
//
TransExecutorParameters parameters = transExecutorMeta.getParameters();
int nrLines = wTransExecutorParameters.nrNonEmpty();
String[] variables = new String[nrLines];
String[] fields = new String[nrLines];
String[] input = new String[nrLines];
parameters.setVariable(variables);
parameters.setField(fields);
parameters.setInput(input);
for (int i = 0; i < nrLines; i++) {
TableItem item = wTransExecutorParameters.getNonEmpty(i);
variables[i] = item.getText(1);
fields[i] = item.getText(2);
input[i] = item.getText(3);
}
parameters.setInheritingAllVariables(wInheritAll.getSelection());
// The group definition
//
transExecutorMeta.setGroupSize(wGroupSize.getText());
transExecutorMeta.setGroupField(wGroupField.getText());
transExecutorMeta.setGroupTime(wGroupTime.getText());
transExecutorMeta.setExecutionResultTargetStep(wExecutionResultTarget.getText());
transExecutorMeta.setExecutionResultTargetStepMeta(transMeta.findStep(wExecutionResultTarget.getText()));
transExecutorMeta.setExecutionTimeField(tiExecutionTimeField.getText(FIELD_NAME));
transExecutorMeta.setExecutionResultField(tiExecutionResultField.getText(FIELD_NAME));
transExecutorMeta.setExecutionNrErrorsField(tiExecutionNrErrorsField.getText(FIELD_NAME));
transExecutorMeta.setExecutionLinesReadField(tiExecutionLinesReadField.getText(FIELD_NAME));
transExecutorMeta.setExecutionLinesWrittenField(tiExecutionLinesWrittenField.getText(FIELD_NAME));
transExecutorMeta.setExecutionLinesInputField(tiExecutionLinesInputField.getText(FIELD_NAME));
transExecutorMeta.setExecutionLinesOutputField(tiExecutionLinesOutputField.getText(FIELD_NAME));
transExecutorMeta.setExecutionLinesRejectedField(tiExecutionLinesRejectedField.getText(FIELD_NAME));
transExecutorMeta.setExecutionLinesUpdatedField(tiExecutionLinesUpdatedField.getText(FIELD_NAME));
transExecutorMeta.setExecutionLinesDeletedField(tiExecutionLinesDeletedField.getText(FIELD_NAME));
transExecutorMeta.setExecutionFilesRetrievedField(tiExecutionFilesRetrievedField.getText(FIELD_NAME));
transExecutorMeta.setExecutionExitStatusField(tiExecutionExitStatusField.getText(FIELD_NAME));
transExecutorMeta.setExecutionLogTextField(tiExecutionLogTextField.getText(FIELD_NAME));
transExecutorMeta.setExecutionLogChannelIdField(tiExecutionLogChannelIdField.getText(FIELD_NAME));
transExecutorMeta.setResultFilesTargetStep(wResultFilesTarget.getText());
transExecutorMeta.setResultFilesTargetStepMeta(transMeta.findStep(wResultFilesTarget.getText()));
transExecutorMeta.setResultFilesFileNameField(wResultFileNameField.getText());
if (!Utils.isEmpty(executorOutputStep)) {
transExecutorMeta.setExecutorsOutputStep(executorOutputStep);
transExecutorMeta.setExecutorsOutputStepMeta(transMeta.findStep(executorOutputStep));
}
// Result row info
//
transExecutorMeta.setOutputRowsSourceStep(wOutputRowsSource.getText());
transExecutorMeta.setOutputRowsSourceStepMeta(transMeta.findStep(wOutputRowsSource.getText()));
int nrFields = wOutputFields.nrNonEmpty();
transExecutorMeta.setOutputRowsField(new String[nrFields]);
transExecutorMeta.setOutputRowsType(new int[nrFields]);
transExecutorMeta.setOutputRowsLength(new int[nrFields]);
transExecutorMeta.setOutputRowsPrecision(new int[nrFields]);
// CHECKSTYLE:Indentation:OFF
for (int i = 0; i < nrFields; i++) {
TableItem item = wOutputFields.getNonEmpty(i);
transExecutorMeta.getOutputRowsField()[i] = item.getText(1);
transExecutorMeta.getOutputRowsType()[i] = ValueMetaFactory.getIdForValueMeta(item.getText(2));
transExecutorMeta.getOutputRowsLength()[i] = Const.toInt(item.getText(3), -1);
transExecutorMeta.getOutputRowsPrecision()[i] = Const.toInt(item.getText(4), -1);
}
}
use of org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters in project pentaho-kettle by pentaho.
the class SubtransExecutorTest method stopsAll.
@Test
public void stopsAll() throws KettleException {
TransMeta parentMeta = new TransMeta(this.getClass().getResource("subtrans-executor-parent.ktr").getPath(), new Variables());
TransMeta subMeta = new TransMeta(this.getClass().getResource("subtrans-executor-sub.ktr").getPath(), new Variables());
LoggingObjectInterface loggingObject = new LoggingObject("anything");
Trans parentTrans = new Trans(parentMeta, loggingObject);
SubtransExecutor subtransExecutor = new SubtransExecutor("subtransname", parentTrans, subMeta, true, new TransExecutorParameters(), "");
subtransExecutor.running = Mockito.spy(subtransExecutor.running);
RowMetaInterface rowMeta = parentMeta.getStepFields("Data Grid");
List<RowMetaAndData> rows = Arrays.asList(new RowMetaAndData(rowMeta, "Pentaho", 1L), new RowMetaAndData(rowMeta, "Pentaho", 2L), new RowMetaAndData(rowMeta, "Pentaho", 3L), new RowMetaAndData(rowMeta, "Pentaho", 4L));
subtransExecutor.execute(rows);
verify(subtransExecutor.running).add(any());
subtransExecutor.stop();
assertTrue(subtransExecutor.running.isEmpty());
}
use of org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters in project pentaho-kettle by pentaho.
the class BaseStreamStep method init.
public boolean init(StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface) {
Preconditions.checkNotNull(stepMetaInterface);
stepMeta = (BaseStreamStepMeta) stepMetaInterface;
stepMeta.setParentStepMeta(getStepMeta());
stepMeta.setFileName(stepMeta.getTransformationPath());
boolean superInit = super.init(stepMetaInterface, stepDataInterface);
try {
TransMeta transMeta = TransExecutorMeta.loadMappingMeta(stepMeta, getTransMeta().getRepository(), getTransMeta().getMetaStore(), getParentVariableSpace());
subtransExecutor = new SubtransExecutor(getStepname(), getTrans(), transMeta, true, new TransExecutorParameters(), environmentSubstitute(stepMeta.getSubStep()));
} catch (KettleException e) {
log.logError(e.getLocalizedMessage(), e);
return false;
}
List<CheckResultInterface> remarks = new ArrayList<>();
stepMeta.check(remarks, getTransMeta(), stepMeta.getParentStepMeta(), // these parameters are not used inside the method
null, // these parameters are not used inside the method
null, // these parameters are not used inside the method
null, // these parameters are not used inside the method
null, variables, getRepository(), getMetaStore());
boolean errorsPresent = remarks.stream().filter(result -> result.getType() == CheckResultInterface.TYPE_RESULT_ERROR).peek(result -> logError(result.getText())).count() > 0;
if (errorsPresent) {
return false;
}
return superInit;
}
use of org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters in project pentaho-kettle by pentaho.
the class SubtransExecutorTest method testRunsATrans.
@Test
public void testRunsATrans() throws Exception {
TransMeta parentMeta = new TransMeta(this.getClass().getResource("subtrans-executor-parent.ktr").getPath(), new Variables());
TransMeta subMeta = new TransMeta(this.getClass().getResource("subtrans-executor-sub.ktr").getPath(), new Variables());
LoggingObjectInterface loggingObject = new LoggingObject("anything");
Trans parentTrans = spy(new Trans(parentMeta, loggingObject));
SubtransExecutor subtransExecutor = new SubtransExecutor("subtransname", parentTrans, subMeta, true, new TransExecutorParameters(), "Group By");
RowMetaInterface rowMeta = parentMeta.getStepFields("Data Grid");
List<RowMetaAndData> rows = Arrays.asList(new RowMetaAndData(rowMeta, "Pentaho", 1L), new RowMetaAndData(rowMeta, "Pentaho", 2L), new RowMetaAndData(rowMeta, "Pentaho", 3L), new RowMetaAndData(rowMeta, "Pentaho", 4L));
Optional<Result> optionalResult = subtransExecutor.execute(rows);
assertEquals(1, optionalResult.orElseThrow(AssertionError::new).getRows().size());
verify(this.logChannel).logBasic(Const.CR + "------------> Linenr 1------------------------------" + Const.CR + "name = Pentaho" + Const.CR + "sum = 10" + Const.CR + Const.CR + "====================");
Map<String, StepStatus> statuses = subtransExecutor.getStatuses();
assertEquals(3, statuses.size());
List<StepStatus> statusList = new ArrayList<>(statuses.values());
assertEquals("Get rows from result", statusList.get(0).getStepname());
assertEquals("Group by", statusList.get(1).getStepname());
assertEquals("Write to log", statusList.get(2).getStepname());
for (Map.Entry<String, StepStatus> entry : statuses.entrySet()) {
StepStatus statusSpy = spy(entry.getValue());
statuses.put(entry.getKey(), statusSpy);
}
subtransExecutor.execute(rows);
for (Map.Entry<String, StepStatus> entry : statuses.entrySet()) {
verify(entry.getValue()).updateAll(any());
}
verify(parentTrans, atLeastOnce()).addActiveSubTransformation(eq("subtransname"), any(Trans.class));
}
use of org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters in project pentaho-kettle by pentaho.
the class SubtransExecutorTest method doesNotExecuteWhenStopped.
@Test
public void doesNotExecuteWhenStopped() throws KettleException {
TransMeta parentMeta = new TransMeta(this.getClass().getResource("subtrans-executor-parent.ktr").getPath(), new Variables());
TransMeta subMeta = new TransMeta(this.getClass().getResource("subtrans-executor-sub.ktr").getPath(), new Variables());
LoggingObjectInterface loggingObject = new LoggingObject("anything");
Trans parentTrans = new Trans(parentMeta, loggingObject);
SubtransExecutor subtransExecutor = new SubtransExecutor("subtransname", parentTrans, subMeta, true, new TransExecutorParameters(), "");
RowMetaInterface rowMeta = parentMeta.getStepFields("Data Grid");
List<RowMetaAndData> rows = Arrays.asList(new RowMetaAndData(rowMeta, "Pentaho", 1L), new RowMetaAndData(rowMeta, "Pentaho", 2L), new RowMetaAndData(rowMeta, "Pentaho", 3L), new RowMetaAndData(rowMeta, "Pentaho", 4L));
subtransExecutor.stop();
subtransExecutor.execute(rows);
verify(this.logChannel, never()).logBasic("\n" + "------------> Linenr 1------------------------------\n" + "name = Pentaho\n" + "sum = 10\n" + "\n" + "====================");
}
Aggregations