@SuppressWarnings("unchecked") public U singleResult() { this.resultType = ResultType.SINGLE_RESULT; if (commandExecutor != null) { return (U) commandExecutor.execute(this); } return executeSingleResult(Context.getCommandContext()); }
protected void ensureEventSubscriptionsInitialized() { if (eventSubscriptions == null) { eventSubscriptions = Context.getCommandContext().getEventSubscriptionEntityManager().findEventSubscriptionsByExecution(id); } }
protected void ensureJobsInitialized() { if (jobs == null) { jobs = Context.getCommandContext().getJobEntityManager().findJobsByExecutionId(id); } }
public TaskEntity getTask() { if ((task == null) && (taskId != null)) { this.task = Context.getCommandContext().getTaskEntityManager().findById(taskId); } return task; }
@Override public void trigger(DelegateExecution execution, String triggerName, Object triggerData) { ExecutionEntity executionEntity = (ExecutionEntity) execution; CommandContext commandContext = Context.getCommandContext(); if (interrupting) { executeInterruptingBehavior(executionEntity, commandContext); } else { executeNonInterruptingBehavior(executionEntity, commandContext); } }
protected void ensureSuperExecutionInitialized() { if (superExecution == null && superExecutionId != null) { superExecution = (ExecutionEntityImpl) Context.getCommandContext().getExecutionEntityManager().findById(superExecutionId); } }
protected void deleteVariableInstanceForExplicitUserCall(VariableInstanceEntity variableInstance, ExecutionEntity sourceActivityExecution) { Context.getCommandContext().getVariableInstanceEntityManager().delete(variableInstance); variableInstance.setValue(null); // Record historic variable deletion Context.getCommandContext().getHistoryManager().recordVariableRemoved(variableInstance); // Record historic detail Context.getCommandContext().getHistoryManager().recordHistoricDetailVariableCreate(variableInstance, sourceActivityExecution, isActivityIdUsedForDetails()); }
@Override protected VariableInstanceEntity getSpecificVariable(String variableName) { CommandContext commandContext = Context.getCommandContext(); if (commandContext == null) { throw new ActivitiException("lazy loading outside command context"); } VariableInstanceEntity variableInstance = commandContext.getVariableInstanceEntityManager().findVariableInstanceByExecutionAndName(id, variableName); return variableInstance; }
@Override protected List<VariableInstanceEntity> getSpecificVariables(Collection<String> variableNames) { CommandContext commandContext = Context.getCommandContext(); if (commandContext == null) { throw new ActivitiException("lazy loading outside command context"); } return commandContext.getVariableInstanceEntityManager().findVariableInstancesByExecutionAndNames(id, variableNames); }
private void ensureInitialized() { if (id != null && entity == null) { entity = Context.getCommandContext().getByteArrayEntityManager().findById(id); name = entity.getName(); } }
@Override public void eventCancelledByEventGateway(DelegateExecution execution) { deleteMessageEventSubScription(execution); Context.getCommandContext().getExecutionEntityManager().deleteExecutionAndRelatedData((ExecutionEntity) execution, DeleteReason.EVENT_BASED_GATEWAY_CANCEL, false); }
@Override public void eventCancelledByEventGateway(DelegateExecution execution) { deleteSignalEventSubscription(execution); Context.getCommandContext().getExecutionEntityManager().deleteExecutionAndRelatedData((ExecutionEntity) execution, DeleteReason.EVENT_BASED_GATEWAY_CANCEL, false); }
@SuppressWarnings("unchecked") public List<U> list() { this.resultType = ResultType.LIST; if (commandExecutor != null) { return (List<U>) commandExecutor.execute(this); } return executeList(Context.getCommandContext(), getParameterMap(), 0, Integer.MAX_VALUE); }
public long count() { this.resultType = ResultType.COUNT; if (commandExecutor != null) { return (Long) commandExecutor.execute(this); } return executeCount(Context.getCommandContext(), getParameterMap()); }
@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); }
protected ExecutionEntity deleteMessageEventSubScription(DelegateExecution execution) { ExecutionEntity executionEntity = (ExecutionEntity) execution; EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager(); List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions(); for (EventSubscriptionEntity eventSubscription : eventSubscriptions) { if (eventSubscription instanceof MessageEventSubscriptionEntity && eventSubscription.getEventName().equals(messageEventDefinition.getMessageRef())) { eventSubscriptionEntityManager.delete(eventSubscription); } } return executionEntity; } }
public void trigger(DelegateExecution execution, String signalName, Object signalData) { CommandContext commandContext = Context.getCommandContext(); TaskEntityManager taskEntityManager = commandContext.getTaskEntityManager(); List<TaskEntity> taskEntities = taskEntityManager.findTasksByExecutionId(execution.getId()); // Should be only one for (TaskEntity taskEntity : taskEntities) { if (!taskEntity.isDeleted()) { throw new ActivitiException("UserTask should not be signalled before complete"); } } leave(execution); }
@Override public void scheduleTimerJob(TimerJobEntity timerJob) { if (timerJob == null) { throw new ActivitiException("Empty timer job can not be scheduled"); } processEngineConfiguration.getTimerJobEntityManager().insert(timerJob); CommandContext commandContext = Context.getCommandContext(); ActivitiEventDispatcher eventDispatcher = commandContext.getEventDispatcher(); if (eventDispatcher.isEnabled()) { eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.TIMER_SCHEDULED, timerJob)); } }
protected void dispatchProcessDefinitionEntityInitializedEvent(ParsedDeployment parsedDeployment) { CommandContext commandContext = Context.getCommandContext(); for (ProcessDefinitionEntity processDefinitionEntity : parsedDeployment.getAllProcessDefinitions()) { log.info("Process deployed: {id: " + processDefinitionEntity.getId() + ", key: " + processDefinitionEntity.getKey() + ", name: " + processDefinitionEntity.getName() +" }"); if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, processDefinitionEntity)); } } }
@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; } }