예제 #1
0
        protected internal virtual 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().Id;
                PvmActivity newActivity = newProcessDefinition.findActivity(activityId);

                if (newActivity == null)
                {
                    throw new ProcessEngineException("The new process definition " + "(key = '" + newProcessDefinition.Key + "') " + "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)
            IList <TaskEntity> tasks = commandContext.TaskManager.findTasksByExecutionId(execution.Id);

            foreach (TaskEntity taskEntity in tasks)
            {
                taskEntity.ProcessDefinitionId = newProcessDefinition.Id;
            }
        }
예제 #2
0
 public virtual ActivityImpl getTargetActivity(MigrationInstruction instruction)
 {
     if (instruction != null)
     {
         return(targetProcessDefinition.findActivity(instruction.TargetActivityId));
     }
     else
     {
         return(null);
     }
 }
예제 #3
0
        protected internal virtual ProcessInstance instantiateProcess(CommandContext commandContext, ConditionHandlerResult result)
        {
            ProcessDefinitionEntity processDefinitionEntity = result.ProcessDefinition;

            ActivityImpl    startEvent      = processDefinitionEntity.findActivity(result.Activity.ActivityId);
            ExecutionEntity processInstance = processDefinitionEntity.createProcessInstance(builder.BusinessKey, startEvent);

            processInstance.start(builder.getVariables());

            return(processInstance);
        }
예제 #4
0
 private void startProcessInstances(IList <EventSubscriptionEntity> startSignalEventSubscriptions, IDictionary <string, ProcessDefinitionEntity> processDefinitions)
 {
     foreach (EventSubscriptionEntity signalStartEventSubscription in startSignalEventSubscriptions)
     {
         ProcessDefinitionEntity processDefinition = processDefinitions[signalStartEventSubscription.Id];
         if (processDefinition != null)
         {
             ActivityImpl       signalStartEvent = processDefinition.findActivity(signalStartEventSubscription.ActivityId);
             PvmProcessInstance processInstance  = processDefinition.createProcessInstanceForInitial(signalStartEvent);
             processInstance.start(builder.getVariables());
         }
     }
 }
예제 #5
0
        /// <summary>
        /// When deploying an async job definition for an activity wrapped in an miBody, set the activity id to the
        /// miBody except the wrapped activity is marked as async.
        ///
        /// Background: in <= 7.2 async job definitions were created for the inner activity, although the
        /// semantics are that they are executed before the miBody is entered
        /// </summary>
        public static void migrateMultiInstanceJobDefinitions(ProcessDefinitionEntity processDefinition, IList <JobDefinitionEntity> jobDefinitions)
        {
            foreach (JobDefinitionEntity jobDefinition in jobDefinitions)
            {
                string activityId = jobDefinition.ActivityId;
                if (!string.ReferenceEquals(activityId, null))
                {
                    ActivityImpl activity = processDefinition.findActivity(jobDefinition.ActivityId);

                    if (!isAsync(activity) && isActivityWrappedInMultiInstanceBody(activity) && isAsyncJobDefinition(jobDefinition))
                    {
                        jobDefinition.ActivityId = activity.FlowScope.Id;
                    }
                }
            }
        }
예제 #6
0
        protected internal virtual ActivityImpl getCurrentActivity(CommandContext commandContext, JobEntity job)
        {
            string       type     = job.JobHandlerType;
            ActivityImpl activity = null;

            if (SUPPORTED_TYPES.Contains(type))
            {
                DeploymentCache         deploymentCache         = Context.ProcessEngineConfiguration.DeploymentCache;
                ProcessDefinitionEntity processDefinitionEntity = deploymentCache.findDeployedProcessDefinitionById(job.ProcessDefinitionId);
                activity = processDefinitionEntity.findActivity(job.ActivityId);
            }
            else
            {
                // noop, because activity type is not supported
            }

            return(activity);
        }
예제 #7
0
        protected internal virtual void handleStartEvent(EventSubscriptionEntity eventSubscription,IDictionary <string,object> payload,string businessKey,CommandContext commandContext)
        {
            string processDefinitionId = eventSubscription.Configuration;

            ensureNotNull("Configuration of signal start event subscription '" + eventSubscription.Id + "' contains no process definition id.",processDefinitionId);

            DeploymentCache         deploymentCache   = Context.ProcessEngineConfiguration.DeploymentCache;
            ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);

            if (processDefinition == null || processDefinition.Suspended)
            {
                // ignore event subscription
                LOG.debugIgnoringEventSubscription(eventSubscription,processDefinitionId);
            }
            else
            {
                ActivityImpl       signalStartEvent = processDefinition.findActivity(eventSubscription.ActivityId);
                PvmProcessInstance processInstance  = processDefinition.createProcessInstance(businessKey,signalStartEvent);
                processInstance.start(payload);
            }
        }