List of usage examples for org.dom4j Document addElement
Element addElement(String name);
Element
node with the given name to this branch and returns a reference to the new node. From source file:com.liferay.alloy.tools.xmlbuilder.XMLBuilder.java
License:Open Source License
private void _createXML() { ArrayList<Component> components = getComponents(); Document doc = DocumentFactory.getInstance().createDocument(); Element root = doc.addElement("taglibs"); root.addAttribute("short-name", _DEFAULT_TAGLIB_SHORT_NAME); root.addAttribute("uri", _DEFAULT_TAGLIB_URI); root.addAttribute("tlib-version", _DEFAULT_TAGLIB_VERSION); for (Component component : components) { Element componentNode = root.addElement("component"); componentNode.addAttribute("name", component.getName()); componentNode.addAttribute("module", component.getModule()); componentNode.addAttribute("package", component.getPackage()); componentNode.addAttribute("bodyContent", String.valueOf(component.isBodyContent())); componentNode.addAttribute("alloyComponent", String.valueOf(component.isAlloyComponent())); Element attributesNode = componentNode.addElement("attributes"); Element eventsNode = componentNode.addElement("events"); for (Attribute attribute : component.getAttributes()) { Element attributeNode = attributesNode.addElement("attribute"); Element nameNode = attributeNode.addElement("name"); Element inputTypeNode = attributeNode.addElement("inputType"); Element outputTypeNode = attributeNode.addElement("outputType"); Element defaultValueNode = attributeNode.addElement("defaultValue"); Element descriptionNode = attributeNode.addElement("description"); nameNode.setText(attribute.getName()); inputTypeNode.setText(attribute.getInputType()); outputTypeNode.setText(attribute.getOutputType()); defaultValueNode.setText(attribute.getDefaultValue()); descriptionNode.addCDATA(_getAttributeDescription(attribute)); }/*w w w .j av a2 s . c o m*/ for (Attribute event : component.getEvents()) { Element eventNode = eventsNode.addElement("event"); Element nameNode = eventNode.addElement("name"); Element typeNode = eventNode.addElement("type"); Element descriptionNode = eventNode.addElement("description"); nameNode.setText(event.getName()); typeNode.setText(event.getInputType()); descriptionNode.addCDATA(_getAttributeDescription(event)); } } try { FileOutputStream fos = new FileOutputStream(_componentXML); OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(fos, format); writer.write(doc); writer.flush(); System.out.println("Writing " + _componentXML); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.liferay.jbpm.WorkflowComponentImpl.java
License:Open Source License
public String getCurrentTasksXml(long instanceId, long tokenId) throws WorkflowComponentException { List tasks = getCurrentTasks(instanceId, tokenId); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("result"); if (tasks != null) { for (int i = 0; i < tasks.size(); i++) { TaskInstance task = (TaskInstance) tasks.get(i); createElement(task, root);/*from w w w. java 2 s .c o m*/ } } return doc.asXML(); }
From source file:com.liferay.jbpm.WorkflowComponentImpl.java
License:Open Source License
public String getDefinitionsXml(long definitionId, String name, int start, int end) throws WorkflowComponentException { List definitions = getDefinitions(definitionId, name, start, end); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("result"); for (int i = 0; i < definitions.size(); i++) { ProcessDefinition definition = (ProcessDefinition) definitions.get(i); createElement(definition, root); }/*from w w w . j a v a 2 s. c o m*/ return doc.asXML(); }
From source file:com.liferay.jbpm.WorkflowComponentImpl.java
License:Open Source License
public String getDefinitionXml(long definitionId) throws WorkflowComponentException { ProcessDefinition definition = (ProcessDefinition) getDefinition(definitionId); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("result"); createElement(definition, root);// w w w . ja va2s . c o m return doc.asXML(); }
From source file:com.liferay.jbpm.WorkflowComponentImpl.java
License:Open Source License
public String getInstancesXml(long definitionId, long instanceId, String definitionName, String definitionVersion, String startDateGT, String startDateLT, String endDateGT, String endDateLT, boolean hideEndedTasks, boolean retrieveUserInstances, boolean andOperator, int start, int end) throws WorkflowComponentException { List instances = getInstances(definitionId, instanceId, definitionName, definitionVersion, startDateGT, startDateLT, endDateGT, endDateLT, hideEndedTasks, retrieveUserInstances, andOperator, start, end); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("result"); for (int i = 0; i < instances.size(); i++) { ProcessInstance instance = (ProcessInstance) instances.get(i); createElement(instance, root, true); }//from w w w . j a va 2s . c o m return doc.asXML(); }
From source file:com.liferay.jbpm.WorkflowComponentImpl.java
License:Open Source License
public String getTaskXml(long taskId) throws WorkflowComponentException { TaskInstance task = (TaskInstance) getTask(taskId); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("result"); createElement(task, root);//w w w . j av a 2 s . com return doc.asXML(); }
From source file:com.liferay.jbpm.WorkflowComponentImpl.java
License:Open Source License
public String getTaskFormElementsXml(long taskId) throws WorkflowComponentException { List taskFormElements = getTaskFormElements(taskId); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("result"); for (int i = 0; i < taskFormElements.size(); i++) { TaskFormElement taskFormElement = (TaskFormElement) taskFormElements.get(i); createElement(taskFormElement, root); }/*from w w w .j av a 2 s . c o m*/ return doc.asXML(); }
From source file:com.liferay.jbpm.WorkflowComponentImpl.java
License:Open Source License
public String getTaskTransitionsXml(long taskId) throws WorkflowComponentException { List transitions = getTaskTransitions(taskId); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("result"); for (int i = 0; i < transitions.size(); i++) { Transition transition = (Transition) transitions.get(i); DocUtil.add(root, "transition", transition.getName()); }/* www . j a v a 2 s . c o m*/ return doc.asXML(); }
From source file:com.liferay.jbpm.WorkflowComponentImpl.java
License:Open Source License
public String getUserTasksXml(long instanceId, String taskName, String definitionName, String assignedTo, String createDateGT, String createDateLT, String startDateGT, String startDateLT, String endDateGT, String endDateLT, boolean hideEndedTasks, boolean andOperator, int start, int end) throws WorkflowComponentException { List tasks = getUserTasks(instanceId, taskName, definitionName, assignedTo, createDateGT, createDateLT, startDateGT, startDateLT, endDateGT, endDateLT, hideEndedTasks, andOperator, start, end); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("result"); for (int i = 0; i < tasks.size(); i++) { TaskInstance task = (TaskInstance) tasks.get(i); createElement(task, root);/* ww w. j av a 2 s .co m*/ } return doc.asXML(); }
From source file:com.liferay.jbpm.WorkflowComponentImpl.java
License:Open Source License
public String startWorkflow(long definitionId) throws WorkflowComponentException { ProcessDefinition definition = graphSession.loadProcessDefinition(definitionId); ProcessInstance instance = new ProcessInstance(definition); // After creating process instance, assign the currently authenticated // user to the first task if it exists if (instance.getTaskMgmtInstance().getTaskMgmtDefinition().getStartTask() != null) { jbpmContext.setActorId(userId);/*from www. ja v a 2 s. c om*/ instance.getTaskMgmtInstance().createStartTaskInstance(); } jbpmContext.save(instance); WorkflowUtil.initInstance(instance); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("result"); createElement(instance, root, false); return doc.asXML(); }