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;
}
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());
}
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?
}
}
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));
}
}
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);
}
}
Aggregations