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);
        }
Example #2
0
        public virtual ActivityStateImpl CreateActivityState()
        {
            ActivityStateImpl activityState = new ActivityStateImpl(_processDefinition);

            AddNode(activityState);
            return(activityState);
        }
Example #3
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);
        }
Example #4
0
        public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            this._nodes       = new ListSet();
            this._attributes  = new ListSet();
            this._childBlocks = new ListSet();

            base.ReadProcessData(xmlElement, creationContext);

            IEnumerator iter = xmlElement.GetChildElements("attribute").GetEnumerator();

            while (iter.MoveNext())
            {
                AttributeImpl attribute = new AttributeImpl();
                attribute.ReadProcessData((XmlElement)iter.Current, creationContext);
                _attributes.Add(attribute);
            }

            iter = xmlElement.GetChildElements("activity-state").GetEnumerator();
            while (iter.MoveNext())
            {
                ActivityStateImpl activityState = new ActivityStateImpl();
                activityState.ReadProcessData((XmlElement)iter.Current, creationContext);
                _nodes.Add(activityState);
            }

            iter = xmlElement.GetChildElements("process-state").GetEnumerator();
            while (iter.MoveNext())
            {
                ProcessStateImpl processState = new ProcessStateImpl();
                processState.ReadProcessData((XmlElement)iter.Current, creationContext);
                _nodes.Add(processState);
            }

            iter = xmlElement.GetChildElements("decision").GetEnumerator();
            while (iter.MoveNext())
            {
                DecisionImpl decision = new DecisionImpl();
                decision.ReadProcessData((XmlElement)iter.Current, creationContext);
                _nodes.Add(decision);
            }

            iter = xmlElement.GetChildElements("concurrent-block").GetEnumerator();
            while (iter.MoveNext())
            {
                ConcurrentBlockImpl concurrentBlock = new ConcurrentBlockImpl();
                concurrentBlock.ReadProcessData((XmlElement)iter.Current, creationContext);
                _childBlocks.Add(concurrentBlock);
            }
        }
 public void StoreRole(String authenticatedActorId, ActivityStateImpl activityState)
 {
     String role = activityState.ActorRoleName;
     if ((Object) role != null)
     {
         IActor authenticatedActor = OrganisationUtil.Instance.GetActor(authenticatedActorId);
         log.Debug("assigning " + authenticatedActor + " to role " + role);
         SetAttribute(role, authenticatedActor);
     }
 }
Example #6
0
		public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
		{
			this._nodes = new ListSet();
			this._attributes = new ListSet();
			this._childBlocks = new ListSet();

			base.ReadProcessData(xmlElement, creationContext);

			IEnumerator iter = xmlElement.GetChildElements("attribute").GetEnumerator();
			while (iter.MoveNext())
			{
				AttributeImpl attribute = new AttributeImpl();
				attribute.ReadProcessData((XmlElement) iter.Current, creationContext);
				_attributes.Add(attribute);
			}

			iter = xmlElement.GetChildElements("activity-state").GetEnumerator();
			while (iter.MoveNext())
			{
				ActivityStateImpl activityState = new ActivityStateImpl();
				activityState.ReadProcessData((XmlElement) iter.Current, creationContext);
				_nodes.Add(activityState);
			}

			iter = xmlElement.GetChildElements("process-state").GetEnumerator();
			while (iter.MoveNext())
			{
				ProcessStateImpl processState = new ProcessStateImpl();
				processState.ReadProcessData((XmlElement) iter.Current, creationContext);
				_nodes.Add(processState);
			}

			iter = xmlElement.GetChildElements("decision").GetEnumerator();
			while (iter.MoveNext())
			{
				DecisionImpl decision = new DecisionImpl();
				decision.ReadProcessData((XmlElement) iter.Current, creationContext);
				_nodes.Add(decision);
			}

			iter = xmlElement.GetChildElements("concurrent-block").GetEnumerator();
			while (iter.MoveNext())
			{
				ConcurrentBlockImpl concurrentBlock = new ConcurrentBlockImpl();
				concurrentBlock.ReadProcessData((XmlElement) iter.Current, creationContext);
				_childBlocks.Add(concurrentBlock);
			}
		}
Example #7
0
        public virtual ActivityStateImpl CreateActivityState()
		{
			ActivityStateImpl activityState = new ActivityStateImpl(_processDefinition);
			AddNode(activityState);
			return activityState;
		}