コード例 #1
0
ファイル: LogComponentImpl.cs プロジェクト: qwinner/NetBPM
		public IList FindProcessInstances(DateTime startedAfter, DateTime startedBefore, String initiatorActorId, String actorId, Int64 processDefinitionId, Relations relations, DbSession dbSession)
		{
			IList processInstances = null;
			String query = queryFindAllProcessInstances;
			ArrayList parameters = new ArrayList();
			ArrayList types = new ArrayList();

			if (startedAfter != DateTime.MinValue)
			{
				query += "and pi.StartNullable > ? ";
				parameters.Add(startedAfter);
				types.Add(DbType.DATE);
			}

			if (startedBefore != DateTime.MinValue)
			{
				query += "and pi.StartNullable < ? ";
				parameters.Add(startedBefore);
				types.Add(DbType.DATE);
			}

			if (initiatorActorId != null && initiatorActorId != "")
			{
				query += "and pi.InitiatorActorId = ? ";
				parameters.Add(initiatorActorId);
				types.Add(DbType.STRING);
			}

			if (actorId != null && actorId != "")
			{
				query += "and f.ActorId = ? ";
				parameters.Add(actorId);
				types.Add(DbType.STRING);
			}

			if (processDefinitionId != 0)
			{
				query += "and pi.ProcessDefinition.Id = ? ";
				parameters.Add(processDefinitionId);
				types.Add(DbType.LONG);
			}

			query += "order by pi.StartNullable desc";

			log.Debug("query for searching process instances : '" + query + "'");

			Object[] parameterArray = parameters.ToArray();
			IType[] typeArray = (IType[]) types.ToArray(typeof (IType));

			processInstances = dbSession.Find(query, parameterArray, typeArray);

			if (relations != null)
			{
				relations.Resolve(processInstances);
			}

			log.Debug("process instances : '" + processInstances + "'");

			return processInstances;
		}
コード例 #2
0
		public IProcessInstance StartProcessInstance(String authenticatedActorId, Int64 processDefinitionId, IDictionary attributeValues, String transitionName, Relations relations, DbSession dbSession, IOrganisationSessionLocal organisationComponent)
		{
			ProcessInstanceImpl processInstance = null;

			// First check if the actor is allowed to start this instance
			authorizationHelper.CheckStartProcessInstance(authenticatedActorId, processDefinitionId, attributeValues, transitionName, dbSession);

			// get the process-definition and its start-state    
			ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) dbSession.Load(typeof (ProcessDefinitionImpl), processDefinitionId);
			StartStateImpl startState = (StartStateImpl) processDefinition.StartState;

			log.Info("actor '" + authenticatedActorId + "' starts an instance of process '" + processDefinition.Name + "'...");

			// create the process-instance
			processInstance = new ProcessInstanceImpl(authenticatedActorId, processDefinition);
			FlowImpl rootFlow = (FlowImpl) processInstance.RootFlow;

			// create the execution-context
			ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, rootFlow, dbSession, organisationComponent);

			// save the process instance to allow hibernate queries    
			dbSession.Save(processInstance);
			//dbSession.Lock(processInstance,LockMode.Upgrade);

			// run the actions 
			engine.RunActionsForEvent(EventType.BEFORE_PERFORM_OF_ACTIVITY, startState.Id, executionContext);

			// store the attributes
			executionContext.CreateLog(authenticatedActorId, EventType.PROCESS_INSTANCE_START);
			executionContext.CheckAccess(attributeValues, startState);
			executionContext.StoreAttributeValues(attributeValues);

			// if this activity has a role-name, save the actor in the corresponding attribute
			executionContext.StoreRole(authenticatedActorId, startState);

			// run the actions 
			engine.RunActionsForEvent(EventType.PROCESS_INSTANCE_START, processDefinitionId, executionContext);

			// from here on, we consider the actor as being the previous actor
			executionContext.SetActorAsPrevious();

			// process the start-transition
			TransitionImpl startTransition = executionContext.GetTransition(transitionName, startState, dbSession);
			engine.ProcessTransition(startTransition, executionContext);

			// run the actions 
			engine.RunActionsForEvent(EventType.AFTER_PERFORM_OF_ACTIVITY, startState.Id, executionContext);

			// flush the updates to the db
			dbSession.Update(processInstance);
			dbSession.Flush();

			//@portme
/*			if (relations != null)
			{
				relations.resolve(processInstance);
			}
*/
			return processInstance;
		}
コード例 #3
0
        public IList FindAttributeInstanceByName(string attributeName,long scopeId,DbSession dbSession)
        {
            Object[] values = new Object[] { attributeName, scopeId };
            IType[] types = new IType[] { DbType.STRING, DbType.LONG };

            return dbSession.Find(queryFindAttributeInstanceByName, values, types);
        }
コード例 #4
0
 /* package private */
 internal virtual TransitionImpl GetTransition(String transitionName, StateImpl state, DbSession dbSession)
 {
     TransitionImpl transition = null;
     if ((Object)transitionName != null)
     {
         Object[] values = new Object[] { transitionName, state.Id };
         IType[] types = new IType[] { DbType.STRING, DbType.LONG };
         transition = (TransitionImpl)dbSession.FindOne(queryFindTransitionByName, values, types);
     }
     else
     {
         ISet leavingTransitions = state.LeavingTransitions;
         if (leavingTransitions.Count == 1)
         {
             IEnumerator transEnum = leavingTransitions.GetEnumerator();
             transEnum.MoveNext();
             transition = (TransitionImpl)transEnum.Current;
         }
         else
         {
             throw new SystemException("no transitionName was specified : this is only allowed if the state (" + state.Name + ") has exactly 1 leaving transition (" + leavingTransitions.Count + ")");
         }
     }
     return transition;
 }
コード例 #5
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);
        }
コード例 #6
0
        internal virtual TransitionImpl FindLeavingTransitionByName(long nodeId,string transitionName, DbSession dbSession)
        {
            Object[] values = new Object[] { nodeId, transitionName };
            IType[] types = new IType[] { DbType.LONG, DbType.STRING };

            return (TransitionImpl)dbSession.FindOne(queryFindLeavingTransitionByName, values, types);
        }
コード例 #7
0
ファイル: _AttributeRepository.cs プロジェクト: ephebe/netbpm
        public AttributeInstanceImpl FindAttributeInstanceInScope(String attributeName, FlowImpl scope,DbSession dbSession)
        {
            AttributeInstanceImpl attributeInstance = null;

            while (attributeInstance == null)
            {
                IList attributes = this.FindAttributeInstanceByName(attributeName, scope.Id, dbSession);
                IEnumerator iter = attributes.GetEnumerator();
                if (iter.MoveNext())
                {
                    attributeInstance = (AttributeInstanceImpl)iter.Current;
                    if (iter.MoveNext())
                    {
                        throw new NetBpm.Util.DB.DbException("duplicate value");
                    }
                }
                else
                {
                    if (!scope.IsRootFlow())
                    {
                        scope = (FlowImpl)scope.Parent;
                    }
                    else
                    {
                        log.Warn("couldn't find attribute-instance '" + attributeName + "' in scope of flow '" + scope + "'");
                        break;
                    }
                }
            }
            return attributeInstance;
        }
コード例 #8
0
ファイル: TransitionService.cs プロジェクト: ephebe/netbpm
 public TransitionService(string previousActorId,DbSession session)
 {
     // TODO: Complete member initialization
     this.session = session;
     delegationService = new DelegationService();
     actorExpressionResolverService = new ActorExpressionResolverService(previousActorId);
 }
コード例 #9
0
ファイル: AuthorizationHelper.cs プロジェクト: qwinner/NetBPM
		public void CheckGetStartForm(String authenticatedActorId, Int64 processDefinitionId, DbSession dbSession)
		{
			IAuthorizationHandler authorizationHandler = GetHandlerFromProcessDefinitionId(processDefinitionId, dbSession);
			if (authorizationHandler != null)
			{
				authorizationHandler.CheckGetStartForm(authenticatedActorId, processDefinitionId);
			}
		}
コード例 #10
0
ファイル: AuthorizationHelper.cs プロジェクト: qwinner/NetBPM
		public void CheckPerformActivity(String authenticatedActorId, Int64 flowId, IDictionary attributeValues, String transitionName, DbSession dbSession)
		{
			IAuthorizationHandler authorizationHandler = GetHandlerFromFlowId(flowId, dbSession);
			if (authorizationHandler != null)
			{
				authorizationHandler.CheckPerformActivity(authenticatedActorId, flowId, attributeValues, transitionName);
			}
		}
コード例 #11
0
ファイル: AuthorizationHelper.cs プロジェクト: qwinner/NetBPM
		public void CheckDelegateActivity(String authenticatedActorId, Int64 flowId, String delegateActorId, DbSession dbSession)
		{
			IAuthorizationHandler authorizationHandler = GetHandlerFromFlowId(flowId, dbSession);
			if (authorizationHandler != null)
			{
				authorizationHandler.CheckDelegateActivity(authenticatedActorId, flowId, delegateActorId);
			}
		}
コード例 #12
0
ファイル: AuthorizationHelper.cs プロジェクト: qwinner/NetBPM
		public void CheckCancelProcessInstance(String authenticatedActorId, Int64 processInstanceId, DbSession dbSession)
		{
			IAuthorizationHandler authorizationHandler = GetHandlerFromProcessInstanceId(processInstanceId, dbSession);
			if (authorizationHandler != null)
			{
				authorizationHandler.CheckCancelProcessInstance(authenticatedActorId, processInstanceId);
			}
		}
コード例 #13
0
ファイル: AuthorizationHelper.cs プロジェクト: qwinner/NetBPM
		public void CheckStartProcessInstance(String authenticatedActorId, Int64 processDefinitionId, IDictionary attributeValues, String transitionName, DbSession dbSession)
		{
			IAuthorizationHandler authorizationHandler = GetHandlerFromProcessDefinitionId(processDefinitionId, dbSession);
			if (authorizationHandler != null)
			{
				authorizationHandler.CheckStartProcessInstance(authenticatedActorId, processDefinitionId, attributeValues, transitionName);
			}
		}
コード例 #14
0
ファイル: BankComponentImpl.cs プロジェクト: qwinner/NetBPM
		public void DeleteAccount(string bank, string costumer, DbSession dbSession)
		{
			log.Debug("DeleteAccount");

			Object[] values = new Object[] {bank, costumer};
			IType[] types = new IType[] {DbType.STRING, DbType.STRING};

			dbSession.Delete(queryFindBankAccount,values,types);
		}
コード例 #15
0
 public ExecutionContextImpl(String actorId, ProcessInstanceImpl processInstance, DbSession dbSession, IOrganisationService organisationComponent)
 {
     this._actorId = actorId;
     this._processInstance = processInstance;
     this._processDefinition = (ProcessDefinitionImpl) processInstance.ProcessDefinition;
     this._dbSession = dbSession;
     this._organisationComponent = organisationComponent;
     this._assignedFlows = new ArrayList();
 }
コード例 #16
0
		public IProcessDefinition GetProcessDefinition(Int64 processDefinitionId, Relations relations, DbSession dbSession)
		{
			ProcessDefinitionImpl processDefinition = null;
			processDefinition = (ProcessDefinitionImpl) dbSession.Load(typeof (ProcessDefinitionImpl), processDefinitionId);
			if (relations != null)
			{
				relations.Resolve(processDefinition);
			}
			return processDefinition;
		}
コード例 #17
0
		public IProcessDefinition GetProcessDefinition(String processDefinitionName, Relations relations, DbSession dbSession)
		{
			ProcessDefinitionImpl processDefinition = null;
			processDefinition = (ProcessDefinitionImpl) dbSession.FindOne(queryFindProcessDefinitionByName, processDefinitionName, DbType.STRING);
			if (relations != null)
			{
				relations.Resolve(processDefinition);
			}
			return processDefinition;
		}
コード例 #18
0
		public IList GetProcessDefinitions(Relations relations, DbSession dbSession)
		{
			IList processDefinitions = null;
			processDefinitions = dbSession.Find(queryFindProcessDefinitions);
			if (relations != null)
			{
				relations.Resolve(processDefinitions);
			}
			return processDefinitions;
		}
コード例 #19
0
		public IList GetAllProcessDefinitions(Relations relations, DbSession dbSession)
		{
			IList processDefinitions = null;
			log.Debug("getting all process definitions...");
			processDefinitions = dbSession.Find(queryFindAllProcessDefinitions);
			if (relations != null)
			{
				relations.Resolve(processDefinitions);
			}
			return processDefinitions;
		}
コード例 #20
0
ファイル: BankComponentImpl.cs プロジェクト: qwinner/NetBPM
		public BankAccount GetBankAccount(string bank, string costumer, DbSession dbSession)
		{
			log.Debug("GetBankAccount");
			BankAccount bankAccount = null;

			Object[] values = new Object[] {bank, costumer};
			IType[] types = new IType[] {DbType.STRING, DbType.STRING};

			bankAccount = (BankAccount) dbSession.FindOne(queryFindBankAccount,values,types);
			return bankAccount;
		}
コード例 #21
0
 public void DeployProcessArchive(byte[] processArchiveBytes, DbSession dbSession)
 {
     try
     {
         Stream mstream = new MemoryStream(processArchiveBytes);
         DeployProcessArchive(mstream, dbSession);
     }
     catch (IOException e)
     {
         throw new NpdlException("couldn't deploy process archive, the processArchiveBytes do not seem to be a valid par-file : " + e.Message, e);
     }
 }
コード例 #22
0
 public void Save(ProcessDefinitionImpl processDefinition,DbSession dbSession) 
 {
     try
     {
         dbSession.SaveOrUpdate(processDefinition);
         dbSession.Flush();
     }
     catch (DbException e)
     {
         throw new NpdlException("couldn't deploy process archive due to a database exception : " + e.Message, e);
     }
 }
コード例 #23
0
 public override void Resolve(DbSession dbSession)
 {
     try
     {
         log.Debug("resolving object reference : " + _referenceId + " : " + _className);
         Type clazz = Type.GetType(_className);
         _object = dbSession.Load(clazz, _referenceId);
     }
     catch (System.Exception e)
     {
         log.Error("error resolving object reference :", e);
     }
 }
コード例 #24
0
        public void DeployProcessArchive(byte[] processArchiveBytes)
        {
            ParFile parFile = new ParFile(processArchiveBytes);

            ProcessDefinitionBuildService buildService = new ProcessDefinitionBuildService(parFile.ProcessDefinition);
            ProcessDefinitionImpl processDefinition = buildService.BuildProcessDefinition();

            using (ISession session = NHibernateHelper.OpenSession())
            {
                DbSession nhSession = new DbSession(session);
                repository.Save(processDefinition, nhSession);
            }
        }
コード例 #25
0
ファイル: TransitionService.cs プロジェクト: ephebe/netbpm
        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);
        }
コード例 #26
0
		public IList GetTaskList(String authenticatedActorId, IList actorIds, Relations relations, DbSession dbSession, IOrganisationSessionLocal organisationComponent)
		{
			ArrayList tasks = null;
			IEnumerator actorIdsIterator = actorIds.GetEnumerator();
			while (actorIdsIterator.MoveNext())
			{
				String actorId = (String) actorIdsIterator.Current;
				if (tasks == null)
				{
					tasks = new ArrayList();
				}
				tasks.AddRange(GetTaskList(authenticatedActorId, actorId, relations, dbSession, organisationComponent));
			}
			return tasks;
		}
コード例 #27
0
 public IList GetTaskList(String actorId,Relations relations = null)
 {
     IList taskLists = null;
     IOrganisationService organisationComponent = null;
     try
     {
         using (ISession session = NHibernateHelper.OpenSession())
         {
             DbSession dbSession = new DbSession(session);
             IActor actor = organisationService.FindActorById(actorId);
             taskLists = taskRepository.FindTasks(actorId, dbSession);
         }
     }
     finally
     {
         ServiceLocator.Instance.Release(organisationComponent);
     }
     return taskLists;
 }
コード例 #28
0
        public void RunActionsForEvent(EventType eventType, long definitionObjectId, ExecutionContextImpl executionContext,DbSession dbSession)
        {
            log.Debug("processing '" + eventType + "' events for executionContext " + executionContext);

            // find all actions for definitionObject on the given eventType
            Object[] values = new Object[] { eventType, definitionObjectId };
            IType[] types = new IType[] { DbType.INTEGER, DbType.LONG };

            IList actions = dbSession.Find(queryFindActionsByEventType, values, types);
            IEnumerator iter = actions.GetEnumerator();
            log.Debug("list" + actions);
            while (iter.MoveNext())
            {
                ActionImpl action = (ActionImpl)iter.Current;
                log.Debug("action: " + action);
                delegationHelper.DelegateAction(action.ActionDelegation, executionContext);
            }
            log.Debug("ende runActionsForEvent!");
        }
コード例 #29
0
		public IList GetTaskList(String authenticatedActorId, String actorId, Relations relations, DbSession dbSession, IOrganisationSessionLocal organisationComponent)
		{
			IList tasks = null;
			IActor actor = organisationComponent.FindActorById(actorId);

			if (actor is IUser)
			{
				log.Debug("getting task lists for actor --> User : [" + actor + "]");
				tasks = GetActorTaskList(actorId, dbSession);
			}
			else if (actor is IGroup)
			{
				log.Debug("getting task lists for actor --> Group : [" + actor + "]");
				tasks = GetGroupTaskList(authenticatedActorId, null, actorId, dbSession, organisationComponent);
			}

			if (relations != null)
			{
				relations.Resolve(tasks);
			}

			return tasks;
		}
コード例 #30
0
        public void CancelFlow(String authenticatedActorId, Int64 flowId, DbSession dbSession, IOrganisationService organisationComponent)
        {
            // first check if the actor is allowed to cancel this flow
            authorizationHelper.CheckCancelFlow(authenticatedActorId, flowId, dbSession);

            FlowImpl flow = (FlowImpl) dbSession.Load(typeof (FlowImpl), flowId);

            log.Info("actor '" + authenticatedActorId + "' cancels flow '" + flowId + "'...");

            // only perform the cancel if this flow is not finished yet
            if (!flow.EndHasValue)
            {
                ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, flow, dbSession, organisationComponent);
                executionContext.CreateLog(authenticatedActorId, EventType.FLOW_CANCEL);

                if (flow.IsRootFlow())
                {
                    // set the flow in the end-state
                    log.Debug("setting root flow to the end state...");
                    EndStateImpl endState = (EndStateImpl) flow.ProcessInstance.ProcessDefinition.EndState;
                    engine.ProcessEndState(endState, executionContext, dbSession);
                }
                else
                {
                    // set the flow in the join
                    ConcurrentBlockImpl concurrentBlock = (ConcurrentBlockImpl) flow.Node.ProcessBlock;
                    JoinImpl join = (JoinImpl) concurrentBlock.Join;
                    log.Debug("setting concurrent flow to join '" + join + "'");
                    engine.ProcessJoin(join, executionContext, dbSession);
                }

                // flush the updates to the db
                dbSession.Update(flow);
                dbSession.Flush();
            }
        }