Search in sources :

Example 16 with BoundaryEvent

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

the class BoundaryEventJsonConverter method convertJsonToElement.

protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
    BoundaryEvent boundaryEvent = new BoundaryEvent();
    String stencilId = BpmnJsonConverterUtil.getStencilId(elementNode);
    if (STENCIL_EVENT_BOUNDARY_TIMER.equals(stencilId)) {
        convertJsonToTimerDefinition(elementNode, boundaryEvent);
        boundaryEvent.setCancelActivity(getPropertyValueAsBoolean(PROPERTY_CANCEL_ACTIVITY, elementNode));
    } else if (STENCIL_EVENT_BOUNDARY_ERROR.equals(stencilId)) {
        convertJsonToErrorDefinition(elementNode, boundaryEvent);
    } else if (STENCIL_EVENT_BOUNDARY_SIGNAL.equals(stencilId)) {
        convertJsonToSignalDefinition(elementNode, boundaryEvent);
        boundaryEvent.setCancelActivity(getPropertyValueAsBoolean(PROPERTY_CANCEL_ACTIVITY, elementNode));
    } else if (STENCIL_EVENT_BOUNDARY_MESSAGE.equals(stencilId)) {
        convertJsonToMessageDefinition(elementNode, boundaryEvent);
        boundaryEvent.setCancelActivity(getPropertyValueAsBoolean(PROPERTY_CANCEL_ACTIVITY, elementNode));
    } else if (STENCIL_EVENT_BOUNDARY_CANCEL.equals(stencilId)) {
        CancelEventDefinition cancelEventDefinition = new CancelEventDefinition();
        boundaryEvent.getEventDefinitions().add(cancelEventDefinition);
        boundaryEvent.setCancelActivity(getPropertyValueAsBoolean(PROPERTY_CANCEL_ACTIVITY, elementNode));
    } else if (STENCIL_EVENT_BOUNDARY_COMPENSATION.equals(stencilId)) {
        CompensateEventDefinition compensateEventDefinition = new CompensateEventDefinition();
        boundaryEvent.getEventDefinitions().add(compensateEventDefinition);
        boundaryEvent.setCancelActivity(getPropertyValueAsBoolean(PROPERTY_CANCEL_ACTIVITY, elementNode));
    }
    boundaryEvent.setAttachedToRefId(lookForAttachedRef(elementNode.get(EDITOR_SHAPE_ID).asText(), modelNode.get(EDITOR_CHILD_SHAPES)));
    return boundaryEvent;
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) CompensateEventDefinition(org.activiti.bpmn.model.CompensateEventDefinition)

Example 17 with BoundaryEvent

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

the class BoundaryEventConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    BoundaryEvent errorElement = (BoundaryEvent) model.getMainProcess().getFlowElement("errorEvent");
    ErrorEventDefinition errorEvent = (ErrorEventDefinition) extractEventDefinition(errorElement);
    //always true
    assertTrue(errorElement.isCancelActivity());
    assertEquals("errorRef", errorEvent.getErrorCode());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
    BoundaryEvent signalElement = (BoundaryEvent) model.getMainProcess().getFlowElement("signalEvent");
    SignalEventDefinition signalEvent = (SignalEventDefinition) extractEventDefinition(signalElement);
    assertFalse(signalElement.isCancelActivity());
    assertEquals("signalRef", signalEvent.getSignalRef());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
    BoundaryEvent messageElement = (BoundaryEvent) model.getMainProcess().getFlowElement("messageEvent");
    MessageEventDefinition messageEvent = (MessageEventDefinition) extractEventDefinition(messageElement);
    assertFalse(messageElement.isCancelActivity());
    assertEquals("messageRef", messageEvent.getMessageRef());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
    BoundaryEvent timerElement = (BoundaryEvent) model.getMainProcess().getFlowElement("timerEvent");
    TimerEventDefinition timerEvent = (TimerEventDefinition) extractEventDefinition(timerElement);
    assertFalse(timerElement.isCancelActivity());
    assertEquals("PT5M", timerEvent.getTimeDuration());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 18 with BoundaryEvent

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

the class MessageEventDefinitionParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, MessageEventDefinition messageDefinition) {
    BpmnModel bpmnModel = bpmnParse.getBpmnModel();
    String messageRef = messageDefinition.getMessageRef();
    if (bpmnModel.containsMessageId(messageRef)) {
        Message message = bpmnModel.getMessage(messageRef);
        messageDefinition.setMessageRef(message.getName());
        messageDefinition.setExtensionElements(message.getExtensionElements());
    }
    EventSubscriptionDeclaration eventSubscription = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
    ScopeImpl scope = bpmnParse.getCurrentScope();
    ActivityImpl activity = bpmnParse.getCurrentActivity();
    if (bpmnParse.getCurrentFlowElement() instanceof StartEvent && bpmnParse.getCurrentSubProcess() != null) {
        // the scope of the event subscription is the parent of the event
        // subprocess (subscription must be created when parent is initialized)
        ScopeImpl catchingScope = ((ActivityImpl) scope).getParent();
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
        eventSubscriptionDeclaration.setActivityId(activity.getId());
        eventSubscriptionDeclaration.setStartEvent(false);
        addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, messageDefinition, catchingScope);
    } else if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
        activity.setProperty("type", "messageStartEvent");
        eventSubscription.setStartEvent(true);
        eventSubscription.setActivityId(activity.getId());
        addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, bpmnParse.getCurrentProcessDefinition());
    } else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
        activity.setProperty("type", "intermediateMessageCatch");
        if (getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
            eventSubscription.setActivityId(activity.getId());
            addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, activity.getParent());
        } else {
            activity.setScope(true);
            addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, activity);
        }
    } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
        BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
        boolean interrupting = boundaryEvent.isCancelActivity();
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
        activity.setProperty("type", "boundaryMessage");
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
        eventSubscriptionDeclaration.setActivityId(activity.getId());
        addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, messageDefinition, activity.getParent());
        if (activity.getParent() instanceof ActivityImpl) {
            ((ActivityImpl) activity.getParent()).setScope(true);
        }
    } else {
    // What to do here?
    }
}
Also used : Message(org.activiti.bpmn.model.Message) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) StartEvent(org.activiti.bpmn.model.StartEvent) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl) EventSubscriptionDeclaration(org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 19 with BoundaryEvent

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

the class CancelEventDefinitionParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, CancelEventDefinition cancelEventDefinition) {
    if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
        ActivityImpl activity = bpmnParse.getCurrentActivity();
        activity.setProperty("type", "cancelBoundaryCatch");
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCancelBoundaryEventActivityBehavior(cancelEventDefinition));
    }
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Example 20 with BoundaryEvent

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

the class ErrorEventDefinitionParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, ErrorEventDefinition eventDefinition) {
    ErrorEventDefinition modelErrorEvent = (ErrorEventDefinition) eventDefinition;
    if (bpmnParse.getBpmnModel().containsErrorRef(modelErrorEvent.getErrorCode())) {
        String errorCode = bpmnParse.getBpmnModel().getErrors().get(modelErrorEvent.getErrorCode());
        modelErrorEvent.setErrorCode(errorCode);
    }
    ScopeImpl scope = bpmnParse.getCurrentScope();
    ActivityImpl activity = bpmnParse.getCurrentActivity();
    if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
        if (scope.getProperty(PROPERTYNAME_INITIAL) == null) {
            scope.setProperty(PROPERTYNAME_INITIAL, activity);
            // the scope of the event subscription is the parent of the event
            // subprocess (subscription must be created when parent is initialized)
            ScopeImpl catchingScope = ((ActivityImpl) scope).getParent();
            createErrorStartEventDefinition(modelErrorEvent, activity, catchingScope);
        }
    } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
        BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
        // non-interrupting not yet supported
        boolean interrupting = true;
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
        ActivityImpl parentActivity = scope.findActivity(boundaryEvent.getAttachedToRefId());
        createBoundaryErrorEventDefinition(modelErrorEvent, interrupting, parentActivity, activity);
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) StartEvent(org.activiti.bpmn.model.StartEvent) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl)

Aggregations

BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)31 FlowElement (org.activiti.bpmn.model.FlowElement)11 SubProcess (org.activiti.bpmn.model.SubProcess)8 StartEvent (org.activiti.bpmn.model.StartEvent)7 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)7 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)6 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)6 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)6 UserTask (org.activiti.bpmn.model.UserTask)6 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)5 CompensateEventDefinition (org.activiti.bpmn.model.CompensateEventDefinition)4 DataObject (org.activiti.bpmn.model.DataObject)4 EventDefinition (org.activiti.bpmn.model.EventDefinition)4 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)4 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)4 Activity (org.activiti.bpmn.model.Activity)3 Association (org.activiti.bpmn.model.Association)3 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)3 Event (org.activiti.bpmn.model.Event)3 FlowNode (org.activiti.bpmn.model.FlowNode)3