public static List<GraphVertex> calculateImpact(BusinessServiceGraph graph, GraphVertex vertex) { if (vertex == null) { return Collections.emptyList(); } // Gather the list of parent vertices that are impacted by the current vertex final List<GraphVertex> impactedParentVertices = graph.getInEdges(vertex).stream() .filter(e -> calculateImpacting(graph, graph.getOpposite(vertex, e)).contains(e)) .map(e -> graph.getOpposite(vertex, e)) .sorted() .collect(Collectors.toList()); // Recurse final List<GraphVertex> impacts = Lists.newArrayList(impactedParentVertices); for (GraphVertex impactedParentVertex : impactedParentVertices) { impacts.addAll(calculateImpact(graph, impactedParentVertex)); } return impacts; }
private void addVertex(BusinessServiceGraph graph, GraphVertex graphVertex, AbstractBusinessServiceVertex topologyVertex) { if (topologyVertex == null) { // Create a topology vertex for the current vertex topologyVertex = createTopologyVertex(graphVertex); addVertices(topologyVertex); } for (GraphEdge graphEdge : graph.getOutEdges(graphVertex)) { GraphVertex childVertex = graph.getOpposite(graphVertex, graphEdge); // Create a topology vertex for the child vertex AbstractBusinessServiceVertex childTopologyVertex = createTopologyVertex(childVertex); graph.getInEdges(childVertex).stream() .map(GraphEdge::getFriendlyName) .filter(s -> !Strings.isNullOrEmpty(s)) .findFirst() .ifPresent(childTopologyVertex::setLabel); addVertices(childTopologyVertex); // Connect the two childTopologyVertex.setParent(topologyVertex); Edge edge = new BusinessServiceEdge(graphEdge, topologyVertex, childTopologyVertex); addEdges(edge); // Recurse addVertex(graph, childVertex, childTopologyVertex); } }
for (GraphEdge edge : graph.getInEdges(vertex)) { Status mappedStatus = newStatus; if (newStatus.isGreaterThan(MIN_SEVERITY)) {