List of usage examples for javax.xml.stream XMLStreamWriter writeStartElement
public void writeStartElement(String localName) throws XMLStreamException;
From source file:org.activiti.designer.export.bpmn20.export.IntermediateCatchEventExport.java
public static void createIntermediateEvent(Object object, XMLStreamWriter xtw) throws Exception { IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) object; List<EventDefinition> eventDefinitionList = catchEvent.getEventDefinitions(); if (eventDefinitionList.size() == 1) { if (eventDefinitionList.get(0) instanceof TimerEventDefinition) { TimerEventDefinition timerDef = (TimerEventDefinition) eventDefinitionList.get(0); // start TimerIntermediateCatchEvent element xtw.writeStartElement("intermediateCatchEvent"); xtw.writeAttribute("id", catchEvent.getId()); if (catchEvent.getName() != null) { xtw.writeAttribute("name", catchEvent.getName()); }//w w w. j ava 2 s . c o m 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(); // end TimerIntermediateCatchEvent element xtw.writeEndElement(); } else if (eventDefinitionList.get(0) instanceof SignalEventDefinition) { SignalEventDefinition signalDef = (SignalEventDefinition) eventDefinitionList.get(0); // start SignalIntermediateCatchEvent element xtw.writeStartElement("intermediateCatchEvent"); xtw.writeAttribute("id", catchEvent.getId()); if (catchEvent.getName() != null) { xtw.writeAttribute("name", catchEvent.getName()); } xtw.writeStartElement("signalEventDefinition"); if (StringUtils.isNotEmpty(signalDef.getSignalRef())) { xtw.writeAttribute("signalRef", signalDef.getSignalRef()); } xtw.writeEndElement(); // end SignalIntermediateCatchEvent element xtw.writeEndElement(); } } }
From source file:org.activiti.designer.export.bpmn20.export.IntermediateThrowEventExport.java
public static void createIntermediateEvent(Object object, XMLStreamWriter xtw) throws Exception { ThrowEvent throwEvent = (ThrowEvent) object; // start IntermediateThrowEvent element xtw.writeStartElement("intermediateThrowEvent"); xtw.writeAttribute("id", throwEvent.getId()); if (throwEvent.getName() != null) { xtw.writeAttribute("name", throwEvent.getName()); }// ww w .j a v a2 s. com List<EventDefinition> eventDefinitionList = throwEvent.getEventDefinitions(); if (eventDefinitionList.size() == 1) { 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(); } } // end IntermediateThrowEvent element xtw.writeEndElement(); }
From source file:org.activiti.designer.export.bpmn20.export.MailTaskExport.java
private static void writeAlfrescoScriptMailTask(AlfrescoMailTask mailTask, XMLStreamWriter xtw) throws Exception { // start AlfrescoMailTask element xtw.writeStartElement("serviceTask"); xtw.writeAttribute("id", mailTask.getId()); if (mailTask.getName() != null) { xtw.writeAttribute("name", mailTask.getName()); }// w w w . j a v a 2 s .c o m xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "class", "org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate"); DefaultFlowExport.createDefaultFlow(mailTask, xtw); AsyncActivityExport.createAsyncAttribute(mailTask, xtw); xtw.writeStartElement("extensionElements"); ExecutionListenerExport.createExecutionListenerXML(mailTask.getExecutionListeners(), false, xtw); xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "field", ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeAttribute("name", "script"); xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "string", ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeCharacters(createMailScript(mailTask)); xtw.writeEndElement(); xtw.writeEndElement(); xtw.writeEndElement(); MultiInstanceExport.createMultiInstance(mailTask, xtw); // end AlfrescoMailTask element xtw.writeEndElement(); }
From source file:org.activiti.designer.export.bpmn20.export.MailTaskExport.java
private static void writeServiceMailTask(MailTask mailTask, XMLStreamWriter xtw) throws Exception { // start MailTask element xtw.writeStartElement("serviceTask"); xtw.writeAttribute("id", mailTask.getId()); if (mailTask.getName() != null) { xtw.writeAttribute("name", mailTask.getName()); }/*from w w w. j av a 2 s.com*/ DefaultFlowExport.createDefaultFlow(mailTask, xtw); AsyncActivityExport.createAsyncAttribute(mailTask, xtw); xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "type", "mail"); xtw.writeStartElement("extensionElements"); ExecutionListenerExport.createExecutionListenerXML(mailTask.getExecutionListeners(), false, xtw); if (StringUtils.isNotEmpty(mailTask.getTo())) { writeField("to", mailTask.getTo(), xtw); } if (StringUtils.isNotEmpty(mailTask.getFrom())) { writeField("from", mailTask.getFrom(), xtw); } if (StringUtils.isNotEmpty(mailTask.getSubject())) { writeField("subject", mailTask.getSubject(), xtw); } if (StringUtils.isNotEmpty(mailTask.getCc())) { writeField("cc", mailTask.getCc(), xtw); } if (StringUtils.isNotEmpty(mailTask.getBcc())) { writeField("bcc", mailTask.getBcc(), xtw); } if (StringUtils.isNotEmpty(mailTask.getCharset())) { writeField("charset", mailTask.getCharset(), xtw); } if (StringUtils.isNotEmpty(mailTask.getHtml())) { writeCDataField("html", mailTask.getHtml(), xtw); } if (StringUtils.isNotEmpty(mailTask.getText())) { writeCDataField("text", mailTask.getText(), xtw); } xtw.writeEndElement(); MultiInstanceExport.createMultiInstance(mailTask, xtw); // end MailTask element xtw.writeEndElement(); }
From source file:org.activiti.designer.export.bpmn20.export.MultiInstanceExport.java
public static void createMultiInstance(Object object, XMLStreamWriter xtw) throws Exception { Activity activity = (Activity) object; if (activity.getLoopCharacteristics() == null) return;// w ww . j a va2 s .co m MultiInstanceLoopCharacteristics multiInstanceDef = (MultiInstanceLoopCharacteristics) activity .getLoopCharacteristics(); if (StringUtils.isNotEmpty(multiInstanceDef.getInputDataItem()) || StringUtils.isNotEmpty(multiInstanceDef.getLoopCardinality()) || StringUtils.isNotEmpty(multiInstanceDef.getCompletionCondition())) { // start multiInstance element xtw.writeStartElement("multiInstanceLoopCharacteristics"); xtw.writeAttribute("isSequential", "" + multiInstanceDef.isSequential()); if (StringUtils.isNotEmpty(multiInstanceDef.getInputDataItem())) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "collection", multiInstanceDef.getInputDataItem()); } if (StringUtils.isNotEmpty(multiInstanceDef.getElementVariable())) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "elementVariable", multiInstanceDef.getElementVariable()); } if (StringUtils.isNotEmpty(multiInstanceDef.getLoopCardinality())) { xtw.writeStartElement("loopCardinality"); xtw.writeCharacters(multiInstanceDef.getLoopCardinality()); xtw.writeEndElement(); } if (StringUtils.isNotEmpty(multiInstanceDef.getCompletionCondition())) { xtw.writeStartElement("completionCondition"); xtw.writeCharacters(multiInstanceDef.getCompletionCondition()); xtw.writeEndElement(); } // end multiInstance element xtw.writeEndElement(); } }
From source file:org.activiti.designer.export.bpmn20.export.ScriptTaskExport.java
public static void createScriptTask(Object object, XMLStreamWriter xtw) throws Exception { ScriptTask scriptTask = (ScriptTask) object; // start ScriptTask element xtw.writeStartElement("scriptTask"); xtw.writeAttribute("id", scriptTask.getId()); if (scriptTask.getName() != null) { xtw.writeAttribute("name", scriptTask.getName()); }/*from w w w .j a v a 2 s .c o m*/ DefaultFlowExport.createDefaultFlow(scriptTask, xtw); AsyncActivityExport.createAsyncAttribute(scriptTask, xtw); if (StringUtils.isNotEmpty(scriptTask.getScriptFormat())) { xtw.writeAttribute("scriptFormat", scriptTask.getScriptFormat()); } ExecutionListenerExport.createExecutionListenerXML(scriptTask.getExecutionListeners(), true, xtw); xtw.writeStartElement("script"); if (StringUtils.isNotEmpty(scriptTask.getScript())) { xtw.writeCData(scriptTask.getScript()); } xtw.writeEndElement(); MultiInstanceExport.createMultiInstance(object, xtw); // end ScriptTask element xtw.writeEndElement(); }
From source file:org.activiti.designer.export.bpmn20.export.SequenceFlowExport.java
public static void createSequenceFlow(Object object, XMLStreamWriter xtw) throws Exception { SequenceFlow sequenceFlow = (SequenceFlow) object; // start SequenceFlow element xtw.writeStartElement("sequenceFlow"); xtw.writeAttribute("id", sequenceFlow.getId()); if (sequenceFlow.getName() == null) { xtw.writeAttribute("name", ""); } else {/*from w ww .java 2s.com*/ xtw.writeAttribute("name", sequenceFlow.getName()); } xtw.writeAttribute("sourceRef", sequenceFlow.getSourceRef().getId()); xtw.writeAttribute("targetRef", sequenceFlow.getTargetRef().getId()); ExecutionListenerExport.createExecutionListenerXML(sequenceFlow.getExecutionListeners(), true, xtw); if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) { String condition = sequenceFlow.getConditionExpression(); // start conditionExpression element xtw.writeStartElement("conditionExpression"); xtw.writeAttribute("xsi", XSI_NAMESPACE, "type", "tFormalExpression"); xtw.writeCData(condition); // end conditionExpression element xtw.writeEndElement(); } // end SequenceFlow element xtw.writeEndElement(); }
From source file:org.activiti.designer.export.bpmn20.export.ServiceTaskExport.java
public static void createServiceTask(Object object, XMLStreamWriter xtw) throws Exception { ServiceTask serviceTask = (ServiceTask) object; // start ServiceTask element xtw.writeStartElement("serviceTask"); xtw.writeAttribute("id", serviceTask.getId()); if (StringUtils.isNotEmpty(serviceTask.getName())) { xtw.writeAttribute("name", serviceTask.getName()); }//w w w . ja v a 2 s .c o m DefaultFlowExport.createDefaultFlow(serviceTask, xtw); AsyncActivityExport.createAsyncAttribute(serviceTask, xtw); ImplementationValueExport.writeImplementationValue(xtw, EXECUTION_LISTENER, serviceTask.getImplementationType(), serviceTask.getImplementation(), true); if (StringUtils.isNotEmpty(serviceTask.getResultVariableName())) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariableName", serviceTask.getResultVariableName()); } boolean executionListenersAvailable = false; if (serviceTask.getExecutionListeners() != null && serviceTask.getExecutionListeners().size() > 0) { executionListenersAvailable = true; } boolean fieldExtensionsAvailable = false; if (serviceTask.getFieldExtensions() != null && serviceTask.getFieldExtensions().size() > 0) { for (FieldExtension fieldExtension : serviceTask.getFieldExtensions()) { if (fieldExtension.getFieldName() != null && fieldExtension.getFieldName().length() > 0 && fieldExtension.getExpression() != null && fieldExtension.getExpression().length() > 0) { fieldExtensionsAvailable = true; break; } } } if (executionListenersAvailable == true || fieldExtensionsAvailable == true) { xtw.writeStartElement("extensionElements"); } ExecutionListenerExport.createExecutionListenerXML(serviceTask.getExecutionListeners(), false, xtw); FieldExtensionsExport.writeFieldExtensions(xtw, serviceTask.getFieldExtensions(), false); if (executionListenersAvailable == true || fieldExtensionsAvailable == true) { xtw.writeEndElement(); } if (serviceTask.getCustomProperties() != null && serviceTask.getCustomProperties().size() > 0) { boolean firstCustomProperty = true; for (CustomProperty customProperty : serviceTask.getCustomProperties()) { if (ExtensionConstants.PROPERTY_ID_CUSTOM_SERVICE_TASK.equals(customProperty.getName())) { continue; } if (customProperty.getSimpleValue() == null || customProperty.getSimpleValue().length() == 0) { continue; } if (firstCustomProperty == true) { xtw.writeStartElement("extensionElements"); firstCustomProperty = false; } xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "field", ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeAttribute("name", customProperty.getName()); xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "string", ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeCharacters(customProperty.getSimpleValue()); xtw.writeEndElement(); xtw.writeEndElement(); } if (firstCustomProperty == false) { xtw.writeEndElement(); } } MultiInstanceExport.createMultiInstance(object, xtw); // end ServiceTask element xtw.writeEndElement(); }
From source file:org.activiti.designer.export.bpmn20.export.UserTaskExport.java
public static void createUserTask(Object object, XMLStreamWriter xtw) throws Exception { UserTask userTask = (UserTask) object; // start UserTask element xtw.writeStartElement("userTask"); xtw.writeAttribute("id", userTask.getId()); if (userTask.getName() != null) { xtw.writeAttribute("name", userTask.getName()); }/*from w w w .j av a2 s.c om*/ if (userTask.getDueDate() != null) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "dueDate", userTask.getDueDate().toString()); } DefaultFlowExport.createDefaultFlow(userTask, xtw); AsyncActivityExport.createAsyncAttribute(userTask, xtw); if (userTask.getAssignee() != null && userTask.getAssignee().length() > 0) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "assignee", userTask.getAssignee()); } if (userTask.getCandidateUsers().size() > 0) { Iterator<String> candidateUserIterator = userTask.getCandidateUsers().iterator(); String candidateUsers = candidateUserIterator.next(); while (candidateUserIterator.hasNext()) { candidateUsers += ", " + candidateUserIterator.next(); } xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "candidateUsers", candidateUsers); } if (userTask.getCandidateGroups().size() > 0) { Iterator<String> candidateGroupIterator = userTask.getCandidateGroups().iterator(); String candidateGroups = candidateGroupIterator.next(); while (candidateGroupIterator.hasNext()) { candidateGroups += ", " + candidateGroupIterator.next(); } xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "candidateGroups", candidateGroups); } if (StringUtils.isNotEmpty(userTask.getFormKey())) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "formKey", userTask.getFormKey()); } if (StringUtils.isNotEmpty(userTask.getPriority())) { xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "priority", userTask.getPriority()); } if (StringUtils.isNotEmpty(userTask.getDocumentation())) { xtw.writeStartElement("documentation"); xtw.writeCharacters(userTask.getDocumentation()); // end documentation element xtw.writeEndElement(); } boolean extensionsElement = true; if (userTask.getFormProperties().size() > 0) { extensionsElement = false; xtw.writeStartElement("extensionElements"); } FormPropertiesExport.createFormPropertiesXML(userTask.getFormProperties(), xtw); TaskListenerExport.createTaskListenerXML(userTask.getTaskListeners(), extensionsElement, xtw); if (extensionsElement == false) { xtw.writeEndElement(); } MultiInstanceExport.createMultiInstance(object, xtw); // end UserTask element xtw.writeEndElement(); }
From source file:org.activiti.designer.export.srcm.export.MailTaskExport.java
private static void writeAlfrescoScriptMailTask(AlfrescoMailTask mailTask, XMLStreamWriter xtw) throws Exception { // start AlfrescoMailTask element xtw.writeStartElement("serviceTask"); xtw.writeAttribute("id", mailTask.getId()); if (mailTask.getName() != null) { xtw.writeAttribute("name", mailTask.getName()); }// w ww. j ava 2s . c o m xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "class", "org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate"); DefaultFlowExport.createDefaultFlow(mailTask, xtw); AsyncActivityExport.createDefaultFlow(mailTask, xtw); xtw.writeStartElement("extensionElements"); ExtensionListenerExport.createExtensionListenerXML(mailTask.getActivitiListeners(), false, EXECUTION_LISTENER, xtw); xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "field", ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeAttribute("name", "script"); xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "string", ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeCharacters(createMailScript(mailTask)); xtw.writeEndElement(); xtw.writeEndElement(); xtw.writeEndElement(); MultiInstanceExport.createMultiInstance(mailTask, xtw); // end AlfrescoMailTask element xtw.writeEndElement(); if (mailTask.getBoundaryEventRefs().size() > 0) { for (BoundaryEvent event : mailTask.getBoundaryEventRefs()) { BoundaryEventExport.createBoundaryEvent(event, xtw); } } }