Java Code Examples for org.activiti.engine.runtime.Job#getProcessDefinitionId()

The following examples show how to use org.activiti.engine.runtime.Job#getProcessDefinitionId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimerSuspendProcessDefinitionHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void execute(Job job, String configuration, ExecutionEntity execution, CommandContext commandContext) {
  JSONObject cfgJson = new JSONObject(configuration);
  String processDefinitionId = job.getProcessDefinitionId();
  boolean suspendProcessInstances = getIncludeProcessInstances(cfgJson);
  
  SuspendProcessDefinitionCmd suspendProcessDefinitionCmd = 
          new SuspendProcessDefinitionCmd(processDefinitionId, null, suspendProcessInstances, null, job.getTenantId());
  suspendProcessDefinitionCmd.execute(commandContext);
}
 
Example 2
Source File: TimerActivateProcessDefinitionHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void execute(Job job, String configuration, ExecutionEntity execution, CommandContext commandContext) {
  JSONObject cfgJson = new JSONObject(configuration);
  String processDefinitionId = job.getProcessDefinitionId();
  boolean activateProcessInstances = getIncludeProcessInstances(cfgJson);
  
  ActivateProcessDefinitionCmd activateProcessDefinitionCmd =
          new ActivateProcessDefinitionCmd(processDefinitionId, null, activateProcessInstances, null, job.getTenantId());
  activateProcessDefinitionCmd.execute(commandContext);
}
 
Example 3
Source File: ExecuteJobCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Object execute(CommandContext commandContext) {

    if (jobId == null) {
      throw new ActivitiIllegalArgumentException("jobId and job is null");
    }

    Job job = commandContext.getJobEntityManager().findById(jobId);

    if (job == null) {
      throw new JobNotFoundException(jobId);
    }

    if (log.isDebugEnabled()) {
      log.debug("Executing job {}", job.getId());
    }
    
    if (job.getProcessDefinitionId() != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, job.getProcessDefinitionId())) {
      Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); 
      activiti5CompatibilityHandler.executeJob(job);
      return null;
    }
    
    commandContext.addCloseListener(new FailedJobListener(commandContext.getProcessEngineConfiguration().getCommandExecutor(), job));

    try {
      commandContext.getJobManager().execute(job);
    } catch (Throwable exception) {
      // Finally, Throw the exception to indicate the ExecuteJobCmd failed
      throw new ActivitiException("Job " + jobId + " failed", exception);
    }

    return null;
  }
 
Example 4
Source File: RestResponseFactory.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public JobResponse createJobResponse(Job job, RestUrlBuilder urlBuilder) {
  JobResponse response = new JobResponse();
  response.setId(job.getId());
  response.setDueDate(job.getDuedate());
  response.setExceptionMessage(job.getExceptionMessage());
  response.setExecutionId(job.getExecutionId());
  response.setProcessDefinitionId(job.getProcessDefinitionId());
  response.setProcessInstanceId(job.getProcessInstanceId());
  response.setRetries(job.getRetries());
  response.setTenantId(job.getTenantId());

  response.setUrl(urlBuilder.buildUrl(RestUrls.URL_JOB, job.getId()));

  if (job.getProcessDefinitionId() != null) {
    response.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, job.getProcessDefinitionId()));
  }

  if (job.getProcessInstanceId() != null) {
    response.setProcessInstanceUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE, job.getProcessInstanceId()));
  }

  if (job.getExecutionId() != null) {
    response.setExecutionUrl(urlBuilder.buildUrl(RestUrls.URL_EXECUTION, job.getExecutionId()));
  }

  return response;
}