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();
}
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 × %d <i class=\"pull-right glyphicon %s\"></i>", edgeStatus.getLabel(), edge.getWeight(), impactingVertices.contains(graph.getVertexByEdgeId(edge.getId())) ? "glyphicon-flash" : "")));
}
return rootLayout;
}
Aggregations