use of org.activiti.bpmn.model.TerminateEventDefinition in project Activiti by Activiti.
the class DefaultActivityBehaviorFactory method createTerminateEndEventActivityBehavior.
public TerminateEndEventActivityBehavior createTerminateEndEventActivityBehavior(EndEvent endEvent) {
boolean terminateAll = false;
boolean terminateMultiInstance = false;
if (endEvent.getEventDefinitions() != null && endEvent.getEventDefinitions().size() > 0 && endEvent.getEventDefinitions().get(0) instanceof TerminateEventDefinition) {
terminateAll = ((TerminateEventDefinition) endEvent.getEventDefinitions().get(0)).isTerminateAll();
terminateMultiInstance = ((TerminateEventDefinition) endEvent.getEventDefinitions().get(0)).isTerminateMultiInstance();
}
TerminateEndEventActivityBehavior terminateEndEventActivityBehavior = new TerminateEndEventActivityBehavior();
terminateEndEventActivityBehavior.setTerminateAll(terminateAll);
terminateEndEventActivityBehavior.setTerminateMultiInstance(terminateMultiInstance);
return terminateEndEventActivityBehavior;
}
use of org.activiti.bpmn.model.TerminateEventDefinition in project Activiti by Activiti.
the class TerminateEventDefinitionParser method parseChildElement.
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (!(parentElement instanceof EndEvent)) {
return;
}
TerminateEventDefinition eventDefinition = new TerminateEventDefinition();
parseTerminateAllAttribute(xtr, eventDefinition);
parseTerminateMultiInstanceAttribute(xtr, eventDefinition);
BpmnXMLUtil.addXMLLocation(eventDefinition, xtr);
BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_TERMINATEDEFINITION, eventDefinition, xtr, model);
((Event) parentElement).getEventDefinitions().add(eventDefinition);
}
use of org.activiti.bpmn.model.TerminateEventDefinition in project Activiti by Activiti.
the class BaseBpmnJsonConverter method addEventProperties.
protected void addEventProperties(Event event, ObjectNode propertiesNode) {
List<EventDefinition> eventDefinitions = event.getEventDefinitions();
if (eventDefinitions.size() == 1) {
EventDefinition eventDefinition = eventDefinitions.get(0);
if (eventDefinition instanceof ErrorEventDefinition) {
ErrorEventDefinition errorDefinition = (ErrorEventDefinition) eventDefinition;
if (StringUtils.isNotEmpty(errorDefinition.getErrorRef())) {
propertiesNode.put(PROPERTY_ERRORREF, errorDefinition.getErrorRef());
}
} else if (eventDefinition instanceof SignalEventDefinition) {
SignalEventDefinition signalDefinition = (SignalEventDefinition) eventDefinition;
if (StringUtils.isNotEmpty(signalDefinition.getSignalRef())) {
propertiesNode.put(PROPERTY_SIGNALREF, signalDefinition.getSignalRef());
}
} else if (eventDefinition instanceof MessageEventDefinition) {
MessageEventDefinition messageDefinition = (MessageEventDefinition) eventDefinition;
if (StringUtils.isNotEmpty(messageDefinition.getMessageRef())) {
propertiesNode.put(PROPERTY_MESSAGEREF, messageDefinition.getMessageRef());
}
} else if (eventDefinition instanceof TimerEventDefinition) {
TimerEventDefinition timerDefinition = (TimerEventDefinition) eventDefinition;
if (StringUtils.isNotEmpty(timerDefinition.getTimeDuration())) {
propertiesNode.put(PROPERTY_TIMER_DURATON, timerDefinition.getTimeDuration());
}
if (StringUtils.isNotEmpty(timerDefinition.getTimeCycle())) {
propertiesNode.put(PROPERTY_TIMER_CYCLE, timerDefinition.getTimeCycle());
}
if (StringUtils.isNotEmpty(timerDefinition.getTimeDate())) {
propertiesNode.put(PROPERTY_TIMER_DATE, timerDefinition.getTimeDate());
}
if (StringUtils.isNotEmpty(timerDefinition.getEndDate())) {
propertiesNode.put(PROPERTY_TIMER_CYCLE_END_DATE, timerDefinition.getEndDate());
}
} else if (eventDefinition instanceof TerminateEventDefinition) {
TerminateEventDefinition terminateEventDefinition = (TerminateEventDefinition) eventDefinition;
propertiesNode.put(PROPERTY_TERMINATE_ALL, terminateEventDefinition.isTerminateAll());
propertiesNode.put(PROPERTY_TERMINATE_MULTI_INSTANCE, terminateEventDefinition.isTerminateMultiInstance());
}
}
}
use of org.activiti.bpmn.model.TerminateEventDefinition in project Activiti by Activiti.
the class EndEventParseHandler method executeParse.
@Override
protected void executeParse(BpmnParse bpmnParse, EndEvent endEvent) {
EventDefinition eventDefinition = null;
if (endEvent.getEventDefinitions().size() > 0) {
eventDefinition = endEvent.getEventDefinitions().get(0);
if (eventDefinition instanceof ErrorEventDefinition) {
ErrorEventDefinition errorDefinition = (ErrorEventDefinition) eventDefinition;
if (bpmnParse.getBpmnModel().containsErrorRef(errorDefinition.getErrorRef())) {
for (Error error : bpmnParse.getBpmnModel().getErrors().values()) {
String errorCode = null;
if (error.getId().equals(errorDefinition.getErrorRef())) {
errorCode = error.getErrorCode();
}
if (StringUtils.isEmpty(errorCode)) {
logger.warn("errorCode is required for an error event " + endEvent.getId());
}
}
}
endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition));
} else if (eventDefinition instanceof TerminateEventDefinition) {
endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createTerminateEndEventActivityBehavior(endEvent));
} else if (eventDefinition instanceof CancelEventDefinition) {
endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createCancelEndEventActivityBehavior(endEvent));
} else if (eventDefinition instanceof MessageEventDefinition) {
MessageEventDefinition messageEventDefinition = MessageEventDefinition.class.cast(eventDefinition);
Message message = bpmnParse.getBpmnModel().getMessage(messageEventDefinition.getMessageRef());
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
if (bpmnModel.containsMessageId(messageEventDefinition.getMessageRef())) {
messageEventDefinition.setMessageRef(message.getName());
messageEventDefinition.setExtensionElements(message.getExtensionElements());
}
endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createThrowMessageEndEventActivityBehavior(endEvent, messageEventDefinition, message));
} else {
endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent));
}
} else {
endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent));
}
}
use of org.activiti.bpmn.model.TerminateEventDefinition in project Activiti by Activiti.
the class EndEventJsonConverter method getStencilId.
protected String getStencilId(BaseElement baseElement) {
EndEvent endEvent = (EndEvent) baseElement;
List<EventDefinition> eventDefinitions = endEvent.getEventDefinitions();
if (eventDefinitions.size() != 1) {
return STENCIL_EVENT_END_NONE;
}
EventDefinition eventDefinition = eventDefinitions.get(0);
if (eventDefinition instanceof ErrorEventDefinition) {
return STENCIL_EVENT_END_ERROR;
} else if (eventDefinition instanceof CancelEventDefinition) {
return STENCIL_EVENT_END_CANCEL;
} else if (eventDefinition instanceof TerminateEventDefinition) {
return STENCIL_EVENT_END_TERMINATE;
} else {
return STENCIL_EVENT_END_NONE;
}
}
Aggregations