use of org.pentaho.di.job.JobEntryListener in project pentaho-kettle by pentaho.
the class JobEntrySetVariables method setParentJob.
@Override
public void setParentJob(Job parentJob) {
super.setParentJob(parentJob);
// PDI-16387 Add a listener for recovering changed values of variables
JobEntryListener jobListener = new JobEntryListener() {
@Override
public void beforeExecution(Job job, JobEntryCopy jobEntryCopy, JobEntryInterface jobEntryInterface) {
for (String key : changedInitialVariables.keySet()) {
setVariable(key, changedInitialVariables.get(key));
parentJob.setVariable(key, changedInitialVariables.get(key));
}
changedInitialVariables.clear();
}
@Override
public void afterExecution(Job job, JobEntryCopy jobEntryCopy, JobEntryInterface jobEntryInterface, Result result) {
}
};
parentJob.addJobEntryListener(jobListener);
}
use of org.pentaho.di.job.JobEntryListener in project pentaho-kettle by pentaho.
the class JobEntrySetVariablesTest method testVariableTypeCurrentJob.
@Test
public void testVariableTypeCurrentJob() throws Exception {
entry.setFilename("src/test/resources/org/pentaho/di/job/entries/setvariables/UTF8Text.properties");
entry.setVariableName(new String[] {});
entry.setReplaceVars(true);
entry.setFileVariableType(JobEntrySetVariables.VARIABLE_TYPE_CURRENT_JOB);
Result result = entry.execute(new Result(), 0);
for (JobEntryListener jobEntryListener : job.getJobEntryListeners()) {
jobEntryListener.beforeExecution(job, null, entry);
}
Assert.assertTrue(result.getResult());
Assert.assertNull(entry.getVariable("Japanese"));
Assert.assertNull(entry.getVariable("English"));
Assert.assertNull(entry.getVariable("Chinese"));
}
Aggregations