Exemplo n.º 1
0
		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;
		}
Exemplo n.º 2
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;
		}
Exemplo n.º 3
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;
		}
Exemplo n.º 4
0
		public IList GetProcessDefinitions(Relations relations, DbSession dbSession)
		{
			IList processDefinitions = null;
			processDefinitions = dbSession.Find(queryFindProcessDefinitions);
			if (relations != null)
			{
				relations.Resolve(processDefinitions);
			}
			return processDefinitions;
		}
Exemplo n.º 5
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;
		}
Exemplo n.º 6
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;
		}
Exemplo n.º 7
0
        public IList PerformActivity(String authenticatedActorId, Int64 flowId, IDictionary attributeValues, String transitionName, Relations relations, DbSession dbSession, IOrganisationService organisationComponent)
        {
            IList assignedFlows = null;
            // get the flow
            FlowImpl flow = (FlowImpl) dbSession.Load(typeof (FlowImpl), flowId);
            dbSession.Lock(flow.ProcessInstance, LockMode.Upgrade);
            ActivityStateImpl activityState = (ActivityStateImpl) flow.Node;

            // TODO : check which part can move to the DefaultAuthorizationHandler
            if ((Object) flow.ActorId == null)
            {
                throw new SystemException("the flow on which you try to perform an activity is not assigned to an actor");
            }
            else
            {
                if ((Object) authenticatedActorId == null)
                {
                    throw new AuthorizationException("you can't perform an activity because you are not authenticated");
                }
                //		else if ( ! authenticatedActorId.equals( flow.getActorId() ) ) {
                //        throw new AuthorizationException( "activity '" + activityState.getName() + "' in flow " + flow.getId() + " is not assigned to the authenticated actor (" + authenticatedActorId + ") but to " + flow.getActorId() );
                //      }
            }

            // first check if the actor is allowed to perform this activity
            authorizationHelper.CheckPerformActivity(authenticatedActorId, flowId, attributeValues, transitionName, dbSession);

            log.Info("actor '" + authenticatedActorId + "' performs activity '" + activityState.Name + "'...");

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

            // if this activity has a role-name, save the actor in the corresponding attribute
            // attributeValues = state.addRoleAttributeValue( attributeValues, authenticatedActorId, organisationComponent );

            // log event & trigger actions
            delegationService.RunActionsForEvent(EventType.BEFORE_PERFORM_OF_ACTIVITY, activityState.Id, executionContext,dbSession);

            // store the supplied attribute values
            executionContext.CreateLog(authenticatedActorId, EventType.PERFORM_OF_ACTIVITY);
            executionContext.AddLogDetail(new ObjectReferenceImpl(activityState));
            executionContext.CheckAccess(attributeValues, activityState);
            executionContext.StoreAttributeValues(attributeValues);

            // log event & trigger actions
            delegationService.RunActionsForEvent(EventType.PERFORM_OF_ACTIVITY, activityState.Id, executionContext,dbSession);

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

            // select and process the transition
            TransitionImpl startTransition = transitionRepository.GetTransition(transitionName, activityState, dbSession);
            engine.ProcessTransition(startTransition, executionContext, dbSession);

            // log event & trigger actions
            delegationService.RunActionsForEvent(EventType.AFTER_PERFORM_OF_ACTIVITY, activityState.Id, executionContext,dbSession);

            assignedFlows = executionContext.AssignedFlows;

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

            if (relations != null)
            {
                relations.Resolve(assignedFlows);
            }
            dbSession.Update(flow.ProcessInstance);
            return assignedFlows;
        }
Exemplo n.º 8
0
        public IFlow GetFlow(String authenticatedActorId, Int64 flowId, Relations relations, DbSession dbSession)
        {
            // first check if the actor is allowed to get this flow
            authorizationHelper.CheckGetFlow(authenticatedActorId, flowId, dbSession);

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

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

            return flow;
        }
Exemplo n.º 9
0
		private void Resolve(FlowImpl flow, Relations relations, DbSession dbSession)
		{
			// resolve the flow 
			if (relations != null)
			{
				log.Debug("resolving relations : '" + relations + "' on flow '" + flow + "'");
				relations.Resolve(flow);
			}

			// resolve the flow-details 
			IEnumerator iter = flow.Logs.GetEnumerator();
			while (iter.MoveNext())
			{
				LogImpl logImpl = (LogImpl) iter.Current;
				IEnumerator detailsIter = logImpl.Details.GetEnumerator();
				while (detailsIter.MoveNext())
				{
					LogDetailImpl LogDetailImpl = (LogDetailImpl) detailsIter.Current;
					LogDetailImpl.Resolve(dbSession);
				}
			}

			// resolve the attribute values
			iter = flow.AttributeInstances.GetEnumerator();
			while (iter.MoveNext())
			{
				AttributeInstanceImpl attributeInstance = (AttributeInstanceImpl) iter.Current;
				log.Debug("resolving attribute instance : " + attributeInstance.GetValue());
			}

			// resolve the child-flows 
			iter = flow.Children.GetEnumerator();
			while (iter.MoveNext())
			{
				FlowImpl subFlow = (FlowImpl) iter.Current;
				Resolve(subFlow, relations, dbSession);
			}

			// resolve the sub-process-flows 
			IProcessInstance subProcessInstance = flow.GetSubProcessInstance();
			if (subProcessInstance != null)
			{
				Resolve((FlowImpl) subProcessInstance.RootFlow, relations, dbSession);
			}
		}
Exemplo n.º 10
0
		// method implementations ////////////////////////////////////////////
		public IActor FindActorById(String actorName, Relations relations, DbSession dbSession)
		{
			IActor actor = null;
			try
			{
				actor = (IActor) dbSession.FindOne(queryFindActorById, actorName, DbType.STRING);
				if (relations != null)
					relations.Resolve(actor);
			}
			catch (Exception t)
			{
				throw new OrganisationRuntimeException("organisation-exception : coudn't find actor '" + actorName + "' by name : " + t.Message);
			}
			return actor;
		}
Exemplo n.º 11
0
		public IGroup FindGroupByMembership(String userId, String membershipType, Relations relations, DbSession dbSession)
		{
			IGroup group = null;
			try
			{
				Object[] args = new Object[] {userId, membershipType};
				IType[] types = new IType[] {DbType.STRING, DbType.STRING};
				group = (IGroup) dbSession.FindOne(queryFindGroupByMembership, args, types);
				if (relations != null)
					relations.Resolve(group);
			}
			catch (Exception t)
			{
				throw new OrganisationRuntimeException("organisation-exception : coudn't find group by membership by user '" + userId + "' and membership-type '" + membershipType + "' : " + t.Message);
			}
			return group;
		}
Exemplo n.º 12
0
		public IList FindMembershipsByUserAndGroup(String userId, String groupId, Relations relations, DbSession dbSession)
		{
			IList memberships = null;
			try
			{
				Object[] args = new Object[] {userId, groupId};
				IType[] types = new IType[] {DbType.STRING, DbType.STRING};
				log.Debug("findMembershipsByUserAndGroup(" + userId + "," + groupId + "): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + memberships);
				memberships = dbSession.Find(queryFindMembershipsByUserAndGroup, args, types);
				log.Debug("findMembershipsByUserAndGroup(" + userId + "," + groupId + "): " + memberships);
				if (relations != null)
					relations.Resolve(memberships);
			}
			catch (Exception t)
			{
				throw new OrganisationRuntimeException("organisation-exception : coudn't find memberships by user '" + userId + "' and group '" + groupId + "' : " + t.Message);
			}
			return memberships;
		}
Exemplo n.º 13
0
		public IList FindUsersByGroupAndRole(String groupId, String role, Relations relations, DbSession dbSession)
		{
			IList users = null;
			try
			{
				Object[] args = new Object[] {groupId, role};
				IType[] types = new IType[] {DbType.STRING, DbType.STRING};
				users = dbSession.Find(queryFindUsersByGroupAndRole, args, types);
				if (relations != null)
					relations.Resolve(users);
			}
			catch (Exception t)
			{
				throw new OrganisationRuntimeException("organisation-exception : coudn't find users by group '" + groupId + "' and role '" + role + "' : " + t.Message);
			}
			return users;
		}
Exemplo n.º 14
0
		public IList FindAllUsers(Relations relations, DbSession dbSession)
		{
			IList users = null;
			try
			{
				users = dbSession.Find(queryFindAllUsers);
				if (relations != null)
					relations.Resolve(users);
			}
			catch (Exception t)
			{
				throw new OrganisationRuntimeException("organisation-exception : coudn't find all users : " + t.Message);
			}
			return users;
		}