/// <summary> /// Creates an emerged activity instance /// </summary> public MigratingActivityInstance(ScopeImpl targetScope, ExecutionEntity scopeExecution) { this.targetScope = targetScope; currentScope = targetScope; RepresentativeExecution = scopeExecution; InstanceBehavior = DetermineBehavior(targetScope); }
public virtual void handle(MigratingInstanceParseContext parseContext, TransitionInstance transitionInstance) { if (!isAsyncTransitionInstance(transitionInstance)) { return; } MigrationInstruction applyingInstruction = parseContext.getInstructionFor(transitionInstance.ActivityId); ScopeImpl sourceScope = parseContext.SourceProcessDefinition.findActivity(transitionInstance.ActivityId); ScopeImpl targetScope = null; if (applyingInstruction != null) { string activityId = applyingInstruction.TargetActivityId; targetScope = parseContext.TargetProcessDefinition.findActivity(activityId); } ExecutionEntity asyncExecution = Context.CommandContext.ExecutionManager.findExecutionById(transitionInstance.ExecutionId); MigratingTransitionInstance migratingTransitionInstance = parseContext.MigratingProcessInstance.addTransitionInstance(applyingInstruction, transitionInstance, sourceScope, targetScope, asyncExecution); MigratingActivityInstance parentInstance = parseContext.getMigratingActivityInstanceById(transitionInstance.ParentActivityInstanceId); migratingTransitionInstance.setParent(parentInstance); IList <JobEntity> jobs = asyncExecution.Jobs; parseContext.handleDependentTransitionInstanceJobs(migratingTransitionInstance, jobs); parseContext.handleDependentVariables(migratingTransitionInstance, collectTransitionInstanceVariables(migratingTransitionInstance)); }
protected internal virtual IDictionary <string, EventSubscriptionDeclaration> GetDeclarationsByTriggeringActivity (ScopeImpl eventScope) { var declarations = EventSubscriptionDeclaration.GetDeclarationsForScope(eventScope); return(new Dictionary <string, EventSubscriptionDeclaration>(declarations)); }
public virtual void validate(ValidatingMigrationInstruction instruction, ValidatingMigrationInstructions instructions, MigrationInstructionValidationReportImpl report) { ActivityImpl sourceActivity = instruction.SourceActivity; if (isCompensationBoundaryEvent(sourceActivity)) { // this is not required for compensation boundary events since their // event scopes need not be active at runtime return; } ScopeImpl sourceEventScope = instruction.SourceActivity.EventScope; ScopeImpl targetEventScope = instruction.TargetActivity.EventScope; if (sourceEventScope == null || sourceEventScope == sourceActivity.FlowScope) { // event scopes must only match if the event scopes are not the flow scopes // => validation necessary for boundary events; // => validation not necessary for event subprocesses return; } if (targetEventScope == null) { report.addFailure("The source activity's event scope (" + sourceEventScope.Id + ") must be mapped but the " + "target activity has no event scope"); } else { ScopeImpl mappedSourceEventScope = findMappedEventScope(sourceEventScope, instruction, instructions); if (mappedSourceEventScope == null || !mappedSourceEventScope.Id.Equals(targetEventScope.Id)) { report.addFailure("The source activity's event scope (" + sourceEventScope.Id + ") " + "must be mapped to the target activity's event scope (" + targetEventScope.Id + ")"); } } }
protected internal virtual void HandleChildRemovalInScope(ExecutionEntity removedExecution) { // TODO: the following should be closer to PvmAtomicOperationDeleteCascadeFireActivityEnd // (note though that e.g. boundary events expect concurrent executions to be preserved) // // Idea: attempting to prune and synchronize on the parent is the default behavior when // a concurrent child is removed, but scope activities implementing ModificationObserverBehavior // override this default (and thereforemust* take care of reorganization themselves) // notify the behavior that a concurrent execution has been removed // must be set due to deleteCascade behavior ActivityImpl activity = removedExecution.Activity as ActivityImpl; ScopeImpl flowScope = activity.FlowScope; IActivityExecution scopeExecution = removedExecution.GetParentScopeExecution(false); IActivityExecution executionInParentScope = removedExecution.IsConcurrent ? removedExecution : removedExecution.Parent; if (flowScope.ActivityBehavior != null && flowScope.ActivityBehavior is IModificationObserverBehavior) { // let child removal be handled by the scope itself IModificationObserverBehavior behavior = (IModificationObserverBehavior)flowScope.ActivityBehavior; behavior.DestroyInnerInstance(executionInParentScope); } else { if (executionInParentScope.IsConcurrent) { executionInParentScope.Remove(); scopeExecution.TryPruneLastConcurrentChild(); scopeExecution.ForceUpdate(); } } }
public override void execute(PvmExecutionImpl execution) { ScopeImpl scope = getScope(execution); int executionListenerIndex = execution.ListenerIndex; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<org.camunda.bpm.engine.delegate.DelegateListener<? extends org.camunda.bpm.engine.delegate.BaseDelegateExecution>> executionListeners = scope.getListeners(getEventName()); IList <DelegateListener <BaseDelegateExecution> > executionListeners = scope.getListeners(EventName); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (org.camunda.bpm.engine.delegate.DelegateListener<? extends org.camunda.bpm.engine.delegate.BaseDelegateExecution> listener : executionListeners) foreach (DelegateListener <BaseDelegateExecution> listener in executionListeners) { execution.EventName = EventName; execution.EventSource = scope; try { execution.invokeListener(listener); } catch (Exception e) { throw e; } catch (Exception e) { throw new PvmException("couldn't execute event listener : " + e.Message, e); } executionListenerIndex += 1; execution.ListenerIndex = executionListenerIndex; } execution.ListenerIndex = 0; execution.EventName = null; execution.EventSource = null; eventNotificationsCompleted(execution); }
/// <summary> /// In case the process instance was migrated from a previous version, activities which are now parsed as scopes /// do not have scope executions. Use the flow scopes of these activities in order to find their execution. /// - For an event subprocess this is the scope execution of the scope in which the event subprocess is embeded in /// - For a multi instance sequential subprocess this is the multi instace scope body. /// </summary> /// <param name="targetScope"> </param> /// <param name="activityExecutionMapping"> /// @return /// </param> public static PvmExecutionImpl GetScopeExecution(ScopeImpl scope, IDictionary <ScopeImpl, PvmExecutionImpl> activityExecutionMapping) { var flowScope = scope.FlowScope; return(activityExecutionMapping[flowScope]); }
public virtual void Generate(ScopeImpl sourceScope, ScopeImpl targetScope, ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition, ValidatingMigrationInstructions existingInstructions, bool updateEventTriggers) { var flowScopeInstructions = GenerateInstructionsForActivities((ICollection <ActivityImpl>)sourceScope.Activities, (ICollection <ActivityImpl>)targetScope.Activities, updateEventTriggers, existingInstructions); existingInstructions.AddAll(flowScopeInstructions); var eventScopeInstructions = GenerateInstructionsForActivities(sourceScope.EventActivities, targetScope.EventActivities, updateEventTriggers, existingInstructions); existingInstructions.AddAll(eventScopeInstructions); existingInstructions.FilterWith(MigrationInstructionValidatorsRenamed); foreach (var generatedInstruction in flowScopeInstructions) { if (existingInstructions.Contains(generatedInstruction)) { Generate((ScopeImpl)generatedInstruction.SourceActivity, (ScopeImpl)generatedInstruction.TargetActivity, sourceProcessDefinition, targetProcessDefinition, existingInstructions, updateEventTriggers); } } }
/// <summary> /// Remove all entries for legacy non-scopes given that the assigned scope execution is also responsible for another scope /// </summary> public static void removeLegacyNonScopesFromMapping(IDictionary <ScopeImpl, PvmExecutionImpl> mapping) { IDictionary <PvmExecutionImpl, IList <ScopeImpl> > scopesForExecutions = new Dictionary <PvmExecutionImpl, IList <ScopeImpl> >(); foreach (KeyValuePair <ScopeImpl, PvmExecutionImpl> mappingEntry in mapping.SetOfKeyValuePairs()) { IList <ScopeImpl> scopesForExecution = scopesForExecutions[mappingEntry.Value]; if (scopesForExecution == null) { scopesForExecution = new List <ScopeImpl>(); scopesForExecutions[mappingEntry.Value] = scopesForExecution; } scopesForExecution.Add(mappingEntry.Key); } foreach (KeyValuePair <PvmExecutionImpl, IList <ScopeImpl> > scopesForExecution in scopesForExecutions.SetOfKeyValuePairs()) { IList <ScopeImpl> scopes = scopesForExecution.Value; if (scopes.Count > 1) { ScopeImpl topMostScope = getTopMostScope(scopes); foreach (ScopeImpl scope in scopes) { if (scope != scope.ProcessDefinition && scope != topMostScope) { mapping.Remove(scope); } } } } }
public MigratingTimerJobInstance(JobEntity jobEntity, JobDefinitionEntity jobDefinitionEntity, ScopeImpl targetScope, bool updateEvent, TimerDeclarationImpl targetTimerDeclaration) : base(jobEntity, jobDefinitionEntity, targetScope) { TimerTriggerTargetScope = DetermineTimerTriggerTargetScope(jobEntity, targetScope); this.UpdateEvent = updateEvent; TargetJobDeclaration = targetTimerDeclaration; }
/// <summary> /// Cannot create more than inner instance in a sequential MI construct /// </summary> protected internal virtual bool supportsConcurrentChildInstantiation(ScopeImpl flowScope) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.camunda.bpm.engine.impl.core.delegate.CoreActivityBehavior<?> behavior = flowScope.getActivityBehavior(); CoreActivityBehavior <object> behavior = flowScope.ActivityBehavior; return(behavior == null || !(behavior is SequentialMultiInstanceActivityBehavior)); }
public MigratingEventSubscriptionInstance(EventSubscriptionEntity eventSubscriptionEntity, ScopeImpl targetScope, bool updateEvent, EventSubscriptionDeclaration targetDeclaration) { this.EventSubscriptionEntity = eventSubscriptionEntity; this.TargetScope = targetScope; this.UpdateEvent = updateEvent; this.TargetDeclaration = targetDeclaration; }
public virtual void TestParseCompensationHandlerOfMiSubprocess() { ActivityImpl miActivity = FindActivityInDeployedProcessDefinition("undoBookHotel"); ScopeImpl flowScope = miActivity.FlowScope; Assert.AreEqual(ActivityTypes.MultiInstanceBody, flowScope.GetProperty(BpmnParse.PropertynameType)); Assert.AreEqual("scope" + BpmnParse.MultiInstanceBodyIdSuffix, ((ActivityImpl)flowScope).ActivityId); }
public override void doLeave(ActivityExecution execution) { // continue via the appropriate cancel boundary event ScopeImpl eventScope = (ScopeImpl)cancelBoundaryEvent.EventScope; ActivityExecution boundaryEventScopeExecution = execution.findExecutionForFlowScope(eventScope); boundaryEventScopeExecution.executeActivity(cancelBoundaryEvent); }
public override void parseBoundaryEvent(Element boundaryEventElement, ScopeImpl scopeElement, ActivityImpl nestedActivity) { string type = nestedActivity.Properties.get(BpmnProperties.TYPE); if ((!string.ReferenceEquals(type, null) && type.Equals(BOUNDARY_TIMER)) || isAsync(nestedActivity)) { setFailedJobRetryTimeCycleValue(boundaryEventElement, nestedActivity); } }
public override void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) { string type = startEventActivity.Properties.get(BpmnProperties.TYPE); if (!string.ReferenceEquals(type, null) && type.Equals(START_TIMER_EVENT) || isAsync(startEventActivity)) { this.setFailedJobRetryTimeCycleValue(startEventElement, startEventActivity); } }
public override void ParseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) { var type = startEventActivity.Properties.Get(BpmnProperties.Type); if (!ReferenceEquals(type, null) && type.Equals(StartTimerEvent)) { SetFailedJobRetryTimeCycleValue(startEventElement, startEventActivity); } }
public virtual void migrateState() { ScopeImpl targetActivity = migratingActivityInstance.TargetScope; ProcessDefinition targetProcessDefinition = (ProcessDefinition)targetActivity.ProcessDefinition; externalTask.ActivityId = targetActivity.Id; externalTask.ProcessDefinitionId = targetProcessDefinition.Id; externalTask.ProcessDefinitionKey = targetProcessDefinition.Key; }
public virtual void visited(MigratingScopeInstance scopeInstance) { ScopeImpl targetScope = scopeInstance.TargetScope; if (targetScope.Scope) { scopeInstances[targetScope] = scopeInstance; } }
public MigratingCompensationEventSubscriptionInstance(IMigrationInstruction migrationInstruction, ScopeImpl sourceScope, ScopeImpl targetScope, EventSubscriptionEntity eventSubscription) { this.migrationInstruction = migrationInstruction; this.EventSubscription = eventSubscription; this.sourceScope = sourceScope; this.targetScope = targetScope; currentScope = sourceScope; }
public override void ParseBoundaryEvent(Element boundaryEventElement, ScopeImpl scopeElement, ActivityImpl nestedActivity) { var type = nestedActivity.Properties.Get(BpmnProperties.Type); if (!ReferenceEquals(type, null) && type.Equals(BoundaryTimer)) { SetFailedJobRetryTimeCycleValue(boundaryEventElement, nestedActivity); } }
/// <summary> /// Cannot create more than inner instance in a sequential MI construct /// </summary> protected internal virtual bool SupportsConcurrentChildInstantiation(ScopeImpl flowScope) { if (flowScope == null) { return(true); } IActivityBehavior behavior = flowScope.ActivityBehavior; return(behavior == null || !(behavior is SequentialMultiInstanceActivityBehavior)); }
public virtual void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) { addActivityHandlers(activity); if (historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_CREATE, null)) { TaskDefinition taskDefinition = ((UserTaskActivityBehavior)activity.ActivityBehavior).TaskDefinition; taskDefinition.addBuiltInTaskListener([email protected]_Fields.EVENTNAME_ASSIGNMENT, USER_TASK_ASSIGNMENT_HANDLER); taskDefinition.addBuiltInTaskListener([email protected]_Fields.EVENTNAME_CREATE, USER_TASK_ID_HANDLER); } }
public virtual MigratingCompensationEventSubscriptionInstance AddCompensationSubscriptionInstance( IMigrationInstruction eventSubscriptionInstruction, EventSubscriptionEntity eventSubscription, ScopeImpl sourceScope, ScopeImpl targetScope) { var compensationInstance = new MigratingCompensationEventSubscriptionInstance(eventSubscriptionInstruction, sourceScope, targetScope, eventSubscription); migratingCompensationSubscriptionInstances.Add(compensationInstance); return(compensationInstance); }
public virtual ISet <ExecutionEntity> getExecutions(ScopeImpl activity) { ISet <ExecutionEntity> executionsForActivity = activityExecutionMapping[activity]; if (executionsForActivity == null) { executionsForActivity = new HashSet <ExecutionEntity>(); activityExecutionMapping[activity] = executionsForActivity; } return(executionsForActivity); }
protected internal virtual void mergeScopeExecutions(ExecutionEntity leaf) { IDictionary <ScopeImpl, PvmExecutionImpl> mapping = leaf.createActivityExecutionMapping(); foreach (KeyValuePair <ScopeImpl, PvmExecutionImpl> mappingEntry in mapping.SetOfKeyValuePairs()) { ScopeImpl scope = mappingEntry.Key; ExecutionEntity scopeExecution = (ExecutionEntity)mappingEntry.Value; submitExecution(scopeExecution, scope); } }
public virtual void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) { addStartEventListener(activity); addEndEventListener(activity); UserTaskActivityBehavior activityBehavior = (UserTaskActivityBehavior)activity.ActivityBehavior; TaskDefinition taskDefinition = activityBehavior.TaskDefinition; addTaskCreateListeners(taskDefinition); addTaskAssignmentListeners(taskDefinition); addTaskCompleteListeners(taskDefinition); addTaskDeleteListeners(taskDefinition); }
public MigratingTransitionInstance(ITransitionInstance transitionInstance, IMigrationInstruction migrationInstruction, ScopeImpl sourceScope, ScopeImpl targetScope, ExecutionEntity asyncExecution) { this.transitionInstance = transitionInstance; this.migrationInstruction = migrationInstruction; this.sourceScope = sourceScope; this.targetScope = targetScope; currentScope = sourceScope; RepresentativeExecution = asyncExecution; ActiveState = RepresentativeExecution.IsActive; }
/// <summary> /// Creates an emerged scope /// </summary> public MigratingEventScopeInstance(EventSubscriptionEntity eventSubscription, ExecutionEntity eventScopeExecution, ScopeImpl targetScope) { MigratingEventSubscription = new MigratingCompensationEventSubscriptionInstance(null, null, targetScope, eventSubscription); this.EventScopeExecution = eventScopeExecution; // compensation handlers (not boundary events) // or parent flow scopes this.targetScope = targetScope; currentScope = targetScope; }
public virtual void ParseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) { addActivityHandlers(activity); if (HistoryLevel.IsHistoryEventProduced(HistoryEventTypes.TaskInstanceCreate, null)) { var taskDefinition = ((UserTaskActivityBehavior)activity.ActivityBehavior).TaskDefinition; taskDefinition.AddBuiltInTaskListener(TaskListenerFields.EventnameAssignment, UserTaskAssignmentHandler); taskDefinition.AddBuiltInTaskListener(TaskListenerFields.EventnameCreate, UserTaskIdHandler); } }