List of usage examples for javax.xml.stream XMLStreamReader getLocalName
public String getLocalName();
From source file:org.flowable.bpmn.converter.child.FieldExtensionParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (!accepts(parentElement)) return;/*from w w w.j ava 2s .c om*/ 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 FlowableListener) { ((FlowableListener) parentElement).getFieldExtensions().add(extension); } else if (parentElement instanceof ServiceTask) { ((ServiceTask) parentElement).getFieldExtensions().add(extension); } else { ((SendTask) parentElement).getFieldExtensions().add(extension); } }
From source file:org.flowable.bpmn.converter.child.FlowableCollectionParser.java
@Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (!(parentElement instanceof MultiInstanceLoopCharacteristics)) { return;// w w w .ja v a 2s . com } MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = (MultiInstanceLoopCharacteristics) parentElement; CollectionHandler collectionHandler = null; if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_MULTIINSTANCE_COLLECTION_CLASS))) { collectionHandler = new CollectionHandler(); collectionHandler .setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_MULTIINSTANCE_COLLECTION_CLASS)); collectionHandler.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); } else if (StringUtils .isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_MULTIINSTANCE_COLLECTION_DELEGATEEXPRESSION))) { collectionHandler = new CollectionHandler(); collectionHandler.setImplementation( xtr.getAttributeValue(null, ATTRIBUTE_MULTIINSTANCE_COLLECTION_DELEGATEEXPRESSION)); collectionHandler.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); } if (collectionHandler != null) { BpmnXMLUtil.addXMLLocation(collectionHandler, xtr); multiInstanceLoopCharacteristics.setHandler(collectionHandler); } boolean readyWithCollection = false; try { while (!readyWithCollection && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_MULTIINSTANCE_COLLECTION_STRING.equalsIgnoreCase(xtr.getLocalName())) { // it is a string value multiInstanceLoopCharacteristics.setCollectionString(xtr.getElementText()); } else if (xtr.isStartElement() && ELEMENT_MULTIINSTANCE_COLLECTION_EXPRESSION.equalsIgnoreCase(xtr.getLocalName())) { // it is an expression multiInstanceLoopCharacteristics.setInputDataItem(xtr.getElementText()); } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) { readyWithCollection = true; } } } catch (Exception e) { LOGGER.warn("Error parsing collection child elements", e); } }
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;// w ww . j a va 2 s. c o 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.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 w w. j a v a 2s.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.parser.SubProcessParser.java
public void parse(XMLStreamReader xtr, List<SubProcess> activeSubProcessList, Process activeProcess) { SubProcess subProcess = null;/*from www .ja va2s . co m*/ if (ELEMENT_TRANSACTION.equalsIgnoreCase(xtr.getLocalName())) { subProcess = new Transaction(); } else if (ELEMENT_ADHOC_SUBPROCESS.equalsIgnoreCase(xtr.getLocalName())) { AdhocSubProcess adhocSubProcess = new AdhocSubProcess(); String orderingAttributeValue = xtr.getAttributeValue(null, ATTRIBUTE_ORDERING); if (StringUtils.isNotEmpty(orderingAttributeValue)) { adhocSubProcess.setOrdering(orderingAttributeValue); } if (ATTRIBUTE_VALUE_FALSE .equalsIgnoreCase(xtr.getAttributeValue(null, ATTRIBUTE_CANCEL_REMAINING_INSTANCES))) { adhocSubProcess.setCancelRemainingInstances(false); } subProcess = adhocSubProcess; } else if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(xtr.getAttributeValue(null, ATTRIBUTE_TRIGGERED_BY))) { subProcess = new EventSubProcess(); } else { subProcess = new SubProcess(); } BpmnXMLUtil.addXMLLocation(subProcess, xtr); activeSubProcessList.add(subProcess); subProcess.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); subProcess.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); boolean async = false; String asyncString = BpmnXMLUtil.getAttributeValue(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, xtr); if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(asyncString)) { async = true; } boolean notExclusive = false; String exclusiveString = BpmnXMLUtil.getAttributeValue(ATTRIBUTE_ACTIVITY_EXCLUSIVE, xtr); if (ATTRIBUTE_VALUE_FALSE.equalsIgnoreCase(exclusiveString)) { notExclusive = true; } boolean forCompensation = false; String compensationString = xtr.getAttributeValue(null, ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION); if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(compensationString)) { forCompensation = true; } subProcess.setAsynchronous(async); subProcess.setNotExclusive(notExclusive); subProcess.setForCompensation(forCompensation); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT))) { subProcess.setDefaultFlow(xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT)); } if (activeSubProcessList.size() > 1) { SubProcess parentSubProcess = activeSubProcessList.get(activeSubProcessList.size() - 2); parentSubProcess.addFlowElement(subProcess); } else { activeProcess.addFlowElement(subProcess); } }
From source file:org.flowable.cmmn.converter.CmmnXmlConverter.java
public CmmnModel convertToCmmnModel(XMLStreamReader xtr) { ConversionHelper conversionHelper = new ConversionHelper(); conversionHelper.setCmmnModel(new CmmnModel()); try {// w w w .j a v a2 s . c o m String currentXmlElement = null; while (xtr.hasNext()) { try { xtr.next(); } catch (Exception e) { LOGGER.debug("Error reading CMMN XML document", e); throw new CmmnXMLException("Error reading XML", e); } if (xtr.isStartElement()) { currentXmlElement = xtr.getLocalName(); if (elementConverters.containsKey(currentXmlElement)) { elementConverters.get(currentXmlElement).convertToCmmnModel(xtr, conversionHelper); } } else if (xtr.isEndElement()) { currentXmlElement = null; if (elementConverters.containsKey(xtr.getLocalName())) { elementConverters.get(xtr.getLocalName()).elementEnd(xtr, conversionHelper); } } else if (xtr.isCharacters() && currentXmlElement != null) { if (textConverters.containsKey(currentXmlElement)) { textConverters.get(currentXmlElement).convertToCmmnModel(xtr, conversionHelper); } } } } catch (CmmnXMLException e) { throw e; } catch (Exception e) { LOGGER.error("Error processing CMMN XML document", e); throw new CmmnXMLException("Error processing CMMN XML document", e); } // Post process all elements: add instances where a reference is used processCmmnElements(conversionHelper); return conversionHelper.getCmmnModel(); }
From source file:org.flowable.cmmn.converter.ExtensionElementsXMLConverter.java
@Override protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { boolean readyWithChildElements = false; try {// w ww . j a v a 2 s.c o m while (!readyWithChildElements && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement()) { if (CmmnXmlConstants.ELEMENT_COMPLETION_NEUTRAL_RULE.equals(xtr.getLocalName())) { readCompletionNeutralRule(xtr, conversionHelper); } else if (CmmnXmlConstants.ELEMENT_FIELD.equals(xtr.getLocalName())) { readFieldExtension(xtr, conversionHelper); } else if (CmmnXmlConstants.ELEMENT_HTTP_REQUEST_HANDLER.equals(xtr.getLocalName())) { readHttpRequestHandler(xtr, conversionHelper); } else if (CmmnXmlConstants.ELEMENT_HTTP_RESPONSE_HANDLER.equals(xtr.getLocalName())) { readHttpResponseHandler(xtr, conversionHelper); } else if (CmmnXmlConstants.ELEMENT_PROCESS_TASK_IN_PARAMETERS.equals(xtr.getLocalName())) { readIOParameter(xtr, true, conversionHelper); } else if (CmmnXmlConstants.ELEMENT_PROCESS_TASK_OUT_PARAMETERS.equals(xtr.getLocalName())) { readIOParameter(xtr, false, conversionHelper); } else if (CmmnXmlConstants.ELEMENT_TASK_LISTENER.equals(xtr.getLocalName())) { readTaskListener(xtr, conversionHelper); } else if (CmmnXmlConstants.ELEMENT_PLAN_ITEM_LIFECYCLE_LISTENER.equals(xtr.getLocalName())) { readLifecycleListener(xtr, conversionHelper); } else { ExtensionElement extensionElement = CmmnXmlUtil.parseExtensionElement(xtr); conversionHelper.getCurrentCmmnElement().addExtensionElement(extensionElement); } } else if (xtr.isEndElement()) { if (CmmnXmlConstants.ELEMENT_TASK_LISTENER.equalsIgnoreCase(xtr.getLocalName()) || CmmnXmlConstants.ELEMENT_PLAN_ITEM_LIFECYCLE_LISTENER .equalsIgnoreCase(xtr.getLocalName())) { conversionHelper.removeCurrentCmmnElement(); } else if (CmmnXmlConstants.ELEMENT_EXTENSION_ELEMENTS.equalsIgnoreCase(xtr.getLocalName())) { readyWithChildElements = true; } } } } catch (Exception ex) { LOGGER.error("Error processing CMMN document", ex); throw new XMLException("Error processing CMMN document", ex); } return null; }
From source file:org.flowable.cmmn.converter.ExtensionElementsXMLConverter.java
protected void readCompletionNeutralRule(XMLStreamReader xtr, ConversionHelper conversionHelper) { if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl) { CompletionNeutralRule completionNeutralRule = new CompletionNeutralRule(); completionNeutralRule.setName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); PlanItemControl planItemControl = (PlanItemControl) conversionHelper.getCurrentCmmnElement(); planItemControl.setCompletionNeutralRule(completionNeutralRule); readCommonXmlInfo(completionNeutralRule, xtr); boolean readyWithChildElements = false; try {/* w ww .ja v a2s . com*/ while (!readyWithChildElements && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement()) { if (CmmnXmlConstants.ELEMENT_CONDITION.equals(xtr.getLocalName())) { xtr.next(); if (xtr.isCharacters()) { completionNeutralRule.setCondition(xtr.getText()); } break; } } else if (xtr.isEndElement()) { if (CmmnXmlConstants.ELEMENT_COMPLETION_NEUTRAL_RULE.equalsIgnoreCase(xtr.getLocalName())) { readyWithChildElements = true; } } } } catch (Exception ex) { LOGGER.error("Error processing CMMN document", ex); throw new XMLException("Error processing CMMN document", ex); } } }
From source file:org.flowable.cmmn.converter.ExtensionElementsXMLConverter.java
protected void readFieldExtension(XMLStreamReader xtr, ConversionHelper conversionHelper) { BaseElement cmmnElement = conversionHelper.getCurrentCmmnElement(); FieldExtension extension = new FieldExtension(); extension.setFieldName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); String stringValueAttribute = xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_FIELD_STRING); String expressionAttribute = xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_FIELD_EXPRESSION); if (StringUtils.isNotEmpty(stringValueAttribute)) { extension.setStringValue(stringValueAttribute); } else if (StringUtils.isNotEmpty(expressionAttribute)) { extension.setExpression(expressionAttribute); } else {/*from ww w .ja v a 2s.com*/ boolean readyWithFieldExtension = false; try { while (!readyWithFieldExtension && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && CmmnXmlConstants.ELEMENT_FIELD_STRING.equalsIgnoreCase(xtr.getLocalName())) { extension.setStringValue(xtr.getElementText().trim()); } else if (xtr.isStartElement() && CmmnXmlConstants.ELEMENT_FIELD_EXPRESSION.equalsIgnoreCase(xtr.getLocalName())) { extension.setExpression(xtr.getElementText().trim()); } else if (xtr.isEndElement() && CmmnXmlConstants.ELEMENT_FIELD.equalsIgnoreCase(xtr.getLocalName())) { readyWithFieldExtension = true; } } } catch (Exception e) { LOGGER.warn("Error parsing field extension child elements", e); } } CmmnElement currentCmmnElement = conversionHelper.getCurrentCmmnElement(); if (currentCmmnElement instanceof ServiceTask) { ((ServiceTask) currentCmmnElement).getFieldExtensions().add(extension); } else if (currentCmmnElement instanceof DecisionTask) { ((DecisionTask) currentCmmnElement).getFieldExtensions().add(extension); } else if (currentCmmnElement instanceof FlowableListener) { ((FlowableListener) currentCmmnElement).getFieldExtensions().add(extension); } else { throw new FlowableException("Programmatic error: field added to unkown element " + currentCmmnElement); } }
From source file:org.flowable.cmmn.converter.FieldExtensionXmlConverter.java
@Override protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { CmmnElement cmmnElement = conversionHelper.getCurrentCmmnElement(); if (!(cmmnElement instanceof ServiceTask || cmmnElement instanceof DecisionTask)) { return null; }/*www.j a v a 2 s. c o m*/ TaskWithFieldExtensions serviceTask = (TaskWithFieldExtensions) cmmnElement; FieldExtension extension = new FieldExtension(); extension.setFieldName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); String stringValueAttribute = xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_FIELD_STRING); String expressionAttribute = xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_FIELD_EXPRESSION); if (StringUtils.isNotEmpty(stringValueAttribute)) { extension.setStringValue(stringValueAttribute); } else if (StringUtils.isNotEmpty(expressionAttribute)) { extension.setExpression(expressionAttribute); } else { boolean readyWithFieldExtension = false; try { while (!readyWithFieldExtension && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && CmmnXmlConstants.ELEMENT_FIELD_STRING.equalsIgnoreCase(xtr.getLocalName())) { extension.setStringValue(xtr.getElementText().trim()); } else if (xtr.isStartElement() && CmmnXmlConstants.ELEMENT_FIELD_EXPRESSION.equalsIgnoreCase(xtr.getLocalName())) { extension.setExpression(xtr.getElementText().trim()); } else if (xtr.isEndElement() && getXMLElementName().equalsIgnoreCase(xtr.getLocalName())) { readyWithFieldExtension = true; } } } catch (Exception e) { LOGGER.warn("Error parsing field extension child elements", e); } } serviceTask.getFieldExtensions().add(extension); return null; }