Beispiel #1
0
        public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            base.ReadProcessData(xmlElement, creationContext);

            // get the process definition for that name
            String subProcessDefinitionName = xmlElement.GetProperty("process");

            creationContext.Check(((Object)subProcessDefinitionName != null), "process is missing in the process state : " + subProcessDefinitionName);
            DbSession dbSession = creationContext.DbSession;

            dbSession.SaveOrUpdate(this._processDefinition);
            try
            {
                this._subProcess = (ProcessDefinitionImpl)dbSession.FindOne(queryFindProcessDefinitionByName, subProcessDefinitionName, DbType.STRING);
            }
            catch (SystemException e)
            {
                creationContext.AddError("process '" + subProcessDefinitionName + "' was not deployed while it is referenced in a process-state. Exception: " + e.Message);
            }

            // parse the processInvokerDelegation
            creationContext.DelegatingObject = this;
            this._processInvokerDelegation   = new DelegationImpl();
            XmlElement invocationElement = xmlElement.GetChildElement("process-invocation");

            creationContext.Check((invocationElement != null), "process-invocation is missing in the process-state : " + xmlElement);
            this._processInvokerDelegation.ReadProcessData(invocationElement, creationContext);

            creationContext.DelegatingObject = null;

            // parse the actorExpression
            this._actorExpression = xmlElement.GetProperty("actor-expression");
            creationContext.Check(((Object)_actorExpression != null), "actor-expression is missing in the process-state : " + xmlElement);
        }
Beispiel #2
0
        public virtual void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            DefinitionObjectImpl definitionObject = creationContext.DefinitionObject;

            // first make sure the definitionObject has got an id
            DbSession dbSession = creationContext.DbSession;

            dbSession.SaveOrUpdate(definitionObject);

            // store the reference link to the definitionObject
            this._definitionObjectId = definitionObject.Id;

            log.Debug("adding action : ");
            log.Debug("  definitionObjectId: " + _definitionObjectId);
            log.Debug("  definitionObject: " + definitionObject);

            this._eventType = EventTypeHelper.fromText(xmlElement.GetAttribute("event"));

            log.Debug("action on eventType '" + _eventType + "' and definitionObject " + creationContext.DefinitionObject);

            // reading the action delegation
            creationContext.DelegatingObject = this;
            this._actionDelegation           = new DelegationImpl();
            this._actionDelegation.ReadProcessData(xmlElement, creationContext);
            creationContext.DelegatingObject = null;

            dbSession.SaveOrUpdate(this);
        }
Beispiel #3
0
        public void ProcessActivityState(ActivityStateImpl activityState, ExecutionContextImpl executionContext, DbSession dbSession)
        {
            // first set the flow-state to the activity-state
            FlowImpl flow = (FlowImpl)executionContext.GetFlow();

            log.Debug("processing activity-state '" + activityState + "' for flow '" + executionContext.GetFlow() + "'");

            // execute the actions scheduled for this assignment
            delegationService.RunActionsForEvent(EventType.BEFORE_ACTIVITYSTATE_ASSIGNMENT, activityState.Id, executionContext, dbSession);

            String         actorId = null;
            String         role    = activityState.ActorRoleName;
            DelegationImpl assignmentDelegation = activityState.AssignmentDelegation;

            if (assignmentDelegation != null)
            {
                // delegate the assignment of the activity-state
                actorId = delegationHelper.DelegateAssignment(activityState.AssignmentDelegation, executionContext);
                if ((Object)actorId == null)
                {
                    throw new SystemException("invalid process definition : assigner of activity-state '" + activityState.Name + "' returned null instead of a valid actorId");
                }
                log.Debug("setting actor of flow " + flow + " to " + actorId);
            }
            else
            {
                // get the assigned actor from the specified attribute instance
                if ((Object)role != null)
                {
                    IActor actor = (IActor)executionContext.GetAttribute(role);
                    if (actor == null)
                    {
                        throw new SystemException("invalid process definition : activity-state must be assigned to role '" + role + "' but that attribute instance is null");
                    }
                    actorId = actor.Id;
                }
                else
                {
                    throw new SystemException("invalid process definition : activity-state '" + activityState.Name + "' does not have an assigner or a role");
                }
            }

            flow.ActorId = actorId;

            // If necessary, store the actor in the role
            if ((string.IsNullOrEmpty(role) == false) && (assignmentDelegation != null))
            {
                executionContext.StoreRole(actorId, activityState);
            }

            // the client of performActivity wants to be Informed of the people in charge of the process
            executionContext.AssignedFlows.Add(flow);

            // log the assignment
            executionContext.CreateLog(actorId, EventType.AFTER_ACTIVITYSTATE_ASSIGNMENT);
            executionContext.AddLogDetail(new ObjectReferenceImpl(activityState));

            // execute the actions scheduled for this assignment
            delegationService.RunActionsForEvent(EventType.AFTER_ACTIVITYSTATE_ASSIGNMENT, activityState.Id, executionContext, dbSession);
        }
Beispiel #4
0
 public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
 {
     base.ReadProcessData(xmlElement, creationContext);
     creationContext.DelegatingObject = this;
     this._decisionDelegation         = new DelegationImpl();
     this._decisionDelegation.ReadProcessData(xmlElement, creationContext);
     creationContext.DelegatingObject = null;
 }
Beispiel #5
0
        private void action(XmlElement actionElement, ActionImpl actionImpl)
        {
            actionImpl.EventType = EventTypeHelper.fromText(actionElement.GetAttribute("event"));
            DelegationImpl delegation = new DelegationImpl();

            delegation.ProcessDefinition = ProcessDefinition;
            actionImpl.ActionDelegation  = delegation;
            this.delegation <ActionImpl>(actionElement, delegation);
        }
Beispiel #6
0
        private void attribute(XmlElement attributeElement, AttributeImpl attribute, ProcessBlockImpl processBlock)
        {
            attribute.InitialValue      = attributeElement.GetProperty("initial-value");
            attribute.ProcessDefinition = processBlock as IProcessDefinition;
            DelegationImpl delegation = new DelegationImpl();

            attribute.SerializerDelegation = delegation;
            delegation.ProcessDefinition   = processBlock as IProcessDefinition;
            this.definitionObject(attributeElement, attribute, processBlock);
            this.delegation <AttributeImpl>(attributeElement, (DelegationImpl)attribute.SerializerDelegation);
        }
Beispiel #7
0
        public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            base.ReadProcessData(xmlElement, creationContext);
            this._scope        = creationContext.ProcessBlock;
            this._initialValue = xmlElement.GetProperty("initial-value");

            creationContext.DelegatingObject = this;
            this._serializerDelegation       = new DelegationImpl();
            this._serializerDelegation.ReadProcessData(xmlElement, creationContext);
            creationContext.DelegatingObject = null;
            creationContext.AddReferencableObject(_name, (ProcessBlockImpl)this._scope, typeof(IAttribute), this);
        }
Beispiel #8
0
        public void ProcessActivityState(ActivityStateImpl activityState, FlowImpl flow, DbSession dbSession)
        {
            String actorId = null;
            String role    = activityState.ActorRoleName;

            DelegationImpl assignmentDelegation = activityState.AssignmentDelegation;

            if (assignmentDelegation != null)
            {
                var delegateParameters = activityState.AssignmentDelegation.ParseConfiguration();
                actorExpressionResolverService.CurrentScope = flow;
                actorExpressionResolverService.DbSession    = dbSession;
                actorId = actorExpressionResolverService.ResolveArgument(delegateParameters["expression"].ToString()).Id;

                if ((Object)actorId == null)
                {
                    throw new SystemException("invalid process definition : assigner of activity-state '" + activityState.Name + "' returned null instead of a valid actorId");
                }
            }
            else
            {
                if ((Object)role != null)
                {
                    IActor actor = null;
                    var    attr  = attributeRepository.FindAttributeInstanceInScope(role, flow, dbSession);
                    if (attr != null)
                    {
                        actor = (IActor)attr.GetValue();
                    }

                    if (actor == null)
                    {
                        throw new SystemException("invalid process definition : activity-state must be assigned to role '" + role + "' but that attribute instance is null");
                    }
                    actorId = actor.Id;
                }
                else
                {
                    throw new SystemException("invalid process definition : activity-state '" + activityState.Name + "' does not have an assigner or a role");
                }
            }

            flow.ActorId = actorId;

            // If necessary, store the actor in the role
            if ((string.IsNullOrEmpty(role) == false) && (assignmentDelegation != null))
            {
                //executionContext.StoreRole(actorId, activityState);
            }

            // the client of performActivity wants to be Informed of the people in charge of the process
            //executionContext.AssignedFlows.Add(flow);
        }
Beispiel #9
0
        public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            base.ReadProcessData(xmlElement, creationContext);

            if ((Object)xmlElement.GetAttribute("handler") != null)
            {
                creationContext.DelegatingObject = this;
                this._forkDelegation             = new DelegationImpl();
                this._forkDelegation.ReadProcessData(xmlElement, creationContext);
                creationContext.DelegatingObject = null;
            }
        }
Beispiel #10
0
        public Object CreateObject(DelegationImpl delegationImpl)
        {
            Object delegateClass = null;

            try
            {
                log.Debug("creating delegate '" + delegationImpl.ClassName + "'");
                if (delegationImpl.ClassName.IndexOf(",") != -1)
                {
                    int    index        = delegationImpl.ClassName.IndexOf(",");
                    string className    = delegationImpl.ClassName.Substring(0, index).Trim();
                    string assemblyName = delegationImpl.ClassName.Substring(index + 1).Trim();

                    DbSession        dbSession    = null;
                    AssemblyFileImpl assemblyFile = null;
                    try
                    {
                        dbSession = OpenSession();
                        Object[] args  = new Object[] { delegationImpl.ProcessDefinition.Id, assemblyName };
                        IType[]  types = new IType[] { DbType.LONG, DbType.STRING };
                        assemblyFile = (AssemblyFileImpl)dbSession.FindOne(queryFindAssemblyFile, args, types);
                    }
                    catch (ObjectNotFoundException) {}
                    finally
                    {
                        if (dbSession != null)
                        {
                            dbSession.Close();
                        }
                    }

                    if (assemblyFile != null)
                    {
                        Assembly loaded           = Assembly.Load(assemblyFile.Bytes);
                        Type     dbDelegationType = loaded.GetType(className);
                        delegateClass = Activator.CreateInstance(dbDelegationType, false);
                        return(delegateClass);
                    }
                }
                //load Assembly from environment
                log.Debug("load Assembly from environment");
                Type delegationType = Type.GetType(delegationImpl.ClassName);
                delegateClass = Activator.CreateInstance(delegationType, false);

                return(delegateClass);
            }
            catch (Exception t)
            {
                log.Error("can't instantiate delegate '" + delegationImpl.ClassName + "' : ", t);
                throw new SystemException("can't instantiate delegate '" + delegationImpl.ClassName + "' : " + t.Message);
            }
        }
Beispiel #11
0
        public JobImpl(Job job, String reference)
        {
            _processDefinition = job.ProcessDefinition;
            _context           = job.Context;
            _date   = job.Date;
            _userId = job.UserId;
            _pwd    = job.Pwd;

            this._reference   = reference;
            _actionDelegation = new DelegationImpl();
            _actionDelegation.ProcessDefinition = job.ProcessDefinition;
            _actionDelegation.ClassName         = job.TaskClassName;
            _actionDelegation.Configuration     = job.Configuration;
        }
Beispiel #12
0
        public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            base.ReadProcessData(xmlElement, creationContext);

            XmlElement assignmentElement = xmlElement.GetChildElement("assignment");

            if (assignmentElement != null)
            {
                creationContext.DelegatingObject = this;
                this._assignmentDelegation       = new DelegationImpl();
                this._assignmentDelegation.ReadProcessData(assignmentElement, creationContext);
                creationContext.DelegatingObject = null;
            }
            this._actorRoleName = xmlElement.GetProperty("role");
        }
Beispiel #13
0
        private void delegation <T>(XmlElement delegationElement, DelegationImpl delegation)
        {
            Type delegatingObjectClass = typeof(T);

            if (delegatingObjectClass == typeof(AttributeImpl))
            {
                String type = delegationElement.GetProperty("type");
                if (string.IsNullOrEmpty(type) == false)
                {
                    delegation.ClassName = ((String)DelegationImpl.attributeTypes[type]);
                    string suportedTypes = "supported types: ";
                    foreach (Object o in DelegationImpl.attributeTypes.Keys)
                    {
                        suportedTypes += o.ToString() + " ,";
                    }
                }
                else
                {
                    delegation.ClassName = delegationElement.GetProperty("serializer");
                }
            }
            else if (delegatingObjectClass == typeof(FieldImpl))
            {
                delegation.ClassName = delegationElement.GetProperty("class");
            }
            else
            {
                delegation.ClassName = delegationElement.GetProperty("handler");
            }

            // parse the exception handler
            String exceptionHandlerText = delegationElement.GetAttribute("on-exception");

            if ((Object)exceptionHandlerText != null)
            {
                delegation.ExceptionHandlingType = ExceptionHandlingTypeHelper.FromText(exceptionHandlerText);
            }

            // create the configuration string
            XmlElement  configurationXml = new XmlElement("cfg");
            IEnumerator iter             = delegationElement.GetChildElements("parameter").GetEnumerator();

            while (iter.MoveNext())
            {
                configurationXml.AddChild((XmlElement)iter.Current);
            }
            delegation.Configuration = configurationXml.ToString();
        }
Beispiel #14
0
        public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            this._endState   = new EndStateImpl();
            this._startState = new StartStateImpl();

            // read the process-block contents, the start- and the end-state
            creationContext.ProcessBlock = this;
            base.ReadProcessData(xmlElement, creationContext);
            XmlElement startElement = xmlElement.GetChildElement("start-state");

            creationContext.Check((startElement != null), "element start-state is missing");
            XmlElement endElement = xmlElement.GetChildElement("end-state");

            creationContext.Check((endElement != null), "element end-state is missing");
            _startState.ReadProcessData(startElement, creationContext);
            _endState.ReadProcessData(endElement, creationContext);
            creationContext.ProcessBlock = null;

            // add the start & end state to the nodes of this process definition
            this._nodes.Add(_startState);
            this._nodes.Add(_endState);

            // add the end state as referencable object
            creationContext.AddReferencableObject(this._endState.Name, this, typeof(INode), this._endState);

            // read the optional authorization handler
            XmlElement authorizationElement = xmlElement.GetChildElement("authorization");

            if (authorizationElement != null)
            {
                creationContext.DelegatingObject = this;
                this.authorizationDelegation     = new DelegationImpl();
                this.authorizationDelegation.ReadProcessData(authorizationElement, creationContext);
                creationContext.DelegatingObject = null;
            }

            // read the optional responsible for this process definition
            this._responsibleUserName = xmlElement.GetProperty("responsible");

            // calculate the version of this process definition
            //todo 這行應該移到ProcessDefinitionService
            //this._version = GetVersionNr(creationContext);

            // attach the class files to this process definitions
            //todo 這行應該移到ProcessDefinitionService
            //this._classFiles = GetAssemblyFiles(creationContext);
        }
Beispiel #15
0
        private void activityState(XmlElement activityStateElement, ActivityStateImpl activityState, ProcessBlockImpl processBlock)
        {
            activityState.ProcessDefinition = ProcessDefinition;
            XmlElement assignmentElement = activityStateElement.GetChildElement("assignment");

            if (assignmentElement != null)
            {
                DelegationImpl delegation = new DelegationImpl();
                delegation.ProcessDefinition       = processBlock as IProcessDefinition;
                activityState.AssignmentDelegation = delegation;
                this.delegation <ActivityStateImpl>(assignmentElement, delegation);
            }

            activityState.ActorRoleName = activityStateElement.GetProperty("role");

            this.state(activityStateElement, activityState, processBlock);
        }
Beispiel #16
0
        public Object CreateObject(DelegationImpl delegationImpl)
        {
            Object delegateClass = null;

            try
            {
                log.Debug("creating delegate '" + delegationImpl.ClassName + "'");
                Type delegationType = Type.GetType(delegationImpl.ClassName);

                delegateClass = Activator.CreateInstance(delegationType, false);
            }
            catch (Exception t)
            {
                log.Error("can't instantiate delegate '" + delegationImpl.ClassName + "' : ", t);
                throw new SystemException("can't instantiate delegate '" + delegationImpl.ClassName + "' : " + t.Message);
            }
            return(delegateClass);
        }
Beispiel #17
0
        public virtual void ReadWebData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            this._name        = xmlElement.GetProperty("name");
            this._description = xmlElement.GetProperty("description");
            this._index       = creationContext.Index;

            log.Debug("paring web information for field " + _name);

            creationContext.DelegatingObject = this;
            XmlElement formatterElement = xmlElement.GetChildElement("htmlformatter");

            if (formatterElement != null)
            {
                this._htmlFormatterDelegation = new DelegationImpl();
                this._htmlFormatterDelegation.ReadProcessData(formatterElement, creationContext);
            }
            creationContext.DelegatingObject = null;
        }
Beispiel #18
0
        public void ProcessFork(ForkImpl fork, FlowImpl flow, DbSession dbSession)
        {
            // First initialize the children of the flow to be forked
            flow.Children = new ListSet();

            DelegationImpl     delegation  = fork.ForkDelegation;
            IList <ForkedFlow> forkedFlows = new List <ForkedFlow>();

            if (delegation != null)
            {
                //delegationHelper.DelegateFork(fork.ForkDelegation, executionContext);
            }
            else
            {
                // execute the default fork behaviour
                IEnumerator iter = fork.LeavingTransitions.GetEnumerator();
                while (iter.MoveNext())
                {
                    TransitionImpl transition = (TransitionImpl)iter.Current;
                    forkedFlows.Add(this.ForkFlow(transition, flow, null));
                }
            }


            IEnumerator iter2 = forkedFlows.GetEnumerator();

            while (iter2.MoveNext())
            {
                ForkedFlow forkedFlow = (ForkedFlow)iter2.Current;
            }

            // loop over all flows that were forked in the ForkHandler implementation
            iter2 = forkedFlows.GetEnumerator();
            while (iter2.MoveNext())
            {
                ForkedFlow forkedFlow = (ForkedFlow)iter2.Current;

                ProcessTransition(forkedFlow.Transition, forkedFlow.Flow, dbSession);
            }
        }
Beispiel #19
0
        //public String DelegateAssignment(DelegationImpl delegation)
        //{
        //    String actorId = null;

        //    IAssignmentHandler assigner = (IAssignmentHandler)delegation.GetDelegate();
        //    IDictionary expression = this.ParseConfiguration(delegation);

        //    actorExpressionResolverService = new ActorExpressionResolverService();
        //    actorId = actorExpressionResolverService.ResolveArgument(expression["expression"].ToString()).Id;

        //    return actorId;
        //}

        public Object GetDelegate(DelegationImpl delegationImpl)
        {
            Object       delegateClass = null;
            IClassLoader classLoader   = null;

            try
            {
                classLoader   = (IClassLoader)ServiceLocator.Instance.GetService(typeof(IClassLoader));
                delegateClass = classLoader.CreateObject(delegationImpl);
            }
            finally
            {
                ServiceLocator.Instance.Release(classLoader);
            }
            // configure class
            if (delegateClass is IConfigurable)
            {
                IConfigurable configurable = (IConfigurable)delegateClass;
                IDictionary   parameters   = ParseConfiguration(delegationImpl);
                configurable.SetConfiguration(parameters);
            }
            return(delegateClass);
        }
Beispiel #20
0
        public IDictionary ParseConfiguration(DelegationImpl delegationImpl)
        {
            IDictionary parameters = new Hashtable();

            try
            {
                String configuration = delegationImpl.Configuration;
                if ((Object)configuration != null)
                {
                    XmlParser xmlParser = new XmlParser(configuration);
                    xmlParser.Validation = false;
                    XmlElement  configurationXmlElement = xmlParser.Parse();
                    IList       parameterXmlElements    = configurationXmlElement.GetChildElements("parameter");
                    IEnumerator iter = parameterXmlElements.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        XmlElement parameterXmlElement = (XmlElement)iter.Current;

                        String name = parameterXmlElement.GetProperty("name");
                        if ((Object)name == null)
                        {
                            throw new SystemException("invalid delegation-configuration : " + configurationXmlElement);
                        }

                        parameters[name] = GetObject(parameterXmlElement);
                    }
                }
            }
            catch (Exception t)
            {
                log.Error("can't parse configuration : ", t);
                throw new SystemException("can't parse configuration : " + t.Message);
            }

            return(parameters);
        }
Beispiel #21
0
 public virtual DelegationImpl CreateAssignmentDelegation()
 {
     _assignmentDelegation = new DelegationImpl(_processDefinition);
     return(_assignmentDelegation);
 }
Beispiel #22
0
        public long ExecuteTask(DbSession dbSession, IOrganisationService organisationComponent)
        {
            long millisToWait = DEFAULT_INTERVAL;

            DateTime now = DateTime.Now;

            IEnumerator iter = dbSession.Iterate(queryFindJobsToBeExecuted, now, DbType.TIMESTAMP).GetEnumerator();

            if (iter.MoveNext())
            {
                JobImpl job = (JobImpl)iter.Current;

                try
                {
                    log.Debug("executing activation '" + job.Id + "' scheduled for " + job.Date.ToString());
                    log.Debug("activation's flow-context is :" + job.Context);

                    String userId = job.UserId;

                    DelegationImpl actionDelegation = job.ActionDelegation;

                    ExecutionContextImpl executionContext = new ExecutionContextImpl(userId, dbSession, organisationComponent);
                    IFlow context = job.Context;
                    if (context != null)
                    {
                        executionContext.SetFlow(context);
                        executionContext.SetProcessInstance(context.ProcessInstance);
                        executionContext.SetProcessDefinition(context.ProcessInstance.ProcessDefinition);
                    }
                    else
                    {
                        executionContext.SetProcessDefinition(job.ProcessDefinition);
                    }

                    delegationHelper.DelegateScheduledAction(actionDelegation, executionContext);
                }
                catch (Exception t)
                {
                    log.Error("scheduler-exception : couldn't perform task : " + t.Message, t);
                }

                dbSession.Delete(job);
                dbSession.Flush();
                if (iter.MoveNext())
                {
                    return(0);
                }
            }

            iter = dbSession.Iterate(queryFindJobsInTheFuture, now, DbType.TIMESTAMP).GetEnumerator();
            if (iter.MoveNext())
            {
                JobImpl activation     = (JobImpl)iter.Current;
                long    activationDate = activation.Date.Ticks;
                millisToWait = activationDate - now.Ticks;
                log.Debug("next activation is scheduled at " + activation.Date.ToString() + ", (in " + millisToWait + " millis)");
                if (millisToWait < 0)
                {
                    millisToWait = 0;
                }
                if (millisToWait > DEFAULT_INTERVAL)
                {
                    millisToWait = DEFAULT_INTERVAL;
                }
            }

            return(millisToWait);
        }
Beispiel #23
0
        public void ProcessFork(ForkImpl fork, ExecutionContextImpl executionContext, DbSession dbSession)
        {
            log.Debug("forking flow " + executionContext.GetFlow());

            // First initialize the children of the flow to be forked
            FlowImpl flow = (FlowImpl)executionContext.GetFlow();

            flow.Children = new ListSet();

            // Then initialise the forked flows in the execution context
            executionContext.ForkedFlows = new ArrayList();

            DelegationImpl delegation = fork.ForkDelegation;

            if (delegation != null)
            {
                delegationHelper.DelegateFork(fork.ForkDelegation, executionContext);
            }
            else
            {
                // execute the default fork behaviour
                IEnumerator iter = fork.LeavingTransitions.GetEnumerator();
                while (iter.MoveNext())
                {
                    TransitionImpl transition = (TransitionImpl)iter.Current;
                    executionContext.ForkFlow(transition, null);
                }
            }

            // create the fork event & remember the parent flow
            FlowImpl parentFlow = (FlowImpl)executionContext.GetFlow();

            executionContext.CreateLog(EventType.FORK);

            // log the event
            executionContext.SetFlow(parentFlow);
            IList       forkedFlows = executionContext.ForkedFlows;
            IEnumerator iter2       = forkedFlows.GetEnumerator();

            while (iter2.MoveNext())
            {
                ForkedFlow forkedFlow = (ForkedFlow)iter2.Current;
                log.Debug("adding object reference [" + forkedFlow.Flow + "] to flow [" + parentFlow + "]");
                executionContext.AddLogDetail(new ObjectReferenceImpl(forkedFlow.Flow));
            }

            // loop over all flows that were forked in the ForkHandler implementation
            iter2 = forkedFlows.GetEnumerator();
            while (iter2.MoveNext())
            {
                ForkedFlow forkedFlow = (ForkedFlow)iter2.Current;

                // trigger actions, scheduled after the creation and setting of the attributeValues
                // but before the fork is being processed
                delegationService.RunActionsForEvent(EventType.FORK, fork.Id, executionContext, dbSession);

                // then process the forked flow transition
                executionContext.SetFlow(forkedFlow.Flow);
                ProcessTransition(forkedFlow.Transition, executionContext, dbSession);
            }
        }
Beispiel #24
0
        public void ProcessJoin(JoinImpl join, ExecutionContextImpl executionContext, DbSession dbSession)
        {
            // First set the state of the flow to finished
            FlowImpl joiningFlow = (FlowImpl)executionContext.GetFlow();

            joiningFlow.End     = DateTime.Now;
            joiningFlow.ActorId = null;
            joiningFlow.Node    = join;          // setting the node is not necessary if this method is called
            // from processTransition, but it is necessary if this method is
            // called from cancelFlow in the component-impl.

            // if parent-reactivation of the flow is true, this means that the parent-flow
            // not yet has been reactivated.  In that case we have to see if it needs to be
            // reactivated.  In the other case (parent-reactivation is false) we don't
            // need to do anything because this means that the parent-flow was already
            // reactivated before.
            if (!false.Equals(joiningFlow.ParentReactivation))
            {
                // check if the parent needs to be reactivated
                bool  parentReactivation = false;
                IList concurrentFlows    = executionContext.GetOtherActiveConcurrentFlows();
                if (concurrentFlows.Count == 0)
                {
                    // if no concurrent flows are present any more, reactivation is forced
                    parentReactivation = true;
                }
                else
                {
                    // if other concurrent flows are present, the decision to reactivate is left
                    // to the join-delegation (if there is one specified)
                    DelegationImpl joinDelegation = join.JoinDelegation;
                    // if no joinDelegation was specified, parentReactivation remains false
                    // so the behaviour is like an and-join. (=sunchronizing merge)
                    if (joinDelegation != null)
                    {
                        parentReactivation = delegationHelper.DelegateJoin(join.JoinDelegation, executionContext);
                    }
                }

                if (parentReactivation)
                {
                    // make sure the other concurrent flows will not reactivate the
                    // parent again
                    IEnumerator iter = concurrentFlows.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        //UPGRADE_TODO: Methode "java.util.Iterator.next" wurde in 'IEnumerator.Current' konvertiert und weist ein anderes Verhalten auf. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javautilIteratornext"'
                        FlowImpl concurrentFlow = (FlowImpl)iter.Current;
                        concurrentFlow.ParentReactivation = false;
                    }

                    // reactivate the parent by first setting the parentflow into the executionContext
                    FlowImpl parentFlow = (FlowImpl)joiningFlow.Parent;
                    executionContext.SetFlow(parentFlow);
                    // and then process the (single, checked at process-archive-parsing-time) leaving transition.
                    ISet leavingTransitions = join.LeavingTransitions;
                    iter = leavingTransitions.GetEnumerator();
                    if (iter.MoveNext())
                    {
                        TransitionImpl leavingTransition = (TransitionImpl)iter.Current;
                        ProcessTransition(leavingTransition, executionContext, dbSession);
                    }
                    else
                    {
                        // no transition throw exception?
                    }
                }
            }
        }
Beispiel #25
0
 public virtual DelegationImpl CreateProcessInvocationDelegation()
 {
     _processInvokerDelegation = new DelegationImpl(_processDefinition);
     return(_processInvokerDelegation);
 }
Beispiel #26
0
 public virtual DelegationImpl CreateJoinDelegation()
 {
     _joinDelegation = new DelegationImpl(_processDefinition);
     return(_joinDelegation);
 }
Beispiel #27
0
 public virtual DelegationImpl CreateForkDelegation()
 {
     _forkDelegation = new DelegationImpl(_processDefinition);
     return(_forkDelegation);
 }
Beispiel #28
0
 public virtual DelegationImpl CreateDecisionDelegation()
 {
     _decisionDelegation = new DelegationImpl(_processDefinition);
     return(_decisionDelegation);
 }
Beispiel #29
0
 public virtual DelegationImpl CreateSerializerDelegation()
 {
     _serializerDelegation = new DelegationImpl(_processDefinition);
     return(_serializerDelegation);
 }