public void deploy(Deployment deployment) { ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) deployment.getProcessDefinition(); if (processDefinition.getId()==null) { String key = processDefinition.getKey(); if (key==null) { key = processDefinition.getName(); } if ("".equals(key)) { throw new PvmException("empty string is not a valid key"); } // replace any non-word character with an underscore key = key.replaceAll("\\W", "_"); String id = key+":"+processDefinition.getVersion(); log.trace("created id '"+id+"' for "+processDefinition); processDefinition.setId(id); } } }
/** to be overwritten by specific process language factories */ protected ProcessDefinitionImpl instantiateProcessDefinition() { return new ProcessDefinitionImpl(); }
public void addAttachment(String name, InputStream inputStream) { byte[] bytes = IoUtil.readBytes(inputStream); addAttachment(name, bytes); }
public void setName(String name) { // if there is no processDefinition associated with this node if (processDefinition==null) { // it s just a setter this.name = name; } else { // otherwise // make sure the processDefinition's activitiesMap remains up to date if (this.name!=null) { processDefinition.removeNode(this); } this.name = name; if (name!=null) { processDefinition.addNode(this); } } } public TransitionImpl getDefaultTransition() {
public void deploy(Deployment deployment) { ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) deployment.getProcessDefinition(); String name = processDefinition.getName(); if (name == null) { throw new PvmException("process must have a name to deploy it"); int version = processDefinition.getVersion(); if ( (version==ProcessDefinitionImpl.UNASSIGNED_VERSION) && ! assign processDefinition.setVersion(version);
props.put(Process.PROPERTY_PROCESS_TYPE, ((ExecutionImpl) execution).getProcessDefinition().getName()); props.put(Process.PROPERTY_PROCESS_ID, execution.getId()); String state = Jbpm.getState(execution.getProcessInstance());
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; }
/** * Deep first search algorithm that creates spanning tree * (see {@link IterationDetection#createSpanningTree(ProcessDefinitionImpl, ProcessDefinitionImpl)} * @param inNode node of the input process currently processed * @param outNode corresponding node in the spanning tree * @param outProcess spanning tree * @return list of unprocessed transitions during the DFS */ private static List<Transition> processNode(Node inNode, NodeImpl outNode, ProcessDefinitionImpl outProcess) { List<Transition> nonProcessedTransitions = new ArrayList<Transition>(); if (inNode.hasOutgoingTransitions()) { for (Transition t : inNode.getOutgoingTransitions()) { NodeImpl destNode = (NodeImpl) t.getDestination(); String destName = destNode.getName(); if (!outProcess.hasNode(destName)) { // create node NodeImpl newNode = outProcess.createNode(destName); outNode.createOutgoingTransition(newNode, t.getName()); nonProcessedTransitions.addAll(processNode(t.getDestination(), newNode, outProcess)); } else { // node already in the spanning tree, the transition is not in the spanning tree. nonProcessedTransitions.add(t); } } } return nonProcessedTransitions; }
public ClientProcessInstance createProcessInstance() { return createProcessInstance(null, null); }
public InputStream getAttachmentInputStream(String name) { byte[] bytes = getAttachmentBytes(name); if (bytes==null) { return null; } return new ByteArrayInputStream(bytes); }
public void resolve() { NodeImpl destination = (NodeImpl) processDefinition.findNode(destinationName); if (destination==null) { throw new PvmException("couldn't find destination node '"+destinationName+"' for transition "+transition); } destination.addIncomingTransition(transition); transition.setDestination(destination); } }
/** * Creates a spanning tree in spanningTree corresponding to the input process * and lists transitions that are not in the spanning tree. * Use a Deep First Search Algorithm for that. * Transitions that are not in the spanning tree can be: * - transitions that creates a second path between two nodes (e.g. split/join) * - transitions that creates loops * @param inProcess input process * @param spanningTree process where the corresponding spanning tree will be created * @return list of transitions of input process that are not in the spanning tree. */ private static List<Transition> createSpanningTree(XpdlProcess inProcess, ProcessDefinitionImpl spanningTree) { Node inNode = inProcess.getInitial(); NodeImpl outNode = spanningTree.createNode(inNode.getName()); // Create a spanning tree in outProcess and list transitions that are not in the spanning tree. // Use a Deep First Search Algorithm for that. return processNode(inNode, outNode, spanningTree); }
props.put(Process.PROPERTY_PROCESS_TYPE, ((ExecutionImpl) execution).getProcessDefinition().getName()); props.put(Process.PROPERTY_PROCESS_ID, execution.getId()); String state = Jbpm.getState(execution.getProcessInstance());
/** * Find transitions in the given list of transitions that would form a cycle if added to the given process. * If a transition can be added to the process without creating a cycle, then the transition is added. * The process returned is a DAG (directed acyclic graph) * @param process input process (this process will be modified by calling this method) * @param transitions transitions to check * @return list of transitions that cannot be added to the DAG (transitions that would create a cycle). */ private static List<Transition> findCycleTransitions(ProcessDefinitionImpl process, List<Transition> transitions) { List<Transition> cycleTransitions = new ArrayList<Transition>(); for (Transition t : transitions) { String sourceNodeName = t.getSource().getName(); String destNodeName = t.getDestination().getName(); // Check if when a transition is added to the spanning tree, it creates a cycle // check if there is already a path from transition dest to transition source. // adding the transition would then create a cycle. NodeImpl sourceNode = process.getNode(sourceNodeName); NodeImpl destNode = process.getNode(destNodeName); if (existsPath(destNode, sourceNode)) { cycleTransitions.add(t); } else { // add transition to the DAG sourceNode.createOutgoingTransition(destNode); } } return cycleTransitions; }
public ClientProcessInstance createProcessInstance(String key) { return createProcessInstance(key, null); }
ProcessDefinitionImpl outProcess = new ProcessDefinitionImpl();
public ClientProcessInstance beginProcessInstance() { ClientProcessInstance processInstance = createProcessInstance(null, null); processInstance.begin(); return processInstance; }
public ClientProcessInstance beginProcessInstance(String key) { ClientProcessInstance processInstance = createProcessInstance(key, null); processInstance.begin(); return processInstance; }