Search in sources :

Example 11 with ExtensionAttribute

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

the class MessageEventDefinitionParser method parseChildElement.

public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
    if (!(parentElement instanceof Event))
        return;
    MessageEventDefinition eventDefinition = new MessageEventDefinition();
    BpmnXMLUtil.addXMLLocation(eventDefinition, xtr);
    eventDefinition.setMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_MESSAGE_REF));
    eventDefinition.setMessageExpression(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_MESSAGE_EXPRESSION));
    eventDefinition.setCorrelationKey(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_MESSAGE_CORRELATION_KEY));
    List<ExtensionAttribute> attributes = parseExtensionAttributes(xtr, parentElement, model);
    if (!attributes.isEmpty()) {
        eventDefinition.setAttributes(singletonMap(ACTIVITI_EXTENSIONS_PREFIX, attributes));
    }
    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);
}
Also used : Event(org.activiti.bpmn.model.Event) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) ExtensionAttribute(org.activiti.bpmn.model.ExtensionAttribute)

Example 12 with ExtensionAttribute

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

the class DecisionTaskJsonConverter method addExtensionAttributeToExtension.

protected void addExtensionAttributeToExtension(ExtensionElement element, String attributeName, String value) {
    ExtensionAttribute extensionAttribute = new ExtensionAttribute(NAMESPACE, attributeName);
    extensionAttribute.setNamespacePrefix("modeler");
    extensionAttribute.setValue(value);
    element.addAttribute(extensionAttribute);
}
Also used : ExtensionAttribute(org.activiti.bpmn.model.ExtensionAttribute)

Aggregations

ExtensionAttribute (org.activiti.bpmn.model.ExtensionAttribute)12 ExtensionElement (org.activiti.bpmn.model.ExtensionElement)4 List (java.util.List)3 FlowElement (org.activiti.bpmn.model.FlowElement)2 Process (org.activiti.bpmn.model.Process)2 Arrays.asList (java.util.Arrays.asList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)1 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 Event (org.activiti.bpmn.model.Event)1 FieldExtension (org.activiti.bpmn.model.FieldExtension)1 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)1 ServiceTask (org.activiti.bpmn.model.ServiceTask)1 UserTask (org.activiti.bpmn.model.UserTask)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1