use of org.activiti.bpmn.model.IntermediateCatchEvent in project Activiti by Activiti.
the class CatchEventJsonConverter method getStencilId.
protected String getStencilId(BaseElement baseElement) {
IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) baseElement;
List<EventDefinition> eventDefinitions = catchEvent.getEventDefinitions();
if (eventDefinitions.size() != 1) {
// return timer event as default;
return STENCIL_EVENT_CATCH_TIMER;
}
EventDefinition eventDefinition = eventDefinitions.get(0);
if (eventDefinition instanceof MessageEventDefinition) {
return STENCIL_EVENT_CATCH_MESSAGE;
} else if (eventDefinition instanceof SignalEventDefinition) {
return STENCIL_EVENT_CATCH_SIGNAL;
} else {
return STENCIL_EVENT_CATCH_TIMER;
}
}
use of org.activiti.bpmn.model.IntermediateCatchEvent in project Activiti by Activiti.
the class CatchEventJsonConverter method convertJsonToElement.
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
IntermediateCatchEvent catchEvent = new IntermediateCatchEvent();
String stencilId = BpmnJsonConverterUtil.getStencilId(elementNode);
if (STENCIL_EVENT_CATCH_TIMER.equals(stencilId)) {
convertJsonToTimerDefinition(elementNode, catchEvent);
} else if (STENCIL_EVENT_CATCH_MESSAGE.equals(stencilId)) {
convertJsonToMessageDefinition(elementNode, catchEvent);
} else if (STENCIL_EVENT_CATCH_SIGNAL.equals(stencilId)) {
convertJsonToSignalDefinition(elementNode, catchEvent);
}
return catchEvent;
}
use of org.activiti.bpmn.model.IntermediateCatchEvent in project Activiti by Activiti.
the class SimpleConverterTest method validateModel.
private void validateModel(BpmnModel model) {
assertEquals("simpleProcess", model.getMainProcess().getId());
assertEquals("Simple process", model.getMainProcess().getName());
assertEquals(true, model.getMainProcess().isExecutable());
FlowElement flowElement = model.getMainProcess().getFlowElement("flow1");
assertNotNull(flowElement);
assertTrue(flowElement instanceof SequenceFlow);
assertEquals("flow1", flowElement.getId());
flowElement = model.getMainProcess().getFlowElement("catchEvent");
assertNotNull(flowElement);
assertTrue(flowElement instanceof IntermediateCatchEvent);
assertEquals("catchEvent", flowElement.getId());
IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement;
assertTrue(catchEvent.getEventDefinitions().size() == 1);
EventDefinition eventDefinition = catchEvent.getEventDefinitions().get(0);
assertTrue(eventDefinition instanceof TimerEventDefinition);
TimerEventDefinition timerDefinition = (TimerEventDefinition) eventDefinition;
assertEquals("PT5M", timerDefinition.getTimeDuration());
flowElement = model.getMainProcess().getFlowElement("flow1Condition");
assertNotNull(flowElement);
assertTrue(flowElement instanceof SequenceFlow);
assertEquals("flow1Condition", flowElement.getId());
SequenceFlow flow = (SequenceFlow) flowElement;
assertEquals("${number <= 1}", flow.getConditionExpression());
}
use of org.activiti.bpmn.model.IntermediateCatchEvent 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.IntermediateCatchEvent in project Activiti by Activiti.
the class TimerDefinitionConverterTest method validateModel.
private void validateModel(BpmnModel model) {
IntermediateCatchEvent timer = (IntermediateCatchEvent) model.getMainProcess().getFlowElement("timer");
assertNotNull(timer);
TimerEventDefinition timerEvent = (TimerEventDefinition) timer.getEventDefinitions().get(0);
assertThat(timerEvent.getCalendarName(), is("custom"));
assertEquals("PT5M", timerEvent.getTimeDuration());
StartEvent start = (StartEvent) model.getMainProcess().getFlowElement("theStart");
assertNotNull(start);
TimerEventDefinition startTimerEvent = (TimerEventDefinition) start.getEventDefinitions().get(0);
assertThat(startTimerEvent.getCalendarName(), is("custom"));
assertEquals("R2/PT5S", startTimerEvent.getTimeCycle());
assertEquals("${EndDate}", startTimerEvent.getEndDate());
BoundaryEvent boundaryTimer = (BoundaryEvent) model.getMainProcess().getFlowElement("boundaryTimer");
assertNotNull(boundaryTimer);
TimerEventDefinition boundaryTimerEvent = (TimerEventDefinition) boundaryTimer.getEventDefinitions().get(0);
assertThat(boundaryTimerEvent.getCalendarName(), is("custom"));
assertEquals("PT10S", boundaryTimerEvent.getTimeDuration());
}
Aggregations