Search in sources :

Example 1 with EdgeVisitor

use of org.opennms.netmgt.bsm.service.model.edge.EdgeVisitor in project opennms by OpenNMS.

the class BusinessServiceRestService method getById.

@GET
@Path("{id}")
public Response getById(@PathParam("id") Long id) {
    BusinessService service = getManager().getBusinessServiceById(id);
    final BusinessServiceResponseDTO response = new BusinessServiceResponseDTO();
    response.setId(service.getId());
    response.setName(service.getName());
    response.setAttributes(service.getAttributes());
    response.setLocation(ResourceLocationFactory.createBusinessServiceLocation(service.getId().toString()));
    response.setParentServices(service.getParentServices().stream().map(BusinessService::getId).collect(Collectors.toSet()));
    response.setOperationalStatus(service.getOperationalStatus());
    response.setReduceFunction(transform(service.getReduceFunction()));
    service.getEdges().forEach(eachEdge -> eachEdge.accept(new EdgeVisitor<Void>() {

        @Override
        public Void visit(IpServiceEdge edge) {
            response.getIpServices().add(transform(edge));
            return null;
        }

        @Override
        public Void visit(ReductionKeyEdge edge) {
            response.getReductionKeys().add(transform(edge));
            return null;
        }

        @Override
        public Void visit(ChildEdge edge) {
            response.getChildren().add(transform(edge));
            return null;
        }
    }));
    return Response.ok(response).build();
}
Also used : BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) BusinessServiceResponseDTO(org.opennms.web.rest.v2.bsm.model.BusinessServiceResponseDTO) ChildEdge(org.opennms.netmgt.bsm.service.model.edge.ChildEdge) IpServiceEdge(org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge) EdgeVisitor(org.opennms.netmgt.bsm.service.model.edge.EdgeVisitor) ReductionKeyEdge(org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 2 with EdgeVisitor

use of org.opennms.netmgt.bsm.service.model.edge.EdgeVisitor in project opennms by OpenNMS.

the class BusinessServiceVertexStatusInfoPanelItemProvider method createComponent.

private Component createComponent(BusinessServiceVertex vertex, GraphContainer container) {
    final FormLayout rootLayout = new FormLayout();
    rootLayout.setSizeFull();
    rootLayout.setSpacing(false);
    rootLayout.setMargin(false);
    rootLayout.addStyleName("severity");
    final BusinessServiceStateMachine stateMachine = SimulationAwareStateMachineFactory.createStateMachine(businessServiceManager, container.getCriteria());
    final Status overallStatus = BusinessServicesStatusProvider.getStatus(stateMachine, vertex);
    rootLayout.addComponent(createStatusLabel("Overall", overallStatus));
    rootLayout.addComponent(new Label());
    final BusinessServiceGraph graph = stateMachine.getGraph();
    final BusinessService businessService = businessServiceManager.getBusinessServiceById(vertex.getServiceId());
    final Set<GraphVertex> impactingVertices = getImpactingVertices(stateMachine, graph, businessService);
    for (final Edge edge : businessService.getEdges()) {
        // Get the topology vertex for the child to determine the display label
        final Vertex childVertex = businessServicesTopologyProvider.getVertex(edge.accept(new EdgeVisitor<VertexRef>() {

            @Override
            public VertexRef visit(final IpServiceEdge edge) {
                return new IpServiceVertex(edge.getIpService(), 0);
            }

            @Override
            public VertexRef visit(final ReductionKeyEdge edge) {
                return new ReductionKeyVertex(edge.getReductionKey(), 0);
            }

            @Override
            public VertexRef visit(final ChildEdge edge) {
                return new BusinessServiceVertex(edge.getChild(), 0);
            }
        }));
        final Status edgeStatus = stateMachine.getOperationalStatus(edge);
        rootLayout.addComponent(createStatusLabel(childVertex.getLabel(), edgeStatus, String.format("%s &times; %d <i class=\"pull-right glyphicon %s\"></i>", edgeStatus.getLabel(), edge.getWeight(), impactingVertices.contains(graph.getVertexByEdgeId(edge.getId())) ? "glyphicon-flash" : "")));
    }
    return rootLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Status(org.opennms.netmgt.bsm.service.model.Status) Vertex(org.opennms.features.topology.api.topo.Vertex) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) ChildEdge(org.opennms.netmgt.bsm.service.model.edge.ChildEdge) Label(com.vaadin.ui.Label) UIHelper.createLabel(org.opennms.netmgt.vaadin.core.UIHelper.createLabel) IpServiceEdge(org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge) BusinessServiceGraph(org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph) EdgeVisitor(org.opennms.netmgt.bsm.service.model.edge.EdgeVisitor) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) ReductionKeyEdge(org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) GraphVertex(org.opennms.netmgt.bsm.service.model.graph.GraphVertex) BusinessServiceStateMachine(org.opennms.netmgt.bsm.service.BusinessServiceStateMachine) ChildEdge(org.opennms.netmgt.bsm.service.model.edge.ChildEdge) ReductionKeyEdge(org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge) Edge(org.opennms.netmgt.bsm.service.model.edge.Edge) IpServiceEdge(org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex)

Aggregations

BusinessService (org.opennms.netmgt.bsm.service.model.BusinessService)2 ChildEdge (org.opennms.netmgt.bsm.service.model.edge.ChildEdge)2 EdgeVisitor (org.opennms.netmgt.bsm.service.model.edge.EdgeVisitor)2 IpServiceEdge (org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge)2 ReductionKeyEdge (org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge)2 FormLayout (com.vaadin.ui.FormLayout)1 Label (com.vaadin.ui.Label)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1 BusinessServiceVertex (org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex)1 IpServiceVertex (org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex)1 ReductionKeyVertex (org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex)1 BusinessServiceStateMachine (org.opennms.netmgt.bsm.service.BusinessServiceStateMachine)1 Status (org.opennms.netmgt.bsm.service.model.Status)1 Edge (org.opennms.netmgt.bsm.service.model.edge.Edge)1 BusinessServiceGraph (org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph)1 GraphVertex (org.opennms.netmgt.bsm.service.model.graph.GraphVertex)1 UIHelper.createLabel (org.opennms.netmgt.vaadin.core.UIHelper.createLabel)1 BusinessServiceResponseDTO (org.opennms.web.rest.v2.bsm.model.BusinessServiceResponseDTO)1