List of usage examples for javax.xml.stream XMLStreamReader getAttributeValue
public String getAttributeValue(String namespaceURI, String localName);
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 {/*from w w w .j a v a 2 s . 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 {/* w w w . j a v a 2 s . c om*/ 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.ExtensionElementsXMLConverter.java
protected void readIOParameter(XMLStreamReader xtr, boolean isInParameter, ConversionHelper conversionHelper) { if (!(conversionHelper.getCurrentCmmnElement() instanceof ProcessTask)) { return;// w ww .j a v a2 s . co m } ProcessTask processTask = (ProcessTask) conversionHelper.getCurrentCmmnElement(); String source = xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_IOPARAMETER_SOURCE); String sourceExpression = xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION); String target = xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_IOPARAMETER_TARGET); String targetExpression = xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_IOPARAMETER_TARGET_EXPRESSION); IOParameter parameter = new IOParameter(); if (StringUtils.isNotEmpty(sourceExpression)) { parameter.setSourceExpression(sourceExpression); } else { parameter.setSource(source); } if (StringUtils.isNotEmpty(targetExpression)) { parameter.setTargetExpression(targetExpression); } else { parameter.setTarget(target); } if (isInParameter) { processTask.getInParameters().add(parameter); } else { processTask.getOutParameters().add(parameter); } }
From source file:org.flowable.cmmn.converter.ExtensionElementsXMLConverter.java
protected void readCommonXmlInfo(BaseElement baseElement, XMLStreamReader xtr) { baseElement.setId(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_ID)); Location location = xtr.getLocation(); baseElement.setXmlRowNumber(location.getLineNumber()); baseElement.setXmlRowNumber(location.getColumnNumber()); }
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; }/* ww w . j a v a 2s . 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; }
From source file:org.flowable.cmmn.converter.HumanTaskXmlConverter.java
@Override protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { HumanTask task = new HumanTask(); convertCommonTaskAttributes(xtr, task); task.setAssignee(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_ASSIGNEE)); task.setOwner(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_OWNER)); task.setPriority(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_PRIORITY)); task.setFormKey(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_FORM_KEY)); task.setDueDate(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_DUE_DATE)); task.setCategory(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_CATEGORY)); String candidateUsersString = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_CANDIDATE_USERS); if (StringUtils.isNotEmpty(candidateUsersString)) { String[] candidateUsers = candidateUsersString.split(","); for (String candidateUser : candidateUsers) { task.getCandidateUsers().add(candidateUser); }/*from w w w . j a va2 s. c o m*/ } String candidateGroupsString = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_CANDIDATE_GROUPS); if (StringUtils.isNotEmpty(candidateGroupsString)) { String[] candidateGroups = candidateGroupsString.split(","); for (String candidateGroup : candidateGroups) { task.getCandidateGroups().add(candidateGroup); } } return task; }
From source file:org.flowable.cmmn.converter.StageXmlConverter.java
@Override protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { Stage stage = new Stage(); stage.setName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); stage.setAutoComplete(/*from w w w. jav a 2s .c o m*/ Boolean.valueOf(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_IS_AUTO_COMPLETE))); stage.setAutoCompleteCondition(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_AUTO_COMPLETE_CONDITION)); String displayOrderString = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_DISPLAY_ORDER); if (StringUtils.isNotEmpty(displayOrderString)) { stage.setDisplayOrder(Integer.valueOf(displayOrderString)); } String includeInStageOverviewString = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_INCLUDE_IN_STAGE_OVERVIEW); if (StringUtils.isNotEmpty(includeInStageOverviewString)) { stage.setIncludeInStageOverview(Boolean.valueOf(includeInStageOverviewString)); } else { stage.setIncludeInStageOverview(true); // True by default } stage.setCase(conversionHelper.getCurrentCase()); stage.setParent(conversionHelper.getCurrentStage()); conversionHelper.setCurrentStage(stage); conversionHelper.addStage(stage); return stage; }
From source file:org.flowable.cmmn.converter.TaskXmlConverter.java
@Override protected CmmnElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { Task task = null;/*from w w w .j a v a2 s . c o m*/ String type = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_TYPE); String className = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_CLASS); if (ServiceTask.JAVA_TASK.equals(type)) { ServiceTask serviceTask = new ServiceTask(); serviceTask.setType(ServiceTask.JAVA_TASK); if (StringUtils.isNotEmpty(className)) { serviceTask.setImplementation(className); } String expression = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_EXPRESSION); String delegateExpression = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_DELEGATE_EXPRESSION); if (StringUtils.isNotEmpty(className)) { serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); } else if (StringUtils.isNotEmpty(expression)) { serviceTask.setImplementation(expression); serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); } else if (StringUtils.isNotEmpty(delegateExpression)) { serviceTask.setImplementation(delegateExpression); serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); } serviceTask.setResultVariableName(xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_RESULT_VARIABLE_NAME)); task = serviceTask; } else if (HttpServiceTask.HTTP_TASK.equals(type)) { HttpServiceTask httpServiceTask = new HttpServiceTask(); if (StringUtils.isNotEmpty(className)) { httpServiceTask.setImplementation(className); } task = httpServiceTask; } else { task = new Task(); } convertCommonTaskAttributes(xtr, task); return task; }
From source file:org.flowable.cmmn.converter.TaskXmlConverter.java
protected void convertCommonTaskAttributes(XMLStreamReader xtr, Task task) { task.setName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); String isBlockingString = xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_IS_BLOCKING); if (StringUtils.isNotEmpty(isBlockingString)) { task.setBlocking(Boolean.valueOf(isBlockingString)); }//w ww. ja v a2 s . c o m String isBlockingExpressionString = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_IS_BLOCKING_EXPRESSION); if (StringUtils.isNotEmpty(isBlockingExpressionString)) { task.setBlockingExpression(isBlockingExpressionString); } String isAsyncString = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_IS_ASYNCHRONOUS); if (StringUtils.isNotEmpty(isAsyncString)) { task.setAsync(Boolean.valueOf(isAsyncString.toLowerCase())); } String isExclusiveString = xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_IS_EXCLUSIVE); if (StringUtils.isNotEmpty(isExclusiveString)) { task.setExclusive(Boolean.valueOf(isExclusiveString)); } }
From source file:org.flowable.cmmn.converter.UserEventListenerXmlConverter.java
private UserEventListener convertCommonAttributes(XMLStreamReader xtr, UserEventListener listener) { listener.setName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); listener.setAvailableConditionExpression( xtr.getAttributeValue(CmmnXmlConstants.FLOWABLE_EXTENSIONS_NAMESPACE, CmmnXmlConstants.ATTRIBUTE_EVENT_LISTENER_AVAILABLE_CONDITION)); String csvRoles = xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_AUTHORIZED_ROLE_REFS); if (StringUtils.isNotBlank(csvRoles)) { String[] roles = csvRoles.split(","); listener.setAuthorizedRoleRefs(roles); }/*from www . jav a2s. c o m*/ return listener; }