예제 #1
0
		public TransitionImpl DelegateDecision(DelegationImpl delegation, ExecutionContextImpl executionContext)
		{
			TransitionImpl selectedTransition = null;

			try
			{
				IDecisionHandler decision = (IDecisionHandler) GetDelegate(delegation);
				executionContext.SetConfiguration(ParseConfiguration(delegation));
				String transitionName = decision.Decide(executionContext);

				if ((Object) transitionName == null)
				{
					throw new SystemException("Decision-delegate for decision '" + executionContext.GetNode() + "' returned null instead of a transition-name : " + decision.GetType().FullName);
				}

				try
				{
					Object[] args = new Object[] {executionContext.GetNode().Id, transitionName};
					IType[] types = new IType[] {DbType.LONG, DbType.STRING};
					selectedTransition = (TransitionImpl) executionContext.DbSession.FindOne(queryFindLeavingTransitionByName, args, types);
				}
				catch (Exception t)
				{
					throw new SystemException("couldn't find transition '" + transitionName + "' that was selected by the decision-delegate of activity '" + executionContext.GetNode().Name + "' : " + t.Message);
				}
			}
			catch (Exception t)
			{
				HandleException(delegation, executionContext, t);
			}

			return selectedTransition;
		}