List of usage examples for javax.xml.stream XMLStreamReader getAttributeValue
public String getAttributeValue(String namespaceURI, String localName);
From source file:org.activiti.bpmn.converter.child.ErrorEventDefinitionParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof Event == false) return;/*from ww w. j a va 2 s . c o m*/ ErrorEventDefinition eventDefinition = new ErrorEventDefinition(); BpmnXMLUtil.addXMLLocation(eventDefinition, xtr); eventDefinition.setErrorCode(xtr.getAttributeValue(null, "errorRef")); if (parentElement instanceof EndEvent && StringUtils.isEmpty(eventDefinition.getErrorCode())) { model.addProblem("errorRef is required for an error event", xtr); } ((Event) parentElement).getEventDefinitions().add(eventDefinition); }
From source file:org.activiti.bpmn.converter.child.FieldExtensionParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof ActivitiListener == false && parentElement instanceof ServiceTask == false && parentElement instanceof SendTask == false) return;/*from www . j a v a2s . c o m*/ FieldExtension extension = new FieldExtension(); BpmnXMLUtil.addXMLLocation(extension, xtr); extension.setFieldName(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_NAME)); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_STRING))) { extension.setStringValue(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_STRING)); } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_EXPRESSION))) { extension.setExpression(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_EXPRESSION)); } else { boolean readyWithFieldExtension = false; try { while (readyWithFieldExtension == false && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_FIELD_STRING.equalsIgnoreCase(xtr.getLocalName())) { extension.setStringValue(xtr.getElementText().trim()); } else if (xtr.isStartElement() && ATTRIBUTE_FIELD_EXPRESSION.equalsIgnoreCase(xtr.getLocalName())) { extension.setExpression(xtr.getElementText().trim()); } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) { readyWithFieldExtension = true; } } } catch (Exception e) { LOGGER.warn("Error parsing field extension child elements", e); } } if (parentElement instanceof ActivitiListener) { ((ActivitiListener) parentElement).getFieldExtensions().add(extension); } else if (parentElement instanceof ServiceTask) { ((ServiceTask) parentElement).getFieldExtensions().add(extension); } else { ((SendTask) parentElement).getFieldExtensions().add(extension); } }
From source file:org.activiti.bpmn.converter.child.FormPropertyParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof UserTask == false && parentElement instanceof StartEvent == false) return;/*from www .j a va 2 s .co m*/ FormProperty property = new FormProperty(); BpmnXMLUtil.addXMLLocation(property, xtr); property.setId(xtr.getAttributeValue(null, ATTRIBUTE_FORM_ID)); property.setName(xtr.getAttributeValue(null, ATTRIBUTE_FORM_NAME)); property.setType(xtr.getAttributeValue(null, ATTRIBUTE_FORM_TYPE)); property.setVariable(xtr.getAttributeValue(null, ATTRIBUTE_FORM_VARIABLE)); property.setExpression(xtr.getAttributeValue(null, ATTRIBUTE_FORM_EXPRESSION)); property.setDefaultExpression(xtr.getAttributeValue(null, ATTRIBUTE_FORM_DEFAULT)); property.setDatePattern(xtr.getAttributeValue(null, ATTRIBUTE_FORM_DATEPATTERN)); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FORM_REQUIRED))) { property.setRequired(Boolean.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_FORM_REQUIRED))); } if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FORM_READABLE))) { property.setReadable(Boolean.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_FORM_READABLE))); } if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FORM_WRITABLE))) { property.setWriteable(Boolean.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_FORM_WRITABLE))); } boolean readyWithFormProperty = false; try { while (readyWithFormProperty == false && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_VALUE.equalsIgnoreCase(xtr.getLocalName())) { FormValue value = new FormValue(); BpmnXMLUtil.addXMLLocation(value, xtr); value.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); value.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); property.getFormValues().add(value); } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) { readyWithFormProperty = true; } } } catch (Exception e) { LOGGER.warn("Error parsing form properties child elements", e); } if (parentElement instanceof UserTask) { ((UserTask) parentElement).getFormProperties().add(property); } else { ((StartEvent) parentElement).getFormProperties().add(property); } }
From source file:org.activiti.bpmn.converter.child.IOSpecificationParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof ServiceTask == false && parentElement instanceof SendTask == false && parentElement instanceof SubProcess == false && parentElement instanceof Process == false) return;// ww w .j a v a 2 s . c om IOSpecification ioSpecification = new IOSpecification(); BpmnXMLUtil.addXMLLocation(ioSpecification, xtr); boolean readyWithIOSpecification = false; try { while (readyWithIOSpecification == false && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_DATA_INPUT.equalsIgnoreCase(xtr.getLocalName())) { DataSpec dataSpec = new DataSpec(); BpmnXMLUtil.addXMLLocation(dataSpec, xtr); dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); dataSpec.setItemSubjectRef( parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_DATA_SUBJECT_REF), model)); ioSpecification.getDataInputs().add(dataSpec); } else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT.equalsIgnoreCase(xtr.getLocalName())) { DataSpec dataSpec = new DataSpec(); BpmnXMLUtil.addXMLLocation(dataSpec, xtr); dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); dataSpec.setItemSubjectRef( parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_DATA_SUBJECT_REF), model)); ioSpecification.getDataOutputs().add(dataSpec); } else if (xtr.isStartElement() && ELEMENT_DATA_INPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) { String dataInputRefs = xtr.getElementText(); if (StringUtils.isNotEmpty(dataInputRefs)) { ioSpecification.getDataInputRefs().add(dataInputRefs.trim()); } } else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) { String dataOutputRefs = xtr.getElementText(); if (StringUtils.isNotEmpty(dataOutputRefs)) { ioSpecification.getDataOutputRefs().add(dataOutputRefs.trim()); } } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) { readyWithIOSpecification = true; } } } catch (Exception e) { LOGGER.warn("Error parsing ioSpecification child elements", e); } if (parentElement instanceof Process) { ((Process) parentElement).setIoSpecification(ioSpecification); } else { ((Activity) parentElement).setIoSpecification(ioSpecification); } }
From source file:org.activiti.bpmn.converter.child.MessageEventDefinitionParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof Event == false) return;/* w w w .j a va2 s . c o m*/ MessageEventDefinition eventDefinition = new MessageEventDefinition(); BpmnXMLUtil.addXMLLocation(eventDefinition, xtr); eventDefinition.setMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_MESSAGE_REF)); if (!StringUtils.isEmpty(eventDefinition.getMessageRef())) { int indexOfP = eventDefinition.getMessageRef().indexOf(':'); if (indexOfP != -1) { String prefix = eventDefinition.getMessageRef().substring(0, indexOfP); String resolvedNamespace = model.getNamespace(prefix); eventDefinition.setMessageRef( resolvedNamespace + ":" + eventDefinition.getMessageRef().substring(indexOfP + 1)); } else { eventDefinition.setMessageRef(model.getTargetNamespace() + ":" + eventDefinition.getMessageRef()); } } BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_MESSAGEDEFINITION, eventDefinition, xtr, model); ((Event) parentElement).getEventDefinitions().add(eventDefinition); }
From source file:org.activiti.bpmn.converter.child.SignalEventDefinitionParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof Event == false) return;//from www.j a v a2 s . c om SignalEventDefinition eventDefinition = new SignalEventDefinition(); BpmnXMLUtil.addXMLLocation(eventDefinition, xtr); eventDefinition.setSignalRef(xtr.getAttributeValue(null, ATTRIBUTE_SIGNAL_REF)); if (StringUtils.isNotEmpty( xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_ACTIVITY_ASYNCHRONOUS))) { eventDefinition.setAsync(Boolean.parseBoolean( xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_ACTIVITY_ASYNCHRONOUS))); } BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_SIGNALDEFINITION, eventDefinition, xtr, model); ((Event) parentElement).getEventDefinitions().add(eventDefinition); }
From source file:org.activiti.bpmn.converter.child.TimeCycleParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof TimerEventDefinition == false) return;/*from w w w .ja v a2s .c o m*/ TimerEventDefinition eventDefinition = (TimerEventDefinition) parentElement; if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_END_DATE))) { eventDefinition.setEndDate(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_END_DATE)); } eventDefinition.setTimeCycle(xtr.getElementText()); }
From source file:org.activiti.bpmn.converter.child.TimerEventDefinitionParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (!(parentElement instanceof Event)) { return;//from w ww .jav a 2s.co m } TimerEventDefinition eventDefinition = new TimerEventDefinition(); String calendarName = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_CALENDAR_NAME); if (StringUtils.isNotEmpty(calendarName)) { eventDefinition.setCalendarName(calendarName); } BpmnXMLUtil.addXMLLocation(eventDefinition, xtr); BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_TIMERDEFINITION, eventDefinition, xtr, model); ((Event) parentElement).getEventDefinitions().add(eventDefinition); }
From source file:org.activiti.bpmn.converter.parser.DataStoreParser.java
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { String id = xtr.getAttributeValue(null, ATTRIBUTE_ID); if (StringUtils.isNotEmpty(id)) { DataStore dataStore = new DataStore(); dataStore.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); String name = xtr.getAttributeValue(null, ATTRIBUTE_NAME); if (StringUtils.isNotEmpty(name)) { dataStore.setName(name);/* ww w. j a v a 2 s . co m*/ } String itemSubjectRef = xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF); if (StringUtils.isNotEmpty(itemSubjectRef)) { dataStore.setItemSubjectRef(itemSubjectRef); } BpmnXMLUtil.addXMLLocation(dataStore, xtr); model.addDataStore(dataStore.getId(), dataStore); BpmnXMLUtil.parseChildElements(ELEMENT_DATA_STORE, dataStore, xtr, model); } }
From source file:org.activiti.bpmn.converter.parser.DefinitionsParser.java
@SuppressWarnings("unchecked") public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { model.setTargetNamespace(xtr.getAttributeValue(null, TARGET_NAMESPACE_ATTRIBUTE)); for (int i = 0; i < xtr.getNamespaceCount(); i++) { String prefix = xtr.getNamespacePrefix(i); if (StringUtils.isNotEmpty(prefix)) { model.addNamespace(prefix, xtr.getNamespaceURI(i)); }/*w w w. jav a 2 s.co m*/ } for (int i = 0; i < xtr.getAttributeCount(); i++) { ExtensionAttribute extensionAttribute = new ExtensionAttribute(); extensionAttribute.setName(xtr.getAttributeLocalName(i)); extensionAttribute.setValue(xtr.getAttributeValue(i)); if (StringUtils.isNotEmpty(xtr.getAttributeNamespace(i))) { extensionAttribute.setNamespace(xtr.getAttributeNamespace(i)); } if (StringUtils.isNotEmpty(xtr.getAttributePrefix(i))) { extensionAttribute.setNamespacePrefix(xtr.getAttributePrefix(i)); } if (!BpmnXMLUtil.isBlacklisted(extensionAttribute, defaultAttributes)) { model.addDefinitionsAttribute(extensionAttribute); } } }