Search in sources :

Example 11 with BusinessService

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;
}
Also used : BsmTestUtils.createDummyBusinessService(org.opennms.netmgt.bsm.test.BsmTestUtils.createDummyBusinessService) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService)

Example 12 with BusinessService

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());
}
Also used : BsmTestUtils.createDummyBusinessService(org.opennms.netmgt.bsm.test.BsmTestUtils.createDummyBusinessService) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) Identity(org.opennms.netmgt.bsm.service.model.functions.map.Identity) Test(org.junit.Test)

Example 13 with BusinessService

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;
}
Also used : Status(org.opennms.netmgt.bsm.service.model.Status) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) NoSuchElementException(java.util.NoSuchElementException)

Example 14 with BusinessService

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;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) Map(java.util.Map)

Example 15 with BusinessService

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;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) GraphContainer(org.opennms.features.topology.api.GraphContainer) AbstractBusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.AbstractBusinessServiceVertex) IpService(org.opennms.netmgt.bsm.service.model.IpService) BaseTheme(com.vaadin.ui.themes.BaseTheme) VerticalLayout(com.vaadin.ui.VerticalLayout) Threshold(org.opennms.netmgt.bsm.service.model.functions.reduce.Threshold) UI(com.vaadin.ui.UI) BusinessServiceManager(org.opennms.netmgt.bsm.service.BusinessServiceManager) HighestSeverityAbove(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverityAbove) Window(com.vaadin.ui.Window) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) BusinessServiceVertexVisitor(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertexVisitor) Strings(com.google.common.base.Strings) FontAwesome(com.vaadin.server.FontAwesome) GraphVertexToTopologyVertexConverter(org.opennms.features.topology.plugins.topo.bsm.GraphVertexToTopologyVertexConverter) VertexInfoPanelItemProvider(org.opennms.features.topology.api.info.VertexInfoPanelItemProvider) DefaultInfoPanelItem(org.opennms.features.topology.api.info.item.DefaultInfoPanelItem) ReductionFunction(org.opennms.netmgt.bsm.service.model.functions.reduce.ReductionFunction) Status(org.opennms.netmgt.bsm.service.model.Status) Label(com.vaadin.ui.Label) ShortcutAction(com.vaadin.event.ShortcutAction) Comparator.comparing(java.util.Comparator.comparing) UIHelper.createLabel(org.opennms.netmgt.vaadin.core.UIHelper.createLabel) BusinessServicesTopologyProvider(org.opennms.features.topology.plugins.topo.bsm.BusinessServicesTopologyProvider) ThresholdResultExplanation(org.opennms.netmgt.bsm.service.model.functions.reduce.ThresholdResultExplanation) InfoPanelItem(org.opennms.features.topology.api.info.item.InfoPanelItem) ExponentialPropagation(org.opennms.netmgt.bsm.service.model.functions.reduce.ExponentialPropagation) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) Collectors(java.util.stream.Collectors) Sizeable(com.vaadin.server.Sizeable) SimulationAwareStateMachineFactory(org.opennms.features.topology.plugins.topo.bsm.simulate.SimulationAwareStateMachineFactory) TransactionAwareBeanProxyFactory(org.opennms.netmgt.vaadin.core.TransactionAwareBeanProxyFactory) BusinessServiceVertexStatusInfoPanelItemProvider.createStatusLabel(org.opennms.features.topology.plugins.topo.bsm.info.BusinessServiceVertexStatusInfoPanelItemProvider.createStatusLabel) List(java.util.List) Button(com.vaadin.ui.Button) Table(com.vaadin.ui.Table) Edge(org.opennms.netmgt.bsm.service.model.edge.Edge) FormLayout(com.vaadin.ui.FormLayout) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) GraphEdge(org.opennms.netmgt.bsm.service.model.graph.GraphEdge) ReduceFunctionVisitor(org.opennms.netmgt.bsm.service.model.functions.reduce.ReduceFunctionVisitor) VertexRef(org.opennms.features.topology.api.topo.VertexRef) HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) UIHelper.createButton(org.opennms.netmgt.vaadin.core.UIHelper.createButton) Component(com.vaadin.ui.Component) HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) ReductionKeyVertex(org.opennms.features.topology.plugins.topo.bsm.ReductionKeyVertex) HighestSeverityAbove(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverityAbove) IpService(org.opennms.netmgt.bsm.service.model.IpService) IpServiceVertex(org.opennms.features.topology.plugins.topo.bsm.IpServiceVertex) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) ReduceFunctionVisitor(org.opennms.netmgt.bsm.service.model.functions.reduce.ReduceFunctionVisitor) Button(com.vaadin.ui.Button) UIHelper.createButton(org.opennms.netmgt.vaadin.core.UIHelper.createButton) ExponentialPropagation(org.opennms.netmgt.bsm.service.model.functions.reduce.ExponentialPropagation) AbstractBusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.AbstractBusinessServiceVertex) BusinessServiceVertex(org.opennms.features.topology.plugins.topo.bsm.BusinessServiceVertex) Threshold(org.opennms.netmgt.bsm.service.model.functions.reduce.Threshold)

Aggregations

BusinessService (org.opennms.netmgt.bsm.service.model.BusinessService)39 Test (org.junit.Test)13 IpServiceEdge (org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge)10 Collectors (java.util.stream.Collectors)9 IpService (org.opennms.netmgt.bsm.service.model.IpService)9 Status (org.opennms.netmgt.bsm.service.model.Status)9 Edge (org.opennms.netmgt.bsm.service.model.edge.Edge)9 BusinessServiceGraph (org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph)9 List (java.util.List)8 BusinessServiceManager (org.opennms.netmgt.bsm.service.BusinessServiceManager)8 BusinessServiceStateMachine (org.opennms.netmgt.bsm.service.BusinessServiceStateMachine)8 Map (java.util.Map)7 Objects (java.util.Objects)7 Path (javax.ws.rs.Path)7 ChildEdge (org.opennms.netmgt.bsm.service.model.edge.ChildEdge)7 ReductionKeyEdge (org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge)7 BusinessServiceEntity (org.opennms.netmgt.bsm.persistence.api.BusinessServiceEntity)6 NoSuchElementException (java.util.NoSuchElementException)5 Set (java.util.Set)5 Criteria (org.opennms.core.criteria.Criteria)5