protected static void createCmmnShape(CmmnModel model, String elementId, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(CMMNDI_PREFIX, ELEMENT_DI_SHAPE, CMMNDI_NAMESPACE); String shapeId = "CMMNShape_" + elementId; xtw.writeAttribute(ATTRIBUTE_ID, shapeId); xtw.writeAttribute(ATTRIBUTE_DI_CMMN_ELEMENT_REF, elementId); GraphicInfo graphicInfo = model.getGraphicInfo(elementId); xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE); xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, String.valueOf(graphicInfo.getHeight())); xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, String.valueOf(graphicInfo.getWidth())); xtw.writeAttribute(ATTRIBUTE_DI_X, String.valueOf(graphicInfo.getX())); xtw.writeAttribute(ATTRIBUTE_DI_Y, String.valueOf(graphicInfo.getY())); xtw.writeEndElement(); // The xsd requires a CMMNLabel to be there, even though the spec text says it's optional xtw.writeStartElement(CMMNDI_PREFIX, ELEMENT_DI_LABEL, CMMNDI_NAMESPACE); xtw.writeEndElement(); xtw.writeEndElement(); }
@RequestMapping(value = "/rest/admin/case-definitions/{caseDefinitionId}/model-json", method = RequestMethod.GET, produces = "application/json") public JsonNode getCaseDefinitionModelJSON(@PathVariable String caseDefinitionId) { ServerConfig config = retrieveServerConfig(EndpointType.CMMN); ObjectNode displayNode = objectMapper.createObjectNode(); CmmnModel pojoModel = clientService.getCaseDefinitionModel(config, caseDefinitionId); if (!pojoModel.getLocationMap().isEmpty()) { try { GraphicInfo diagramInfo = new GraphicInfo(); processCaseElements(config, pojoModel, displayNode, diagramInfo); displayNode.put("diagramBeginX", diagramInfo.getX()); displayNode.put("diagramBeginY", diagramInfo.getY()); displayNode.put("diagramWidth", diagramInfo.getWidth()); displayNode.put("diagramHeight", diagramInfo.getHeight()); } catch (Exception e) { LOGGER.error("Error creating model JSON", e); } } return displayNode; }
protected void fillGraphicInfo(ObjectNode elementNode, GraphicInfo graphicInfo, boolean includeWidthAndHeight) { commonFillGraphicInfo(elementNode, graphicInfo.getX(), graphicInfo.getY(), graphicInfo.getWidth(), graphicInfo.getHeight(), includeWidthAndHeight); }
protected void fillGraphicInfo(ObjectNode elementNode, GraphicInfo graphicInfo, boolean includeWidthAndHeight) { commonFillGraphicInfo(elementNode, graphicInfo.getX(), graphicInfo.getY(), graphicInfo.getWidth(), graphicInfo.getHeight(), includeWidthAndHeight); }
protected void fillDiagramInfo(GraphicInfo graphicInfo, GraphicInfo diagramInfo) { double rightX = graphicInfo.getX() + graphicInfo.getWidth(); double bottomY = graphicInfo.getY() + graphicInfo.getHeight(); double middleX = graphicInfo.getX() + (graphicInfo.getWidth() / 2); if (middleX < diagramInfo.getX()) { diagramInfo.setX(middleX); } if (graphicInfo.getY() < diagramInfo.getY()) { diagramInfo.setY(graphicInfo.getY()); } if (rightX > diagramInfo.getWidth()) { diagramInfo.setWidth(rightX); } if (bottomY > diagramInfo.getHeight()) { diagramInfo.setHeight(bottomY); } } }
protected void fillDiagramInfo(GraphicInfo graphicInfo, GraphicInfo diagramInfo) { double rightX = graphicInfo.getX() + graphicInfo.getWidth(); double bottomY = graphicInfo.getY() + graphicInfo.getHeight(); double middleX = graphicInfo.getX() + (graphicInfo.getWidth() / 2); if (middleX < diagramInfo.getX()) { diagramInfo.setX(middleX); } if (graphicInfo.getY() < diagramInfo.getY()) { diagramInfo.setY(graphicInfo.getY()); } if (rightX > diagramInfo.getWidth()) { diagramInfo.setWidth(rightX); } if (bottomY > diagramInfo.getHeight()) { diagramInfo.setHeight(bottomY); } } }
displayNode.put("diagramWidth", diagramInfo.getWidth()); displayNode.put("diagramHeight", diagramInfo.getHeight()); return displayNode;
displayNode.put("diagramWidth", diagramInfo.getWidth()); displayNode.put("diagramHeight", diagramInfo.getHeight());