use of org.opennms.features.status.api.SeverityFilter in project opennms by OpenNMS.
the class StatusRestService method getApplications.
@GET
@Path("/applications")
public Response getApplications(@Context final UriInfo uriInfo) {
final QueryParameters queryParameters = QueryParametersBuilder.buildFrom(uriInfo);
final SeverityFilter severityFilter = getSeverityFilter(uriInfo);
final Query query = new Query(queryParameters, severityFilter);
final List<StatusEntity<OnmsApplication>> applications = applicationStatusService.getStatus(query);
final int totalCount = applicationStatusService.count(query);
final int offset = queryParameters.getOffset();
final List<ApplicationDTO> statusEntities = applications.stream().map(a -> {
ApplicationDTO dto = new ApplicationDTO();
dto.setId(a.getEntity().getId());
dto.setName(a.getEntity().getName());
dto.setSeverity(a.getStatus());
return dto;
}).collect(Collectors.toList());
final ApplicationDTOList list = new ApplicationDTOList(statusEntities);
list.setOffset(queryParameters.getOffset());
list.setTotalCount(totalCount);
return createResponse(list, offset, totalCount);
}
use of org.opennms.features.status.api.SeverityFilter in project opennms by OpenNMS.
the class StatusRestService method getSeverityFilter.
private static SeverityFilter getSeverityFilter(UriInfo uriInfo) {
final SeverityFilter severityFilter = new SeverityFilter();
final List<String> severityFilterList = uriInfo.getQueryParameters().get("severityFilter");
if (severityFilterList != null) {
for (String eachSeverity : severityFilterList) {
OnmsSeverity severity = getSeverity(eachSeverity);
severityFilter.add(severity);
}
}
return severityFilter;
}
use of org.opennms.features.status.api.SeverityFilter in project opennms by OpenNMS.
the class StatusRestService method getNodes.
@GET
@Path("/nodes/{type}")
public Response getNodes(@Context final UriInfo uriInfo, @PathParam("type") String type) {
final NodeStatusCalculationStrategy strategy = NodeStatusCalculationStrategy.createFrom(type);
if (strategy == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("Strategy '" + type + "' not supported. Supported values are:" + Arrays.toString(NodeStatusCalculationStrategy.values())).build();
}
final QueryParameters queryParameters = QueryParametersBuilder.buildFrom(uriInfo);
final SeverityFilter severityFilter = getSeverityFilter(uriInfo);
final NodeQuery query = new NodeQuery(queryParameters, severityFilter);
query.setStatusCalculationStrategy(strategy);
// Adjust order parameters
if (query.getParameters().getOrder() != null && query.getParameters().getOrder().getColumn().equals("label")) {
query.getParameters().setOrder(new QueryParameters.Order("node.nodelabel", query.getParameters().getOrder().isDesc()));
}
final List<StatusEntity<OnmsNode>> nodes = nodeStatusService.getStatus(query);
final int totalCount = nodeStatusService.count(query);
final int offset = queryParameters.getOffset();
final List<NodeDTO> statusEntities = nodes.stream().map(node -> {
NodeDTO nodeDTO = new NodeDTO();
nodeDTO.setId(node.getEntity().getId());
nodeDTO.setName(node.getEntity().getLabel());
nodeDTO.setSeverity(node.getStatus());
return nodeDTO;
}).collect(Collectors.toList());
final NodeDTOList list = new NodeDTOList(statusEntities);
list.setOffset(queryParameters.getOffset());
list.setTotalCount(totalCount);
return createResponse(list, offset, totalCount);
}
use of org.opennms.features.status.api.SeverityFilter in project opennms by OpenNMS.
the class StatusRestService method getBusinessServices.
@GET
@Path("/business-services")
public Response getBusinessServices(@Context final UriInfo uriInfo) {
final QueryParameters queryParameters = QueryParametersBuilder.buildFrom(uriInfo);
final SeverityFilter severityFilter = getSeverityFilter(uriInfo);
final Query query = new Query(queryParameters, severityFilter);
final List<StatusEntity<BusinessService>> services = businessServiceStatusService.getStatus(query);
final int totalCount = businessServiceStatusService.count(query);
final int offset = queryParameters.getOffset();
final List<BusinessServiceDTO> statusEntities = services.stream().map(bs -> {
BusinessServiceDTO statusDTO = new BusinessServiceDTO();
statusDTO.setId(bs.getEntity().getId().intValue());
statusDTO.setName(bs.getEntity().getName());
statusDTO.setSeverity(bs.getStatus());
return statusDTO;
}).collect(Collectors.toList());
final BusinessServiceDTOList list = new BusinessServiceDTOList(statusEntities);
list.setOffset(queryParameters.getOffset());
list.setTotalCount(totalCount);
return createResponse(list, offset, totalCount);
}
Aggregations