public Map<Status, Integer> getHitsByStatusWithIndex(List<StatusWithIndex> statuses) { return getHitsByStatus(statuses.stream() .map(StatusWithIndex::getStatus) .collect(Collectors.toList())); }
public Map<Status, Integer> getHitsByStatusWithIndex(List<StatusWithIndex> statuses) { return getHitsByStatus(statuses.stream() .map(StatusWithIndex::getStatus) .collect(Collectors.toList())); }
@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; }