Search in sources :

Example 1 with BusinessServiceSearchCriteriaBuilder

use of org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder in project opennms by OpenNMS.

the class BSMConfigHelperTest method testFromMap.

@Test
public void testFromMap() {
    Map<String, String> properties = new HashMap<>();
    properties.put("attributeKey", null);
    properties.put("attributeValue", null);
    properties.put("filterByAttribute", "false");
    properties.put("filterByName", "false");
    properties.put("filterBySeverity", "false");
    properties.put("nameValue", null);
    properties.put("orderAsc", "true");
    properties.put("orderBy", "Severity");
    properties.put("orderSequence", "Descending");
    properties.put("resultsLimit", "10");
    properties.put("severityCompareOperator", "GreaterOrEqual");
    properties.put("severityValue", "Warning");
    properties.put("columnCountBoard", "10");
    properties.put("columnCountPanel", "5");
    BusinessServiceSearchCriteriaBuilder businessServiceSearchCriteria = (BusinessServiceSearchCriteriaBuilder) BSMConfigHelper.fromMap(properties);
    Assert.assertEquals(BusinessServiceSearchCriteriaBuilder.Order.Severity, businessServiceSearchCriteria.getOrder());
    Assert.assertEquals(BusinessServiceSearchCriteriaBuilder.Sequence.Descending, businessServiceSearchCriteria.getSequence());
}
Also used : HashMap(java.util.HashMap) BusinessServiceSearchCriteriaBuilder(org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder) Test(org.junit.Test)

Example 2 with BusinessServiceSearchCriteriaBuilder

use of org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder in project opennms by OpenNMS.

the class BusinessServiceCriteriaTest method testFilterByAttribute.

@Test
public void testFilterByAttribute() {
    BusinessServiceSearchCriteriaBuilder b = new BusinessServiceSearchCriteriaBuilder().attribute("att1", ".*Yes").order(BusinessServiceSearchCriteriaBuilder.Order.Name).desc();
    assertEquals(ImmutableList.<BusinessService>builder().add(bs7, bs5, bs4, bs2, bs1).build(), businessServiceManager.search(b));
}
Also used : BusinessServiceSearchCriteriaBuilder(org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder) Test(org.junit.Test)

Example 3 with BusinessServiceSearchCriteriaBuilder

use of org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder in project opennms by OpenNMS.

the class BusinessServiceCriteriaTest method testFilterBySeverity.

@Test
public void testFilterBySeverity() {
    BusinessServiceSearchCriteriaBuilder b = new BusinessServiceSearchCriteriaBuilder().greaterOrEqualSeverity(Status.WARNING).order(BusinessServiceSearchCriteriaBuilder.Order.Severity).desc();
    assertEquals(ImmutableList.<BusinessService>builder().add(bs7, bs6, bs5, bs4).build(), businessServiceManager.search(b));
}
Also used : BusinessServiceSearchCriteriaBuilder(org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder) Test(org.junit.Test)

Example 4 with BusinessServiceSearchCriteriaBuilder

use of org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder in project opennms by OpenNMS.

the class BusinessServicesBoxController method handleRequestInternal.

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    int numberOfRows = Integer.getInteger("opennms.businessServicesWithProblems.count", DEFAULT_ROW_COUNT);
    boolean all = "true".equalsIgnoreCase(request.getParameter("all"));
    BusinessServiceSearchCriteriaBuilder criteriaBuilder = new BusinessServiceSearchCriteriaBuilder().order(BusinessServiceSearchCriteriaBuilder.Order.Severity).greaterSeverity(Status.NORMAL).desc();
    List<BusinessService> bsList = criteriaBuilder.apply(businessServiceManager, businessServiceManager.getAllBusinessServices());
    boolean more = !all && bsList.size() - numberOfRows > 0;
    if (!all) {
        if (bsList.size() > numberOfRows) {
            bsList = bsList.subList(0, numberOfRows);
        }
    }
    ModelAndView modelAndView = new ModelAndView(m_successView);
    modelAndView.addObject("more", more);
    modelAndView.addObject("services", bsList);
    return modelAndView;
}
Also used : BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) BusinessServiceSearchCriteriaBuilder(org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 5 with BusinessServiceSearchCriteriaBuilder

use of org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder in project opennms by OpenNMS.

the class BusinessServiceStatusService method getStatus.

public List<StatusEntity<BusinessService>> getStatus(Query query) {
    final BusinessServiceSearchCriteriaBuilder criteria = buildFrom(query);
    final List<BusinessService> services = criteria.apply(businessServiceManager, businessServiceManager.getAllBusinessServices());
    final List<StatusEntity<BusinessService>> mappedServices = services.stream().map(eachService -> new StatusEntityWrapper<>(eachService, OnmsSeverity.get(eachService.getOperationalStatus().getLabel()))).collect(Collectors.toList());
    return mappedServices;
}
Also used : QueryParameters(org.opennms.web.utils.QueryParameters) BusinessServiceManager(org.opennms.netmgt.bsm.service.BusinessServiceManager) Autowired(org.springframework.beans.factory.annotation.Autowired) Query(org.opennms.features.status.api.Query) StatusEntityWrapper(org.opennms.features.status.api.StatusEntityWrapper) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) Collectors(java.util.stream.Collectors) StatusEntity(org.opennms.features.status.api.StatusEntity) BusinessServiceSearchCriteriaBuilder(org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder) List(java.util.List) StatusSummary(org.opennms.features.status.api.StatusSummary) Status(org.opennms.netmgt.bsm.service.model.Status) Service(org.springframework.stereotype.Service) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) StatusEntityWrapper(org.opennms.features.status.api.StatusEntityWrapper) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) BusinessServiceSearchCriteriaBuilder(org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder) StatusEntity(org.opennms.features.status.api.StatusEntity)

Aggregations

BusinessServiceSearchCriteriaBuilder (org.opennms.netmgt.bsm.service.BusinessServiceSearchCriteriaBuilder)11 Test (org.junit.Test)6 BusinessService (org.opennms.netmgt.bsm.service.model.BusinessService)4 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Query (org.opennms.features.status.api.Query)2 StatusEntity (org.opennms.features.status.api.StatusEntity)2 StatusEntityWrapper (org.opennms.features.status.api.StatusEntityWrapper)2 StatusSummary (org.opennms.features.status.api.StatusSummary)2 BusinessServiceManager (org.opennms.netmgt.bsm.service.BusinessServiceManager)2 Status (org.opennms.netmgt.bsm.service.model.Status)2 OnmsSeverity (org.opennms.netmgt.model.OnmsSeverity)2 QueryParameters (org.opennms.web.utils.QueryParameters)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Service (org.springframework.stereotype.Service)2 HashMap (java.util.HashMap)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1