use of org.activiti.bpmn.model.SignalEventDefinition in project Activiti by Activiti.
the class SignalEventDefinitionParser method parseChildElement.
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (parentElement instanceof Event == false)
return;
SignalEventDefinition eventDefinition = new SignalEventDefinition();
BpmnXMLUtil.addXMLLocation(eventDefinition, xtr);
eventDefinition.setSignalRef(xtr.getAttributeValue(null, ATTRIBUTE_SIGNAL_REF));
if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_ACTIVITY_ASYNCHRONOUS))) {
eventDefinition.setAsync(Boolean.parseBoolean(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_ACTIVITY_ASYNCHRONOUS)));
}
BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_SIGNALDEFINITION, eventDefinition, xtr, model);
((Event) parentElement).getEventDefinitions().add(eventDefinition);
}
use of org.activiti.bpmn.model.SignalEventDefinition 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);
}
}
}
}
use of org.activiti.bpmn.model.SignalEventDefinition in project Activiti by Activiti.
the class BpmnModelUtil method createSignalThrowEvent.
public static ThrowEvent createSignalThrowEvent(WorkflowDefinitionConversion conversion, Signal approvalFinishedSignal) {
SignalEventDefinition signalEventDefinition = new SignalEventDefinition();
signalEventDefinition.setSignalRef(approvalFinishedSignal.getId());
List<EventDefinition> signalEventDefinitions = new ArrayList<EventDefinition>();
signalEventDefinitions.add(signalEventDefinition);
ThrowEvent signalThrowEvent = new ThrowEvent();
signalThrowEvent.setId(conversion.getUniqueNumberedId(SIGNAL_THROWEVENT_PREFIX));
signalThrowEvent.setEventDefinitions(signalEventDefinitions);
return signalThrowEvent;
}
use of org.activiti.bpmn.model.SignalEventDefinition in project Activiti by Activiti.
the class FeedbackStepDefinitionConverter method createSignalThrow.
protected ThrowEvent createSignalThrow(WorkflowDefinitionConversion conversion, Signal signal) {
ThrowEvent signalThrowEvent = new ThrowEvent();
signalThrowEvent.setId(conversion.getUniqueNumberedId(ConversionConstants.EVENT_ID_PREFIX));
SignalEventDefinition signalThrowEventDefinition = new SignalEventDefinition();
signalThrowEventDefinition.setSignalRef(signal.getId());
signalThrowEvent.addEventDefinition(signalThrowEventDefinition);
addFlowElement(conversion, signalThrowEvent);
return signalThrowEvent;
}
use of org.activiti.bpmn.model.SignalEventDefinition in project Activiti by Activiti.
the class ThrowEventJsonConverter method getStencilId.
protected String getStencilId(BaseElement baseElement) {
ThrowEvent throwEvent = (ThrowEvent) baseElement;
List<EventDefinition> eventDefinitions = throwEvent.getEventDefinitions();
if (eventDefinitions.size() != 1) {
// return none event as default;
return STENCIL_EVENT_THROW_NONE;
}
EventDefinition eventDefinition = eventDefinitions.get(0);
if (eventDefinition instanceof SignalEventDefinition) {
return STENCIL_EVENT_THROW_SIGNAL;
} else {
return STENCIL_EVENT_THROW_NONE;
}
}
Aggregations