private void join(XmlElement joinElement, JoinImpl joinImpl, ProcessBlockImpl currentProcessBlock) { this.node(joinElement, joinImpl, currentProcessBlock); if ((Object)joinElement.GetAttribute("handler") != null) { joinImpl.JoinDelegation = new DelegationImpl(); this.delegation <JoinImpl>(joinElement, joinImpl.JoinDelegation); } }
public void ProcessJoin(JoinImpl join, FlowImpl joiningFlow, DbSession dbSession) { joiningFlow.End = DateTime.Now; joiningFlow.ActorId = null; joiningFlow.Node = join; if (false != joiningFlow.ParentReactivation) { bool parentReactivation = false; IList concurrentFlows = flowRepository.GetOtherActiveConcurrentFlows(joiningFlow.Id, dbSession); if (concurrentFlows.Count == 0) { parentReactivation = true; } else { //DelegationImpl joinDelegation = join.JoinDelegation; //if (joinDelegation != null) //{ // IJoinHandler joiner = (IJoinHandler)joinDelegation.GetDelegate(); // IDictionary attributes = joinDelegation.ParseConfiguration(); // parentReactivation = delegationHelper.DelegateJoin(join.JoinDelegation, executionContext); //} } if (parentReactivation) { IEnumerator iter = concurrentFlows.GetEnumerator(); while (iter.MoveNext()) { 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, parentFlow, dbSession); } else { // no transition throw exception? } } } }
private void concurrentBlock(XmlElement concurrentElement, ConcurrentBlockImpl concurrentBlock, ProcessBlockImpl currentProcessBlock) { concurrentBlock.ProcessDefinition = ProcessDefinition; this.processBlock(concurrentElement, concurrentBlock); JoinImpl joinImpl = concurrentBlock.CreateJoin(); ForkImpl forkImpl = concurrentBlock.CreateFork(); XmlElement joinElement = concurrentElement.GetChildElement("join"); this.join(joinElement, joinImpl, concurrentBlock); XmlElement forkElement = concurrentElement.GetChildElement("fork"); this.fork(forkElement, forkImpl, concurrentBlock); this.addReferencableObject(joinImpl.Name, currentProcessBlock, typeof(INode), joinImpl); this.addReferencableObject(forkImpl.Name, currentProcessBlock, typeof(INode), forkImpl); }
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(); } }
private string EncodeAsJSON() { var parameters = new Dictionary <string, object>(); if (WhereImpl != null) { parameters["WHERE"] = WhereImpl.ConvertToJSON(); } if (Distinct) { parameters["DISTINCT"] = true; } if (LimitValue != null) { var e = Misc.TryCast <IExpression, QueryExpression>(LimitValue); parameters["LIMIT"] = e.ConvertToJSON(); } if (SkipValue != null) { var e = Misc.TryCast <IExpression, QueryExpression>(SkipValue); parameters["OFFSET"] = e.ConvertToJSON(); } if (OrderByImpl != null) { parameters["ORDER_BY"] = OrderByImpl.ToJSON(); } var selectParam = SelectImpl?.ToJSON(); if (selectParam != null) { parameters["WHAT"] = selectParam; } if (JoinImpl != null) { var fromJson = FromImpl?.ToJSON(); if (fromJson == null) { throw new InvalidOperationException(CouchbaseLiteErrorMessage.NoAliasInJoin); } var joinJson = JoinImpl.ToJSON() as IList <object>; Debug.Assert(joinJson != null); joinJson.Insert(0, fromJson); parameters["FROM"] = joinJson; } else { var fromJson = FromImpl?.ToJSON(); if (fromJson != null) { parameters["FROM"] = new[] { fromJson }; } } if (GroupByImpl != null) { parameters["GROUP_BY"] = GroupByImpl.ToJSON(); } if (HavingImpl != null) { parameters["HAVING"] = HavingImpl.ToJSON(); } return(JsonConvert.SerializeObject(parameters)); }
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? } } } }