@Override public void migrateState() { ExecutionEntity representativeExecution = resolveRepresentativeExecution(); representativeExecution.setProcessDefinition(targetScope.getProcessDefinition()); representativeExecution.setActivity((PvmActivity) targetScope); }
/** * for setting the process definition, this setter must be used as subclasses * can override */ protected void ensureProcessDefinitionInitialized() { if ((processDefinition == null) && (processDefinitionId != null)) { ProcessDefinitionEntity deployedProcessDefinition = Context.getProcessEngineConfiguration().getDeploymentCache() .findDeployedProcessDefinitionById(processDefinitionId); setProcessDefinition(deployedProcessDefinition); } }
@Override public void migrateState() { migratingEventSubscription.migrateState(); eventScopeExecution.setActivity((ActivityImpl) targetScope); eventScopeExecution.setProcessDefinition(targetScope.getProcessDefinition()); currentScope = targetScope; }
@Override public void migrateState() { migratingEventSubscription.migrateState(); eventScopeExecution.setActivity((ActivityImpl) targetScope); eventScopeExecution.setProcessDefinition(targetScope.getProcessDefinition()); currentScope = targetScope; }
@Override public void migrateState() { ExecutionEntity representativeExecution = resolveRepresentativeExecution(); representativeExecution.setProcessDefinition(targetScope.getProcessDefinition()); representativeExecution.setActivity((PvmActivity) targetScope); }
/** * for setting the process definition, this setter must be used as subclasses * can override */ protected void ensureProcessDefinitionInitialized() { if ((processDefinition == null) && (processDefinitionId != null)) { ProcessDefinitionEntity deployedProcessDefinition = Context.getProcessEngineConfiguration().getDeploymentCache() .findDeployedProcessDefinitionById(processDefinitionId); setProcessDefinition(deployedProcessDefinition); } }
@Override public void migrateState() { ExecutionEntity currentExecution = resolveRepresentativeExecution(); currentExecution.setProcessDefinition(targetScope.getProcessDefinition()); currentExecution.setActivity((PvmActivity) targetScope); currentScope = targetScope; if (targetScope.isScope()) { becomeScope(); } migrateHistory(currentExecution); }
@Override public void migrateState() { ExecutionEntity currentExecution = resolveRepresentativeExecution(); currentExecution.setProcessDefinition(targetScope.getProcessDefinition()); currentExecution.setActivity((PvmActivity) targetScope); currentScope = targetScope; if (targetScope.isScope()) { becomeScope(); } migrateHistory(currentExecution); }
@Override public ExecutionEntity createProcessInstance(String businessKey, String caseInstanceId, ActivityImpl initial) { ensureNotSuspended(); ExecutionEntity processInstance = (ExecutionEntity) createProcessInstanceForInitial(initial); // do not reset executions (CAM-2557)! // processInstance.setExecutions(new ArrayList<ExecutionEntity>()); processInstance.setProcessDefinition(processDefinition); // Do not initialize variable map (let it happen lazily) // reset the process instance in order to have the db-generated process instance id available processInstance.setProcessInstance(processInstance); // initialize business key if (businessKey != null) { processInstance.setBusinessKey(businessKey); } // initialize case instance id if (caseInstanceId != null) { processInstance.setCaseInstanceId(caseInstanceId); } if(tenantId != null) { processInstance.setTenantId(tenantId); } return processInstance; }
@Override public ExecutionEntity createProcessInstance(String businessKey, String caseInstanceId, ActivityImpl initial) { ensureNotSuspended(); ExecutionEntity processInstance = (ExecutionEntity) createProcessInstanceForInitial(initial); // do not reset executions (CAM-2557)! // processInstance.setExecutions(new ArrayList<ExecutionEntity>()); processInstance.setProcessDefinition(processDefinition); // Do not initialize variable map (let it happen lazily) // reset the process instance in order to have the db-generated process instance id available processInstance.setProcessInstance(processInstance); // initialize business key if (businessKey != null) { processInstance.setBusinessKey(businessKey); } // initialize case instance id if (caseInstanceId != null) { processInstance.setCaseInstanceId(caseInstanceId); } if(tenantId != null) { processInstance.setTenantId(tenantId); } return processInstance; }
@Override public void migrateState() { ExecutionEntity currentScopeExecution = resolveRepresentativeExecution(); currentScopeExecution.setProcessDefinition(targetScope.getProcessDefinition()); ExecutionEntity parentExecution = currentScopeExecution.getParent(); if (parentExecution != null && parentExecution.isConcurrent()) { parentExecution.setProcessDefinition(targetScope.getProcessDefinition()); } currentScope = targetScope; if (!targetScope.isScope()) { becomeNonScope(); currentScopeExecution = resolveRepresentativeExecution(); } if (isLeafActivity(targetScope)) { currentScopeExecution.setActivity((PvmActivity) targetScope); } if (sourceScope.getActivityBehavior() instanceof MigrationObserverBehavior) { ((MigrationObserverBehavior) sourceScope.getActivityBehavior()).migrateScope(currentScopeExecution); } migrateHistory(currentScopeExecution); }
@Override public void migrateState() { ExecutionEntity currentScopeExecution = resolveRepresentativeExecution(); currentScopeExecution.setProcessDefinition(targetScope.getProcessDefinition()); ExecutionEntity parentExecution = currentScopeExecution.getParent(); if (parentExecution != null && parentExecution.isConcurrent()) { parentExecution.setProcessDefinition(targetScope.getProcessDefinition()); } currentScope = targetScope; if (!targetScope.isScope()) { becomeNonScope(); currentScopeExecution = resolveRepresentativeExecution(); } if (isLeafActivity(targetScope)) { currentScopeExecution.setActivity((PvmActivity) targetScope); } if (sourceScope.getActivityBehavior() instanceof MigrationObserverBehavior) { ((MigrationObserverBehavior) sourceScope.getActivityBehavior()).migrateScope(currentScopeExecution); } migrateHistory(currentScopeExecution); }
protected boolean evaluateCondition(ConditionSet conditionSet, ActivityImpl activity) { ExecutionEntity temporaryExecution = new ExecutionEntity(); if (conditionSet.getVariables() != null) { temporaryExecution.initializeVariableStore(conditionSet.getVariables()); } temporaryExecution.setProcessDefinition(activity.getProcessDefinition()); ConditionalEventDefinition conditionalEventDefinition = activity.getProperties().get(BpmnProperties.CONDITIONAL_EVENT_DEFINITION); if (conditionalEventDefinition.getVariableName() == null || conditionSet.getVariables().containsKey(conditionalEventDefinition.getVariableName())) { return conditionalEventDefinition.tryEvaluate(temporaryExecution); } else { return false; } }
protected boolean evaluateCondition(ConditionSet conditionSet, ActivityImpl activity) { ExecutionEntity temporaryExecution = new ExecutionEntity(); if (conditionSet.getVariables() != null) { temporaryExecution.initializeVariableStore(conditionSet.getVariables()); } temporaryExecution.setProcessDefinition(activity.getProcessDefinition()); ConditionalEventDefinition conditionalEventDefinition = activity.getProperties().get(BpmnProperties.CONDITIONAL_EVENT_DEFINITION); if (conditionalEventDefinition.getVariableName() == null || conditionSet.getVariables().containsKey(conditionalEventDefinition.getVariableName())) { return conditionalEventDefinition.tryEvaluate(temporaryExecution); } else { return false; } }
protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinitionEntity newProcessDefinition) { // check that the new process definition version contains the current activity if (execution.getActivity() != null) { String activityId = execution.getActivity().getId(); PvmActivity newActivity = newProcessDefinition.findActivity(activityId); if (newActivity == null) { throw new ProcessEngineException( "The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '" + activityId + "') " + "of the process instance " + "(id = '" + processInstanceId + "')."); } // clear cached activity so that outgoing transitions are refreshed execution.setActivity(newActivity); } // 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.getTaskManager().findTasksByExecutionId(execution.getId()); for (TaskEntity taskEntity : tasks) { taskEntity.setProcessDefinitionId(newProcessDefinition.getId()); } }
protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinitionEntity newProcessDefinition) { // check that the new process definition version contains the current activity if (execution.getActivity() != null) { String activityId = execution.getActivity().getId(); PvmActivity newActivity = newProcessDefinition.findActivity(activityId); if (newActivity == null) { throw new ProcessEngineException( "The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '" + activityId + "') " + "of the process instance " + "(id = '" + processInstanceId + "')."); } // clear cached activity so that outgoing transitions are refreshed execution.setActivity(newActivity); } // 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.getTaskManager().findTasksByExecutionId(execution.getId()); for (TaskEntity taskEntity : tasks) { taskEntity.setProcessDefinitionId(newProcessDefinition.getId()); } }
createdExecution.setProcessDefinition(getProcessDefinition()); createdExecution.setProcessInstance(getProcessInstance()); createdExecution.setActivity(getActivity());
createdExecution.setProcessDefinition(getProcessDefinition()); createdExecution.setProcessInstance(getProcessInstance()); createdExecution.setActivity(getActivity());
public void testExecutionEntitySerialization() throws Exception { ExecutionEntity execution = new ExecutionEntity(); ActivityImpl activityImpl = new ActivityImpl("test", null); activityImpl.getExecutionListeners().put("start", Collections.<ExecutionListener>singletonList(new TestExecutionListener())); execution.setActivity(activityImpl); ProcessDefinitionImpl processDefinitionImpl = new ProcessDefinitionImpl("test"); processDefinitionImpl.getExecutionListeners().put("start", Collections.<ExecutionListener>singletonList(new TestExecutionListener())); execution.setProcessDefinition(processDefinitionImpl); TransitionImpl transitionImpl = new TransitionImpl("test", new ProcessDefinitionImpl("test")); transitionImpl.addExecutionListener(new TestExecutionListener()); execution.setTransition(transitionImpl); execution.getProcessInstanceStartContext().setInitial(activityImpl); execution.setSuperExecution(new ExecutionEntity()); execution.setActive(true); execution.setCanceled(false); execution.setBusinessKey("myBusinessKey"); execution.setDeleteReason("no reason"); execution.setActivityInstanceId("123"); execution.setScope(false); byte[] data = writeObject(execution); execution = (ExecutionEntity) readObject(data); assertEquals("myBusinessKey", execution.getBusinessKey()); assertEquals("no reason", execution.getDeleteReason()); assertEquals("123", execution.getActivityInstanceId()); }
@Override public void migrateState() { migratingEventSubscription.migrateState(); eventScopeExecution.setActivity((ActivityImpl) targetScope); eventScopeExecution.setProcessDefinition(targetScope.getProcessDefinition()); currentScope = targetScope; }