Search in sources :

Example 11 with MessageEventDefinition

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

the class BoundaryEventParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, BoundaryEvent boundaryEvent) {
    ActivityImpl parentActivity = findActivity(bpmnParse, boundaryEvent.getAttachedToRefId());
    if (parentActivity == null) {
        logger.warn("Invalid reference in boundary event. Make sure that the referenced activity is defined in the same scope as the boundary event " + boundaryEvent.getId());
        return;
    }
    ActivityImpl nestedActivity = createActivityOnScope(bpmnParse, boundaryEvent, BpmnXMLConstants.ELEMENT_EVENT_BOUNDARY, parentActivity);
    bpmnParse.setCurrentActivity(nestedActivity);
    EventDefinition eventDefinition = null;
    if (!boundaryEvent.getEventDefinitions().isEmpty()) {
        eventDefinition = boundaryEvent.getEventDefinitions().get(0);
    }
    if (eventDefinition instanceof TimerEventDefinition || eventDefinition instanceof org.activiti.bpmn.model.ErrorEventDefinition || eventDefinition instanceof SignalEventDefinition || eventDefinition instanceof CancelEventDefinition || eventDefinition instanceof MessageEventDefinition || eventDefinition instanceof org.activiti.bpmn.model.CompensateEventDefinition) {
        bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);
    } else {
        logger.warn("Unsupported boundary event type for boundary event " + boundaryEvent.getId());
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 12 with MessageEventDefinition

use of org.activiti.bpmn.model.MessageEventDefinition 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 == false)
        return;
    MessageEventDefinition eventDefinition = new MessageEventDefinition();
    BpmnXMLUtil.addXMLLocation(eventDefinition, xtr);
    eventDefinition.setMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_MESSAGE_REF));
    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)

Example 13 with MessageEventDefinition

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

the class BaseBpmnJsonConverter method convertJsonToMessageDefinition.

protected void convertJsonToMessageDefinition(JsonNode objectNode, Event event) {
    String messageRef = getPropertyValueAsString(PROPERTY_MESSAGEREF, objectNode);
    MessageEventDefinition eventDefinition = new MessageEventDefinition();
    eventDefinition.setMessageRef(messageRef);
    event.getEventDefinitions().add(eventDefinition);
}
Also used : MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition)

Example 14 with MessageEventDefinition

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

the class BpmnJsonConverter method postProcessElements.

private void postProcessElements(FlowElementsContainer parentContainer, Collection<FlowElement> flowElementList, Map<String, JsonNode> edgeMap, BpmnModel bpmnModel, Map<String, FlowWithContainer> allFlowMap, List<Gateway> gatewayWithOrderList) {
    for (FlowElement flowElement : flowElementList) {
        if (flowElement instanceof Event) {
            Event event = (Event) flowElement;
            if (CollectionUtils.isNotEmpty(event.getEventDefinitions())) {
                EventDefinition eventDef = event.getEventDefinitions().get(0);
                if (eventDef instanceof SignalEventDefinition) {
                    SignalEventDefinition signalEventDef = (SignalEventDefinition) eventDef;
                    if (StringUtils.isNotEmpty(signalEventDef.getSignalRef())) {
                        if (bpmnModel.getSignal(signalEventDef.getSignalRef()) == null) {
                            bpmnModel.addSignal(new Signal(signalEventDef.getSignalRef(), signalEventDef.getSignalRef()));
                        }
                    }
                } else if (eventDef instanceof MessageEventDefinition) {
                    MessageEventDefinition messageEventDef = (MessageEventDefinition) eventDef;
                    if (StringUtils.isNotEmpty(messageEventDef.getMessageRef())) {
                        if (bpmnModel.getMessage(messageEventDef.getMessageRef()) == null) {
                            bpmnModel.addMessage(new Message(messageEventDef.getMessageRef(), messageEventDef.getMessageRef(), null));
                        }
                    }
                }
            }
        }
        if (flowElement instanceof BoundaryEvent) {
            BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
            Activity activity = retrieveAttachedRefObject(boundaryEvent.getAttachedToRefId(), parentContainer.getFlowElements());
            if (activity == null) {
                LOGGER.warn("Boundary event " + boundaryEvent.getId() + " is not attached to any activity");
            } else {
                boundaryEvent.setAttachedToRef(activity);
                activity.getBoundaryEvents().add(boundaryEvent);
            }
        } else if (flowElement instanceof Gateway) {
            if (flowElement.getExtensionElements().containsKey("EDITOR_FLOW_ORDER")) {
                gatewayWithOrderList.add((Gateway) flowElement);
            }
        } else if (flowElement instanceof SubProcess) {
            SubProcess subProcess = (SubProcess) flowElement;
            postProcessElements(subProcess, subProcess.getFlowElements(), edgeMap, bpmnModel, allFlowMap, gatewayWithOrderList);
        } else if (flowElement instanceof SequenceFlow) {
            SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
            FlowElement sourceFlowElement = parentContainer.getFlowElement(sequenceFlow.getSourceRef());
            if (sourceFlowElement != null && sourceFlowElement instanceof FlowNode) {
                FlowWithContainer flowWithContainer = new FlowWithContainer(sequenceFlow, parentContainer);
                if (sequenceFlow.getExtensionElements().get("EDITOR_RESOURCEID") != null && sequenceFlow.getExtensionElements().get("EDITOR_RESOURCEID").size() > 0) {
                    allFlowMap.put(sequenceFlow.getExtensionElements().get("EDITOR_RESOURCEID").get(0).getElementText(), flowWithContainer);
                    sequenceFlow.getExtensionElements().remove("EDITOR_RESOURCEID");
                }
                ((FlowNode) sourceFlowElement).getOutgoingFlows().add(sequenceFlow);
                JsonNode edgeNode = edgeMap.get(sequenceFlow.getId());
                if (edgeNode != null) {
                    boolean isDefault = JsonConverterUtil.getPropertyValueAsBoolean(PROPERTY_SEQUENCEFLOW_DEFAULT, edgeNode);
                    if (isDefault) {
                        if (sourceFlowElement instanceof Activity) {
                            ((Activity) sourceFlowElement).setDefaultFlow(sequenceFlow.getId());
                        } else if (sourceFlowElement instanceof Gateway) {
                            ((Gateway) sourceFlowElement).setDefaultFlow(sequenceFlow.getId());
                        }
                    }
                }
            }
            FlowElement targetFlowElement = parentContainer.getFlowElement(sequenceFlow.getTargetRef());
            if (targetFlowElement != null && targetFlowElement instanceof FlowNode) {
                ((FlowNode) targetFlowElement).getIncomingFlows().add(sequenceFlow);
            }
        }
    }
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) Message(org.activiti.bpmn.model.Message) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) Activity(org.activiti.bpmn.model.Activity) JsonNode(com.fasterxml.jackson.databind.JsonNode) EventDefinition(org.activiti.bpmn.model.EventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) Signal(org.activiti.bpmn.model.Signal) FlowElement(org.activiti.bpmn.model.FlowElement) Gateway(org.activiti.bpmn.model.Gateway) Event(org.activiti.bpmn.model.Event) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) FlowNode(org.activiti.bpmn.model.FlowNode)

Aggregations

MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)14 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)11 EventDefinition (org.activiti.bpmn.model.EventDefinition)10 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)7 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)4 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)4 FlowElement (org.activiti.bpmn.model.FlowElement)4 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)3 Event (org.activiti.bpmn.model.Event)3 Message (org.activiti.bpmn.model.Message)3 CompensateEventDefinition (org.activiti.bpmn.model.CompensateEventDefinition)2 Signal (org.activiti.bpmn.model.Signal)2 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)2 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Activity (org.activiti.bpmn.model.Activity)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 FlowNode (org.activiti.bpmn.model.FlowNode)1