@Override public void execute(ExecutionImpl execution) { execution.historyActivityStart(); if (startState) { execution.signal(); } else { execution.waitForSignal(); } }
public void setExecution(ExecutionImpl execution) { this.execution = execution; this.processInstance = (execution!=null ? execution.getProcessInstance() : null); }
protected ExecutionImpl newProcessInstance() { return new ExecutionImpl(); }
public ClientProcessInstance beginSubProcessInstance(ClientProcessDefinition processDefinition, String key) { createSubProcessInstance(processDefinition, key); subProcessInstance.begin(); return subProcessInstance; }
public void execute(ExecutionImpl execution) { execution.historyActivityStart(); execution.waitForSignal(); }
public ExecutionImpl createScope(CompositeElementImpl scope) { ExecutionImpl child = createExecution(scope.getName()); // copy the current state from the child execution to the parent execution child.setNode(getNode()); child.setTransition(getTransition()); child.setPropagation(getPropagation()); child.setTransitionOrigin(getTransitionOrigin()); child.setPreviousTransition(getPreviousTransition()); child.setPreviousNode(getPreviousNode()); child.initializeVariables(scope, this); child.initializeTimers(scope); return child; }
public void execute(ExecutionImpl execution) { Activity activity = execution.getActivity(); List<? extends Transition> outgoingTransitions = activity.getOutgoingTransitions(); ActivityImpl parentActivity = (ActivityImpl) activity.getParentActivity(); execution.take(outgoingTransition); execution.setActivity(parentActivity); execution.signal(); OpenExecution executionToEnd = null; if (endProcessInstance) { executionToEnd = execution.getProcessInstance(); } else { executionToEnd = execution; execution.end(executionToEnd); } else { execution.end(executionToEnd, state); if (parent != null && parent.getExecutions().isEmpty() && Execution.STATE_INACTIVE_CONCURRENT_ROOT.equals(parent.getState()) ) { parent.end();
LOG.debug("Proceeding from execution in " + execution.getActivityName()); Activity activity = execution.getActivity(); LOG.debug("No outgoing transitions found. Ending the execution"); execution.end(); execution.take(transitions.get(0)); if (Execution.STATE_ACTIVE_ROOT.equals(execution.getState())) { concurrentRoot = execution; execution.setState(Execution.STATE_INACTIVE_CONCURRENT_ROOT); execution.setActivity(null); } else if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) { concurrentRoot = execution.getParent(); execution.end(); ExecutionImpl concurrentExecution = concurrentRoot.createExecution(transition.getName()); concurrentExecution.setActivity(activity); concurrentExecution.setState(Execution.STATE_ACTIVE_CONCURRENT); childExecutionsMap.put(transition, concurrentExecution); childExecutionsMap.get(transition).take(transition); if (concurrentRoot.isEnded()) { break;
/** * Section 14.3.2 of the BPMN 2.0 specification. * * The Inclusive Gateway is activated if * - At least one incoming sequence flow has at least one Token and * - for each empty incoming sequence flow, there is no Token in the graph anywhere * upstream of this sequence flow, i.e., there is no directed path (formed by Sequence Flow) * from a Token to this sequence flow unless * - the path visits the inclusive gateway or * - the path visits a node that has a directed path to a non-empty incoming sequence * flow of the inclusive gateway. */ protected boolean isComplete(ExecutionImpl incomingExecution) { String currentActivityId = incomingExecution.getActivityName(); // id is stored in the name attribute Collection<ExecutionImpl> allExecutions = incomingExecution.getProcessInstance().getExecutions(); BpmnProcessDefinition processDefinition = (BpmnProcessDefinition) incomingExecution.getProcessDefinition(); for (ExecutionImpl execution : allExecutions) { if (incomingExecution.getParent().equals(execution.getParent())) { String activityId = execution.getActivityName(); // id is stored in the name attribute if (activityId != null && !currentActivityId.equals(activityId)) { if (processDefinition.isReachable(activityId, currentActivityId)) { return false; } } } } return true; }
public void execute(ExecutionImpl execution) { List<Activity> startActivities = findStartActivities(execution); if (!startActivities.isEmpty()) { ExecutionImpl parent = execution.createScope(execution.getActivity()); for (Activity startActivity: startActivities) { parent.setState(Execution.STATE_INACTIVE_CONCURRENT_ROOT); ExecutionImpl concurrentExecution = parent.createExecution(); concurrentExecution.setState(Execution.STATE_ACTIVE_CONCURRENT); concurrentExecution.execute(startActivity); } } else { throw new JbpmException("Could not find start activity for the sub-process " + execution.getActivityName()); } }
/** * Joins all the incoming executions currently waiting at the gateway. * * @return An execution that can be used to leave the gateway (one outgoing sequence flow) * or to create child executions on (fork behaviour when multiple outgoing sequence flow). */ protected ExecutionImpl join(ExecutionImpl execution) { Activity activity = execution.getActivity(); ExecutionImpl concurrentRoot = execution.getParent(); if (concurrentRoot == null) { return execution; } List<ExecutionImpl> joinedExecutions = getJoinedExecutions(concurrentRoot, activity); endJoinedExecutions(joinedExecutions); ExecutionImpl outgoingExecution = null; if (concurrentRoot.getExecutions().size() == 0) { outgoingExecution = concurrentRoot; outgoingExecution.setState(Execution.STATE_ACTIVE_ROOT); } else { outgoingExecution = concurrentRoot.createExecution(); outgoingExecution.setState(Execution.STATE_ACTIVE_CONCURRENT); } outgoingExecution.setActivity(activity); return outgoingExecution; }
public void signal(Map<String, Object> parameters) { signal(null, parameters); }
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { ExecutionImpl execution = createExecution(owner); String nodeName = rs.getString(names[0]); NodeImpl node = (NodeImpl) execution.getProcessDefinition().getNode(nodeName); execution.setNode(node); execution.setState(Execution.STATE_ACTIVE); return execution; }
/** * Joins the incoming executions. * Returns true if all executions have reached the gateway. */ protected boolean handleIncomingExecution(ExecutionImpl execution) { if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) { // force version increment in the parent execution Session session = EnvironmentImpl.getFromCurrent(Session.class); session.lock(execution.getParent(), lockMode); execution.setState(Execution.STATE_INACTIVE_JOIN); } execution.waitForSignal(); return isComplete(execution); }
public static ProcessInstanceRef adoptExecution(Execution execution) { ProcessInstanceRef ref = new ProcessInstanceRef(); ref.setId(execution.getId()); ref.setKey(execution.getKey()); ref.setDefinitionId(execution.getProcessDefinitionId()); // Start date is only available through historyService HistoryService historyService = ProcessEngineUtil.retrieveProcessEngine().getHistoryService(); Date startDate = historyService.createHistoryProcessInstanceQuery() .processInstanceId(execution.getId()) .uniqueResult().getStartTime(); ref.setStartDate(startDate); ExecutionImpl processInstance = (ExecutionImpl) execution.getProcessInstance(); ProcessDefinitionImpl processDefinition = processInstance.getProcessDefinition(); TokenReference tok = execution2TokenReference(processInstance); Collection<? extends Execution> childExecutions = processInstance.getExecutions(); if (childExecutions != null) { for (Execution child : childExecutions) { ExecutionImpl childExecution = (ExecutionImpl) child; // set process definition on child execution from process instance childExecution.setProcessDefinition(processDefinition); TokenReference childTok = execution2TokenReference(childExecution); tok.getChildren().add(childTok); } } ref.setRootToken(tok); return ref; }
task.setTaskDefinition(taskDefinition); task.setExecution(execution); task.setProcessInstance(execution.getProcessInstance()); task.setSignalling(true); task.setName(taskDefinition.getName()); } else { task.setName(execution.getActivityName()); execution.initializeAssignments(taskDefinition, task); execution.waitForSignal();
if (signalName!=null) { if (log.isDebugEnabled()) log.debug("feeding timer signal "+signalName+" into "+execution); execution.signal(signalName); ObservableElement eventSource = execution.getNode(); if (log.isDebugEnabled()) log.debug("firing event "+signalName+" into "+eventSource); execution.fire(eventName, eventSource);
props.put(Process.PROPERTY_PROCESS_TYPE, ((ExecutionImpl) execution).getProcessDefinition().getName()); props.put(Process.PROPERTY_PROCESS_ID, execution.getId()); String state = Jbpm.getState(execution.getProcessInstance());
protected ExecutionImpl initializeScopes() { LinkedList<NodeImpl> enteredNodes = new LinkedList<NodeImpl>(); NodeImpl initial = processDefinition.getInitial(); ExecutionImpl scopedExecution = null; if (initial!=null) { enteredNodes.add(initial); NodeImpl parentNode = initial.getParentNode(); while (parentNode!=null) { enteredNodes.addFirst(parentNode); parentNode = parentNode.getParentNode(); } scopedExecution = this; initializeVariables(processDefinition, this); initializeTimers(processDefinition); for (NodeImpl enteredNode: enteredNodes) { if (enteredNode.isLocalScope()) { scopedExecution.setNode(enteredNode); scopedExecution = scopedExecution.createScope(enteredNode); } } scopedExecution.setNode(initial); } return scopedExecution; }