📄 executioncomponentimpl.cs
字号:
public void SaveActivity(String authenticatedActorId, Int64 flowId, IDictionary attributeValues, DbSession dbSession, IOrganisationSessionLocal organisationComponent)
{
// get the flow
FlowImpl flow = (FlowImpl) dbSession.Load(typeof (FlowImpl), flowId);
// create the execution-context
ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, flow, dbSession, organisationComponent);
executionContext.StoreAttributeValues(attributeValues);
}
public IList PerformActivity(String authenticatedActorId, Int64 flowId, IDictionary attributeValues, String transitionName, Relations relations, DbSession dbSession, IOrganisationSessionLocal 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
engine.RunActionsForEvent(EventType.BEFORE_PERFORM_OF_ACTIVITY, activityState.Id, executionContext);
// 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
engine.RunActionsForEvent(EventType.PERFORM_OF_ACTIVITY, activityState.Id, executionContext);
// from here on, we consider the actor as being the previous actor
executionContext.SetActorAsPrevious();
// select and process the transition
TransitionImpl startTransition = executionContext.GetTransition(transitionName, activityState, dbSession);
engine.ProcessTransition(startTransition, executionContext);
// log event & trigger actions
engine.RunActionsForEvent(EventType.AFTER_PERFORM_OF_ACTIVITY, activityState.Id, executionContext);
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;
}
//@todo delete parameter organisationComponent
public void DelegateActivity(String authenticatedActorId, Int64 flowId, String delegateActorId, DbSession dbSession, IOrganisationSessionLocal organisationComponent)
{
// first check if the actor is allowed to delegate this activity
authorizationHelper.CheckDelegateActivity(authenticatedActorId, flowId, delegateActorId, dbSession);
// reassign the flow
FlowImpl flow = (FlowImpl) dbSession.Load(typeof (FlowImpl), flowId);
flow.ActorId = delegateActorId;
// flush the updates to the db
dbSession.Update(flow);
dbSession.Flush();
}
public void CancelProcessInstance(String authenticatedActorId, Int64 processInstanceId, DbSession dbSession, IOrganisationSessionLocal organisationComponent)
{
// first check if the actor is allowed to cancel this process instance
authorizationHelper.CheckCancelProcessInstance(authenticatedActorId, processInstanceId, dbSession);
ProcessInstanceImpl processInstance = (ProcessInstanceImpl) dbSession.Load(typeof (ProcessInstanceImpl), processInstanceId);
log.Info("actor '" + authenticatedActorId + "' cancels processInstance '" + processInstanceId + "'...");
if (!processInstance.EndHasValue)
{
CancelFlowRecursive((FlowImpl) processInstance.RootFlow, DateTime.Now);
ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, (FlowImpl) processInstance.RootFlow, dbSession, organisationComponent);
executionContext.CreateLog(authenticatedActorId, EventType.PROCESS_INSTANCE_CANCEL);
EndStateImpl endState = (EndStateImpl) processInstance.ProcessDefinition.EndState;
engine.ProcessEndState(endState, executionContext);
processInstance.End = DateTime.Now;
// flush the updates to the db
dbSession.Update(processInstance);
dbSession.Flush();
}
else
{
throw new SystemException("couldn't cancel process instance : process instance '" + processInstanceId + "' was already finished");
}
}
public void CancelFlow(String authenticatedActorId, Int64 flowId, DbSession dbSession, IOrganisationSessionLocal 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);
}
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);
}
// flush the updates to the db
dbSession.Update(flow);
dbSession.Flush();
}
}
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;
}
private void CancelFlowRecursive(FlowImpl flow, DateTime now)
{
flow.End = now;
flow.ActorId = null;
IEnumerator iter = flow.Children.GetEnumerator();
while (iter.MoveNext())
{
CancelFlowRecursive((FlowImpl) iter.Current, now);
}
}
private IList GetActorTaskList(String actorId, DbSession dbSession)
{
IList tasks = (IList) dbSession.Find(queryFindTasks, actorId, DbType.STRING);
return tasks;
}
private IList GetGroupTaskList(String authenticatedActorId, ArrayList groupTaskLists, String groupId, DbSession dbSession, IOrganisationSessionLocal organisationComponent)
{
if (groupTaskLists == null)
{
groupTaskLists = new ArrayList();
}
IGroup g = organisationComponent.FindGroupById(groupId, new Relations("parent"));
IGroup gParent = g.Parent;
if (gParent != null)
{
// scan if this group has more parent(s)
GetGroupTaskList(authenticatedActorId, groupTaskLists, gParent.Id, dbSession, organisationComponent);
}
// no more parent
IList gTaskLists = GetActorTaskList(g.Id, dbSession);
groupTaskLists.AddRange(gTaskLists);
log.Debug("added task lists [" + gTaskLists + "] for group [" + g + "]");
return groupTaskLists;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -