Java Code Examples for org.activiti.engine.impl.persistence.entity.ExecutionEntity#getActivity()
The following examples show how to use
org.activiti.engine.impl.persistence.entity.ExecutionEntity#getActivity() .
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: AbstractEventHandler.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void dispatchExecutionCancelled(EventSubscriptionEntity eventSubscription, ExecutionEntity execution, CommandContext commandContext) { // subprocesses for (ExecutionEntity subExecution : execution.getExecutions()) { dispatchExecutionCancelled(eventSubscription, subExecution, commandContext); } // call activities ExecutionEntity subProcessInstance = commandContext.getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId()); if (subProcessInstance != null) { dispatchExecutionCancelled(eventSubscription, subProcessInstance, commandContext); } // activity with message/signal boundary events ActivityImpl activity = execution.getActivity(); if (activity != null && activity.getActivityBehavior() != null) { dispatchActivityCancelled(eventSubscription, execution, activity, commandContext); } }
Example 2
Source File: TimerExecuteNestedActivityJobHandler.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void dispatchExecutionTimeOut(Job job, ExecutionEntity execution, CommandContext commandContext) { // subprocesses for (ExecutionEntity subExecution : execution.getExecutions()) { dispatchExecutionTimeOut(job, subExecution, commandContext); } // call activities ExecutionEntity subProcessInstance = commandContext.getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId()); if (subProcessInstance != null) { dispatchExecutionTimeOut(job, subProcessInstance, commandContext); } // activity with timer boundary event ActivityImpl activity = execution.getActivity(); if (activity != null && activity.getActivityBehavior() != null) { dispatchActivityTimeOut(job, activity, execution, commandContext); } }
Example 3
Source File: SetProcessDefinitionVersionCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinitionEntity newProcessDefinition) { // check that the new process definition version contains the current activity if (execution.getActivity() != null && !newProcessDefinition.contains(execution.getActivity())) { throw new ActivitiException( "The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '" + execution.getActivity().getId() + "') " + "of the process instance " + "(id = '" + processInstanceId + "')."); } // switch the process instance to the new process definition version execution.setProcessDefinition(newProcessDefinition); // and change possible existing tasks (as the process definition id is stored there too) List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByExecutionId(execution.getId()); for (TaskEntity taskEntity : tasks) { taskEntity.setProcessDefinitionId(newProcessDefinition.getId()); commandContext.getHistoryManager().recordTaskProcessDefinitionChange(taskEntity.getId(), newProcessDefinition.getId()); } }
Example 4
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void recordActivityStart(ExecutionEntity executionEntity) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { if (executionEntity.getActivity() != null) { IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator(); String processDefinitionId = executionEntity.getProcessDefinitionId(); String processInstanceId = executionEntity.getProcessInstanceId(); String executionId = executionEntity.getId(); HistoricActivityInstanceEntity historicActivityInstance = new HistoricActivityInstanceEntity(); historicActivityInstance.setId(idGenerator.getNextId()); historicActivityInstance.setProcessDefinitionId(processDefinitionId); historicActivityInstance.setProcessInstanceId(processInstanceId); historicActivityInstance.setExecutionId(executionId); historicActivityInstance.setActivityId(executionEntity.getActivityId()); historicActivityInstance.setActivityName((String) executionEntity.getActivity().getProperty("name")); historicActivityInstance.setActivityType((String) executionEntity.getActivity().getProperty("type")); historicActivityInstance.setStartTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime()); // Inherit tenant id (if applicable) if (executionEntity.getTenantId() != null) { historicActivityInstance.setTenantId(executionEntity.getTenantId()); } getDbSqlSession().insert(historicActivityInstance); // Fire event ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); if (config != null && config.getEventDispatcher().isEnabled()) { config.getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance)); } } } }
Example 5
Source File: HumanTaskEventListener.java From lemon with Apache License 2.0 | 5 votes |
/** * 是否会签任务. */ public boolean isVote(DelegateTask delegateTask) { ExecutionEntity executionEntity = (ExecutionEntity) delegateTask .getExecution(); ActivityImpl activityImpl = executionEntity.getActivity(); return activityImpl.getProperty("multiInstance") != null; }
Example 6
Source File: HumanTaskTaskListener.java From lemon with Apache License 2.0 | 5 votes |
/** * 是否会签任务. */ public boolean isVote(DelegateTask delegateTask) { ExecutionEntity executionEntity = (ExecutionEntity) delegateTask .getExecution(); ActivityImpl activityImpl = executionEntity.getActivity(); return activityImpl.getProperty("multiInstance") != null; }
Example 7
Source File: AuthenticatedTimerJobHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void execute(final JobEntity job, final String configuration, final ExecutionEntity execution, final CommandContext commandContext) { String userName = null; String tenantToRunIn = (String) execution.getVariable(ActivitiConstants.VAR_TENANT_DOMAIN); if(tenantToRunIn != null && tenantToRunIn.trim().length() == 0) { tenantToRunIn = null; } final ActivitiScriptNode initiatorNode = (ActivitiScriptNode) execution.getVariable(WorkflowConstants.PROP_INITIATOR); // Extracting the properties from the initiatornode should be done in correct tennant or as administrator, since we don't // know who started the workflow yet (We can't access node-properties when no valid authentication context is set up). if(tenantToRunIn != null) { userName = TenantUtil.runAsTenant(new TenantRunAsWork<String>() { @Override public String doWork() throws Exception { return getInitiator(initiatorNode); } }, tenantToRunIn); } else { // No tenant on worklfow, run as admin in default tenant userName = AuthenticationUtil.runAs(new RunAsWork<String>() { @SuppressWarnings("synthetic-access") public String doWork() throws Exception { return getInitiator(initiatorNode); } }, AuthenticationUtil.getSystemUserName()); } // Fall back to task assignee, if no initiator is found if(userName == null) { PvmActivity targetActivity = execution.getActivity(); if (targetActivity != null) { // Only try getting active task, if execution timer is waiting on is a userTask String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE); if (ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType)) { Task task = new TaskQueryImpl(commandContext) .executionId(execution.getId()) .executeSingleResult(commandContext); if (task != null && task.getAssignee() != null) { userName = task.getAssignee(); } } } } // When no task assignee is set, nor the initiator, use system user to run job if (userName == null) { userName = AuthenticationUtil.getSystemUserName(); tenantToRunIn = null; } if(tenantToRunIn != null) { TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>() { @Override public Void doWork() throws Exception { wrappedHandler.execute(job, configuration, execution, commandContext); return null; } }, userName, tenantToRunIn); } else { // Execute the timer without tenant AuthenticationUtil.runAs(new RunAsWork<Void>() { @SuppressWarnings("synthetic-access") public Void doWork() throws Exception { wrappedHandler.execute(job, configuration, execution, commandContext); return null; } }, userName); } }
Example 8
Source File: ScopeUtil.java From flowable-engine with Apache License 2.0 | 4 votes |
/** * returns the top-most execution sitting in an activity part of the scope defined by 'scopeActivity'. */ public static ExecutionEntity findScopeExecutionForScope(ExecutionEntity execution, PvmScope scopeActivity) { // TODO: this feels hacky! if (scopeActivity instanceof PvmProcessDefinition) { return execution.getProcessInstance(); } else { ActivityImpl currentActivity = execution.getActivity(); ExecutionEntity candiadateExecution = null; ExecutionEntity originalExecution = execution; while (execution != null) { currentActivity = execution.getActivity(); if (scopeActivity.getActivities().contains(currentActivity) /* does not search rec */ || scopeActivity.equals(currentActivity)) { // found a candidate execution; lets still check whether we find an // execution which is also sitting in an activity part of this scope // higher up the hierarchy candiadateExecution = execution; } else if (currentActivity != null && currentActivity.contains((ActivityImpl) scopeActivity) /* searches rec */) { // now we're too "high", the candidate execution is the one. break; } execution = execution.getParent(); } // if activity is scope, we need to get the parent at least: if (originalExecution == candiadateExecution && originalExecution.getActivity().isScope() && !originalExecution.getActivity().equals(scopeActivity)) { candiadateExecution = originalExecution.getParent(); } return candiadateExecution; } }
Example 9
Source File: BoundaryEventActivityBehavior.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") public void execute(DelegateExecution execution) { ExecutionEntity executionEntity = (ExecutionEntity) execution; ActivityImpl boundaryActivity = executionEntity.getProcessDefinition().findActivity(activityId); ActivityImpl interruptedActivity = executionEntity.getActivity(); List<PvmTransition> outgoingTransitions = boundaryActivity.getOutgoingTransitions(); List<ExecutionEntity> interruptedExecutions = null; if (interrupting) { // Call activity if (executionEntity.getSubProcessInstance() != null) { executionEntity.getSubProcessInstance().deleteCascade(executionEntity.getDeleteReason()); } else { Context.getCommandContext().getHistoryManager().recordActivityEnd(executionEntity); } executionEntity.setActivity(boundaryActivity); interruptedExecutions = new ArrayList<>(executionEntity.getExecutions()); for (ExecutionEntity interruptedExecution : interruptedExecutions) { interruptedExecution.deleteCascade("interrupting boundary event '" + executionEntity.getActivity().getId() + "' fired"); } executionEntity.takeAll(outgoingTransitions, (List) interruptedExecutions); } else { // non interrupting event, introduced with BPMN 2.0, we need to create a new execution in this case // create a new execution and move it out from the timer activity ExecutionEntity concurrentRoot = executionEntity.getParent().isConcurrent() ? executionEntity.getParent() : executionEntity; ExecutionEntity outgoingExecution = concurrentRoot.createExecution(); outgoingExecution.setActive(true); outgoingExecution.setScope(false); outgoingExecution.setConcurrent(true); outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST); outgoingExecution.remove(); // now we have to move the execution back to the real activity // since the execution stays there (non interrupting) and it was // set to the boundary event before executionEntity.setActivity(interruptedActivity); } }
Example 10
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override public void recordSubProcessInstanceStart(ExecutionEntity parentExecution, ExecutionEntity subProcessInstance) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity(subProcessInstance); ActivityImpl initialActivity = subProcessInstance.getActivity(); // Fix for ACT-1728: startActivityId not initialized with subprocess-instance if (historicProcessInstance.getStartActivityId() == null) { historicProcessInstance.setStartActivityId(subProcessInstance.getProcessDefinition().getInitial().getId()); initialActivity = subProcessInstance.getProcessDefinition().getInitial(); } getDbSqlSession().insert(historicProcessInstance); // Fire event ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); if (config != null && config.getEventDispatcher().isEnabled()) { config.getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance)); } HistoricActivityInstanceEntity activityInstance = findActivityInstance(parentExecution); if (activityInstance != null) { activityInstance.setCalledProcessInstanceId(subProcessInstance.getProcessInstanceId()); } // Fix for ACT-1728: start-event not recorded for subprocesses IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator(); // Also record the start-event manually, as there is no "start" activity history listener for this HistoricActivityInstanceEntity historicActivityInstance = new HistoricActivityInstanceEntity(); historicActivityInstance.setId(idGenerator.getNextId()); historicActivityInstance.setProcessDefinitionId(subProcessInstance.getProcessDefinitionId()); historicActivityInstance.setProcessInstanceId(subProcessInstance.getProcessInstanceId()); historicActivityInstance.setExecutionId(subProcessInstance.getId()); historicActivityInstance.setActivityId(initialActivity.getId()); historicActivityInstance.setActivityName((String) initialActivity.getProperty("name")); historicActivityInstance.setActivityType((String) initialActivity.getProperty("type")); Date now = Context.getProcessEngineConfiguration().getClock().getCurrentTime(); historicActivityInstance.setStartTime(now); getDbSqlSession().insert(historicActivityInstance); // Fire event if (config != null && config.getEventDispatcher().isEnabled()) { config.getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance)); } } }