@Override public void readNodes(Element nodeCollectionElement, NodeCollection nodeCollection) { super.readNodes(nodeCollectionElement, nodeCollection); if ( "pageflow-definition".equals( nodeCollectionElement.getName() ) ) { String startPageName = nodeCollectionElement.attributeValue("start-page"); if (startPageName==null) { Element startPageElement = nodeCollectionElement.element("start-page"); if (startPageElement!=null) { startPageName = startPageElement.attributeValue("name"); } } if (startPageName!=null) { Node startPage = getProcessDefinition().getNode(startPageName); if (startPage!=null) { getProcessDefinition().setStartState(startPage); } } } }
public static ProcessDefinition createNewProcessDefinition() { ProcessDefinition processDefinition = new ProcessDefinition(); // instantiate default modules List moduleClasses = getModuleClasses(); for (Iterator iter = moduleClasses.iterator(); iter.hasNext();) { Class moduleClass = (Class) iter.next(); try { ModuleDefinition moduleDefinition = (ModuleDefinition) moduleClass.newInstance(); processDefinition.addDefinition(moduleDefinition); } catch (InstantiationException e) { throw new JbpmException("failed to instantiate " + moduleClass, e); } catch (IllegalAccessException e) { throw new JbpmException(ProcessDefinition.class + " has no access to " + moduleClass, e); } } return processDefinition; }
public String getName() { return jbpmProc.getName(); }
/** * Tells whether this process definition is equal to the given object. This method considers * two process definitions equal if they are equal in name and version, the name is not null * and the version is not negative. */ public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof ProcessDefinition)) return false; ProcessDefinition other = (ProcessDefinition) o; if (id != 0 && id == other.getId()) return true; return name != null && version >= 0 && name.equals(other.getName()) && version == other.getVersion(); }
public void read(Element element, JpdlXmlReader jpdlReader) { // TODO // just making sure that the context definition is present // because the interleave node needs the context instance at runtime ProcessDefinition processDefinition = jpdlReader.getProcessDefinition(); if (processDefinition.getDefinition(ContextDefinition.class)==null) { processDefinition.addDefinition(new ContextDefinition()); } }
private Document createDomTree(ProcessDefinition processDefinition) { Document document = DocumentHelper.createDocument(); Element root = addElement(document, "process-definition"); String value = processDefinition.getName(); if (value != null) root.addAttribute("name", value); // write the start-state if (processDefinition.getStartState() != null) { root.addComment("START-STATE"); writeStartNode(root, (StartState) processDefinition.getStartState()); } // write the nodeMap if (processDefinition.getNodes() != null && processDefinition.getNodes().size() > 0) { root.addComment("NODES"); writeNodes(root, processDefinition.getNodes()); } // write the process level actions if (processDefinition.hasEvents()) { root.addComment("PROCESS-EVENTS"); writeEvents(root, processDefinition); } if (processDefinition.hasActions()) { root.addComment("ACTIONS"); List namedProcessActions = getNamedProcessActions(processDefinition.getActions()); writeActions(root, namedProcessActions); } return document; }
protected Class findClass(String className) throws ClassNotFoundException { ProcessDefinition processDefinition = getProcessDefinition(); FileDefinition fileDefinition; if (processDefinition == null || (fileDefinition = processDefinition.getFileDefinition()) == null) { throw new ClassNotFoundException(className); } // look in the classes directory of the file module definition String fileName = "classes/" + className.replace('.', '/') + ".class"; byte[] classBytes = fileDefinition.getBytes(fileName); if (classBytes == null) throw new ClassNotFoundException(className); // if the class is in a package int packageIndex = className.lastIndexOf('.'); if (packageIndex != -1) { // check whether this class loader (or any ancestor) defined the package already String packageName = className.substring(0, packageIndex); if (getPackage(packageName) == null) { // define the package prior to defining the class // see https://jira.jboss.org/jira/browse/JBPM-1404 definePackage(packageName, null, null, null, processDefinition.getName(), Integer.toString(processDefinition.getVersion()), null, null); } } return defineClass(className, classBytes, 0, classBytes.length); } }
/** * assigns a version number to the given process definition and then makes it persistent. */ public void deployProcessDefinition(ProcessDefinition processDefinition) { // versioning applies to named process definitions only String processName = processDefinition.getName(); if (processName == null) { throw new JbpmException("process definition has no name"); } // find the current latest process definition ProcessDefinition previousLatestVersion = findLatestProcessDefinition(processName); // if there is a current latest process definition if (previousLatestVersion != null) { // take the next version number processDefinition.setVersion(previousLatestVersion.getVersion() + 1); } else { // start from 1 processDefinition.setVersion(1); } saveProcessDefinition(processDefinition); }
/** * 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(); }
public static void addNodesAndTransitions(ProcessDefinition pd, String[] nodes, String[] transitions) { for ( int i = 0; i < nodes.length; i++ ) { pd.addNode( createNode( nodes[i] ) ); } for ( int i = 0; i < transitions.length; i++ ) { String[] parsedTransition = cutTransitionText( transitions[i] ); Node from = pd.getNode( parsedTransition[0] ); Node to = pd.getNode( parsedTransition[2] ); Transition t = new Transition( parsedTransition[1] ); t.setProcessDefinition(pd); from.addLeavingTransition(t); to.addArrivingTransition(t); } }
private static ProcessInstance createInstance(ProcessDefinition processDefinition) { JbpmContext jbpmContext = Jbpm.createPageflowContext(); try { log.debug( "new pageflow instance for definition: " + processDefinition.getName() ); return processDefinition.createProcessInstance(); } finally { jbpmContext.close(); } }
if(activeProcess == null) activeProcess = definition.createProcessInstance(); session.setActiveProcess(activeProcess); if(rootToken.getNode().getName().equals(this.definition.getNode("synchronize").getName()))
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 ProcessBuilder addProcess(String name) { ProcessDefinition jbpmProc = new ProcessDefinition(name); proc = new ProcessImpl(jbpmProc); return this; }
public InputStream getInputStream() throws IOException { connect(); /* * ideally, the connection would fetch the process definition and assign it to a class * field on connect(); however, that strategy "leaks" a detached process definition */ ProcessDefinition processDefinition = getProcessDefinition(); if (processDefinition == null) throw new IOException("no active jbpm context"); // having established a "connection", check whether the file exists String fileName = url.getPath(); FileDefinition fileDefinition = processDefinition.getFileDefinition(); if (fileDefinition == null || !fileDefinition.hasFile(fileName)) { throw new FileNotFoundException(fileName); } // retrieve file content byte[] fileContent = fileDefinition.getBytes(fileName); return new ByteArrayInputStream(fileContent); } }
private void registerForDeletion(ProcessDefinition processDefinition) { // start new transaction to avoid registering an uncommitted process definition newTransaction(); if (processDefinitionIds == null) processDefinitionIds = new ArrayList(); processDefinitionIds.add(new Long(processDefinition.getId())); }
throw new TagException(tag, "Value for process attribute is null"); final FileDefinition fileDefinition = processDefinition.getFileDefinition(); if (fileDefinition == null) { throw new TagException(tag, "Process has a null fileDefinition property"); try { final StringBuffer buffer = new StringBuffer(); buffer.append(processDefinition.getId()); buffer.append("/"); buffer.append(file);
public String getNoConversationViewId(String pageflowName, String pageflowNodeName) { ProcessDefinition pageflowProcessDefinition = getPageflowProcessDefinition(pageflowName); Node node = pageflowProcessDefinition.getNode(pageflowNodeName); if (node!=null && node instanceof Page) { return ( (Page) node ).getNoConversationViewId(); } else { return null; } }
public ProcessDefinition readFromArchive(ProcessArchive processArchive, ProcessDefinition processDefinition) { Map entries = processArchive.getEntries(); if (!entries.isEmpty()) { // get or create file definition FileDefinition fileDefinition = processDefinition.getFileDefinition(); if (fileDefinition == null) { fileDefinition = new FileDefinition(); processDefinition.addDefinition(fileDefinition); } // add file entries to definition for (Iterator iter = entries.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); fileDefinition.addFile((String) entry.getKey(), (byte[]) entry.getValue()); } } return processDefinition; }
public ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) { // use database identifier as key to lookup cached class loader long id = processDefinition.getId(); // if process definition is transient, use hash code as key Long key = new Long(id == 0L ? processDefinition.hashCode() : id); // consider that the context class loader changes among applications ClassLoader parentClassLoader = ClassLoaderUtil.getClassLoader(); synchronized (classLoaderRefs) { // lookup cached class loader ClassLoader processClassLoader = getProcessClassLoader(key, parentClassLoader); // if class loader is not cached, if (processClassLoader == null) { // (re-)create class loader processClassLoader = new ProcessClassLoader(parentClassLoader, processDefinition, jbpmConfiguration); // add class loader to cache putProcessClassLoader(key, processClassLoader); } return processClassLoader; } }