Search in sources :

Example 11 with ExtensionElement

use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.

the class UserTaskJsonConverter method getExtensionElementValue.

protected String getExtensionElementValue(String name, UserTask userTask) {
    String value = "";
    if (CollectionUtils.isNotEmpty(userTask.getExtensionElements().get(name))) {
        ExtensionElement extensionElement = userTask.getExtensionElements().get(name).get(0);
        value = extensionElement.getElementText();
    }
    return value;
}
Also used : ExtensionElement(org.activiti.bpmn.model.ExtensionElement)

Example 12 with ExtensionElement

use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.

the class SequenceFlowJsonConverter method addExtensionElement.

protected void addExtensionElement(String name, String value, SequenceFlow flow) {
    ExtensionElement extensionElement = new ExtensionElement();
    extensionElement.setNamespace(NAMESPACE);
    extensionElement.setNamespacePrefix("modeler");
    extensionElement.setName(name);
    extensionElement.setElementText(value);
    flow.addExtensionElement(extensionElement);
}
Also used : ExtensionElement(org.activiti.bpmn.model.ExtensionElement)

Example 13 with ExtensionElement

use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.

the class BpmnXMLUtil method parseChildElements.

public static void parseChildElements(String elementName, BaseElement parentElement, XMLStreamReader xtr, Map<String, BaseChildElementParser> childParsers, BpmnModel model) throws Exception {
    Map<String, BaseChildElementParser> localParserMap = new HashMap<String, BaseChildElementParser>(genericChildParserMap);
    if (childParsers != null) {
        localParserMap.putAll(childParsers);
    }
    boolean inExtensionElements = false;
    boolean readyWithChildElements = false;
    while (readyWithChildElements == false && xtr.hasNext()) {
        xtr.next();
        if (xtr.isStartElement()) {
            if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
                inExtensionElements = true;
            } else if (localParserMap.containsKey(xtr.getLocalName())) {
                BaseChildElementParser childParser = localParserMap.get(xtr.getLocalName());
                //if we're into an extension element but the current element is not accepted by this parentElement then is read as a custom extension element
                if (inExtensionElements && !childParser.accepts(parentElement)) {
                    ExtensionElement extensionElement = BpmnXMLUtil.parseExtensionElement(xtr);
                    parentElement.addExtensionElement(extensionElement);
                    continue;
                }
                localParserMap.get(xtr.getLocalName()).parseChildElement(xtr, parentElement, model);
            } else if (inExtensionElements) {
                ExtensionElement extensionElement = BpmnXMLUtil.parseExtensionElement(xtr);
                parentElement.addExtensionElement(extensionElement);
            }
        } else if (xtr.isEndElement()) {
            if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
                inExtensionElements = false;
            } else if (elementName.equalsIgnoreCase(xtr.getLocalName())) {
                readyWithChildElements = true;
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ExtensionElement(org.activiti.bpmn.model.ExtensionElement) BaseChildElementParser(org.activiti.bpmn.converter.child.BaseChildElementParser)

Example 14 with ExtensionElement

use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.

the class BpmnXMLUtil method writeExtensionElements.

public static boolean writeExtensionElements(BaseElement baseElement, boolean didWriteExtensionStartElement, Map<String, String> namespaceMap, XMLStreamWriter xtw) throws Exception {
    if (!baseElement.getExtensionElements().isEmpty()) {
        if (didWriteExtensionStartElement == false) {
            xtw.writeStartElement(ELEMENT_EXTENSIONS);
            didWriteExtensionStartElement = true;
        }
        if (namespaceMap == null) {
            namespaceMap = new HashMap<String, String>();
        }
        for (List<ExtensionElement> extensionElements : baseElement.getExtensionElements().values()) {
            for (ExtensionElement extensionElement : extensionElements) {
                writeExtensionElement(extensionElement, namespaceMap, xtw);
            }
        }
    }
    return didWriteExtensionStartElement;
}
Also used : ExtensionElement(org.activiti.bpmn.model.ExtensionElement)

Example 15 with ExtensionElement

use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.

the class ValuedDataObjectXMLConverter method convertXMLToElement.

@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
    ValuedDataObject dataObject = null;
    ItemDefinition itemSubjectRef = new ItemDefinition();
    String structureRef = xtr.getAttributeValue(null, ATTRIBUTE_DATA_ITEM_REF);
    if (StringUtils.isNotEmpty(structureRef) && structureRef.contains(":")) {
        String dataType = structureRef.substring(structureRef.indexOf(':') + 1);
        if (dataType.equals("string")) {
            dataObject = new StringDataObject();
        } else if (dataType.equals("int")) {
            dataObject = new IntegerDataObject();
        } else if (dataType.equals("long")) {
            dataObject = new LongDataObject();
        } else if (dataType.equals("double")) {
            dataObject = new DoubleDataObject();
        } else if (dataType.equals("boolean")) {
            dataObject = new BooleanDataObject();
        } else if (dataType.equals("datetime")) {
            dataObject = new DateDataObject();
        } else {
            LOGGER.error("Error converting {}, invalid data type: " + dataType, xtr.getAttributeValue(null, ATTRIBUTE_DATA_NAME));
        }
    } else {
        // use String as default type
        dataObject = new StringDataObject();
        structureRef = "xsd:string";
    }
    if (dataObject != null) {
        dataObject.setId(xtr.getAttributeValue(null, ATTRIBUTE_DATA_ID));
        dataObject.setName(xtr.getAttributeValue(null, ATTRIBUTE_DATA_NAME));
        BpmnXMLUtil.addXMLLocation(dataObject, xtr);
        itemSubjectRef.setStructureRef(structureRef);
        dataObject.setItemSubjectRef(itemSubjectRef);
        parseChildElements(getXMLElementName(), dataObject, model, xtr);
        List<ExtensionElement> valuesElement = dataObject.getExtensionElements().get("value");
        if (valuesElement != null && !valuesElement.isEmpty()) {
            ExtensionElement valueElement = valuesElement.get(0);
            if (StringUtils.isNotEmpty(valueElement.getElementText())) {
                if (dataObject instanceof DateDataObject) {
                    try {
                        dataObject.setValue(sdf.parse(valueElement.getElementText()));
                    } catch (Exception e) {
                        LOGGER.error("Error converting {}", dataObject.getName(), e.getMessage());
                    }
                } else {
                    dataObject.setValue(valueElement.getElementText());
                }
            }
            // remove value element
            dataObject.getExtensionElements().remove("value");
        }
    }
    return dataObject;
}
Also used : ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) StringDataObject(org.activiti.bpmn.model.StringDataObject) DoubleDataObject(org.activiti.bpmn.model.DoubleDataObject) DateDataObject(org.activiti.bpmn.model.DateDataObject) ItemDefinition(org.activiti.bpmn.model.ItemDefinition) ExtensionElement(org.activiti.bpmn.model.ExtensionElement) IntegerDataObject(org.activiti.bpmn.model.IntegerDataObject) LongDataObject(org.activiti.bpmn.model.LongDataObject) BooleanDataObject(org.activiti.bpmn.model.BooleanDataObject)

Aggregations

ExtensionElement (org.activiti.bpmn.model.ExtensionElement)24 HashMap (java.util.HashMap)5 FlowElement (org.activiti.bpmn.model.FlowElement)5 SubProcess (org.activiti.bpmn.model.SubProcess)5 ValuedDataObject (org.activiti.bpmn.model.ValuedDataObject)5 List (java.util.List)4 ExtensionAttribute (org.activiti.bpmn.model.ExtensionAttribute)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 ArrayList (java.util.ArrayList)3 BpmnModel (org.activiti.bpmn.model.BpmnModel)3 Gateway (org.activiti.bpmn.model.Gateway)3 Lane (org.activiti.bpmn.model.Lane)3 Process (org.activiti.bpmn.model.Process)3 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)3 UserTask (org.activiti.bpmn.model.UserTask)3 DynamicBpmnService (org.activiti.engine.DynamicBpmnService)3 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 LinkedHashMap (java.util.LinkedHashMap)2