@Override
public JobParameters getJobParameters(Job job, StepExecution stepExecution) {
String stepName = stepExecution.getStepName();
int index = stepName.lastIndexOf("-");
int stepNumber = Integer.parseInt(stepName.substring(index + 1));
JobParameters jobParameters = stepExecution.getJobParameters();
Map<String, JobParameter> jobParametersMap =
jobParameters.getParameters();
Map<String, JobParameter> subJobParameters =
new TreeMap<String, JobParameter>();
for (String key : jobParametersMap.keySet()) {
subJobParameters.put(key, jobParametersMap.get(key));
}
if (jobParametersMap
.containsKey(JobConstants.SUB_JOB_PARAMETERS_NUMBER
+ stepNumber)) {
int jobParametersNumber =
(int) jobParameters
.getLong(JobConstants.SUB_JOB_PARAMETERS_NUMBER
+ stepNumber);
for (int count = 0; count < jobParametersNumber; count++) {
String key =
jobParameters.getString(JobUtils.getSubJobParameterPrefixKey(
stepNumber, count));
JobParameter parameterValue =
jobParametersMap.get(JobUtils.getSubJobParameterPrefixValue(
stepNumber, count));
subJobParameters.put(key, parameterValue);
}
}
subJobParameters.put(JobConstants.TIMESTAMP_JOB_PARAM, new JobParameter(
new Date()));
return new JobParameters(subJobParameters);
}