private Token getRootToken() { return processInstance.getRootToken(); }
private Token getRootToken() { return processInstance.getRootToken(); }
public boolean isRoot() { return processInstance != null && equals(processInstance.getRootToken()); }
public boolean isRoot() { return processInstance != null && equals(processInstance.getRootToken()); }
/** * Get the current Node of the pageflow. */ public Node getNode() { if (processInstance==null) return null; Node node = getSubProcessInstance().getRootToken().getNode(); if (node==null) { throw new IllegalStateException("pageflow has not yet started"); } return node; }
public Token findToken(String relativeTokenPath) { if (relativeTokenPath == null) return null; String path = relativeTokenPath.trim(); if (path.length() == 0 || ".".equals(path)) return this; if ("..".equals(path)) return parent; if (path.startsWith("/")) { return processInstance.getRootToken().findToken(path.substring(1)); } if (path.startsWith("./")) return findToken(path.substring(2)); if (path.startsWith("../")) { return parent != null ? parent.findToken(path.substring(3)) : null; } if (children == null) return null; int slashIndex = path.indexOf('/'); if (slashIndex == -1) return (Token) children.get(path); Token token = (Token) children.get(path.substring(0, slashIndex)); return token != null ? token.findToken(path.substring(slashIndex + 1)) : null; }
public Token findToken(String relativeTokenPath) { if (relativeTokenPath == null) return null; String path = relativeTokenPath.trim(); if (path.length() == 0 || ".".equals(path)) return this; if ("..".equals(path)) return parent; if (path.startsWith("/")) { return processInstance.getRootToken().findToken(path.substring(1)); } if (path.startsWith("./")) return findToken(path.substring(2)); if (path.startsWith("../")) { return parent != null ? parent.findToken(path.substring(3)) : null; } if (children == null) return null; int slashIndex = path.indexOf('/'); if (slashIndex == -1) return (Token) children.get(path); Token token = (Token) children.get(path.substring(0, slashIndex)); return token != null ? token.findToken(path.substring(slashIndex + 1)) : null; }
private static ProcessInstance getSubProcess(ProcessInstance processInstance) { ProcessInstance subProcess = processInstance.getRootToken().getSubProcessInstance(); if (subProcess!=null) { return getSubProcess(subProcess); } else { return processInstance; } }
public boolean isStarted() { return getSubProcessInstance().getRootToken().getNode() != null; }
/** * returns a map that maps {@link Token}s to {@link List}s. The lists contain the ordered logs * for the given token. The lists are retrieved with {@link #findLogsByToken(long)}. */ public Map findLogsByProcessInstance(long processInstanceId) { Map tokenLogs = new HashMap(); try { ProcessInstance processInstance = (ProcessInstance) session.load(ProcessInstance.class, new Long( processInstanceId)); collectTokenLogs(tokenLogs, processInstance.getRootToken()); } catch (HibernateException e) { handle(e); throw new JbpmPersistenceException("couldn't get logs for process instance " + processInstanceId, e); } return tokenLogs; }
/** * returns a map that maps {@link Token}s to {@link List}s. The lists contain the ordered logs * for the given token. The lists are retrieved with {@link #findLogsByToken(long)}. */ public Map findLogsByProcessInstance(long processInstanceId) { Map tokenLogs = new HashMap(); try { ProcessInstance processInstance = (ProcessInstance) session.load(ProcessInstance.class, new Long( processInstanceId)); collectTokenLogs(tokenLogs, processInstance.getRootToken()); } catch (HibernateException e) { handle(e); throw new JbpmPersistenceException("couldn't get logs for process instance " + processInstanceId, e); } return tokenLogs; }
public ProcessInstance execute(ProcessInstance pi) { ProcessDefinition oldDef = pi.getProcessDefinition(); ProcessDefinition newDef = findNewProcessDefinition(oldDef.getName()); boolean debug = log.isDebugEnabled(); if (debug) { log.debug("migrating " + pi + " from version " + oldDef.getVersion() + " to " + newDef.getVersion()); } pi.setProcessDefinition(newDef); changeTokenVersion(pi.getRootToken()); if (debug) log.debug(pi + " migrated to version " + newDef.getVersion()); return pi; }
public ProcessInstance execute(ProcessInstance pi) { ProcessDefinition oldDef = pi.getProcessDefinition(); ProcessDefinition newDef = findNewProcessDefinition(oldDef.getName()); boolean debug = log.isDebugEnabled(); if (debug) { log.debug("migrating " + pi + " from version " + oldDef.getVersion() + " to " + newDef.getVersion()); } pi.setProcessDefinition(newDef); changeTokenVersion(pi.getRootToken()); if (debug) log.debug(pi + " migrated to version " + newDef.getVersion()); return pi; }
/** * Reposition the pageflow at the named node. * * @param nodeName the name of a node */ public void reposition(String nodeName) { if (processInstance==null) { throw new IllegalStateException("no pageflow in progress"); } ProcessInstance subProcess = getSubProcessInstance(); Node node = subProcess.getProcessDefinition().getNode(nodeName); if (node==null) { throw new IllegalArgumentException( "no node named: " + nodeName + " for pageflow: " + subProcess.getProcessDefinition().getName() ); } subProcess.getRootToken().setNode(node); setDirty(); }
protected void cancelProcess(long processIdToCancel) { ProcessInstance pi = jbpmContext.getGraphSession().loadProcessInstance(processIdToCancel); log.info("cancel process instance " + pi.getId()); // Record a standardized variable that we can use to determine that this // process has been 'canceled' and not just ended. pi.getContextInstance().createVariable(CANCELLATION_INDICATOR_VARIABLE_NAME, Clock.getCurrentTime()); try { // End the process instance and any open tokens // TODO: Think about maybe canceling sub processes? cancelToken(pi.getRootToken()); pi.end(); log.info("finished process cancellation"); } catch (RuntimeException ex) { log.error("problems while cancel process", ex); throw ex; } }
/** * creates a task instance on the rootToken, and assigns it to the currently authenticated * user. */ public TaskInstance createStartTaskInstance() { TaskInstance taskInstance = null; Task startTask = taskMgmtDefinition.getStartTask(); if (startTask != null) { Token rootToken = processInstance.getRootToken(); ExecutionContext executionContext = new ExecutionContext(rootToken); taskInstance = createTaskInstance(startTask, executionContext); taskInstance.setActorId(SecurityHelper.getAuthenticatedActorId()); } return taskInstance; }
/** * creates a task instance on the rootToken, and assigns it to the currently authenticated * user. */ public TaskInstance createStartTaskInstance() { TaskInstance taskInstance = null; Task startTask = taskMgmtDefinition.getStartTask(); if (startTask != null) { Token rootToken = processInstance.getRootToken(); ExecutionContext executionContext = new ExecutionContext(rootToken); taskInstance = createTaskInstance(startTask, executionContext); taskInstance.setActorId(SecurityHelper.getAuthenticatedActorId()); } return taskInstance; }
protected VariableContainer getVariableContainer(JbpmContext jbpmContext) { if (previousProcessInstance != null) { return getVariableContainer(previousProcessInstance.getRootToken()); } if (previousToken != null) { return getVariableContainer(previousToken); } if (previousTaskInstance != null) { return previousTaskInstance; } if (tokenId != 0) { return getVariableContainer(jbpmContext.getToken(tokenId)); } if (taskInstanceId != 0) { return jbpmContext.getTaskInstance(taskInstanceId); } return null; }
protected VariableContainer getVariableContainer(JbpmContext jbpmContext) { if (previousProcessInstance != null) { return getVariableContainer(previousProcessInstance.getRootToken()); } if (previousToken != null) { return getVariableContainer(previousToken); } if (previousTaskInstance != null) { return previousTaskInstance; } if (tokenId != 0) { return getVariableContainer(jbpmContext.getToken(tokenId)); } if (taskInstanceId != 0) { return jbpmContext.getTaskInstance(taskInstanceId); } return null; }
public ProcessInstance retrieveProcessInstance(ProcessInstance pi) { try { // process definition Hibernate.initialize(pi.getProcessDefinition()); // root token retrieveToken(pi.getRootToken()); // super process token Token superProcessToken = pi.getSuperProcessToken(); if (superProcessToken != null) { Hibernate.initialize(superProcessToken); Hibernate.initialize(superProcessToken.getProcessInstance()); } retrieveVariables(pi); } catch (RuntimeException ex) { log.warn("failure retrieving " + pi, ex); } return pi; }