protected void validate(Process process, Association association, List<ValidationError> errors) { if (StringUtils.isEmpty(association.getSourceRef())) { addError(errors, Problems.ASSOCIATION_INVALID_SOURCE_REFERENCE, process, association, "association element missing attribute 'sourceRef'"); } if (StringUtils.isEmpty(association.getTargetRef())) { addError(errors, Problems.ASSOCIATION_INVALID_TARGET_REFERENCE, process, association, "association element missing attribute 'targetRef'"); } }
@Override protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception { Association association = new Association(); BpmnXMLUtil.addXMLLocation(association, xtr); association.setSourceRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SOURCE_REF)); association.setTargetRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_TARGET_REF)); association.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); String asociationDirectionString = xtr.getAttributeValue(null, ATTRIBUTE_ASSOCIATION_DIRECTION); if (StringUtils.isNotEmpty(asociationDirectionString)) { AssociationDirection associationDirection = AssociationDirection.valueOf(asociationDirectionString.toUpperCase()); association.setAssociationDirection(associationDirection); } parseChildElements(getXMLElementName(), association, model, xtr); return association; }
@Override protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { Association association = (Association) element; writeDefaultAttribute(ATTRIBUTE_FLOW_SOURCE_REF, association.getSourceRef(), xtw); writeDefaultAttribute(ATTRIBUTE_FLOW_TARGET_REF, association.getTargetRef(), xtw); AssociationDirection associationDirection = association.getAssociationDirection(); if (associationDirection !=null) { writeDefaultAttribute(ATTRIBUTE_ASSOCIATION_DIRECTION, associationDirection.getValue(), xtw); } }
@Override protected BaseElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) { Association association = new Association(); String sourceRef = BpmnJsonConverterUtil.lookForSourceRef(elementNode.get(EDITOR_SHAPE_ID).asText(), modelNode.get(EDITOR_CHILD_SHAPES)); if (sourceRef != null) { association.setSourceRef(sourceRef); String targetId = elementNode.get("target").get(EDITOR_SHAPE_ID).asText(); association.setTargetRef(BpmnJsonConverterUtil.getElementId(shapeMap.get(targetId))); } return association; } }
protected void handleAssociations() { Hashtable<String, Object> edgeStyle = new Hashtable<String, Object>(); edgeStyle.put(mxConstants.STYLE_ORTHOGONAL, true); edgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.ElbowConnector); edgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.0); edgeStyle.put(mxConstants.STYLE_ENTRY_Y, 0.5); graph.getStylesheet().putCellStyle(STYLE_SEQUENCEFLOW, edgeStyle); Hashtable<String, Object> boundaryEdgeStyle = new Hashtable<String, Object>(); boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_X, 0.5); boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_Y, 1.0); boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.5); boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_Y, 1.0); boundaryEdgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.OrthConnector); graph.getStylesheet().putCellStyle(STYLE_BOUNDARY_SEQUENCEFLOW, boundaryEdgeStyle); for (Association association : associations.values()) { Object sourceVertex = generatedVertices.get(association.getSourceRef()); Object targetVertex = generatedVertices.get(association.getTargetRef()); String style = null; if (handledFlowElements.get(association.getSourceRef()) instanceof BoundaryEvent) { // Sequence flow out of boundary events are handled in a different way, // to make them visually appealing for the eye of the dear end user. style = STYLE_BOUNDARY_SEQUENCEFLOW; } else { style = STYLE_SEQUENCEFLOW; } Object associationEdge = graph.insertEdge(cellParent, association.getId(), "", sourceVertex, targetVertex, style); generatedAssociationEdges.put(association.getId(), associationEdge); } }
@Override protected BaseElement convertXMLToElement(XMLStreamReader xtr) throws Exception { Association association = new Association(); BpmnXMLUtil.addXMLLocation(association, xtr); association.setSourceRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SOURCE_REF)); association.setTargetRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_TARGET_REF)); association.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); if(StringUtils.isEmpty(association.getSourceRef())) { model.addProblem("association element missing attribute 'sourceRef'", xtr); } if(StringUtils.isEmpty(association.getTargetRef())) { model.addProblem("association element missing attribute 'targetRef'", xtr); } return association; }
if (artifact instanceof Association) { Association association = (Association) artifact; if (StringUtils.isNotEmpty(association.getSourceRef()) && association.getSourceRef().equals(baseElement.getId())) { outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(association.getId()));
List<Association> associations = process.findAssociationsWithSourceRefRecursive(boundaryEvent.getId()); for (Association association : associations) { FlowElement targetElement = process.getFlowElement(association.getTargetRef(), true); if (targetElement instanceof Activity) { Activity activity = (Activity) targetElement;
protected void handleAssociation(Association association) { ensureArtifactIdSet(association); associations.put(association.getId(), association); }
ObjectNode flowNode = BpmnJsonConverterUtil.createChildShape(association.getId(), STENCIL_ASSOCIATION, 172, 212, 128, 212); ArrayNode dockersArrayNode = objectMapper.createArrayNode(); ObjectNode dockNode = objectMapper.createObjectNode(); dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(association.getSourceRef()).getWidth() / 2.0); dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(association.getSourceRef()).getHeight() / 2.0); dockersArrayNode.add(dockNode); List<GraphicInfo> graphicInfoList = model.getFlowLocationGraphicInfo(association.getId()); if (graphicInfoList.size() > 2) { for (int i = 1; i < graphicInfoList.size() - 1; i++) { GraphicInfo targetGraphicInfo = model.getGraphicInfo(association.getTargetRef()); GraphicInfo flowGraphicInfo = graphicInfoList.get(graphicInfoList.size() - 1); flowNode.set("dockers", dockersArrayNode); ArrayNode outgoingArrayNode = objectMapper.createArrayNode(); outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(association.getTargetRef())); flowNode.set("outgoing", outgoingArrayNode); flowNode.set("target", BpmnJsonConverterUtil.createResourceNode(association.getTargetRef())); propertiesNode.put(PROPERTY_OVERRIDE_ID, association.getId());
if (artifact instanceof Association) { Association association = (Association) artifact; if (StringUtils.isNotEmpty(association.getSourceRef()) && association.getSourceRef().equals(baseElement.getId())) { outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(association.getId()));
@Override protected BaseElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) { Association association = new Association(); String sourceRef = BpmnJsonConverterUtil.lookForSourceRef(elementNode.get(EDITOR_SHAPE_ID).asText(), modelNode.get(EDITOR_CHILD_SHAPES)); if (sourceRef != null) { association.setSourceRef(sourceRef); String targetId = elementNode.get("target").get(EDITOR_SHAPE_ID).asText(); association.setTargetRef(BpmnJsonConverterUtil.getElementId(shapeMap.get(targetId))); } return association; } }
List<Association> associations = process.findAssociationsWithSourceRefRecursive(boundaryEvent.getId()); for (Association association : associations) { FlowElement targetElement = process.getFlowElement(association.getTargetRef(), true); if (targetElement instanceof Activity) { Activity activity = (Activity) targetElement;
protected void createAssociation(BpmnParse bpmnParse, Association association) { BpmnModel bpmnModel = bpmnParse.getBpmnModel(); if (bpmnModel.getArtifact(association.getSourceRef()) != null || bpmnModel.getArtifact(association.getTargetRef()) != null) {
Artifact artifact) { Association association = (Association) artifact; String sourceRef = association.getSourceRef(); String targetRef = association.getTargetRef(); AssociationDirection associationDirection = association.getAssociationDirection(); processDiagramCanvas.drawAssociation(xPoints, yPoints,
ObjectNode flowNode = BpmnJsonConverterUtil.createChildShape(association.getId(), STENCIL_ASSOCIATION, 172, 212, 128, 212); ArrayNode dockersArrayNode = objectMapper.createArrayNode(); ObjectNode dockNode = objectMapper.createObjectNode(); dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(association.getSourceRef()).getWidth() / 2.0); dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(association.getSourceRef()).getHeight() / 2.0); dockersArrayNode.add(dockNode); List<GraphicInfo> graphicInfoList = model.getFlowLocationGraphicInfo(association.getId()); if (graphicInfoList.size() > 2) { for (int i = 1; i < graphicInfoList.size() - 1; i++) { GraphicInfo targetGraphicInfo = model.getGraphicInfo(association.getTargetRef()); GraphicInfo flowGraphicInfo = graphicInfoList.get(graphicInfoList.size() - 1); flowNode.set("dockers", dockersArrayNode); ArrayNode outgoingArrayNode = objectMapper.createArrayNode(); outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(association.getTargetRef())); flowNode.set("outgoing", outgoingArrayNode); flowNode.set("target", BpmnJsonConverterUtil.createResourceNode(association.getTargetRef())); propertiesNode.put(PROPERTY_OVERRIDE_ID, association.getId());
@Override protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception { Association association = new Association(); BpmnXMLUtil.addXMLLocation(association, xtr); association.setSourceRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SOURCE_REF)); association.setTargetRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_TARGET_REF)); association.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); String asociationDirectionString = xtr.getAttributeValue(null, ATTRIBUTE_ASSOCIATION_DIRECTION); if (StringUtils.isNotEmpty(asociationDirectionString)) { AssociationDirection associationDirection = AssociationDirection.valueOf(asociationDirectionString.toUpperCase()); association.setAssociationDirection(associationDirection); } parseChildElements(getXMLElementName(), association, model, xtr); return association; }
protected void validate(Process process, Association association, List<ValidationError> errors) { if (StringUtils.isEmpty(association.getSourceRef())) { addError(errors, Problems.ASSOCIATION_INVALID_SOURCE_REFERENCE, process, association, "association element missing attribute 'sourceRef'"); } if (StringUtils.isEmpty(association.getTargetRef())) { addError(errors, Problems.ASSOCIATION_INVALID_TARGET_REFERENCE, process, association, "association element missing attribute 'targetRef'"); } }
@Override protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { Association association = (Association) element; writeDefaultAttribute(ATTRIBUTE_FLOW_SOURCE_REF, association.getSourceRef(), xtw); writeDefaultAttribute(ATTRIBUTE_FLOW_TARGET_REF, association.getTargetRef(), xtw); AssociationDirection associationDirection = association.getAssociationDirection(); if (associationDirection !=null) { writeDefaultAttribute(ATTRIBUTE_ASSOCIATION_DIRECTION, associationDirection.getValue(), xtw); } }
@Override protected void writeAdditionalAttributes(BaseElement element, XMLStreamWriter xtw) throws Exception { Association association = (Association) element; writeDefaultAttribute(ATTRIBUTE_FLOW_SOURCE_REF, association.getSourceRef(), xtw); writeDefaultAttribute(ATTRIBUTE_FLOW_TARGET_REF, association.getTargetRef(), xtw); }