@Override public boolean isDetached() { ExecutionEntity representativeExecution = resolveRepresentativeExecution(); return representativeExecution != representativeExecution.getProcessInstance() && representativeExecution.getParent() == null; }
protected void initActivityInstanceEvent(HistoricActivityInstanceEventEntity evt, ExecutionEntity execution, HistoryEventType eventType) { PvmScope eventSource = execution.getActivity(); if (eventSource == null) { eventSource = (PvmScope) execution.getEventSource(); } String activityInstanceId = execution.getActivityInstanceId(); String parentActivityInstanceId = null; ExecutionEntity parentExecution = execution.getParent(); if (parentExecution != null && CompensationBehavior.isCompensationThrowing(parentExecution) && execution.getActivity() != null) { parentActivityInstanceId = CompensationBehavior.getParentActivityInstanceId(execution); } else { parentActivityInstanceId = execution.getParentActivityInstanceId(); } initActivityInstanceEvent(evt, execution, eventSource, activityInstanceId, parentActivityInstanceId, eventType); }
@Override public boolean isDetached() { ExecutionEntity representativeExecution = resolveRepresentativeExecution(); return representativeExecution != representativeExecution.getProcessInstance() && representativeExecution.getParent() == null; }
protected void addEventToScopeExecution(ExecutionEntity sourceScope, VariableEvent event) { // ignore events of variables that are not set in an execution ExecutionEntity sourceExecution = sourceScope; ExecutionEntity scopeExecution = sourceExecution.isScope() ? sourceExecution : sourceExecution.getParent(); scopeExecution.delayEvent((ExecutionEntity) targetScope, event); } }
protected void addEventToScopeExecution(ExecutionEntity sourceScope, VariableEvent event) { // ignore events of variables that are not set in an execution ExecutionEntity sourceExecution = sourceScope; ExecutionEntity scopeExecution = sourceExecution.isScope() ? sourceExecution : sourceExecution.getParent(); scopeExecution.delayEvent((ExecutionEntity) targetScope, event); } }
@Override public void destroyAttachableExecution(ExecutionEntity execution) { if (currentScope.getActivityBehavior() instanceof ModificationObserverBehavior) { ModificationObserverBehavior behavior = (ModificationObserverBehavior) currentScope.getActivityBehavior(); behavior.destroyInnerInstance(execution); } else { if (execution.isConcurrent()) { execution.remove(); execution.getParent().tryPruneLastConcurrentChild(); execution.getParent().forceUpdate(); } } } }
@Override public void attachState(MigratingScopeInstance owningActivityInstance) { ExecutionEntity representativeExecution = owningActivityInstance.resolveRepresentativeExecution(); ScopeImpl currentScope = owningActivityInstance.getCurrentScope(); ExecutionEntity newOwningExecution = representativeExecution; if (currentScope.isScope() && isConcurrentLocalInParentScope) { newOwningExecution = representativeExecution.getParent(); } newOwningExecution.addVariableInternal(variable); }
@Override public void attachState(MigratingScopeInstance owningActivityInstance) { ExecutionEntity representativeExecution = owningActivityInstance.resolveRepresentativeExecution(); ScopeImpl currentScope = owningActivityInstance.getCurrentScope(); ExecutionEntity newOwningExecution = representativeExecution; if (currentScope.isScope() && isConcurrentLocalInParentScope) { newOwningExecution = representativeExecution.getParent(); } newOwningExecution.addVariableInternal(variable); }
@Override public void destroyAttachableExecution(ExecutionEntity execution) { if (currentScope.getActivityBehavior() instanceof ModificationObserverBehavior) { ModificationObserverBehavior behavior = (ModificationObserverBehavior) currentScope.getActivityBehavior(); behavior.destroyInnerInstance(execution); } else { if (execution.isConcurrent()) { execution.remove(); execution.getParent().tryPruneLastConcurrentChild(); execution.getParent().forceUpdate(); } } } }
@Override public void detachState() { ExecutionEntity currentScopeExecution = resolveRepresentativeExecution(); ExecutionEntity parentExecution = currentScopeExecution.getParent(); currentScopeExecution.setParent(null); if (sourceScope.getActivityBehavior() instanceof CompositeActivityBehavior) { parentExecution.leaveActivityInstance(); } getParent().destroyAttachableExecution(parentExecution); }
@Override public void detachState() { ExecutionEntity currentScopeExecution = resolveRepresentativeExecution(); ExecutionEntity parentExecution = currentScopeExecution.getParent(); currentScopeExecution.setParent(null); if (sourceScope.getActivityBehavior() instanceof CompositeActivityBehavior) { parentExecution.leaveActivityInstance(); } getParent().destroyAttachableExecution(parentExecution); }
@Override public void handle(MigratingInstanceParseContext parseContext, MigratingProcessElementInstance owningInstance, List<VariableInstanceEntity> variables) { ExecutionEntity representativeExecution = owningInstance.resolveRepresentativeExecution(); for (VariableInstanceEntity variable : variables) { parseContext.consume(variable); boolean isConcurrentLocalInParentScope = (variable.getExecution() == representativeExecution.getParent() && variable.isConcurrentLocal()) || representativeExecution.isConcurrent(); owningInstance.addMigratingDependentInstance(new MigratingVariableInstance(variable, isConcurrentLocalInParentScope)); } } }
@Override public void handle(MigratingInstanceParseContext parseContext, MigratingProcessElementInstance owningInstance, List<VariableInstanceEntity> variables) { ExecutionEntity representativeExecution = owningInstance.resolveRepresentativeExecution(); for (VariableInstanceEntity variable : variables) { parseContext.consume(variable); boolean isConcurrentLocalInParentScope = (variable.getExecution() == representativeExecution.getParent() && variable.isConcurrentLocal()) || representativeExecution.isConcurrent(); owningInstance.addMigratingDependentInstance(new MigratingVariableInstance(variable, isConcurrentLocalInParentScope)); } } }
protected void becomeNonScope() { for (MigratingInstance dependentInstance : migratingDependentInstances) { dependentInstance.detachState(); } ExecutionEntity parentExecution = representativeExecution.getParent(); parentExecution.setActivity(representativeExecution.getActivity()); parentExecution.setActivityInstanceId(representativeExecution.getActivityInstanceId()); representativeExecution.remove(); representativeExecution = parentExecution; for (MigratingInstance dependentInstance : migratingDependentInstances) { dependentInstance.attachState(MigratingActivityInstance.this); } instanceBehavior = new MigratingNonScopeActivityInstanceBehavior(); }
protected void becomeNonScope() { for (MigratingInstance dependentInstance : migratingDependentInstances) { dependentInstance.detachState(); } ExecutionEntity parentExecution = representativeExecution.getParent(); parentExecution.setActivity(representativeExecution.getActivity()); parentExecution.setActivityInstanceId(representativeExecution.getActivityInstanceId()); representativeExecution.remove(); representativeExecution = parentExecution; for (MigratingInstance dependentInstance : migratingDependentInstances) { dependentInstance.attachState(MigratingActivityInstance.this); } instanceBehavior = new MigratingNonScopeActivityInstanceBehavior(); }
protected void becomeScope() { for (MigratingInstance dependentInstance : migratingDependentInstances) { dependentInstance.detachState(); } ExecutionEntity currentExecution = resolveRepresentativeExecution(); currentExecution = currentExecution.createExecution(); ExecutionEntity parent = currentExecution.getParent(); parent.setActivity(null); if (!parent.isConcurrent()) { parent.leaveActivityInstance(); } representativeExecution = currentExecution; for (MigratingInstance dependentInstance : migratingDependentInstances) { dependentInstance.attachState(MigratingActivityInstance.this); } instanceBehavior = new MigratingScopeActivityInstanceBehavior(); }
protected void becomeScope() { for (MigratingInstance dependentInstance : migratingDependentInstances) { dependentInstance.detachState(); } ExecutionEntity currentExecution = resolveRepresentativeExecution(); currentExecution = currentExecution.createExecution(); ExecutionEntity parent = currentExecution.getParent(); parent.setActivity(null); if (!parent.isConcurrent()) { parent.leaveActivityInstance(); } representativeExecution = currentExecution; for (MigratingInstance dependentInstance : migratingDependentInstances) { dependentInstance.attachState(MigratingActivityInstance.this); } instanceBehavior = new MigratingScopeActivityInstanceBehavior(); }
@Override public void remove(boolean skipCustomListeners, boolean skipIoMappings) { ExecutionEntity currentExecution = resolveRepresentativeExecution(); ExecutionEntity parentExecution = currentExecution.getParent(); currentExecution.setActivity((PvmActivity) sourceScope); currentExecution.setActivityInstanceId(activityInstance.getId()); currentExecution.deleteCascade("migration", skipCustomListeners, skipIoMappings); getParent().destroyAttachableExecution(parentExecution); setParent(null); for (MigratingTransitionInstance child : childTransitionInstances) { child.setParent(null); } for (MigratingActivityInstance child : childActivityInstances) { child.setParent(null); } for (MigratingEventScopeInstance child : childCompensationInstances) { child.setParent(null); } }
@Override public void remove(boolean skipCustomListeners, boolean skipIoMappings) { ExecutionEntity currentExecution = resolveRepresentativeExecution(); ExecutionEntity parentExecution = currentExecution.getParent(); currentExecution.setActivity((PvmActivity) sourceScope); currentExecution.setActivityInstanceId(activityInstance.getId()); currentExecution.deleteCascade("migration", skipCustomListeners, skipIoMappings); getParent().destroyAttachableExecution(parentExecution); setParent(null); for (MigratingTransitionInstance child : childTransitionInstances) { child.setParent(null); } for (MigratingActivityInstance child : childActivityInstances) { child.setParent(null); } for (MigratingEventScopeInstance child : childCompensationInstances) { child.setParent(null); } }
@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); }