private static String getChildDescription(Edge edge) { return edge.accept(new EdgeVisitor<String>() { @Override public String visit(IpServiceEdge edge) { return describeIpService(edge.getIpService(), edge.getFriendlyName()); } @Override public String visit(ReductionKeyEdge edge) { return describeReductionKey(edge.getReductionKey(), edge.getFriendlyName()); } @Override public String visit(ChildEdge edge) { return describeBusinessService(edge.getChild()); } }); }
public GraphEdgeImpl(Edge edge) { this(edge.getMapFunction(), edge.getWeight(), edge.getFriendlyName()); }
public Edge getEdgeByReductionKey(String reductionKey) { return m_builder.m_businessServicesById.values().stream() .map(MockBusinessService::getEdges) .flatMap(Set::stream) .filter(e -> e.getReductionKeys().contains(reductionKey)) .findFirst().orElse(null); } }
public static String describeEdge(final Edge edge) { String edgePrefix = getEdgePrefix(edge); String itemDescription = getChildDescription(edge); return String.format("%s: %s, Map: %s, Weight: %s", edgePrefix, itemDescription, edge.getMapFunction().getClass()== SetTo.class ? String.format("%s (%s)", edge.getMapFunction().getClass().getSimpleName(), ((SetTo)edge.getMapFunction()).getStatus()) : edge.getMapFunction().getClass().getSimpleName(), edge.getWeight()); } }
edge.accept(new EdgeVisitor<Void>() { @Override public Void visit(IpServiceEdge edge) { m_mapFunctionSelect.setValue(edge.getMapFunction().getClass()); edge.getMapFunction().accept(new MapFunctionVisitor<Void>() { @Override public Void visit(Decrease decrease) { m_weightField.setValue(String.valueOf(edge.getWeight()));
for (final Edge edge : businessService.getEdges()) { final Vertex childVertex = businessServicesTopologyProvider.getVertex(edge.accept(new EdgeVisitor<VertexRef>() { @Override public VertexRef visit(final IpServiceEdge edge) { String.format("%s × %d <i class=\"pull-right glyphicon %s\"></i>", edgeStatus.getLabel(), edge.getWeight(), impactingVertices.contains(graph.getVertexByEdgeId(edge.getId())) ? "glyphicon-flash" : "")));
@Override public Void visit(SetTo setTo) { m_mapFunctionSeveritySelect.setValue(((SetTo) edge.getMapFunction()).getStatus()); return null; } });
@Override public Status getOperationalStatus(Edge edge) { m_rwLock.readLock().lock(); try { GraphVertex vertex = m_g.getVertexByEdgeId(edge.getId()); if (vertex != null) { return vertex.getStatus(); } return null; } finally { m_rwLock.readLock().unlock(); } }
if (m_edgesListSelect.getValue() != null) { removeEdgeButton.setEnabled(false); ((Edge) m_edgesListSelect.getValue()).delete(); refreshEdges();
edge.accept(new EdgeVisitor<Void>() { @Override public Void visit(IpServiceEdge edge) { m_mapFunctionSelect.setValue(edge.getMapFunction().getClass()); edge.getMapFunction().accept(new MapFunctionVisitor<Void>() { @Override public Void visit(Decrease decrease) { m_weightField.setValue(String.valueOf(edge.getWeight()));
public static String describeEdge(final Edge edge) { String edgePrefix = getEdgePrefix(edge); String itemDescription = getChildDescription(edge); return String.format("%s: %s, Map: %s, Weight: %s", edgePrefix, itemDescription, edge.getMapFunction().getClass()== SetTo.class ? String.format("%s (%s)", edge.getMapFunction().getClass().getSimpleName(), ((SetTo)edge.getMapFunction()).getStatus()) : edge.getMapFunction().getClass().getSimpleName(), edge.getWeight()); } }
@Override public Void visit(SetTo setTo) { m_mapFunctionSeveritySelect.setValue(((SetTo) edge.getMapFunction()).getStatus()); return null; } });
@Override public ThresholdResultExplanation explain(BusinessService businessService, Threshold threshold) { final GraphVertex vertex = getGraph().getVertexByBusinessServiceId(businessService.getId()); // Calculate the weighed statuses from the child edges List<StatusWithIndex> statusesWithIndices = weighEdges(getGraph().getOutEdges(vertex)); List<Status> statuses = statusesWithIndices.stream() .map(StatusWithIndex::getStatus) .collect(Collectors.toList()); // Reduce Status reducedStatus = threshold.reduce(statusesWithIndices) .orElse(new StatusWithIndices(MIN_SEVERITY, Collections.emptyList())) .getStatus(); ThresholdResultExplanation explanation = new ThresholdResultExplanation(); explanation.setStatus(reducedStatus); explanation.setHitsByStatus(threshold.getHitsByStatus(statuses)); explanation.setGraphEdges(getGraph().getOutEdges(vertex)); explanation.setWeightStatuses(statuses); explanation.setFunction(threshold); Map<GraphEdge, GraphVertex> graphEdgeToGraphVertex = new HashMap<>(); for (Edge eachEdge : businessService.getEdges()) { GraphVertex vertexForEdge = getGraph().getVertexByEdgeId(eachEdge.getId()); GraphEdge graphEdge = getGraph().getGraphEdgeByEdgeId(eachEdge.getId()); if (vertexForEdge != null && graphEdge != null) { graphEdgeToGraphVertex.put(graphEdge, vertexForEdge); } } explanation.setGraphEdgeToGraphVertexMapping(graphEdgeToGraphVertex); return explanation; }
if (m_edgesListSelect.getValue() != null) { removeEdgeButton.setEnabled(false); ((Edge) m_edgesListSelect.getValue()).delete(); refreshEdges();
private static String getEdgePrefix(Edge edge) { return edge.accept(new EdgeVisitor<String>() { @Override public String visit(IpServiceEdge edge) { return "IPSvc"; } @Override public String visit(ReductionKeyEdge edge) { return "ReKey"; } @Override public String visit(ChildEdge edge) { return "Child"; } }); }
private static String getEdgePrefix(Edge edge) { return edge.accept(new EdgeVisitor<String>() { @Override public String visit(IpServiceEdge edge) { return "IPSvc"; } @Override public String visit(ReductionKeyEdge edge) { return "ReKey"; } @Override public String visit(ChildEdge edge) { return "Child"; } @Override public String visit(ApplicationEdge edge) { return "Application"; } }); }
private GraphVertex getExistingVertex(Edge edge) { return edge.accept(new EdgeVisitor<GraphVertex>() { @Override public GraphVertex visit(IpServiceEdge edge) { return m_verticesByIpServiceId.get(edge.getIpService().getId()); } @Override public GraphVertex visit(ApplicationEdge edge) { return m_verticesByApplicationId.get(edge.getApplication().getId()); } @Override public GraphVertex visit(ReductionKeyEdge edge) { return m_verticesByReductionKey.get(edge.getReductionKey()); } @Override public GraphVertex visit(ChildEdge edge) { return m_verticesByBusinessServiceId.get(edge.getChild().getId()); } }); }
private static String getChildDescription(Edge edge) { return edge.accept(new EdgeVisitor<String>() { @Override public String visit(IpServiceEdge edge) { return describeIpService(edge.getIpService(), edge.getFriendlyName()); } @Override public String visit(ReductionKeyEdge edge) { return describeReductionKey(edge.getReductionKey(), edge.getFriendlyName()); } @Override public String visit(ChildEdge edge) { return describeBusinessService(edge.getChild()); } @Override public String visit(ApplicationEdge edge) { return describeApplication(edge.getApplication()); } }); }
private AbstractEdgeResponseDTO transform(Edge edge) { Objects.requireNonNull(edge); return edge.accept(new EdgeVisitor<AbstractEdgeResponseDTO>() { @Override public AbstractEdgeResponseDTO visit(IpServiceEdge edge) { return transform(edge); } @Override public AbstractEdgeResponseDTO visit(ReductionKeyEdge edge) { return transform(edge); } @Override public AbstractEdgeResponseDTO visit(ChildEdge edge) { return transform(edge); } @Override public AbstractEdgeResponseDTO visit(ApplicationEdge edge) { return transform(edge); } }); }