List of usage examples for javax.xml.stream XMLStreamWriter writeStartElement
public void writeStartElement(String localName) throws XMLStreamException;
From source file:org.activiti.bpmn.converter.BaseBpmnXMLConverter.java
protected void writeErrorDefinition(Event parentEvent, ErrorEventDefinition errorDefinition, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(ELEMENT_EVENT_ERRORDEFINITION); writeDefaultAttribute(ATTRIBUTE_ERROR_REF, errorDefinition.getErrorCode(), xtw); boolean didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(errorDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.writeEndElement();//from w w w. j a v a2s .c o m } xtw.writeEndElement(); }
From source file:org.activiti.bpmn.converter.BaseBpmnXMLConverter.java
protected void writeTerminateDefinition(Event parentEvent, TerminateEventDefinition terminateDefinition, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(ELEMENT_EVENT_TERMINATEDEFINITION); boolean didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(terminateDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.writeEndElement();/*from w ww. ja va 2 s . c om*/ } xtw.writeEndElement(); }
From source file:org.activiti.bpmn.converter.BpmnXMLConverter.java
private void createXML(FlowElement flowElement, BpmnModel model, XMLStreamWriter xtw) throws Exception { if (flowElement instanceof SubProcess) { SubProcess subProcess = (SubProcess) flowElement; xtw.writeStartElement(ELEMENT_SUBPROCESS); xtw.writeAttribute(ATTRIBUTE_ID, subProcess.getId()); if (StringUtils.isNotEmpty(subProcess.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, subProcess.getName()); } else {/*from ww w.j a va 2s . com*/ xtw.writeAttribute(ATTRIBUTE_NAME, "subProcess"); } if (subProcess instanceof EventSubProcess) { xtw.writeAttribute(ATTRIBUTE_TRIGGERED_BY, ATTRIBUTE_VALUE_TRUE); } if (StringUtils.isNotEmpty(subProcess.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); xtw.writeCharacters(subProcess.getDocumentation()); xtw.writeEndElement(); } boolean didWriteExtensionStartElement = ActivitiListenerExport.writeListeners(subProcess, false, xtw); didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(subProcess, didWriteExtensionStartElement, xtw); if (didWriteExtensionStartElement) { // closing extensions element xtw.writeEndElement(); } MultiInstanceExport.writeMultiInstance(subProcess, xtw); for (FlowElement subElement : subProcess.getFlowElements()) { createXML(subElement, model, xtw); } for (Artifact artifact : subProcess.getArtifacts()) { createXML(artifact, model, xtw); } xtw.writeEndElement(); } else { BaseBpmnXMLConverter converter = convertersToXMLMap.get(flowElement.getClass()); if (converter == null) { throw new XMLException("No converter for " + flowElement.getClass() + " found"); } converter.convertToXML(xtw, flowElement, model); } }
From source file:org.activiti.bpmn.converter.CallActivityXMLConverter.java
private boolean writeIOParameters(String elementName, List<IOParameter> parameterList, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { if (parameterList.size() == 0) return didWriteExtensionStartElement; for (IOParameter ioParameter : parameterList) { if (didWriteExtensionStartElement == false) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; }//from w w w .ja v a2 s .c om xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, elementName, ACTIVITI_EXTENSIONS_NAMESPACE); if (StringUtils.isNotEmpty(ioParameter.getSource())) { writeDefaultAttribute(ATTRIBUTE_IOPARAMETER_SOURCE, ioParameter.getSource(), xtw); } if (StringUtils.isNotEmpty(ioParameter.getSourceExpression())) { writeDefaultAttribute(ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION, ioParameter.getSourceExpression(), xtw); } if (StringUtils.isNotEmpty(ioParameter.getTarget())) { writeDefaultAttribute(ATTRIBUTE_IOPARAMETER_TARGET, ioParameter.getTarget(), xtw); } xtw.writeEndElement(); } return didWriteExtensionStartElement; }
From source file:org.activiti.bpmn.converter.DataStoreReferenceXMLConverter.java
@Override protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { DataStoreReference dataStoreRef = (DataStoreReference) element; if (StringUtils.isNotEmpty(dataStoreRef.getDataState())) { xtw.writeStartElement(ELEMENT_DATA_STATE); xtw.writeCharacters(dataStoreRef.getDataState()); xtw.writeEndElement();/*from w w w. j a va 2s .c o m*/ } }
From source file:org.activiti.bpmn.converter.export.ActivitiListenerExport.java
protected static boolean writeEventListeners(List<EventListener> eventListeners, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { if (eventListeners != null && !eventListeners.isEmpty()) { for (EventListener eventListener : eventListeners) { if (!didWriteExtensionStartElement) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; }/*from ww w . j av a2 s . c o m*/ xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_EVENT_LISTENER, ACTIVITI_EXTENSIONS_NAMESPACE); BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_EVENTS, eventListener.getEvents(), xtw); BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_ENTITY_TYPE, eventListener.getEntityType(), xtw); if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(eventListener.getImplementationType())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_CLASS, eventListener.getImplementation(), xtw); } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION .equals(eventListener.getImplementationType())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_DELEGATEEXPRESSION, eventListener.getImplementation(), xtw); } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT .equals(eventListener.getImplementationType())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_THROW_SIGNAL_EVENT_NAME, eventListener.getImplementation(), xtw); BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_THROW_EVENT_TYPE, ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_SIGNAL, xtw); } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT .equals(eventListener.getImplementationType())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_THROW_SIGNAL_EVENT_NAME, eventListener.getImplementation(), xtw); BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_THROW_EVENT_TYPE, ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_GLOBAL_SIGNAL, xtw); } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT .equals(eventListener.getImplementationType())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_THROW_MESSAGE_EVENT_NAME, eventListener.getImplementation(), xtw); BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_THROW_EVENT_TYPE, ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_MESSAGE, xtw); } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT .equals(eventListener.getImplementationType())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_THROW_ERROR_EVENT_CODE, eventListener.getImplementation(), xtw); BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_THROW_EVENT_TYPE, ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_ERROR, xtw); } xtw.writeEndElement(); } } return didWriteExtensionStartElement; }
From source file:org.activiti.bpmn.converter.export.ActivitiListenerExport.java
private static boolean writeListeners(String xmlElementName, List<ActivitiListener> listenerList, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { if (listenerList != null) { for (ActivitiListener listener : listenerList) { if (StringUtils.isNotEmpty(listener.getEvent())) { if (!didWriteExtensionStartElement) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; }// w ww. ja va 2s . c o m xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, xmlElementName, ACTIVITI_EXTENSIONS_NAMESPACE); BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_EVENT, listener.getEvent(), xtw); if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_CLASS, listener.getImplementation(), xtw); } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION .equals(listener.getImplementationType())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_EXPRESSION, listener.getImplementation(), xtw); } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION .equals(listener.getImplementationType())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LISTENER_DELEGATEEXPRESSION, listener.getImplementation(), xtw); } FieldExtensionExport.writeFieldExtensions(listener.getFieldExtensions(), true, xtw); xtw.writeEndElement(); } } } return didWriteExtensionStartElement; }
From source file:org.activiti.bpmn.converter.export.CollaborationExport.java
public static void writePools(BpmnModel model, XMLStreamWriter xtw) throws Exception { if (!model.getPools().isEmpty()) { xtw.writeStartElement(ELEMENT_COLLABORATION); xtw.writeAttribute(ATTRIBUTE_ID, "Collaboration"); for (Pool pool : model.getPools()) { xtw.writeStartElement(ELEMENT_PARTICIPANT); xtw.writeAttribute(ATTRIBUTE_ID, pool.getId()); if (StringUtils.isNotEmpty(pool.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, pool.getName()); }/*from w ww. j av a 2 s .co m*/ if (StringUtils.isNotEmpty(pool.getProcessRef())) { xtw.writeAttribute(ATTRIBUTE_PROCESS_REF, pool.getProcessRef()); } xtw.writeEndElement(); } for (MessageFlow messageFlow : model.getMessageFlows().values()) { xtw.writeStartElement(ELEMENT_MESSAGE_FLOW); xtw.writeAttribute(ATTRIBUTE_ID, messageFlow.getId()); if (StringUtils.isNotEmpty(messageFlow.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, messageFlow.getName()); } if (StringUtils.isNotEmpty(messageFlow.getSourceRef())) { xtw.writeAttribute(ATTRIBUTE_FLOW_SOURCE_REF, messageFlow.getSourceRef()); } if (StringUtils.isNotEmpty(messageFlow.getTargetRef())) { xtw.writeAttribute(ATTRIBUTE_FLOW_TARGET_REF, messageFlow.getTargetRef()); } if (StringUtils.isNotEmpty(messageFlow.getMessageRef())) { xtw.writeAttribute(ATTRIBUTE_MESSAGE_REF, messageFlow.getMessageRef()); } xtw.writeEndElement(); } xtw.writeEndElement(); } }
From source file:org.activiti.bpmn.converter.export.DefinitionsRootExport.java
@SuppressWarnings("unchecked") public static void writeRootElement(BpmnModel model, XMLStreamWriter xtw, String encoding) throws Exception { xtw.writeStartDocument(encoding, "1.0"); // start definitions root element xtw.writeStartElement(ELEMENT_DEFINITIONS); xtw.setDefaultNamespace(BPMN2_NAMESPACE); xtw.writeDefaultNamespace(BPMN2_NAMESPACE); xtw.writeNamespace(XSI_PREFIX, XSI_NAMESPACE); xtw.writeNamespace(XSD_PREFIX, SCHEMA_NAMESPACE); xtw.writeNamespace(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeNamespace(BPMNDI_PREFIX, BPMNDI_NAMESPACE); xtw.writeNamespace(OMGDC_PREFIX, OMGDC_NAMESPACE); xtw.writeNamespace(OMGDI_PREFIX, OMGDI_NAMESPACE); for (String prefix : model.getNamespaces().keySet()) { if (!defaultNamespaces.contains(prefix) && StringUtils.isNotEmpty(prefix)) xtw.writeNamespace(prefix, model.getNamespaces().get(prefix)); }//w w w . ja v a2s . com xtw.writeAttribute(TYPE_LANGUAGE_ATTRIBUTE, SCHEMA_NAMESPACE); xtw.writeAttribute(EXPRESSION_LANGUAGE_ATTRIBUTE, XPATH_NAMESPACE); if (StringUtils.isNotEmpty(model.getTargetNamespace())) { xtw.writeAttribute(TARGET_NAMESPACE_ATTRIBUTE, model.getTargetNamespace()); } else { xtw.writeAttribute(TARGET_NAMESPACE_ATTRIBUTE, PROCESS_NAMESPACE); } BpmnXMLUtil.writeCustomAttributes(model.getDefinitionsAttributes().values(), xtw, model.getNamespaces(), defaultAttributes); }
From source file:org.activiti.bpmn.converter.export.FieldExtensionExport.java
public static boolean writeFieldExtensions(List<FieldExtension> fieldExtensionList, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { for (FieldExtension fieldExtension : fieldExtensionList) { if (StringUtils.isNotEmpty(fieldExtension.getFieldName())) { if (StringUtils.isNotEmpty(fieldExtension.getStringValue()) || StringUtils.isNotEmpty(fieldExtension.getExpression())) { if (didWriteExtensionStartElement == false) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; }//ww w. ja v a 2 s. co m xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_FIELD, ACTIVITI_EXTENSIONS_NAMESPACE); BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_FIELD_NAME, fieldExtension.getFieldName(), xtw); if (StringUtils.isNotEmpty(fieldExtension.getStringValue())) { xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_FIELD_STRING, ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeCData(fieldExtension.getStringValue()); } else { xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ATTRIBUTE_FIELD_EXPRESSION, ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeCharacters(fieldExtension.getExpression()); } xtw.writeEndElement(); xtw.writeEndElement(); } } } return didWriteExtensionStartElement; }