org.camunda.bpm.engine.impl.context.Context Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.context.Context. 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: BpmnDeploymentTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testDiagramCreationDisabled() {
  repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/parse/BpmnParseTest.testParseDiagramInterchangeElements.bpmn20.xml").deploy();

  // Graphical information is not yet exposed publicly, so we need to do some plumbing
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
    @Override
    public ProcessDefinitionEntity execute(CommandContext commandContext) {
      return Context.getProcessEngineConfiguration()
                    .getDeploymentCache()
                    .findDeployedLatestProcessDefinitionByKey("myProcess");
    }
  });

  assertNotNull(processDefinitionEntity);
  assertEquals(7, processDefinitionEntity.getActivities().size());

  // Check that no diagram has been created
  List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinitionEntity.getDeploymentId());
  assertEquals(1, resourceNames.size());

  repositoryService.deleteDeployment(repositoryService.createDeploymentQuery().singleResult().getId(), true);
}
 
Example #2
Source File: ProcessApplicationManager.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void createJobExecutorRegistrations(Set<String> deploymentIds) {
  try {
    final DeploymentFailListener deploymentFailListener = new DeploymentFailListener(deploymentIds,
      Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew());
    Context.getCommandContext()
      .getTransactionContext()
      .addTransactionListener(TransactionState.ROLLED_BACK, deploymentFailListener);

    Set<String> registeredDeployments = Context.getProcessEngineConfiguration().getRegisteredDeployments();
    registeredDeployments.addAll(deploymentIds);

  }
  catch (Exception e) {
    throw LOG.exceptionWhileRegisteringDeploymentsWithJobExecutor(e);
  }
}
 
Example #3
Source File: DeploymentManager.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void deleteDecisionRequirementDeployment(String deploymentId) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  if (processEngineConfiguration.isDmnEnabled()) {
    DecisionRequirementsDefinitionManager manager = getDecisionRequirementsDefinitionManager();
    List<DecisionRequirementsDefinition> decisionRequirementsDefinitions =
        manager.findDecisionRequirementsDefinitionByDeploymentId(deploymentId);

    // delete decision requirements definitions from db
    manager.deleteDecisionRequirementsDefinitionsByDeploymentId(deploymentId);

    DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();

    for (DecisionRequirementsDefinition decisionRequirementsDefinition : decisionRequirementsDefinitions) {
      String decisionDefinitionId = decisionRequirementsDefinition.getId();

      // remove decision requirements definitions from cache:
      deploymentCache.removeDecisionRequirementsDefinition(decisionDefinitionId);
    }
  }
}
 
Example #4
Source File: ProcessApplicationElResolverDelegate.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected ELResolver getElResolverDelegate() {

    ProcessApplicationReference processApplicationReference = Context.getCurrentProcessApplication();
    if(processApplicationReference != null) {

      try {
        ProcessApplicationInterface processApplication = processApplicationReference.getProcessApplication();
        return processApplication.getElResolver();

      } catch (ProcessApplicationUnavailableException e) {
        throw new ProcessEngineException("Cannot access process application '"+processApplicationReference.getName()+"'", e);
      }

    } else {
      return null;
    }

  }
 
Example #5
Source File: CommandContextInterceptorTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testCommandContextNestedFailingCommands() {
  final ExceptionThrowingCmd innerCommand1 = new ExceptionThrowingCmd(new IdentifiableRuntimeException(1));
  final ExceptionThrowingCmd innerCommand2 = new ExceptionThrowingCmd(new IdentifiableRuntimeException(2));

  try {
    processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Object>() {
      public Object execute(CommandContext commandContext) {
        CommandExecutor commandExecutor = Context.getProcessEngineConfiguration().getCommandExecutorTxRequired();

        commandExecutor.execute(innerCommand1);
        commandExecutor.execute(innerCommand2);

        return null;
      }
    });

    fail("Exception expected");
  } catch (IdentifiableRuntimeException e) {
    assertEquals(1, e.id);
  }

  assertTrue(innerCommand1.executed);
  assertFalse(innerCommand2.executed);
}
 
Example #6
Source File: HistoricTaskInstanceManager.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void markTaskInstanceEnded(String taskId, final String deleteReason) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();

  final TaskEntity taskEntity = Context.getCommandContext()
      .getDbEntityManager()
      .selectById(TaskEntity.class, taskId);

  HistoryLevel historyLevel = configuration.getHistoryLevel();
  if(historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_COMPLETE, taskEntity)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createTaskInstanceCompleteEvt(taskEntity, deleteReason);
      }
    });
  }
}
 
Example #7
Source File: TaskEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void setOwner(String owner) {
  ensureTaskActive();
  registerCommandContextCloseListener();

  String oldOwner = this.owner;
  if (owner==null && oldOwner==null) {
    return;
  }

  addIdentityLinkChanges(IdentityLinkType.OWNER, oldOwner, owner);
  propertyChanged(OWNER, oldOwner, owner);
  this.owner = owner;

  CommandContext commandContext = Context.getCommandContext();
  // if there is no command context, then it means that the user is calling the
  // setOwner outside a service method.  E.g. while creating a new task.
  if (commandContext != null && commandContext.getDbEntityManager().contains(this)) {
    fireOwnerAuthorizationProvider(oldOwner, owner);
    this.fireHistoricIdentityLinks();
  }

}
 
Example #8
Source File: ProcessApplicationEventListenerDelegate.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void performNotification(final DelegateExecution execution, Callable<Void> notification) throws Exception {
  final ProcessApplicationReference processApp = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution);
  if (processApp == null) {
    // ignore silently
    LOG.noTargetProcessApplicationForExecution(execution);

  } else {
    if (ProcessApplicationContextUtil.requiresContextSwitch(processApp)) {
      // this should not be necessary since context switch is already performed by OperationContext and / or DelegateInterceptor
      Context.executeWithinProcessApplication(notification, processApp, new InvocationContext(execution));

    } else {
      // context switch already performed
      notification.call();

    }
  }
}
 
Example #9
Source File: ExecutionEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch all the executions inside the same process instance as list and then
 * reconstruct the complete execution tree.
 *
 * In many cases this is an optimization over fetching the execution tree
 * lazily. Usually we need all executions anyway and it is preferable to fetch
 * more data in a single query (maybe even too much data) then to run multiple
 * queries, each returning a fraction of the data.
 *
 * The most important consideration here is network roundtrip: If the process
 * engine and database run on separate hosts, network roundtrip has to be
 * added to each query. Economizing on the number of queries economizes on
 * network roundtrip. The tradeoff here is network roundtrip vs. throughput:
 * multiple roundtrips carrying small chucks of data vs. a single roundtrip
 * carrying more data.
 *
 */
protected void ensureExecutionTreeInitialized() {
  List<ExecutionEntity> executions = Context.getCommandContext()
    .getExecutionManager()
    .findExecutionsByProcessInstanceId(processInstanceId);

  ExecutionEntity processInstance = isProcessInstanceExecution() ? this : null;

  if(processInstance == null) {
    for (ExecutionEntity execution : executions) {
      if (execution.isProcessInstanceExecution()) {
        processInstance = execution;
      }
    }
  }

  processInstance.restoreProcessInstance(executions, null, null, null, null, null, null);
}
 
Example #10
Source File: HistoricTaskInstanceManager.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Deletes all data related with tasks, which belongs to specified process instance ids.
 * @param processInstanceIds
 * @param deleteVariableInstances when true, will also delete variable instances. Can be false when variable instances were deleted separately.
 */
public void deleteHistoricTaskInstancesByProcessInstanceIds(List<String> processInstanceIds, boolean deleteVariableInstances) {

  CommandContext commandContext = Context.getCommandContext();

  if (deleteVariableInstances) {
    getHistoricVariableInstanceManager().deleteHistoricVariableInstancesByTaskProcessInstanceIds(processInstanceIds);
  }

  getHistoricDetailManager()
      .deleteHistoricDetailsByTaskProcessInstanceIds(processInstanceIds);

  commandContext
      .getCommentManager()
      .deleteCommentsByTaskProcessInstanceIds(processInstanceIds);

  getAttachmentManager()
      .deleteAttachmentsByTaskProcessInstanceIds(processInstanceIds);

  getHistoricIdentityLinkManager()
      .deleteHistoricIdentityLinksLogByTaskProcessInstanceIds(processInstanceIds);

  getDbEntityManager().deletePreserveOrder(HistoricTaskInstanceEntity.class, "deleteHistoricTaskInstanceByProcessInstanceIds", processInstanceIds);
}
 
Example #11
Source File: JPAVariableSerializer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void writeValue(ObjectValue objectValue, ValueFields valueFields) {
  EntityManagerSession entityManagerSession = Context
    .getCommandContext()
    .getSession(EntityManagerSession.class);
  if (entityManagerSession == null) {
    throw new ProcessEngineException("Cannot set JPA variable: " + EntityManagerSession.class + " not configured");
  } else {
    // Before we set the value we must flush all pending changes from the entitymanager
    // If we don't do this, in some cases the primary key will not yet be set in the object
    // which will cause exceptions down the road.
    entityManagerSession.flush();
  }

  Object value = objectValue.getValue();
  if(value != null) {
    String className = mappings.getJPAClassString(value);
    String idString = mappings.getJPAIdString(value);
    valueFields.setTextValue(className);
    valueFields.setTextValue2(idString);
  } else {
    valueFields.setTextValue(null);
    valueFields.setTextValue2(null);
  }
}
 
Example #12
Source File: MeterLogManager.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public Long executeSelectSum(MetricsQueryImpl query) {
  Long result = (Long) getDbEntityManager().selectOne(SELECT_METER_SUM, query);
  result = result != null ? result : 0;

  if(shouldAddCurrentUnloggedCount(query)) {
    // add current unlogged count
    Meter meter = Context.getProcessEngineConfiguration()
      .getMetricsRegistry()
      .getMeterByName(query.getName());
    if(meter != null) {
      result += meter.get();
    }
  }

  return result;
}
 
Example #13
Source File: DeleteProcessDefinitionsByIdsCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected ProcessDefinitionEntity findNewLatestProcessDefinition(ProcessDefinitionGroup group) {
  ProcessDefinitionEntity newLatestProcessDefinition = null;

  List<ProcessDefinitionEntity> processDefinitions = group.processDefinitions;
  ProcessDefinitionEntity firstProcessDefinition = processDefinitions.get(0);

  if (isLatestProcessDefinition(firstProcessDefinition)) {
    for (ProcessDefinitionEntity processDefinition : processDefinitions) {
      String previousProcessDefinitionId = processDefinition.getPreviousProcessDefinitionId();
      if (previousProcessDefinitionId != null && !this.processDefinitionIds.contains(previousProcessDefinitionId)) {
        CommandContext commandContext = Context.getCommandContext();
        ProcessDefinitionManager processDefinitionManager = commandContext.getProcessDefinitionManager();
        newLatestProcessDefinition = processDefinitionManager.findLatestDefinitionById(previousProcessDefinitionId);
        break;
      }
    }
  }

  return newLatestProcessDefinition;
}
 
Example #14
Source File: RestartProcessInstancesCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected HistoricActivityInstance resolveStartActivityInstance(
    HistoricProcessInstance processInstance) {
  HistoryService historyService = Context.getProcessEngineConfiguration().getHistoryService();

  String processInstanceId = processInstance.getId();
  String startActivityId = processInstance.getStartActivityId();

  ensureNotNull("startActivityId", startActivityId);

  List<HistoricActivityInstance> historicActivityInstances = historyService
      .createHistoricActivityInstanceQuery()
      .processInstanceId(processInstanceId)
      .activityId(startActivityId)
      .orderPartiallyByOccurrence()
      .asc()
      .list();

  ensureNotEmpty("historicActivityInstances", historicActivityInstances);

  HistoricActivityInstance startActivityInstance = historicActivityInstances.get(0);
  return startActivityInstance;
}
 
Example #15
Source File: CaseExecutionManager.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void deleteCaseInstance(String caseInstanceId, String deleteReason, boolean cascade) {
  CaseExecutionEntity execution = findCaseExecutionById(caseInstanceId);

  if(execution == null) {
    throw new BadUserRequestException("No case instance found for id '" + caseInstanceId + "'");
  }

  CommandContext commandContext = Context.getCommandContext();
  commandContext
    .getTaskManager()
    .deleteTasksByCaseInstanceId(caseInstanceId, deleteReason, cascade);

  execution.deleteCascade();

  if (cascade) {
    Context
      .getCommandContext()
      .getHistoricCaseInstanceManager()
      .deleteHistoricCaseInstancesByIds(Arrays.asList(caseInstanceId));
  }
}
 
Example #16
Source File: GetDeploymentProcessDiagramCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public InputStream execute(final CommandContext commandContext) {
  ProcessDefinitionEntity processDefinition = Context
          .getProcessEngineConfiguration()
          .getDeploymentCache()
          .findDeployedProcessDefinitionById(processDefinitionId);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkReadProcessDefinition(processDefinition);
  }

  final String deploymentId = processDefinition.getDeploymentId();
  final String resourceName = processDefinition.getDiagramResourceName();

  if (resourceName == null ) {
    return null;
  } else {

    InputStream processDiagramStream = commandContext.runWithoutAuthorization(new Callable<InputStream>() {
      public InputStream call() throws Exception {
        return new GetDeploymentResourceCmd(deploymentId, resourceName).execute(commandContext);
      }
    });

    return processDiagramStream;
  }
}
 
Example #17
Source File: GetDeploymentDmnModelInstanceCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public DmnModelInstance execute(CommandContext commandContext) {
  ensureNotNull("decisionDefinitionId", decisionDefinitionId);

  DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache();

  DecisionDefinitionEntity decisionDefinition = deploymentCache.findDeployedDecisionDefinitionById(decisionDefinitionId);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkReadDecisionDefinition(decisionDefinition);
  }

  DmnModelInstance modelInstance = deploymentCache.findDmnModelInstanceForDecisionDefinition(decisionDefinitionId);

  ensureNotNull(DmnModelInstanceNotFoundException.class, "No DMN model instance found for decision definition id " + decisionDefinitionId, "modelInstance",
      modelInstance);
  return modelInstance;
}
 
Example #18
Source File: ScriptingEngines.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Loads the given script engine by language name. Will throw an exception if no script engine can be loaded for the given language name.
 *
 * @param language the name of the script language to lookup an implementation for
 * @return the script engine
 * @throws ProcessEngineException if no such engine can be found.
 */
public ScriptEngine getScriptEngineForLanguage(String language) {

  if (language != null) {
    language = language.toLowerCase();
  }

  ProcessApplicationReference pa = Context.getCurrentProcessApplication();
  ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();

  ScriptEngine engine = null;
  if (config.isEnableFetchScriptEngineFromProcessApplication()) {
    if(pa != null) {
      engine = getPaScriptEngine(language, pa);
    }
  }

  if(engine == null) {
    engine = getGlobalScriptEngine(language);
  }

  return engine;
}
 
Example #19
Source File: FailingOnLastRetryAspect.java    From flowing-retail with Apache License 2.0 6 votes vote down vote up
@Around("@annotation(FailingOnLastRetry)")
public Object guardedExecute(ProceedingJoinPoint joinPoint) throws Throwable {
  JobExecutorContext jobExecutorContext = Context.getJobExecutorContext();
  if (jobExecutorContext!=null && jobExecutorContext.getCurrentJob()!=null) {
    // this is called from a Job
    if (jobExecutorContext.getCurrentJob().getRetries()<=1) {
      // and the job will run out of retries when it fails again
      try {
        return joinPoint.proceed();
      } catch (Exception ex) {
        // Probably save the exception somewhere
        throw new BpmnError(NO_RETRIES_ERROR);
      }
    }      
  }
  // otherwise normal behavior (including retries possibly)
  return joinPoint.proceed();
}
 
Example #20
Source File: ExecutionEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * generates an activity instance id
 */
@Override
protected String generateActivityInstanceId(String activityId) {

  if (activityId.equals(processDefinitionId)) {
    return processInstanceId;

  } else {

    String nextId = Context.getProcessEngineConfiguration().getIdGenerator().getNextId();

    String compositeId = activityId + ":" + nextId;
    if (compositeId.length() > 64) {
      return String.valueOf(nextId);
    } else {
      return compositeId;
    }
  }
}
 
Example #21
Source File: JPAEntityMappings.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private Object findEntity(Class< ? > entityClass, Object primaryKey) {
  EntityManager em = Context
    .getCommandContext()
    .getSession(EntityManagerSession.class)
    .getEntityManager();

  Object entity = em.find(entityClass, primaryKey);
  ensureNotNull("Entity does not exist: " + entityClass.getName() + " - " + primaryKey, "entity", entity);
  return entity;
}
 
Example #22
Source File: ProcessInstanceQueryImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
protected void ensureVariablesInitialized() {
  super.ensureVariablesInitialized();

  if (!queries.isEmpty()) {
    VariableSerializers variableSerializers = Context.getProcessEngineConfiguration()
        .getVariableSerializers();

    for (ProcessInstanceQueryImpl orQuery: queries) {
      for (QueryVariableValue var : orQuery.queryVariableValues) {
        var.initialize(variableSerializers);
      }
    }
  }
}
 
Example #23
Source File: CommandInvocationContext.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void performNext() {
  AtomicOperationInvocation nextInvocation = queuedInvocations.get(0);

  if(nextInvocation.operation.isAsyncCapable() && isExecuting) {
    // will be picked up by while loop below
    return;
  }

  ProcessApplicationReference targetProcessApplication = getTargetProcessApplication(nextInvocation.execution);
  if(requiresContextSwitch(targetProcessApplication)) {

    Context.executeWithinProcessApplication(new Callable<Void>() {
      public Void call() throws Exception {
        performNext();
        return null;
      }

    }, targetProcessApplication, new InvocationContext(nextInvocation.execution));
  }
  else {
    if(!nextInvocation.operation.isAsyncCapable()) {
      // if operation is not async capable, perform right away.
      invokeNext();
    }
    else {
      try  {
        isExecuting = true;
        while (! queuedInvocations.isEmpty()) {
          // assumption: all operations are executed within the same process application...
          invokeNext();
        }
      }
      finally {
        isExecuting = false;
      }
    }
  }
}
 
Example #24
Source File: ClassDelegateActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void signal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception {
  ProcessApplicationReference targetProcessApplication = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution);
  if(ProcessApplicationContextUtil.requiresContextSwitch(targetProcessApplication)) {
    Context.executeWithinProcessApplication(new Callable<Void>() {
      public Void call() throws Exception {
        signal(execution, signalName, signalData);
        return null;
      }
    }, targetProcessApplication, new InvocationContext(execution));
  }
  else {
    doSignal(execution, signalName, signalData);
  }
}
 
Example #25
Source File: AbstractNativeQuery.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public U singleResult() {
  this.resultType = ResultType.SINGLE_RESULT;
  if (commandExecutor != null) {
    return (U) commandExecutor.execute(this);
  }
  return executeSingleResult(Context.getCommandContext());
}
 
Example #26
Source File: MyTaskFormHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void submitFormVariables(VariableMap properties, VariableScope variableScope) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  IdentityService identityService = processEngineConfiguration.getIdentityService();
  RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();

  logAuthentication(identityService);
  logInstancesCount(runtimeService);
}
 
Example #27
Source File: ScriptBindings.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected boolean isAutoStoreScriptVariablesEnabled() {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  if(processEngineConfiguration != null) {
    return processEngineConfiguration.isAutoStoreScriptVariables();
  }
  return false;
}
 
Example #28
Source File: ExternalTaskEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void ensureExecutionInitialized() {
  if (execution == null) {
    execution = Context.getCommandContext().getExecutionManager().findExecutionById(executionId);
    EnsureUtil.ensureNotNull(
        "Cannot find execution with id " + executionId + " for external task " + id,
        "execution",
        execution);
  }
}
 
Example #29
Source File: BatchEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public JobDefinitionEntity getBatchJobDefinition() {
  if (batchJobDefinition == null && batchJobDefinitionId != null) {
    batchJobDefinition = Context.getCommandContext().getJobDefinitionManager().findById(batchJobDefinitionId);
  }

  return batchJobDefinition;
}
 
Example #30
Source File: AbstractBatchJobHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteJobs(BatchEntity batch) {
  List<JobEntity> jobs = Context.getCommandContext()
      .getJobManager()
      .findJobsByJobDefinitionId(batch.getBatchJobDefinitionId());

  for (JobEntity job : jobs) {
    job.delete();
  }
}