Search in sources :

Example 1 with Defaults

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;
    });
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) Defaults(org.opennms.features.topology.api.topo.Defaults) VertexHopGraphProvider(org.opennms.features.topology.api.support.VertexHopGraphProvider)

Example 2 with Defaults

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();
        }
    });
}
Also used : Status(org.opennms.features.topology.api.topo.Status) NodeDao(org.opennms.netmgt.dao.api.NodeDao) Collection(java.util.Collection) AbstractTopologyProvider(org.opennms.features.topology.api.topo.AbstractTopologyProvider) DirectedSparseGraph(edu.uci.ics.jung.graph.DirectedSparseGraph) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) Collectors(java.util.stream.Collectors) VertexHopGraphProvider(org.opennms.features.topology.api.support.VertexHopGraphProvider) ArrayList(java.util.ArrayList) List(java.util.List) Lists(com.google.common.collect.Lists) Map(java.util.Map) Criteria(org.opennms.features.topology.api.topo.Criteria) Defaults(org.opennms.features.topology.api.topo.Defaults) EdgeType(edu.uci.ics.jung.graph.util.EdgeType) Optional(java.util.Optional) SelectionChangedListener(org.opennms.features.topology.api.browsers.SelectionChangedListener) AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) Status(org.opennms.features.topology.api.topo.Status) Comparator(java.util.Comparator) VertexRef(org.opennms.features.topology.api.topo.VertexRef) ContentType(org.opennms.features.topology.api.browsers.ContentType) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) Defaults(org.opennms.features.topology.api.topo.Defaults) VertexHopGraphProvider(org.opennms.features.topology.api.support.VertexHopGraphProvider) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Aggregations

VertexHopGraphProvider (org.opennms.features.topology.api.support.VertexHopGraphProvider)2 Defaults (org.opennms.features.topology.api.topo.Defaults)2 Lists (com.google.common.collect.Lists)1 DirectedSparseGraph (edu.uci.ics.jung.graph.DirectedSparseGraph)1 EdgeType (edu.uci.ics.jung.graph.util.EdgeType)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)1 ContentType (org.opennms.features.topology.api.browsers.ContentType)1 SelectionChangedListener (org.opennms.features.topology.api.browsers.SelectionChangedListener)1 AbstractEdge (org.opennms.features.topology.api.topo.AbstractEdge)1 AbstractTopologyProvider (org.opennms.features.topology.api.topo.AbstractTopologyProvider)1 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)1 Criteria (org.opennms.features.topology.api.topo.Criteria)1 Status (org.opennms.features.topology.api.topo.Status)1