Exemplo n.º 1
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();
            }
        }