List of usage examples for javax.xml.stream XMLStreamWriter writeEndElement
public void writeEndElement() throws XMLStreamException;
From source file:org.flowable.bpmn.converter.export.LaneExport.java
public static void writeLanes(Process process, XMLStreamWriter xtw) throws Exception { if (!process.getLanes().isEmpty()) { xtw.writeStartElement(ELEMENT_LANESET); xtw.writeAttribute(ATTRIBUTE_ID, "laneSet_" + process.getId()); for (Lane lane : process.getLanes()) { xtw.writeStartElement(ELEMENT_LANE); xtw.writeAttribute(ATTRIBUTE_ID, lane.getId()); if (StringUtils.isNotEmpty(lane.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, lane.getName()); }/*from w w w.j a va 2s .co m*/ boolean didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(lane, false, xtw); if (didWriteExtensionStartElement) { xtw.writeEndElement(); } for (String flowNodeRef : lane.getFlowReferences()) { xtw.writeStartElement(ELEMENT_FLOWNODE_REF); xtw.writeCharacters(flowNodeRef); xtw.writeEndElement(); } xtw.writeEndElement(); } xtw.writeEndElement(); } }
From source file:org.flowable.bpmn.converter.export.ProcessExport.java
@SuppressWarnings("unchecked") public static void writeProcess(Process process, XMLStreamWriter xtw) throws Exception { // start process element xtw.writeStartElement(ELEMENT_PROCESS); xtw.writeAttribute(ATTRIBUTE_ID, process.getId()); if (StringUtils.isNotEmpty(process.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, process.getName()); }/*from w w w .j a va 2 s . c o m*/ xtw.writeAttribute(ATTRIBUTE_PROCESS_EXECUTABLE, Boolean.toString(process.isExecutable())); if (!process.getCandidateStarterUsers().isEmpty()) { xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_USERS, BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterUsers())); } if (!process.getCandidateStarterGroups().isEmpty()) { xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_GROUPS, BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterGroups())); } // write custom attributes BpmnXMLUtil.writeCustomAttributes(process.getAttributes().values(), xtw, defaultProcessAttributes); if (StringUtils.isNotEmpty(process.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); xtw.writeCharacters(process.getDocumentation()); xtw.writeEndElement(); } boolean didWriteExtensionStartElement = FlowableListenerExport.writeListeners(process, false, xtw); didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(process, didWriteExtensionStartElement, xtw); if (didWriteExtensionStartElement) { // closing extensions element xtw.writeEndElement(); } LaneExport.writeLanes(process, xtw); }
From source file:org.flowable.bpmn.converter.ScriptTaskXMLConverter.java
@Override protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { ScriptTask scriptTask = (ScriptTask) element; if (StringUtils.isNotEmpty(scriptTask.getScript())) { xtw.writeStartElement(ATTRIBUTE_TASK_SCRIPT_TEXT); xtw.writeCData(scriptTask.getScript()); xtw.writeEndElement(); }//from ww w. j av a2 s . com }
From source file:org.flowable.bpmn.converter.ServiceTaskXMLConverter.java
@Override protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { ServiceTask serviceTask = (ServiceTask) element; if (!serviceTask.getCustomProperties().isEmpty()) { for (CustomProperty customProperty : serviceTask.getCustomProperties()) { if (StringUtils.isEmpty(customProperty.getSimpleValue())) { continue; }/* w w w . java2s . c om*/ if (didWriteExtensionStartElement == false) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; } xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_FIELD, FLOWABLE_EXTENSIONS_NAMESPACE); xtw.writeAttribute(ATTRIBUTE_FIELD_NAME, customProperty.getName()); if ((customProperty.getSimpleValue().contains("${") || customProperty.getSimpleValue().contains("#{")) && customProperty.getSimpleValue().contains("}")) { xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ATTRIBUTE_FIELD_EXPRESSION, FLOWABLE_EXTENSIONS_NAMESPACE); } else { xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_FIELD_STRING, FLOWABLE_EXTENSIONS_NAMESPACE); } xtw.writeCharacters(customProperty.getSimpleValue()); xtw.writeEndElement(); xtw.writeEndElement(); } } else { didWriteExtensionStartElement = FieldExtensionExport .writeFieldExtensions(serviceTask.getFieldExtensions(), didWriteExtensionStartElement, xtw); } return didWriteExtensionStartElement; }
From source file:org.flowable.bpmn.converter.UserTaskXMLConverter.java
@Override protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { UserTask userTask = (UserTask) element; didWriteExtensionStartElement = writeFormProperties(userTask, didWriteExtensionStartElement, xtw); didWriteExtensionStartElement = writeCustomIdentities(element, didWriteExtensionStartElement, xtw); if (!userTask.getCustomProperties().isEmpty()) { for (CustomProperty customProperty : userTask.getCustomProperties()) { if (StringUtils.isEmpty(customProperty.getSimpleValue())) { continue; }// ww w.j a va 2s . c o m if (didWriteExtensionStartElement == false) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; } xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, customProperty.getName(), FLOWABLE_EXTENSIONS_NAMESPACE); xtw.writeCharacters(customProperty.getSimpleValue()); xtw.writeEndElement(); } } return didWriteExtensionStartElement; }
From source file:org.flowable.bpmn.converter.UserTaskXMLConverter.java
protected void writeCustomIdentities(UserTask userTask, String identityType, Set<String> users, Set<String> groups, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_CUSTOM_RESOURCE, FLOWABLE_EXTENSIONS_NAMESPACE); writeDefaultAttribute(ATTRIBUTE_NAME, identityType, xtw); List<String> identityList = new ArrayList<String>(); if (users != null) { for (String userId : users) { identityList.add("user(" + userId + ")"); }//from www .ja v a 2 s . c o m } if (groups != null) { for (String groupId : groups) { identityList.add("group(" + groupId + ")"); } } String delimitedString = convertToDelimitedString(identityList); xtw.writeStartElement(ELEMENT_RESOURCE_ASSIGNMENT); xtw.writeStartElement(ELEMENT_FORMAL_EXPRESSION); xtw.writeCharacters(delimitedString); xtw.writeEndElement(); // End ELEMENT_FORMAL_EXPRESSION xtw.writeEndElement(); // End ELEMENT_RESOURCE_ASSIGNMENT xtw.writeEndElement(); // End ELEMENT_CUSTOM_RESOURCE }
From source file:org.flowable.cmmn.converter.CmmnXmlConverter.java
public byte[] convertToXML(CmmnModel model, String encoding) { try {/*from ww w . jav a 2 s . c o m*/ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XMLOutputFactory xof = XMLOutputFactory.newInstance(); OutputStreamWriter out = new OutputStreamWriter(outputStream, encoding); XMLStreamWriter writer = xof.createXMLStreamWriter(out); XMLStreamWriter xtw = new IndentingXMLStreamWriter(writer); DefinitionsRootExport.writeRootElement(model, xtw, encoding); for (Case caseModel : model.getCases()) { if (caseModel.getPlanModel().getPlanItems().isEmpty()) { // empty case, ignore it continue; } CaseExport.writeCase(caseModel, xtw); Stage planModel = caseModel.getPlanModel(); StageExport.writeStage(planModel, xtw); // end case element xtw.writeEndElement(); } CmmnDIExport.writeCmmnDI(model, xtw); // end definitions root element xtw.writeEndElement(); xtw.writeEndDocument(); xtw.flush(); outputStream.close(); xtw.close(); return outputStream.toByteArray(); } catch (Exception e) { LOGGER.error("Error writing CMMN XML", e); throw new XMLException("Error writing CMMN XML", e); } }
From source file:org.flowable.cmmn.converter.export.AbstractPlanItemDefinitionExport.java
public static void writeCommonPlanItemDefinitionAttributes(PlanItemDefinition planItemDefinition, XMLStreamWriter xtw) throws Exception { xtw.writeAttribute(ATTRIBUTE_ID, planItemDefinition.getId()); if (StringUtils.isNotEmpty(planItemDefinition.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, planItemDefinition.getName()); }//from w ww . j av a 2s .c o m if (StringUtils.isNotEmpty(planItemDefinition.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); xtw.writeCharacters(planItemDefinition.getDocumentation()); xtw.writeEndElement(); } }
From source file:org.flowable.cmmn.converter.export.CaseExport.java
public static void writeCase(Case caseModel, XMLStreamWriter xtw) throws Exception { // start process element xtw.writeStartElement(ELEMENT_CASE); xtw.writeAttribute(ATTRIBUTE_ID, caseModel.getId()); if (StringUtils.isNotEmpty(caseModel.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, caseModel.getName()); }// w w w . j a v a 2 s . com if (StringUtils.isNotEmpty(caseModel.getInitiatorVariableName())) { xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_INITIATOR_VARIABLE_NAME, caseModel.getInitiatorVariableName()); } if (StringUtils.isNotEmpty(caseModel.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); xtw.writeCharacters(caseModel.getDocumentation()); xtw.writeEndElement(); } }
From source file:org.flowable.cmmn.converter.export.CaseTaskExport.java
public static void writeCaseTask(CaseTask caseTask, XMLStreamWriter xtw) throws Exception { // start case task element xtw.writeStartElement(ELEMENT_CASE_TASK); writeCommonTaskAttributes(xtw, caseTask); if (StringUtils.isNotEmpty(caseTask.getCaseRef())) { xtw.writeAttribute(ATTRIBUTE_CASE_REF, caseTask.getCaseRef()); }/*from w w w. j a va 2 s. c om*/ // end case task element xtw.writeEndElement(); }