response = new IsJobInstanceExistsRes(jobInstanceExists);
return response;
}
private BaseResponseObject handleCreateJobExecutionReq(CreateJobExecutionReq request) {
CreateJobExecutionRes response = null;
String jobName = request.jobName;
Map<String, JobParameter> map = new HashMap<String, JobParameter>();
for(Entry<String, JobParameterType> entry : request.jobParameters.entrySet()) {
ParameterType parameterType = entry.getValue().parameterType;
if(parameterType == ParameterType.DATE) {
if(entry.getValue().parameter instanceof Integer) {
map.put(entry.getKey(), new JobParameter(new Date((Integer)entry.getValue().parameter)));
} else if(entry.getValue().parameter instanceof Date) {
map.put(entry.getKey(), new JobParameter(((Date)entry.getValue().parameter)));
}
} else if(parameterType == ParameterType.DOUBLE) {
map.put(entry.getKey(), new JobParameter((Double)entry.getValue().parameter));
} else if(parameterType == ParameterType.LONG) {
if(entry.getValue().parameter instanceof Long) {
map.put(entry.getKey(), new JobParameter((Long)entry.getValue().parameter));
} else if(entry.getValue().parameter instanceof Integer) {
Long tmp = new Long((Integer)entry.getValue().parameter);
map.put(entry.getKey(), new JobParameter(tmp));
}
} else if(parameterType == ParameterType.STRING) {
map.put(entry.getKey(), new JobParameter((String)entry.getValue().parameter));
}
}
JobParameters jobParameters = new JobParameters(map);
//throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException
JobExecution jobExecution = null;
try {
jobExecution = jobRepository.createJobExecution(jobName, jobParameters);
} catch (JobExecutionAlreadyRunningException e) {
e.printStackTrace();
} catch (JobRestartException e) {
e.printStackTrace();
} catch (JobInstanceAlreadyCompleteException e) {
e.printStackTrace();
}
response = new CreateJobExecutionRes();
response.jobExecution = JobRepositoryRpcFactory.convertJobExecutionType(jobExecution);
return response;
}