use of org.opennms.features.topology.api.topo.Defaults in project opennms by OpenNMS.
the class BusinessServicesTopologyProvider method getDefaults.
@Override
public Defaults getDefaults() {
return new Defaults().withPreferredLayout("Hierarchy Layout").withCriteria(() -> {
// Grab the business service with the smallest id
List<BusinessService> businessServices = businessServiceManager.findMatching(new CriteriaBuilder(BusinessService.class).orderBy("id", true).limit(1).toCriteria());
// If one was found, use it for the default focus
if (!businessServices.isEmpty()) {
BusinessService businessService = businessServices.iterator().next();
BusinessServiceVertex businessServiceVertex = new BusinessServiceVertex(businessService, 0);
return Lists.newArrayList(new VertexHopGraphProvider.DefaultVertexHopCriteria(businessServiceVertex));
}
return null;
});
}
use of org.opennms.features.topology.api.topo.Defaults in project opennms by OpenNMS.
the class PathOutageProvider method getDefaults.
@Override
public Defaults getDefaults() {
// semantic zoom level 0 and the node with the worst state; or for the first node (if all nodes have state NORMAL)
return new Defaults().withSemanticZoomLevel(0).withPreferredLayout("Hierarchy Layout").withCriteria(() -> {
Map<VertexRef, Status> resultMap = statusProvider.getStatusForVertices(this, Lists.newArrayList(this.getVertices()), new Criteria[0]);
Optional<Map.Entry<VertexRef, Status>> max = resultMap.entrySet().stream().max(Comparator.comparing(e -> OnmsSeverity.get(e.getValue().computeStatus())));
if (max.isPresent()) {
return Lists.newArrayList(new VertexHopGraphProvider.DefaultVertexHopCriteria(max.get().getKey()));
} else if (this.getVertexTotalCount() > 0) {
return Lists.newArrayList(new VertexHopGraphProvider.DefaultVertexHopCriteria(this.getVertices().get(0)));
} else {
return Lists.newArrayList();
}
});
}
Aggregations