List of usage examples for javax.xml.stream XMLStreamWriter writeStartElement
public void writeStartElement(String localName) throws XMLStreamException;
From source file:org.activiti.bpmn.converter.export.LaneExport.java
public static void writeLanes(Process process, XMLStreamWriter xtw) throws Exception { if (process.getLanes().size() > 0) { 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()); }// w w w . j ava 2 s. co m for (String flowNodeRef : lane.getFlowReferences()) { xtw.writeStartElement(ATTRIBUTE_FLOWNODE_REF); xtw.writeCharacters(flowNodeRef); xtw.writeEndElement(); } xtw.writeEndElement(); } xtw.writeEndElement(); } }
From source file:org.activiti.bpmn.converter.export.MultiInstanceExport.java
public static void writeMultiInstance(Activity activity, XMLStreamWriter xtw) throws Exception { if (activity.getLoopCharacteristics() != null) { MultiInstanceLoopCharacteristics multiInstanceObject = activity.getLoopCharacteristics(); if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality()) || StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem()) || StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE); BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL, String.valueOf(multiInstanceObject.isSequential()).toLowerCase(), xtw); if (StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem())) { BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_MULTIINSTANCE_COLLECTION, multiInstanceObject.getInputDataItem(), xtw); }/*from w ww . j a va 2s .co m*/ if (StringUtils.isNotEmpty(multiInstanceObject.getElementVariable())) { BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_MULTIINSTANCE_VARIABLE, multiInstanceObject.getElementVariable(), xtw); } if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CARDINALITY); xtw.writeCharacters(multiInstanceObject.getLoopCardinality()); xtw.writeEndElement(); } if (StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CONDITION); xtw.writeCharacters(multiInstanceObject.getCompletionCondition()); xtw.writeEndElement(); } xtw.writeEndElement(); } } }
From source file:org.activiti.bpmn.converter.export.PoolExport.java
public static void writePools(BpmnModel model, XMLStreamWriter xtw) throws Exception { if (model.getPools().size() > 0) { 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 a va2 s .c om*/ if (StringUtils.isNotEmpty(pool.getProcessRef())) { xtw.writeAttribute(ATTRIBUTE_PROCESS_REF, pool.getProcessRef()); } xtw.writeEndElement(); } xtw.writeEndElement(); } }
From source file:org.activiti.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 ava 2 s.co m xtw.writeAttribute(ATTRIBUTE_PROCESS_EXECUTABLE, Boolean.toString(process.isExecutable())); if (process.getCandidateStarterUsers().size() > 0) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_USERS, BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterUsers())); } if (process.getCandidateStarterGroups().size() > 0) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_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 = ActivitiListenerExport.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.activiti.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.writeCharacters(scriptTask.getScript()); xtw.writeEndElement();/* w ww .ja va 2 s .c om*/ } }
From source file:org.activiti.bpmn.converter.SequenceFlowXMLConverter.java
@Override protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { SequenceFlow sequenceFlow = (SequenceFlow) element; if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) { xtw.writeStartElement(ELEMENT_FLOW_CONDITION); xtw.writeAttribute(XSI_PREFIX, XSI_NAMESPACE, "type", "tFormalExpression"); xtw.writeCData(sequenceFlow.getConditionExpression()); xtw.writeEndElement();/*from w w w . j a v a 2s. c o m*/ } }
From source file:org.activiti.bpmn.converter.ServiceTaskXMLConverter.java
@Override protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { ServiceTask serviceTask = (ServiceTask) element; if (serviceTask.getCustomProperties().size() > 0) { for (CustomProperty customProperty : serviceTask.getCustomProperties()) { if (StringUtils.isEmpty(customProperty.getSimpleValue())) { continue; }//from w w w . j a v a 2s . co m if (didWriteExtensionStartElement == false) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; } xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_FIELD, ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeAttribute(ATTRIBUTE_FIELD_NAME, customProperty.getName()); if ((customProperty.getSimpleValue().contains("${") || customProperty.getSimpleValue().contains("#{")) && customProperty.getSimpleValue().contains("}")) { xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ATTRIBUTE_FIELD_EXPRESSION, ACTIVITI_EXTENSIONS_NAMESPACE); } else { xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_FIELD_STRING, ACTIVITI_EXTENSIONS_NAMESPACE); } xtw.writeCharacters(customProperty.getSimpleValue()); xtw.writeEndElement(); xtw.writeEndElement(); } } else { didWriteExtensionStartElement = FieldExtensionExport .writeFieldExtensions(serviceTask.getFieldExtensions(), didWriteExtensionStartElement, xtw); } return didWriteExtensionStartElement; }
From source file:org.activiti.bpmn.converter.TextAnnotationXMLConverter.java
@Override protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { TextAnnotation textAnnotation = (TextAnnotation) element; if (StringUtils.isNotEmpty(textAnnotation.getText())) { xtw.writeStartElement(ELEMENT_TEXT_ANNOTATION_TEXT); xtw.writeCharacters(textAnnotation.getText()); xtw.writeEndElement();//from w w w.j ava 2 s . c o m } }
From source file:org.activiti.designer.export.bpmn20.export.BoundaryEventExport.java
public static void createBoundaryEvent(Object object, XMLStreamWriter xtw) throws Exception { BoundaryEvent boundaryEvent = (BoundaryEvent) object; List<EventDefinition> eventDefinitionList = boundaryEvent.getEventDefinitions(); if (eventDefinitionList.size() == 1) { xtw.writeStartElement("boundaryEvent"); xtw.writeAttribute("id", boundaryEvent.getId()); if (boundaryEvent.getName() != null) { xtw.writeAttribute("name", boundaryEvent.getName()); }// w w w. j av a 2 s .co m if (boundaryEvent.isCancelActivity()) { xtw.writeAttribute("cancelActivity", "true"); } else { xtw.writeAttribute("cancelActivity", "false"); } if (boundaryEvent.getAttachedToRef() != null) { xtw.writeAttribute("attachedToRef", boundaryEvent.getAttachedToRef().getId()); } if (eventDefinitionList.get(0) instanceof TimerEventDefinition) { TimerEventDefinition timerDef = (TimerEventDefinition) eventDefinitionList.get(0); xtw.writeStartElement("timerEventDefinition"); if (StringUtils.isNotEmpty(timerDef.getTimeDuration())) { xtw.writeStartElement("timeDuration"); xtw.writeCharacters(timerDef.getTimeDuration()); xtw.writeEndElement(); } else if (StringUtils.isNotEmpty(timerDef.getTimeDate())) { xtw.writeStartElement("timeDate"); xtw.writeCharacters(timerDef.getTimeDate()); xtw.writeEndElement(); } else if (StringUtils.isNotEmpty(timerDef.getTimeCycle())) { xtw.writeStartElement("timeCycle"); xtw.writeCharacters(timerDef.getTimeCycle()); xtw.writeEndElement(); } xtw.writeEndElement(); } else if (eventDefinitionList.get(0) instanceof ErrorEventDefinition) { ErrorEventDefinition errorDef = (ErrorEventDefinition) eventDefinitionList.get(0); xtw.writeStartElement("errorEventDefinition"); if (StringUtils.isNotEmpty(errorDef.getErrorCode())) { xtw.writeAttribute("errorRef", errorDef.getErrorCode()); } xtw.writeEndElement(); } else if (eventDefinitionList.get(0) instanceof SignalEventDefinition) { SignalEventDefinition signalDef = (SignalEventDefinition) eventDefinitionList.get(0); xtw.writeStartElement("signalEventDefinition"); if (StringUtils.isNotEmpty(signalDef.getSignalRef())) { xtw.writeAttribute("signalRef", signalDef.getSignalRef()); } xtw.writeEndElement(); } xtw.writeEndElement(); } }
From source file:org.activiti.designer.export.bpmn20.export.CallActivityExport.java
public static void createCallActivity(Object object, XMLStreamWriter xtw) throws Exception { CallActivity callActivity = (CallActivity) object; // start CallActivity element xtw.writeStartElement("callActivity"); xtw.writeAttribute("id", callActivity.getId()); if (callActivity.getName() != null) { xtw.writeAttribute("name", callActivity.getName()); }/* w ww . j a v a2 s .c o m*/ DefaultFlowExport.createDefaultFlow(callActivity, xtw); AsyncActivityExport.createAsyncAttribute(callActivity, xtw); if (callActivity.getCalledElement() != null && callActivity.getCalledElement().length() > 0) { xtw.writeAttribute("calledElement", callActivity.getCalledElement()); } if (callActivity.getExecutionListeners().size() > 0 || callActivity.getInParameters().size() > 0 || callActivity.getOutParameters().size() > 0) { xtw.writeStartElement("extensionElements"); } ExecutionListenerExport.createExecutionListenerXML(callActivity.getExecutionListeners(), false, xtw); if (callActivity.getInParameters().size() > 0 || callActivity.getOutParameters().size() > 0) { for (IOParameter parameter : callActivity.getInParameters()) { writeParameter(parameter, "in", xtw); } for (IOParameter parameter : callActivity.getOutParameters()) { writeParameter(parameter, "out", xtw); } } if (callActivity.getExecutionListeners().size() > 0 || callActivity.getInParameters().size() > 0 || callActivity.getOutParameters().size() > 0) { xtw.writeEndElement(); } MultiInstanceExport.createMultiInstance(object, xtw); // end CallActivity element xtw.writeEndElement(); }