//private const String queryFindAttributeInstanceByName = "select ai " + // "from ai in class NetBpm.Workflow.Execution.Impl.AttributeInstanceImpl, " + // " f in class NetBpm.Workflow.Execution.Impl.FlowImpl " + // "where ai.Scope = f.id " + " and ai.Attribute.Name = ? " + // " and f.id = ? "; private AttributeInstanceImpl FindAttributeInstanceInScope(String attributeName) { AttributeInstanceImpl attributeInstance = null; FlowImpl scope = this._flow; while (attributeInstance == null) { IList attributes = attributeRepository.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 { //throw new RuntimeException( "couldn't find attribute-instance '" + attributeName + "' in scope of flow '" + this.flow + "'" ); // log a warning message (indicate that attribute supplied is not defined in attribute-instance in db) log.Warn("couldn't find attribute-instance '" + attributeName + "' in scope of flow '" + this._flow + "'"); break; } } } return(attributeInstance); }
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(); } }
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; }