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());
}
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));
}
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));
}
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;
}
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;
}
Aggregations