// set job definition id
job.setJobDefinitionId(jobDefinitionId);
if(jobDefinitionId != null) {
JobDefinitionEntity jobDefinition = Context.getCommandContext()
.getJobDefinitionManager()
.findById(jobDefinitionId);
if(jobDefinition != null) {
// if job definition is suspended while creating a job instance,
// suspend the job instance right away:
job.setSuspensionState(jobDefinition.getSuspensionState());
job.setProcessDefinitionKey(jobDefinition.getProcessDefinitionKey());
job.setProcessDefinitionId(jobDefinition.getProcessDefinitionId());
}
}
job.setJobHandlerType(jobHandlerType);