use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.
the class BusinessServiceManagerImplIT method createBusinessService.
private BusinessService createBusinessService(String serviceName) {
BusinessService service = new BusinessServiceImpl(businessServiceManager, createDummyBusinessService(serviceName));
service.save();
return service;
}
use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.
the class BusinessServiceManagerImplIT method testChildDeletionSingleLevel.
// 1 parent -> 2 children
@Test
public void testChildDeletionSingleLevel() {
BusinessService service_p = createBusinessService("Business Service #p");
BusinessService service_c_1 = createBusinessService("Business Service #c1");
BusinessService service_c_2 = createBusinessService("Business Service #c2");
businessServiceManager.addChildEdge(service_p, service_c_1, new Identity(), Edge.DEFAULT_WEIGHT);
businessServiceManager.addChildEdge(service_p, service_c_2, new Identity(), Edge.DEFAULT_WEIGHT);
service_p.save();
service_c_1.save();
service_c_2.save();
// ensure the edges are there before deleting
Assert.assertEquals(2, edgeDao.countAll());
service_c_1.delete();
Assert.assertEquals(ImmutableSet.of(service_c_2), service_p.getChildServices());
// verify that the edge is also gone
Assert.assertEquals(1, edgeDao.countAll());
}
use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.
the class BusinessServicesTableCellStyleGenerator method getStyle.
@Override
public String getStyle(Table source, Object itemId, Object propertyId) {
if (propertyId == null) {
Long serviceId = (Long) itemId;
try {
BusinessService businessService = businessServiceManager.getBusinessServiceById(serviceId);
Status status = businessService.getOperationalStatus();
return String.format("alarm-%s", status.name().toLowerCase());
} catch (NoSuchElementException nse) {
return null;
}
}
return null;
}
use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.
the class BusinessServiceVertexAttributesInfoPanelItemProvider method createComponent.
private Component createComponent(VertexRef ref) {
final FormLayout formLayout = new FormLayout();
formLayout.setSpacing(false);
formLayout.setMargin(false);
final BusinessService businessService = businessServiceManager.getBusinessServiceById(((BusinessServiceVertex) ref).getServiceId());
for (Map.Entry<String, String> e : businessService.getAttributes().entrySet()) {
formLayout.addComponent(createLabel(e.getKey(), e.getValue()));
}
return formLayout;
}
use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.
the class BusinessServiceVertexInfoPanelItemProvider method createComponent.
private Component createComponent(AbstractBusinessServiceVertex ref, GraphContainer graphContainer) {
final FormLayout formLayout = new FormLayout();
formLayout.setSpacing(false);
formLayout.setMargin(false);
ref.accept(new BusinessServiceVertexVisitor<Void>() {
@Override
public Void visit(BusinessServiceVertex vertex) {
final BusinessService businessService = businessServiceManager.getBusinessServiceById(vertex.getServiceId());
formLayout.addComponent(createLabel("Reduce function", getReduceFunctionDescription(businessService.getReduceFunction())));
// Apply Reduce Function specific details
businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() {
@Override
public Void visit(HighestSeverity highestSeverity) {
return null;
}
@Override
public Void visit(HighestSeverityAbove highestSeverityAbove) {
return null;
}
@Override
public // Threshold is not very transparent, we add an Explain Button in these cases
Void visit(Threshold threshold) {
final Button explainButton = createButton("Explain", "Explain the Threshold function", FontAwesome.TABLE, (Button.ClickListener) event -> {
ThresholdExplanationWindow explainWindow = new ThresholdExplanationWindow(SimulationAwareStateMachineFactory.createSimulatedStateMachine(businessServiceManager, graphContainer.getCriteria()).explain(businessService, (Threshold) businessService.getReduceFunction()));
UI.getCurrent().addWindow(explainWindow);
});
explainButton.setStyleName(BaseTheme.BUTTON_LINK);
formLayout.addComponent(explainButton);
return null;
}
@Override
public Void visit(ExponentialPropagation exponentialPropagation) {
return null;
}
});
return null;
}
@Override
public Void visit(IpServiceVertex vertex) {
IpService ipService = businessServiceManager.getIpServiceById(vertex.getIpServiceId());
formLayout.addComponent(createLabel("Interface", ipService.getIpAddress()));
formLayout.addComponent(createLabel("Service", ipService.getServiceName()));
if (!ipService.getServiceName().equals(vertex.getLabel())) {
formLayout.addComponent(createLabel("Friendly Name", vertex.getLabel()));
}
return null;
}
@Override
public Void visit(ReductionKeyVertex vertex) {
formLayout.addComponent(createLabel("Reduction Key", vertex.getReductionKey()));
if (!vertex.getReductionKey().equals(vertex.getLabel())) {
formLayout.addComponent(createLabel("Friendly Name", vertex.getLabel()));
}
return null;
}
});
return formLayout;
}
Aggregations