List of usage examples for javax.xml.stream XMLStreamReader getAttributeValue
public String getAttributeValue(String namespaceURI, String localName);
From source file:org.flowable.bpmn.converter.child.FlowableHttpResponseHandlerParser.java
@Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { FlowableHttpResponseHandler responseHandler = new FlowableHttpResponseHandler(); BpmnXMLUtil.addXMLLocation(responseHandler, xtr); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CLASS))) { responseHandler.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CLASS)); responseHandler.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION))) { responseHandler.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION)); responseHandler.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); }//from w ww . ja v a2 s . c o m if (parentElement instanceof HttpServiceTask) { ((HttpServiceTask) parentElement).setHttpResponseHandler(responseHandler); parseChildElements(xtr, responseHandler, model, new FieldExtensionParser()); } }
From source file:org.flowable.bpmn.converter.child.FlowableListenerParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { FlowableListener listener = new FlowableListener(); BpmnXMLUtil.addXMLLocation(listener, xtr); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CLASS))) { listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CLASS)); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EXPRESSION))) { listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EXPRESSION)); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION))) { listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION)); listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); }/*from w w w.j av a 2 s . c o m*/ listener.setEvent(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EVENT)); listener.setOnTransaction(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_ON_TRANSACTION)); if (StringUtils .isNotEmpty((xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_CLASS)))) { listener.setCustomPropertiesResolverImplementation( xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_CLASS)); listener.setCustomPropertiesResolverImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); } else if (StringUtils.isNotEmpty( xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_EXPRESSION))) { listener.setCustomPropertiesResolverImplementation( xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_EXPRESSION)); listener.setCustomPropertiesResolverImplementationType( ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); } else if (StringUtils.isNotEmpty( xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_DELEGATEEXPRESSION))) { listener.setCustomPropertiesResolverImplementation( xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_DELEGATEEXPRESSION)); listener.setCustomPropertiesResolverImplementationType( ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); } addListenerToParent(listener, parentElement); parseChildElements(xtr, listener, model, new FieldExtensionParser()); }
From source file:org.flowable.bpmn.converter.child.FormPropertyParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (!accepts(parentElement)) return;//from w w w. j a v a 2s .c om 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.flowable.bpmn.converter.child.InParameterParser.java
@Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { String source = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_SOURCE); String sourceExpression = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION); String target = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_TARGET); if ((StringUtils.isNotEmpty(source) || StringUtils.isNotEmpty(sourceExpression)) && StringUtils.isNotEmpty(target)) { IOParameter parameter = new IOParameter(); if (StringUtils.isNotEmpty(sourceExpression)) { parameter.setSourceExpression(sourceExpression); } else {/*from w w w. j av a2s . c om*/ parameter.setSource(source); } parameter.setTarget(target); if (parentElement instanceof CallActivity) { ((CallActivity) parentElement).getInParameters().add(parameter); } else if (parentElement instanceof CaseServiceTask) { ((CaseServiceTask) parentElement).getInParameters().add(parameter); } } }
From source file:org.flowable.bpmn.converter.child.IOSpecificationParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof Activity == false && parentElement instanceof Process == false) return;// w ww .j a v a 2 s . c o m 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_ITEM_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_ITEM_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.flowable.bpmn.converter.child.MessageEventDefinitionParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof Event == false) return;// ww w .j a va2 s . c o m MessageEventDefinition eventDefinition = new MessageEventDefinition(); BpmnXMLUtil.addXMLLocation(eventDefinition, xtr); eventDefinition.setMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_MESSAGE_REF)); eventDefinition.setMessageExpression(BpmnXMLUtil.getAttributeValue(ATTRIBUTE_MESSAGE_EXPRESSION, xtr)); 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); String messageRef = eventDefinition.getMessageRef().substring(indexOfP + 1); if (resolvedNamespace == null) { // if it's an invalid prefix will consider this is not a namespace prefix so will be used as part of the stringReference messageRef = prefix + ":" + messageRef; } else if (!resolvedNamespace.equalsIgnoreCase(model.getTargetNamespace())) { // if it's a valid namespace prefix but it's not the targetNamespace then we'll use it as a valid namespace // (even out editor does not support defining namespaces it is still a valid xml file) messageRef = resolvedNamespace + ":" + messageRef; } eventDefinition.setMessageRef(messageRef); } else { eventDefinition.setMessageRef(eventDefinition.getMessageRef()); } } BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_MESSAGEDEFINITION, eventDefinition, xtr, model); ((Event) parentElement).getEventDefinitions().add(eventDefinition); }
From source file:org.flowable.bpmn.converter.child.OutParameterParser.java
@Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { String source = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_SOURCE); String sourceExpression = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION); String target = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_TARGET); if ((StringUtils.isNotEmpty(source) || StringUtils.isNotEmpty(sourceExpression)) && StringUtils.isNotEmpty(target)) { IOParameter parameter = new IOParameter(); if (StringUtils.isNotEmpty(sourceExpression)) { parameter.setSourceExpression(sourceExpression); } else {// w w w . java 2 s . c om parameter.setSource(source); } parameter.setTarget(target); if (parentElement instanceof CallActivity) { ((CallActivity) parentElement).getOutParameters().add(parameter); } else if (parentElement instanceof CaseServiceTask) { ((CaseServiceTask) parentElement).getOutParameters().add(parameter); } } }
From source file:org.flowable.bpmn.converter.child.SignalEventDefinitionParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof Event == false) return;/*from w w w .j av a 2 s .com*/ SignalEventDefinition eventDefinition = new SignalEventDefinition(); BpmnXMLUtil.addXMLLocation(eventDefinition, xtr); eventDefinition.setSignalRef(xtr.getAttributeValue(null, ATTRIBUTE_SIGNAL_REF)); eventDefinition.setSignalExpression(BpmnXMLUtil.getAttributeValue(ATTRIBUTE_SIGNAL_EXPRESSION, xtr)); if (StringUtils.isNotEmpty(BpmnXMLUtil.getAttributeValue(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, xtr))) { eventDefinition.setAsync( Boolean.parseBoolean(BpmnXMLUtil.getAttributeValue(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, xtr))); } BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_SIGNALDEFINITION, eventDefinition, xtr, model); ((Event) parentElement).getEventDefinitions().add(eventDefinition); }
From source file:org.flowable.bpmn.converter.parser.MessageParser.java
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) { String messageId = xtr.getAttributeValue(null, ATTRIBUTE_ID); String messageName = xtr.getAttributeValue(null, ATTRIBUTE_NAME); String itemRef = parseItemRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_REF), model); Message message = new Message(messageId, messageName, itemRef); BpmnXMLUtil.addXMLLocation(message, xtr); BpmnXMLUtil.parseChildElements(ELEMENT_MESSAGE, message, xtr, model); model.addMessage(message);//w w w . j a v a 2s .c om } }
From source file:org.flowable.bpmn.converter.parser.ProcessParser.java
public Process parse(XMLStreamReader xtr, BpmnModel model) throws Exception { Process process = null;/*from www. j av a 2s . c o m*/ if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) { String processId = xtr.getAttributeValue(null, ATTRIBUTE_ID); process = new Process(); process.setId(processId); BpmnXMLUtil.addXMLLocation(process, xtr); process.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_EXECUTABLE))) { process.setExecutable( Boolean.parseBoolean(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_EXECUTABLE))); } String candidateUsersString = BpmnXMLUtil.getAttributeValue(ATTRIBUTE_PROCESS_CANDIDATE_USERS, xtr); if (StringUtils.isNotEmpty(candidateUsersString)) { List<String> candidateUsers = BpmnXMLUtil.parseDelimitedList(candidateUsersString); process.setCandidateStarterUsers(candidateUsers); } String candidateGroupsString = BpmnXMLUtil.getAttributeValue(ATTRIBUTE_PROCESS_CANDIDATE_GROUPS, xtr); if (StringUtils.isNotEmpty(candidateGroupsString)) { List<String> candidateGroups = BpmnXMLUtil.parseDelimitedList(candidateGroupsString); process.setCandidateStarterGroups(candidateGroups); } BpmnXMLUtil.addCustomAttributes(xtr, process, ProcessExport.defaultProcessAttributes); model.getProcesses().add(process); } return process; }