Java Code Examples for org.camunda.bpm.engine.impl.interceptor.CommandContext#getJobDefinitionManager()

The following examples show how to use org.camunda.bpm.engine.impl.interceptor.CommandContext#getJobDefinitionManager() . 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: AbstractSetJobDefinitionStateCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateSuspensionState(CommandContext commandContext, SuspensionState suspensionState) {
  JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
  JobManager jobManager = commandContext.getJobManager();

  if (jobDefinitionId != null) {
    jobDefinitionManager.updateJobDefinitionSuspensionStateById(jobDefinitionId, suspensionState);

  } else if (processDefinitionId != null) {
    jobDefinitionManager.updateJobDefinitionSuspensionStateByProcessDefinitionId(processDefinitionId, suspensionState);
    jobManager.updateStartTimerJobSuspensionStateByProcessDefinitionId(processDefinitionId, suspensionState);

  } else if (processDefinitionKey != null) {

    if (!isProcessDefinitionTenantIdSet) {
      jobDefinitionManager.updateJobDefinitionSuspensionStateByProcessDefinitionKey(processDefinitionKey, suspensionState);
      jobManager.updateStartTimerJobSuspensionStateByProcessDefinitionKey(processDefinitionKey, suspensionState);

    } else {
      jobDefinitionManager.updateJobDefinitionSuspensionStateByProcessDefinitionKeyAndTenantId(processDefinitionKey, processDefinitionTenantId, suspensionState);
      jobManager.updateStartTimerJobSuspensionStateByProcessDefinitionKeyAndTenantId(processDefinitionKey, processDefinitionTenantId, suspensionState);
    }
  }
}
 
Example 2
Source File: SetJobRetriesCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void setJobRetriesByJobDefinitionId(CommandContext commandContext) {
  JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
  JobDefinitionEntity jobDefinition = jobDefinitionManager.findById(jobDefinitionId);

  if (jobDefinition != null) {
    String processDefinitionId = jobDefinition.getProcessDefinitionId();
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
      checker.checkUpdateRetriesProcessInstanceByProcessDefinitionId(processDefinitionId);
    }
  }

  commandContext
      .getJobManager()
      .updateFailedJobRetriesByJobDefinitionId(jobDefinitionId, retries);

  PropertyChange propertyChange = new PropertyChange(RETRIES, null, retries);
  commandContext.getOperationLogManager().logJobOperation(getLogEntryOperation(), null, jobDefinitionId, null,
      null, null, propertyChange);
}
 
Example 3
Source File: BatchEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void delete(boolean cascadeToHistory, boolean deleteJobs) {
  CommandContext commandContext = Context.getCommandContext();

  deleteSeedJob();
  deleteMonitorJob();
  if (deleteJobs) {
    getBatchJobHandler().deleteJobs(this);
  }

  JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
  jobDefinitionManager.delete(getSeedJobDefinition());
  jobDefinitionManager.delete(getMonitorJobDefinition());
  jobDefinitionManager.delete(getBatchJobDefinition());

  commandContext.getBatchManager().delete(this);
  configuration.deleteByteArrayValue();

  fireHistoricEndEvent();

  if (cascadeToHistory) {
    HistoricIncidentManager historicIncidentManager = commandContext.getHistoricIncidentManager();
    historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(seedJobDefinitionId);
    historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(monitorJobDefinitionId);
    historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(batchJobDefinitionId);

    HistoricJobLogManager historicJobLogManager = commandContext.getHistoricJobLogManager();
    historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(seedJobDefinitionId);
    historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(monitorJobDefinitionId);
    historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(batchJobDefinitionId);

    commandContext.getHistoricBatchManager().deleteHistoricBatchById(id);
  }
}
 
Example 4
Source File: AbstractSetStateCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String getDeploymentIdByJobDefinition(CommandContext commandContext, String jobDefinitionId) {
  JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
  JobDefinitionEntity jobDefinition = jobDefinitionManager.findById(jobDefinitionId);
  if (jobDefinition != null) {
    if (jobDefinition.getProcessDefinitionId() != null) {
      return getDeploymentIdByProcessDefinition(commandContext, jobDefinition.getProcessDefinitionId());
    }
  }
  return null;
}
 
Example 5
Source File: AbstractSetJobDefinitionStateCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
protected void checkAuthorization(CommandContext commandContext) {

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    if (jobDefinitionId != null) {

      JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
      JobDefinitionEntity jobDefinition = jobDefinitionManager.findById(jobDefinitionId);

      if (jobDefinition != null && jobDefinition.getProcessDefinitionKey() != null) {
        String processDefinitionKey = jobDefinition.getProcessDefinitionKey();
        checker.checkUpdateProcessDefinitionByKey(processDefinitionKey);

        if (includeSubResources) {
          checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
        }
      }

    } else

    if (processDefinitionId != null) {
      checker.checkUpdateProcessDefinitionById(processDefinitionId);

      if (includeSubResources) {
        checker.checkUpdateProcessInstanceByProcessDefinitionId(processDefinitionId);
      }

    } else

    if (processDefinitionKey != null) {
      checker.checkUpdateProcessDefinitionByKey(processDefinitionKey);

      if (includeSubResources) {
        checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
      }
    }
  }
}