Java Code Examples for org.flowable.bpmn.model.BpmnModel#addGraphicInfo()
The following examples show how to use
org.flowable.bpmn.model.BpmnModel#addGraphicInfo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseDynamicSubProcessInjectUtil.java From flowable-engine with Apache License 2.0 | 5 votes |
protected static void processSubProcessFlowElements(CommandContext commandContext, String prefix, Process process, BpmnModel bpmnModel, SubProcess subProcess, BpmnModel subProcessBpmnModel, ProcessDefinition originalProcessDefinition, DeploymentEntity newDeploymentEntity, Map<String, FlowElement> generatedIds, boolean includeDiInfo) { Collection<FlowElement> flowElementsOfSubProcess = subProcess.getFlowElementMap().values(); for (FlowElement flowElement : flowElementsOfSubProcess) { if (process.getFlowElement(flowElement.getId(), true) != null) { generateIdForDuplicateFlowElement(prefix, process, bpmnModel, subProcessBpmnModel, flowElement, generatedIds, includeDiInfo); } else { if (includeDiInfo) { if (flowElement instanceof SequenceFlow) { List<GraphicInfo> wayPoints = subProcessBpmnModel.getFlowLocationGraphicInfo(flowElement.getId()); if (wayPoints != null) { bpmnModel.addFlowGraphicInfoList(flowElement.getId(), wayPoints); } } else { GraphicInfo graphicInfo = subProcessBpmnModel.getGraphicInfo(flowElement.getId()); if (graphicInfo != null) { bpmnModel.addGraphicInfo(flowElement.getId(), subProcessBpmnModel.getGraphicInfo(flowElement.getId())); } } } } processUserTask(flowElement, originalProcessDefinition, newDeploymentEntity, commandContext); processDecisionTask(flowElement, originalProcessDefinition, newDeploymentEntity, commandContext); if (flowElement instanceof SubProcess) { processSubProcessFlowElements(commandContext, prefix, process, bpmnModel, (SubProcess) flowElement, subProcessBpmnModel, originalProcessDefinition, newDeploymentEntity, generatedIds, includeDiInfo); } } }
Example 2
Source File: BpmnShapeParser.java From flowable-engine with Apache License 2.0 | 5 votes |
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { String id = xtr.getAttributeValue(null, ATTRIBUTE_DI_BPMNELEMENT); GraphicInfo graphicInfo = new GraphicInfo(); String strIsExpanded = xtr.getAttributeValue(null, ATTRIBUTE_DI_IS_EXPANDED); if ("true".equalsIgnoreCase(strIsExpanded)) { graphicInfo.setExpanded(true); } else if ("false".equalsIgnoreCase(strIsExpanded)) { graphicInfo.setExpanded(false); } BpmnXMLUtil.addXMLLocation(graphicInfo, xtr); while (xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_DI_BOUNDS.equalsIgnoreCase(xtr.getLocalName())) { graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_X))); graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_Y))); graphicInfo.setWidth(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_WIDTH))); graphicInfo.setHeight(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_HEIGHT))); model.addGraphicInfo(id, graphicInfo); break; } else if (xtr.isEndElement() && ELEMENT_DI_SHAPE.equalsIgnoreCase(xtr.getLocalName())) { break; } } }
Example 3
Source File: BaseDynamicSubProcessInjectUtil.java From flowable-engine with Apache License 2.0 | 4 votes |
protected static void generateIdForDuplicateFlowElement(String prefix, org.flowable.bpmn.model.Process process, BpmnModel bpmnModel, BpmnModel subProcessBpmnModel, FlowElement duplicateFlowElement, Map<String, FlowElement> generatedIds, boolean includeDiInfo) { String originalFlowElementId = duplicateFlowElement.getId(); if (process.getFlowElement(originalFlowElementId, true) != null) { String newFlowElementId = prefix + "-" + originalFlowElementId; int counter = 0; boolean maxLengthReached = false; while (!maxLengthReached && process.getFlowElement(newFlowElementId, true) != null) { newFlowElementId = prefix + counter++ + "-" + originalFlowElementId; if (newFlowElementId.length() > 255) { maxLengthReached = true; } } if (maxLengthReached) { newFlowElementId = prefix + "-" + UUID.randomUUID().toString(); } duplicateFlowElement.setId(newFlowElementId); generatedIds.put(originalFlowElementId, duplicateFlowElement); if (includeDiInfo) { if (duplicateFlowElement instanceof SequenceFlow) { bpmnModel.addFlowGraphicInfoList(newFlowElementId, subProcessBpmnModel.getFlowLocationGraphicInfo(originalFlowElementId)); } else { bpmnModel.addGraphicInfo(newFlowElementId, subProcessBpmnModel.getGraphicInfo(originalFlowElementId)); } } for (FlowElement flowElement : duplicateFlowElement.getParentContainer().getFlowElements()) { if (flowElement instanceof SequenceFlow) { SequenceFlow sequenceFlow = (SequenceFlow) flowElement; if (sequenceFlow.getSourceRef().equals(originalFlowElementId)) { sequenceFlow.setSourceRef(newFlowElementId); } if (sequenceFlow.getTargetRef().equals(originalFlowElementId)) { sequenceFlow.setTargetRef(newFlowElementId); } } else if (flowElement instanceof BoundaryEvent) { BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement; if (boundaryEvent.getAttachedToRefId().equals(originalFlowElementId)) { boundaryEvent.setAttachedToRefId(newFlowElementId); } if (boundaryEvent.getEventDefinitions() != null && boundaryEvent.getEventDefinitions().size() > 0 && (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition)) { CompensateEventDefinition compensateEventDefinition = (CompensateEventDefinition) boundaryEvent.getEventDefinitions().get(0); if (compensateEventDefinition.getActivityRef().equals(originalFlowElementId)) { compensateEventDefinition.setActivityRef(newFlowElementId); } } } } } if (duplicateFlowElement instanceof FlowElementsContainer) { FlowElementsContainer flowElementsContainer = (FlowElementsContainer) duplicateFlowElement; for (FlowElement childFlowElement : flowElementsContainer.getFlowElements()) { generateIdForDuplicateFlowElement(prefix, process, bpmnModel, subProcessBpmnModel, childFlowElement, generatedIds, includeDiInfo); } } }
Example 4
Source File: BpmnJsonConverter.java From flowable-engine with Apache License 2.0 | 4 votes |
private void readShapeDI(JsonNode objectNode, double parentX, double parentY, Map<String, JsonNode> shapeMap, Map<String, JsonNode> sourceRefMap, BpmnModel bpmnModel) { if (objectNode.get(EDITOR_CHILD_SHAPES) != null) { for (JsonNode jsonChildNode : objectNode.get(EDITOR_CHILD_SHAPES)) { String stencilId = BpmnJsonConverterUtil.getStencilId(jsonChildNode); if (!STENCIL_SEQUENCE_FLOW.equals(stencilId) && !STENCIL_ASSOCIATION.equals(stencilId)) { GraphicInfo graphicInfo = new GraphicInfo(); JsonNode boundsNode = jsonChildNode.get(EDITOR_BOUNDS); ObjectNode upperLeftNode = (ObjectNode) boundsNode.get(EDITOR_BOUNDS_UPPER_LEFT); ObjectNode lowerRightNode = (ObjectNode) boundsNode.get(EDITOR_BOUNDS_LOWER_RIGHT); graphicInfo.setX(upperLeftNode.get(EDITOR_BOUNDS_X).asDouble() + parentX); graphicInfo.setY(upperLeftNode.get(EDITOR_BOUNDS_Y).asDouble() + parentY); graphicInfo.setWidth(lowerRightNode.get(EDITOR_BOUNDS_X).asDouble() - graphicInfo.getX() + parentX); graphicInfo.setHeight(lowerRightNode.get(EDITOR_BOUNDS_Y).asDouble() - graphicInfo.getY() + parentY); String childShapeId = jsonChildNode.get(EDITOR_SHAPE_ID).asText(); bpmnModel.addGraphicInfo(BpmnJsonConverterUtil.getElementId(jsonChildNode), graphicInfo); shapeMap.put(childShapeId, jsonChildNode); ArrayNode outgoingNode = (ArrayNode) jsonChildNode.get("outgoing"); if (outgoingNode != null && outgoingNode.size() > 0) { for (JsonNode outgoingChildNode : outgoingNode) { JsonNode resourceNode = outgoingChildNode.get(EDITOR_SHAPE_ID); if (resourceNode != null) { sourceRefMap.put(resourceNode.asText(), jsonChildNode); } } } //The graphic info of the collapsed subprocess is relative to its parent. //But the children of the collapsed subprocess are relative to the canvas upper corner. (always 0,0) if (STENCIL_COLLAPSED_SUB_PROCESS.equals(stencilId)) { readShapeDI(jsonChildNode, 0,0, shapeMap, sourceRefMap, bpmnModel); } else { readShapeDI(jsonChildNode, graphicInfo.getX(), graphicInfo.getY(), shapeMap, sourceRefMap, bpmnModel); } } } } }