List of usage examples for javax.xml.stream XMLStreamWriter writeAttribute
public void writeAttribute(String localName, String value) throws XMLStreamException;
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()); }/*from w w w . j ava2s .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 ww w. ja va 2s . co m 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.MailTaskExport.java
private static void writeField(String name, String expression, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "field", ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeAttribute("name", name); xtw.writeAttribute("expression", expression); xtw.writeEndElement();/*from w ww . ja va 2 s . c om*/ }
From source file:org.activiti.designer.export.bpmn20.export.MailTaskExport.java
private static void writeCDataField(String name, String text, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "field", ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeAttribute("name", name); xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "expression", ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeCData(text);//from w w w .ja va2 s . c om xtw.writeEndElement(); 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;/*from w w w. j a v a2 s. c o 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 ww w .j a v a2 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 w w . j a v a 2s. c o m*/ 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()); }/*ww w . jav a2s . c om*/ 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 ava2s .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()); }/*from www.ja va 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); } } }