-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
Add mermaid graphs for information supply chain, soluton blueprints and solution roles
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* Copyright Contributors to the ODPi Egeria project. */ | ||
|
||
package org.odpi.openmetadata.commonservices.mermaid; | ||
|
||
/** | ||
* Colour helps to capture the colours we are using in the mermaid graphs. | ||
*/ | ||
public enum Colour | ||
{ | ||
BLACK ("#000000"), | ||
WHITE ("#FFFFFF"), | ||
CERISE ("#AA00FF"), | ||
EGERIA_BLUE ("#39add1"), | ||
DARK_BLUE ("#3079ab"), | ||
BLUE_SKY ("#A8C2FF"), | ||
PINKY ("#E1D5E7"), | ||
MAUVE ("#EFEFFF"), | ||
RED ("#e15258"), | ||
ORANGE ("#f9845b"), | ||
LAVENDER ("#838cc7"), | ||
PURPLE ("#7d669e"), | ||
TEAL ("#53bbb4"), | ||
GREEN ("#51b46d"), | ||
MUSTARD ("#e0ab18"), | ||
PINK ("#f092b0"), | ||
LIGHT_GRAY ("#b7c0c7"), | ||
DARK_GRAY ("#637a91"), | ||
SLATE ("#004563"), | ||
SAND ("#F9F7ED") | ||
; | ||
|
||
private final String colourNumber; | ||
|
||
|
||
/** | ||
* Construct each of the colours. | ||
* | ||
* @param colourNumber string | ||
*/ | ||
Colour(String colourNumber) | ||
{ | ||
this.colourNumber = colourNumber; | ||
} | ||
|
||
|
||
/** | ||
* Return the colour number. | ||
* | ||
* @return string | ||
*/ | ||
public String getColourNumber() | ||
{ | ||
return colourNumber; | ||
} | ||
|
||
|
||
/** | ||
* JSON-style toString | ||
* | ||
* @return return string containing the property names and values | ||
*/ | ||
@Override | ||
public String toString() | ||
{ | ||
return "Colour{" + | ||
"colourNumber='" + colourNumber + '\'' + | ||
"} "; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* Copyright Contributors to the ODPi Egeria project. */ | ||
|
||
package org.odpi.openmetadata.commonservices.mermaid; | ||
|
||
import org.odpi.openmetadata.frameworks.openmetadata.metadataelements.*; | ||
import org.odpi.openmetadata.frameworks.openmetadata.types.OpenMetadataType; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* Creates a mermaid graph rendering of the Open Metadata Framework's information supply chain graph. | ||
*/ | ||
public class InformationSupplyChainMermaidGraphBuilder extends MermaidGraphBuilderBase | ||
{ | ||
/** | ||
* Construct a mermaid markdown graph. | ||
* | ||
* @param informationSupplyChainElement content | ||
*/ | ||
public InformationSupplyChainMermaidGraphBuilder(InformationSupplyChainElement informationSupplyChainElement) | ||
{ | ||
mermaidGraph.append("---\n"); | ||
mermaidGraph.append("title: Information Supply Chain - "); | ||
mermaidGraph.append(informationSupplyChainElement.getProperties().getDisplayName()); | ||
mermaidGraph.append(" ["); | ||
mermaidGraph.append(informationSupplyChainElement.getElementHeader().getGUID()); | ||
mermaidGraph.append("]\n---\nflowchart TD\n%%{init: {\"flowchart\": {\"htmlLabels\": false}} }%%\n\n"); | ||
|
||
String currentNodeName = informationSupplyChainElement.getElementHeader().getGUID(); | ||
String currentDisplayName = informationSupplyChainElement.getProperties().getDisplayName(); | ||
|
||
appendNewMermaidNode(currentNodeName, | ||
currentDisplayName, | ||
informationSupplyChainElement.getElementHeader().getType().getTypeName(), | ||
VisualStyle.INFORMATION_SUPPLY_CHAIN); | ||
|
||
if (informationSupplyChainElement.getSegments() != null) | ||
{ | ||
for (InformationSupplyChainSegmentElement node : informationSupplyChainElement.getSegments()) | ||
{ | ||
if (node != null) | ||
{ | ||
currentNodeName = node.getElementHeader().getGUID(); | ||
currentDisplayName = node.getProperties().getDisplayName(); | ||
if (currentDisplayName == null) | ||
{ | ||
currentDisplayName = node.getProperties().getQualifiedName(); | ||
} | ||
|
||
appendNewMermaidNode(currentNodeName, | ||
currentDisplayName, | ||
node.getElementHeader().getType().getTypeName(), | ||
VisualStyle.INFORMATION_SUPPLY_CHAIN_SEG); | ||
|
||
if (node.getLinks() != null) | ||
{ | ||
for (InformationSupplyChainLink link : node.getLinks()) | ||
{ | ||
if (link != null) | ||
{ | ||
super.appendMermaidLine(link.getEnd1Element().getGUID(), | ||
this.getListLabel(Collections.singletonList(super.addSpacesToTypeName(link.getElementHeader().getType().getTypeName()))), | ||
link.getEnd2Element().getGUID()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
List<String> solutionLinkingWireGUIDs = new ArrayList<>(); | ||
|
||
for (InformationSupplyChainSegmentElement node : informationSupplyChainElement.getSegments()) | ||
{ | ||
if (node != null) | ||
{ | ||
if (node.getImplementedByList() != null) | ||
{ | ||
for (ImplementedByRelationship implementedByRelationship : node.getImplementedByList()) | ||
{ | ||
if (implementedByRelationship != null) | ||
{ | ||
appendNewMermaidNode(implementedByRelationship.getEnd1Element().getGUID(), | ||
implementedByRelationship.getEnd1Element().getUniqueName(), | ||
implementedByRelationship.getEnd1Element().getType().getTypeName(), | ||
VisualStyle.SOLUTION_COMPONENT); | ||
|
||
appendNewMermaidNode(implementedByRelationship.getEnd2Element().getGUID(), | ||
implementedByRelationship.getEnd2Element().getUniqueName(), | ||
implementedByRelationship.getEnd2Element().getType().getTypeName(), | ||
VisualStyle.SOLUTION_COMPONENT); | ||
} | ||
} | ||
} | ||
|
||
if (node.getSolutionLinkingWires() != null) | ||
{ | ||
for (SolutionLinkingWireRelationship relationship : node.getSolutionLinkingWires()) | ||
{ | ||
if (relationship != null) | ||
{ | ||
appendNewMermaidNode(relationship.getEnd1Element().getGUID(), | ||
relationship.getEnd1Element().getUniqueName(), | ||
relationship.getEnd1Element().getType().getTypeName(), | ||
VisualStyle.SOLUTION_COMPONENT); | ||
|
||
appendNewMermaidNode(relationship.getEnd2Element().getGUID(), | ||
relationship.getEnd2Element().getUniqueName(), | ||
relationship.getEnd2Element().getType().getTypeName(), | ||
VisualStyle.SOLUTION_COMPONENT); | ||
|
||
if (! solutionLinkingWireGUIDs.contains(relationship.getElementHeader().getGUID())) | ||
{ | ||
super.appendMermaidLine(relationship.getEnd1Element().getGUID(), | ||
this.getListLabel(Collections.singletonList(super.addSpacesToTypeName(relationship.getElementHeader().getType().getTypeName()))), | ||
relationship.getEnd2Element().getGUID()); | ||
|
||
solutionLinkingWireGUIDs.add(relationship.getElementHeader().getGUID()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |