protected DbSqlSession getDbSqlSession() { return commandContext.getDbSqlSession(); }
protected ExecutionEntity fetchExecutionEntity(CommandContext commandContext, String executionId) { if (executionId == null) { return null; } return commandContext.getExecutionEntityManager().findById(executionId); }
protected Void execute(CommandContext commandContext, TaskEntity task) { if (IdentityLinkType.ASSIGNEE.equals(type)) { commandContext.getTaskEntityManager().changeTaskAssignee(task, null); } else if (IdentityLinkType.OWNER.equals(type)) { commandContext.getTaskEntityManager().changeTaskOwner(task, null); } else { commandContext.getIdentityLinkEntityManager().deleteIdentityLink(task, userId, groupId, type); } commandContext.getHistoryManager().createIdentityLinkComment(taskId, userId, groupId, type, false); return null; }
@Override public Void execute(CommandContext commandContext) { boolean messageQueueMode = commandContext.getProcessEngineConfiguration().isAsyncExecutorIsMessageQueueMode(); for (String jobId : jobIds) { if (!messageQueueMode) { Job job = commandContext.getJobEntityManager().findById(jobId); commandContext.getJobManager().unacquire(job); } else { commandContext.getJobEntityManager().resetExpiredJob(jobId); } } return null; }
@Override public void closing(CommandContext commandContext) { if (commandContext.getException() != null) { return; // Not interested in events about exceptions } EventLogEntryEntityManager eventLogEntryEntityManager = commandContext.getEventLogEntryEntityManager(); for (EventLoggerEventHandler eventHandler : eventHandlers) { try { eventLogEntryEntityManager.insert(eventHandler.generateEventLogEntry(commandContext), false); } catch (Exception e) { logger.warn("Could not create event log", e); } } }
DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("Could not find deployment with id " + deploymentId, Deployment.class); commandContext.getProcessDefinitionEntityManager().updateProcessDefinitionTenantIdForDeployment(deploymentId, newTenantId); commandContext.getExecutionEntityManager().updateExecutionTenantIdForDeployment(deploymentId, newTenantId); commandContext.getTaskEntityManager().updateTaskTenantIdForDeployment(deploymentId, newTenantId); commandContext.getJobEntityManager().updateJobTenantIdForDeployment(deploymentId, newTenantId); commandContext.getTimerJobEntityManager().updateJobTenantIdForDeployment(deploymentId, newTenantId); commandContext.getSuspendedJobEntityManager().updateJobTenantIdForDeployment(deploymentId, newTenantId); commandContext.getDeadLetterJobEntityManager().updateJobTenantIdForDeployment(deploymentId, newTenantId); commandContext.getEventSubscriptionEntityManager().updateEventSubscriptionTenantId(oldTenantId, newTenantId); commandContext.getProcessEngineConfiguration().getProcessDefinitionCache().remove(processDefinition.getId()); commandContext.getProcessEngineConfiguration().getProcessDefinitionCache().clear();
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()); } 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; }
public Void execute(CommandContext commandContext) { ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); ExecutionEntity processInstance = executionEntityManager.findById(processInstanceId); if (processInstance == null) { throw new ActivitiObjectNotFoundException("Cannot find process instance with id " + processInstanceId, ExecutionEntity.class); } IdentityLinkEntityManager identityLinkEntityManager = commandContext.getIdentityLinkEntityManager(); identityLinkEntityManager.addIdentityLink(processInstance, userId, groupId, type); commandContext.getHistoryManager().createProcessInstanceIdentityLinkComment(processInstanceId, userId, groupId, type, true); return null; }
if (!config.isContextReusePossible() || context == null || context.getException() != null) { context = commandContextFactory.createCommandContext(command); } else { log.debug("Valid context found. Reusing it for the current command '{}'", command.getClass().getCanonicalName()); contextReused = true; context.setReused(true); context.exception(e); context.close();
public TaskEntity getTask() { if ((task == null) && (taskId != null)) { this.task = Context.getCommandContext().getTaskEntityManager().findById(taskId); } return task; }
if (!isContextReusePossible || context == null || context.getException() != null) { context = commandContextFactory.createCommandContext(command); context.exception(e); context.close();
@Override public Comment execute(CommandContext commandContext) { for (TaskEntity taskEntity : commandContext.getTaskEntityManager().findTasksByExecutionId(executionId)) { commandContext.getTaskEntityManager().deleteTask(taskEntity, "jump", false); } ExecutionEntity executionEntity = Context.getCommandContext().getExecutionEntityManager().findExecutionById(executionId); ProcessDefinitionImpl processDefinition = executionEntity.getProcessDefinition(); ActivityImpl activity = processDefinition.findActivity(activityId); executionEntity.executeActivity(activity); return null; } }
protected Date calculateDueDate(CommandContext commandContext, int waitTimeInSeconds, Date oldDate) { Calendar newDateCal = new GregorianCalendar(); if (oldDate != null) { newDateCal.setTime(oldDate); } else { newDateCal.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime()); } newDateCal.add(Calendar.SECOND, waitTimeInSeconds); return newDateCal.getTime(); }
public Void execute(CommandContext commandContext) { if (deploymentId == null) { throw new ActivitiIllegalArgumentException("Deployment id is null"); } DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("No deployment found for id = '" + deploymentId + "'", Deployment.class); } // Update category deployment.setKey(key); if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, deployment)); } return null; }
EventFlusher eventFlusher = (EventFlusher) currentCommandContext.getAttribute(EVENT_FLUSHER_KEY); eventFlusher = new DatabaseEventFlusher(); // Default currentCommandContext.addAttribute(EVENT_FLUSHER_KEY, eventFlusher); currentCommandContext.addCloseListener(eventFlusher); currentCommandContext .addCloseListener(new CommandContextCloseListener() {
@Override public void closeFailure(CommandContext commandContext) { if (commandContext.getEventDispatcher().isEnabled()) { commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityExceptionEvent( ActivitiEventType.JOB_EXECUTION_FAILURE, job, commandContext.getException())); } CommandConfig commandConfig = commandExecutor.getDefaultConfig().transactionRequiresNew(); FailedJobCommandFactory failedJobCommandFactory = commandContext.getFailedJobCommandFactory(); Command<Object> cmd = failedJobCommandFactory.getCommand(job.getId(), commandContext.getException()); log.trace("Using FailedJobCommandFactory '" + failedJobCommandFactory.getClass() + "' and command of type '" + cmd.getClass() + "'"); commandExecutor.execute(commandConfig, cmd); }
@Override public void eventCancelledByEventGateway(DelegateExecution execution) { JobEntityManager jobEntityManager = Context.getCommandContext().getJobEntityManager(); List<JobEntity> jobEntities = jobEntityManager.findJobsByExecutionId(execution.getId()); for (JobEntity jobEntity : jobEntities) { // Should be only one jobEntityManager.delete(jobEntity); } Context.getCommandContext().getExecutionEntityManager().deleteExecutionAndRelatedData((ExecutionEntity) execution, DeleteReason.EVENT_BASED_GATEWAY_CANCEL, false); }
public DeadLetterJobEntity execute(CommandContext commandContext) { if (jobId == null) { throw new ActivitiIllegalArgumentException("jobId and job is null"); } AbstractJobEntity job = commandContext.getTimerJobEntityManager().findById(jobId); if (job == null) { job = commandContext.getJobEntityManager().findById(jobId); } if (job == null) { throw new JobNotFoundException(jobId); } if (log.isDebugEnabled()) { log.debug("Moving job to deadletter job table {}", job.getId()); } DeadLetterJobEntity deadLetterJob = commandContext.getJobManager().moveJobToDeadLetterJob(job); return deadLetterJob; }
@Override public JobEntity execute(CommandContext commandContext) { return commandContext.getJobEntityManager().findById(jobId); } });
protected Void execute(CommandContext commandContext, TaskEntity task) { task.setPriority(priority); commandContext.getHistoryManager().recordTaskPriorityChange(task.getId(), task.getPriority()); commandContext.getTaskEntityManager().update(task); return null; }