use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BpmnJsonConverter method convertToBpmnModel.
public BpmnModel convertToBpmnModel(JsonNode modelNode, Map<String, String> formKeyMap, Map<String, String> decisionTableKeyMap) {
BpmnModel bpmnModel = new BpmnModel();
bpmnModel.setTargetNamespace("http://activiti.org/test");
Map<String, JsonNode> shapeMap = new HashMap<String, JsonNode>();
Map<String, JsonNode> sourceRefMap = new HashMap<String, JsonNode>();
Map<String, JsonNode> edgeMap = new HashMap<String, JsonNode>();
Map<String, List<JsonNode>> sourceAndTargetMap = new HashMap<String, List<JsonNode>>();
readShapeDI(modelNode, 0, 0, shapeMap, sourceRefMap, bpmnModel);
filterAllEdges(modelNode, edgeMap, sourceAndTargetMap, shapeMap, sourceRefMap);
readEdgeDI(edgeMap, sourceAndTargetMap, bpmnModel);
ArrayNode shapesArrayNode = (ArrayNode) modelNode.get(EDITOR_CHILD_SHAPES);
if (shapesArrayNode == null || shapesArrayNode.size() == 0) {
return bpmnModel;
}
boolean nonEmptyPoolFound = false;
Map<String, Lane> elementInLaneMap = new HashMap<String, Lane>();
// first create the pool structure
for (JsonNode shapeNode : shapesArrayNode) {
String stencilId = BpmnJsonConverterUtil.getStencilId(shapeNode);
if (STENCIL_POOL.equals(stencilId)) {
Pool pool = new Pool();
pool.setId(BpmnJsonConverterUtil.getElementId(shapeNode));
pool.setName(JsonConverterUtil.getPropertyValueAsString(PROPERTY_NAME, shapeNode));
pool.setProcessRef(JsonConverterUtil.getPropertyValueAsString(PROPERTY_PROCESS_ID, shapeNode));
pool.setExecutable(JsonConverterUtil.getPropertyValueAsBoolean(PROPERTY_PROCESS_EXECUTABLE, shapeNode, true));
bpmnModel.getPools().add(pool);
Process process = new Process();
process.setId(pool.getProcessRef());
process.setName(pool.getName());
process.setExecutable(pool.isExecutable());
bpmnModel.addProcess(process);
ArrayNode laneArrayNode = (ArrayNode) shapeNode.get(EDITOR_CHILD_SHAPES);
for (JsonNode laneNode : laneArrayNode) {
// should be a lane, but just check to be certain
String laneStencilId = BpmnJsonConverterUtil.getStencilId(laneNode);
if (STENCIL_LANE.equals(laneStencilId)) {
nonEmptyPoolFound = true;
Lane lane = new Lane();
lane.setId(BpmnJsonConverterUtil.getElementId(laneNode));
lane.setName(JsonConverterUtil.getPropertyValueAsString(PROPERTY_NAME, laneNode));
lane.setParentProcess(process);
process.getLanes().add(lane);
processJsonElements(laneNode.get(EDITOR_CHILD_SHAPES), modelNode, lane, shapeMap, formKeyMap, decisionTableKeyMap, bpmnModel);
if (CollectionUtils.isNotEmpty(lane.getFlowReferences())) {
for (String elementRef : lane.getFlowReferences()) {
elementInLaneMap.put(elementRef, lane);
}
}
}
}
}
}
// Signal Definitions exist on the root level
JsonNode signalDefinitionNode = BpmnJsonConverterUtil.getProperty(PROPERTY_SIGNAL_DEFINITIONS, modelNode);
signalDefinitionNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(signalDefinitionNode);
// no idea why this needs to be done twice ..
signalDefinitionNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(signalDefinitionNode);
if (signalDefinitionNode != null) {
if (signalDefinitionNode instanceof ArrayNode) {
ArrayNode signalDefinitionArrayNode = (ArrayNode) signalDefinitionNode;
Iterator<JsonNode> signalDefinitionIterator = signalDefinitionArrayNode.iterator();
while (signalDefinitionIterator.hasNext()) {
JsonNode signalDefinitionJsonNode = signalDefinitionIterator.next();
String signalId = signalDefinitionJsonNode.get(PROPERTY_SIGNAL_DEFINITION_ID).asText();
String signalName = signalDefinitionJsonNode.get(PROPERTY_SIGNAL_DEFINITION_NAME).asText();
String signalScope = signalDefinitionJsonNode.get(PROPERTY_SIGNAL_DEFINITION_SCOPE).asText();
if (StringUtils.isNotEmpty(signalId) && StringUtils.isNotEmpty(signalName)) {
Signal signal = new Signal();
signal.setId(signalId);
signal.setName(signalName);
signal.setScope((signalScope.toLowerCase().equals("processinstance")) ? Signal.SCOPE_PROCESS_INSTANCE : Signal.SCOPE_GLOBAL);
bpmnModel.addSignal(signal);
}
}
}
}
if (!nonEmptyPoolFound) {
Process process = new Process();
bpmnModel.getProcesses().add(process);
process.setId(BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_PROCESS_ID, modelNode));
process.setName(BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_NAME, modelNode));
String namespace = BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_PROCESS_NAMESPACE, modelNode);
if (StringUtils.isNotEmpty(namespace)) {
bpmnModel.setTargetNamespace(namespace);
}
process.setDocumentation(BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_DOCUMENTATION, modelNode));
JsonNode processExecutableNode = JsonConverterUtil.getProperty(PROPERTY_PROCESS_EXECUTABLE, modelNode);
if (processExecutableNode != null && StringUtils.isNotEmpty(processExecutableNode.asText())) {
process.setExecutable(JsonConverterUtil.getPropertyValueAsBoolean(PROPERTY_PROCESS_EXECUTABLE, modelNode));
}
BpmnJsonConverterUtil.convertJsonToMessages(modelNode, bpmnModel);
BpmnJsonConverterUtil.convertJsonToListeners(modelNode, process);
JsonNode eventListenersNode = BpmnJsonConverterUtil.getProperty(PROPERTY_EVENT_LISTENERS, modelNode);
if (eventListenersNode != null) {
eventListenersNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(eventListenersNode);
BpmnJsonConverterUtil.parseEventListeners(eventListenersNode.get(PROPERTY_EVENTLISTENER_VALUE), process);
}
JsonNode processDataPropertiesNode = modelNode.get(EDITOR_SHAPE_PROPERTIES).get(PROPERTY_DATA_PROPERTIES);
if (processDataPropertiesNode != null) {
List<ValuedDataObject> dataObjects = BpmnJsonConverterUtil.convertJsonToDataProperties(processDataPropertiesNode, process);
process.setDataObjects(dataObjects);
process.getFlowElements().addAll(dataObjects);
}
processJsonElements(shapesArrayNode, modelNode, process, shapeMap, formKeyMap, decisionTableKeyMap, bpmnModel);
} else {
// sequence flows are on root level so need additional parsing for pools
for (JsonNode shapeNode : shapesArrayNode) {
if (STENCIL_SEQUENCE_FLOW.equalsIgnoreCase(BpmnJsonConverterUtil.getStencilId(shapeNode)) || STENCIL_ASSOCIATION.equalsIgnoreCase(BpmnJsonConverterUtil.getStencilId(shapeNode))) {
String sourceRef = BpmnJsonConverterUtil.lookForSourceRef(shapeNode.get(EDITOR_SHAPE_ID).asText(), modelNode.get(EDITOR_CHILD_SHAPES));
if (sourceRef != null) {
Lane lane = elementInLaneMap.get(sourceRef);
SequenceFlowJsonConverter flowConverter = new SequenceFlowJsonConverter();
if (lane != null) {
flowConverter.convertToBpmnModel(shapeNode, modelNode, this, lane, shapeMap, bpmnModel);
} else {
flowConverter.convertToBpmnModel(shapeNode, modelNode, this, bpmnModel.getProcesses().get(0), shapeMap, bpmnModel);
}
}
}
}
}
// sequence flows are now all on root level
Map<String, SubProcess> subShapesMap = new HashMap<String, SubProcess>();
for (Process process : bpmnModel.getProcesses()) {
for (FlowElement flowElement : process.findFlowElementsOfType(SubProcess.class)) {
SubProcess subProcess = (SubProcess) flowElement;
fillSubShapes(subShapesMap, subProcess);
}
if (subShapesMap.size() > 0) {
List<String> removeSubFlowsList = new ArrayList<String>();
for (FlowElement flowElement : process.findFlowElementsOfType(SequenceFlow.class)) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
if (subShapesMap.containsKey(sequenceFlow.getSourceRef())) {
SubProcess subProcess = subShapesMap.get(sequenceFlow.getSourceRef());
if (subProcess.getFlowElement(sequenceFlow.getId()) == null) {
subProcess.addFlowElement(sequenceFlow);
removeSubFlowsList.add(sequenceFlow.getId());
}
}
}
for (String flowId : removeSubFlowsList) {
process.removeFlowElement(flowId);
}
}
}
Map<String, FlowWithContainer> allFlowMap = new HashMap<String, FlowWithContainer>();
List<Gateway> gatewayWithOrderList = new ArrayList<Gateway>();
// post handling of process elements
for (Process process : bpmnModel.getProcesses()) {
postProcessElements(process, process.getFlowElements(), edgeMap, bpmnModel, allFlowMap, gatewayWithOrderList);
}
// sort the sequence flows
for (Gateway gateway : gatewayWithOrderList) {
List<ExtensionElement> orderList = gateway.getExtensionElements().get("EDITOR_FLOW_ORDER");
if (CollectionUtils.isNotEmpty(orderList)) {
for (ExtensionElement orderElement : orderList) {
String flowValue = orderElement.getElementText();
if (StringUtils.isNotEmpty(flowValue)) {
if (allFlowMap.containsKey(flowValue)) {
FlowWithContainer flowWithContainer = allFlowMap.get(flowValue);
flowWithContainer.getFlowContainer().removeFlowElement(flowWithContainer.getSequenceFlow().getId());
flowWithContainer.getFlowContainer().addFlowElement(flowWithContainer.getSequenceFlow());
}
}
}
}
gateway.getExtensionElements().remove("EDITOR_FLOW_ORDER");
}
return bpmnModel;
}
use of org.activiti.bpmn.model.SequenceFlow 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.SequenceFlow in project Activiti by Activiti.
the class SequenceFlowJsonConverter method convertToJson.
@Override
public void convertToJson(BaseElement baseElement, ActivityProcessor processor, BpmnModel model, FlowElementsContainer container, ArrayNode shapesArrayNode, double subProcessX, double subProcessY) {
SequenceFlow sequenceFlow = (SequenceFlow) baseElement;
ObjectNode flowNode = BpmnJsonConverterUtil.createChildShape(sequenceFlow.getId(), STENCIL_SEQUENCE_FLOW, 172, 212, 128, 212);
ArrayNode dockersArrayNode = objectMapper.createArrayNode();
ObjectNode dockNode = objectMapper.createObjectNode();
dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(sequenceFlow.getSourceRef()).getWidth() / 2.0);
dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(sequenceFlow.getSourceRef()).getHeight() / 2.0);
dockersArrayNode.add(dockNode);
if (model.getFlowLocationGraphicInfo(sequenceFlow.getId()).size() > 2) {
for (int i = 1; i < model.getFlowLocationGraphicInfo(sequenceFlow.getId()).size() - 1; i++) {
GraphicInfo graphicInfo = model.getFlowLocationGraphicInfo(sequenceFlow.getId()).get(i);
dockNode = objectMapper.createObjectNode();
dockNode.put(EDITOR_BOUNDS_X, graphicInfo.getX());
dockNode.put(EDITOR_BOUNDS_Y, graphicInfo.getY());
dockersArrayNode.add(dockNode);
}
}
dockNode = objectMapper.createObjectNode();
dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(sequenceFlow.getTargetRef()).getWidth() / 2.0);
dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(sequenceFlow.getTargetRef()).getHeight() / 2.0);
dockersArrayNode.add(dockNode);
flowNode.set("dockers", dockersArrayNode);
ArrayNode outgoingArrayNode = objectMapper.createArrayNode();
outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getTargetRef()));
flowNode.set("outgoing", outgoingArrayNode);
flowNode.set("target", BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getTargetRef()));
ObjectNode propertiesNode = objectMapper.createObjectNode();
propertiesNode.put(PROPERTY_OVERRIDE_ID, sequenceFlow.getId());
if (StringUtils.isNotEmpty(sequenceFlow.getName())) {
propertiesNode.put(PROPERTY_NAME, sequenceFlow.getName());
}
if (StringUtils.isNotEmpty(sequenceFlow.getDocumentation())) {
propertiesNode.put(PROPERTY_DOCUMENTATION, sequenceFlow.getDocumentation());
}
if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) {
propertiesNode.put(PROPERTY_SEQUENCEFLOW_CONDITION, sequenceFlow.getConditionExpression());
}
if (StringUtils.isNotEmpty(sequenceFlow.getSourceRef())) {
FlowElement sourceFlowElement = container.getFlowElement(sequenceFlow.getSourceRef());
if (sourceFlowElement != null) {
String defaultFlowId = null;
if (sourceFlowElement instanceof ExclusiveGateway) {
ExclusiveGateway parentExclusiveGateway = (ExclusiveGateway) sourceFlowElement;
defaultFlowId = parentExclusiveGateway.getDefaultFlow();
} else if (sourceFlowElement instanceof Activity) {
Activity parentActivity = (Activity) sourceFlowElement;
defaultFlowId = parentActivity.getDefaultFlow();
}
if (defaultFlowId != null && defaultFlowId.equals(sequenceFlow.getId())) {
propertiesNode.put(PROPERTY_SEQUENCEFLOW_DEFAULT, true);
}
}
}
if (sequenceFlow.getExecutionListeners().size() > 0) {
BpmnJsonConverterUtil.convertListenersToJson(sequenceFlow.getExecutionListeners(), true, propertiesNode);
}
flowNode.set(EDITOR_SHAPE_PROPERTIES, propertiesNode);
shapesArrayNode.add(flowNode);
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BaseBpmnJsonConverter method convertToJson.
public void convertToJson(BaseElement baseElement, ActivityProcessor processor, BpmnModel model, FlowElementsContainer container, ArrayNode shapesArrayNode, double subProcessX, double subProcessY) {
this.model = model;
this.processor = processor;
this.subProcessX = subProcessX;
this.subProcessY = subProcessY;
this.shapesArrayNode = shapesArrayNode;
GraphicInfo graphicInfo = model.getGraphicInfo(baseElement.getId());
String stencilId = null;
if (baseElement instanceof ServiceTask) {
ServiceTask serviceTask = (ServiceTask) baseElement;
if ("mail".equalsIgnoreCase(serviceTask.getType())) {
stencilId = STENCIL_TASK_MAIL;
} else if ("camel".equalsIgnoreCase(serviceTask.getType())) {
stencilId = STENCIL_TASK_CAMEL;
} else if ("mule".equalsIgnoreCase(serviceTask.getType())) {
stencilId = STENCIL_TASK_MULE;
} else if ("dmn".equalsIgnoreCase(serviceTask.getType())) {
stencilId = STENCIL_TASK_DECISION;
} else {
stencilId = getStencilId(baseElement);
}
} else {
stencilId = getStencilId(baseElement);
}
flowElementNode = BpmnJsonConverterUtil.createChildShape(baseElement.getId(), stencilId, graphicInfo.getX() - subProcessX + graphicInfo.getWidth(), graphicInfo.getY() - subProcessY + graphicInfo.getHeight(), graphicInfo.getX() - subProcessX, graphicInfo.getY() - subProcessY);
shapesArrayNode.add(flowElementNode);
ObjectNode propertiesNode = objectMapper.createObjectNode();
propertiesNode.put(PROPERTY_OVERRIDE_ID, baseElement.getId());
if (baseElement instanceof FlowElement) {
FlowElement flowElement = (FlowElement) baseElement;
if (StringUtils.isNotEmpty(flowElement.getName())) {
propertiesNode.put(PROPERTY_NAME, flowElement.getName());
}
if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {
propertiesNode.put(PROPERTY_DOCUMENTATION, flowElement.getDocumentation());
}
}
convertElementToJson(propertiesNode, baseElement);
flowElementNode.set(EDITOR_SHAPE_PROPERTIES, propertiesNode);
ArrayNode outgoingArrayNode = objectMapper.createArrayNode();
if (baseElement instanceof FlowNode) {
FlowNode flowNode = (FlowNode) baseElement;
for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getId()));
}
for (MessageFlow messageFlow : model.getMessageFlows().values()) {
if (messageFlow.getSourceRef().equals(flowNode.getId())) {
outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(messageFlow.getId()));
}
}
}
if (baseElement instanceof Activity) {
Activity activity = (Activity) baseElement;
for (BoundaryEvent boundaryEvent : activity.getBoundaryEvents()) {
outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(boundaryEvent.getId()));
}
propertiesNode.put(PROPERTY_ASYNCHRONOUS, activity.isAsynchronous());
propertiesNode.put(PROPERTY_EXCLUSIVE, !activity.isNotExclusive());
if (activity.getLoopCharacteristics() != null) {
MultiInstanceLoopCharacteristics loopDef = activity.getLoopCharacteristics();
if (StringUtils.isNotEmpty(loopDef.getLoopCardinality()) || StringUtils.isNotEmpty(loopDef.getInputDataItem()) || StringUtils.isNotEmpty(loopDef.getCompletionCondition())) {
if (!loopDef.isSequential()) {
propertiesNode.put(PROPERTY_MULTIINSTANCE_TYPE, "Parallel");
} else {
propertiesNode.put(PROPERTY_MULTIINSTANCE_TYPE, "Sequential");
}
if (StringUtils.isNotEmpty(loopDef.getLoopCardinality())) {
propertiesNode.put(PROPERTY_MULTIINSTANCE_CARDINALITY, loopDef.getLoopCardinality());
}
if (StringUtils.isNotEmpty(loopDef.getInputDataItem())) {
propertiesNode.put(PROPERTY_MULTIINSTANCE_COLLECTION, loopDef.getInputDataItem());
}
if (StringUtils.isNotEmpty(loopDef.getElementVariable())) {
propertiesNode.put(PROPERTY_MULTIINSTANCE_VARIABLE, loopDef.getElementVariable());
}
if (StringUtils.isNotEmpty(loopDef.getCompletionCondition())) {
propertiesNode.put(PROPERTY_MULTIINSTANCE_CONDITION, loopDef.getCompletionCondition());
}
}
}
if (activity instanceof UserTask) {
BpmnJsonConverterUtil.convertListenersToJson(((UserTask) activity).getTaskListeners(), false, propertiesNode);
}
if (CollectionUtils.isNotEmpty(activity.getDataInputAssociations())) {
for (DataAssociation dataAssociation : activity.getDataInputAssociations()) {
if (model.getFlowElement(dataAssociation.getSourceRef()) != null) {
createDataAssociation(dataAssociation, true, activity);
}
}
}
if (CollectionUtils.isNotEmpty(activity.getDataOutputAssociations())) {
for (DataAssociation dataAssociation : activity.getDataOutputAssociations()) {
if (model.getFlowElement(dataAssociation.getTargetRef()) != null) {
createDataAssociation(dataAssociation, false, activity);
outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(dataAssociation.getId()));
}
}
}
}
if (baseElement instanceof FlowElement) {
BpmnJsonConverterUtil.convertListenersToJson(((FlowElement) baseElement).getExecutionListeners(), true, propertiesNode);
}
for (Artifact artifact : container.getArtifacts()) {
if (artifact instanceof Association) {
Association association = (Association) artifact;
if (StringUtils.isNotEmpty(association.getSourceRef()) && association.getSourceRef().equals(baseElement.getId())) {
outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(association.getId()));
}
}
}
if (baseElement instanceof DataStoreReference) {
for (Process process : model.getProcesses()) {
processDataStoreReferences(process, baseElement.getId(), outgoingArrayNode);
}
}
flowElementNode.set("outgoing", outgoingArrayNode);
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BaseBpmnJsonConverter method convertToBpmnModel.
public void convertToBpmnModel(JsonNode elementNode, JsonNode modelNode, ActivityProcessor processor, BaseElement parentElement, Map<String, JsonNode> shapeMap, BpmnModel bpmnModel) {
this.processor = processor;
this.model = bpmnModel;
BaseElement baseElement = convertJsonToElement(elementNode, modelNode, shapeMap);
baseElement.setId(BpmnJsonConverterUtil.getElementId(elementNode));
if (baseElement instanceof FlowElement) {
FlowElement flowElement = (FlowElement) baseElement;
flowElement.setName(getPropertyValueAsString(PROPERTY_NAME, elementNode));
flowElement.setDocumentation(getPropertyValueAsString(PROPERTY_DOCUMENTATION, elementNode));
BpmnJsonConverterUtil.convertJsonToListeners(elementNode, flowElement);
if (baseElement instanceof Activity) {
Activity activity = (Activity) baseElement;
activity.setAsynchronous(getPropertyValueAsBoolean(PROPERTY_ASYNCHRONOUS, elementNode));
activity.setNotExclusive(!getPropertyValueAsBoolean(PROPERTY_EXCLUSIVE, elementNode));
String multiInstanceType = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_TYPE, elementNode);
String multiInstanceCardinality = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_CARDINALITY, elementNode);
String multiInstanceCollection = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_COLLECTION, elementNode);
String multiInstanceCondition = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_CONDITION, elementNode);
if (StringUtils.isNotEmpty(multiInstanceType) && !"none".equalsIgnoreCase(multiInstanceType)) {
String multiInstanceVariable = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_VARIABLE, elementNode);
MultiInstanceLoopCharacteristics multiInstanceObject = new MultiInstanceLoopCharacteristics();
if ("sequential".equalsIgnoreCase(multiInstanceType)) {
multiInstanceObject.setSequential(true);
} else {
multiInstanceObject.setSequential(false);
}
multiInstanceObject.setLoopCardinality(multiInstanceCardinality);
multiInstanceObject.setInputDataItem(multiInstanceCollection);
multiInstanceObject.setElementVariable(multiInstanceVariable);
multiInstanceObject.setCompletionCondition(multiInstanceCondition);
activity.setLoopCharacteristics(multiInstanceObject);
}
} else if (baseElement instanceof Gateway) {
JsonNode flowOrderNode = getProperty(PROPERTY_SEQUENCEFLOW_ORDER, elementNode);
if (flowOrderNode != null) {
flowOrderNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(flowOrderNode);
JsonNode orderArray = flowOrderNode.get("sequenceFlowOrder");
if (orderArray != null && orderArray.size() > 0) {
for (JsonNode orderNode : orderArray) {
ExtensionElement orderElement = new ExtensionElement();
orderElement.setName("EDITOR_FLOW_ORDER");
orderElement.setElementText(orderNode.asText());
flowElement.addExtensionElement(orderElement);
}
}
}
}
}
if (baseElement instanceof FlowElement) {
FlowElement flowElement = (FlowElement) baseElement;
if (flowElement instanceof SequenceFlow) {
ExtensionElement idExtensionElement = new ExtensionElement();
idExtensionElement.setName("EDITOR_RESOURCEID");
idExtensionElement.setElementText(elementNode.get(EDITOR_SHAPE_ID).asText());
flowElement.addExtensionElement(idExtensionElement);
}
if (parentElement instanceof Process) {
((Process) parentElement).addFlowElement(flowElement);
} else if (parentElement instanceof SubProcess) {
((SubProcess) parentElement).addFlowElement(flowElement);
} else if (parentElement instanceof Lane) {
Lane lane = (Lane) parentElement;
lane.getFlowReferences().add(flowElement.getId());
lane.getParentProcess().addFlowElement(flowElement);
}
} else if (baseElement instanceof Artifact) {
Artifact artifact = (Artifact) baseElement;
if (parentElement instanceof Process) {
((Process) parentElement).addArtifact(artifact);
} else if (parentElement instanceof SubProcess) {
((SubProcess) parentElement).addArtifact(artifact);
} else if (parentElement instanceof Lane) {
Lane lane = (Lane) parentElement;
lane.getFlowReferences().add(artifact.getId());
lane.getParentProcess().addArtifact(artifact);
}
}
}
Aggregations