Java Code Examples for org.camunda.bpm.engine.impl.persistence.entity.JobEntity#setDuedate()

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.JobEntity#setDuedate() . 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: SetJobDuedateCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public Void execute(CommandContext commandContext) {
  JobEntity job = commandContext
          .getJobManager()
          .findJobById(jobId);
  if (job != null) {

    for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
      checker.checkUpdateJob(job);
    }
    
    commandContext.getOperationLogManager().logJobOperation(UserOperationLogEntry.OPERATION_TYPE_SET_DUEDATE, jobId, 
        job.getJobDefinitionId(), job.getProcessInstanceId(), job.getProcessDefinitionId(), job.getProcessDefinitionKey(),
        Collections.singletonList(new PropertyChange("duedate", job.getDuedate(), newDuedate)));

    // for timer jobs cascade due date changes
    if (cascade && newDuedate != null && job instanceof TimerEntity) {
      long offset = newDuedate.getTime() - job.getDuedate().getTime();
      ((TimerEntity) job).setRepeatOffset(((TimerEntity) job).getRepeatOffset() + offset);
    }

    job.setDuedate(newDuedate);
  } else {
    throw new ProcessEngineException("No job found with id '" + jobId + "'.");
  }
  return null;
}
 
Example 2
Source File: BatchEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public JobEntity createMonitorJob(boolean setDueDate) {
  // Maybe use an other job declaration
  JobEntity monitorJob = BATCH_MONITOR_JOB_DECLARATION.createJobInstance(this);
  if (setDueDate) {
    monitorJob.setDuedate(calculateMonitorJobDueDate());
  }

  Context.getCommandContext()
    .getJobManager().insertAndHintJobExecutor(monitorJob);

  return monitorJob;
}
 
Example 3
Source File: DefaultJobRetryCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void executeCustomStrategy(CommandContext commandContext, JobEntity job, ActivityImpl activity) throws Exception {
  FailedJobRetryConfiguration retryConfiguration = getFailedJobRetryConfiguration(job, activity);

  if (retryConfiguration == null) {
    executeStandardStrategy(commandContext);

  } else {

    if (isFirstJobExecution(job)) {
      // then change default retries to the ones configured
      initializeRetries(job, retryConfiguration.getRetries());

    } else {
      LOG.debugDecrementingRetriesForJob(job.getId());
    }

    List<String> intervals = retryConfiguration.getRetryIntervals();
    int intervalsCount = intervals.size();
    int indexOfInterval = Math.max(0, Math.min(intervalsCount - 1, intervalsCount - (job.getRetries() - 1)));
    DurationHelper durationHelper = getDurationHelper(intervals.get(indexOfInterval));

    job.setDuedate(durationHelper.getDateAfter());
    job.unlock();

    logException(job);
    decrementRetries(job);
    notifyAcquisition(commandContext);
  }
}
 
Example 4
Source File: HistoryCleanupCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void suspendJobs(List<Job> jobs) {
  for (Job job: jobs) {
    JobEntity jobInstance = (JobEntity) job;
    jobInstance.setSuspensionState(SuspensionState.SUSPENDED.getStateCode());
    jobInstance.setDuedate(null);
  }
}