Search in sources :

Example 1 with BusinessServiceDTO

use of org.opennms.web.rest.v2.status.model.BusinessServiceDTO 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);
}
Also used : Arrays(java.util.Arrays) PathParam(javax.ws.rs.PathParam) QueryParameters(org.opennms.web.utils.QueryParameters) NodeStatusCalculationStrategy(org.opennms.features.status.api.node.strategy.NodeStatusCalculationStrategy) Produces(javax.ws.rs.Produces) BusinessServiceDTO(org.opennms.web.rest.v2.status.model.BusinessServiceDTO) GET(javax.ws.rs.GET) NodeDTO(org.opennms.web.rest.v2.status.model.NodeDTO) Path(javax.ws.rs.Path) Autowired(org.springframework.beans.factory.annotation.Autowired) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) JaxbListWrapper(org.opennms.core.config.api.JaxbListWrapper) ApplicationStatusService(org.opennms.features.status.api.application.ApplicationStatusService) Strings(com.google.common.base.Strings) MediaType(javax.ws.rs.core.MediaType) StatusSummary(org.opennms.features.status.api.StatusSummary) BusinessServiceStatusService(org.opennms.features.status.api.bsm.BusinessServiceStatusService) Map(java.util.Map) NodeQuery(org.opennms.features.status.api.node.NodeQuery) QueryParametersBuilder(org.opennms.web.utils.QueryParametersBuilder) OnmsNode(org.opennms.netmgt.model.OnmsNode) ApplicationDTO(org.opennms.web.rest.v2.status.model.ApplicationDTO) SeverityFilter(org.opennms.features.status.api.SeverityFilter) Context(javax.ws.rs.core.Context) NodeDTOList(org.opennms.web.rest.v2.status.model.NodeDTOList) Query(org.opennms.features.status.api.Query) NodeStatusService(org.opennms.features.status.api.node.NodeStatusService) Collectors(java.util.stream.Collectors) StatusEntity(org.opennms.features.status.api.StatusEntity) List(java.util.List) Component(org.springframework.stereotype.Component) Response(javax.ws.rs.core.Response) BusinessServiceDTOList(org.opennms.web.rest.v2.status.model.BusinessServiceDTOList) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) ApplicationDTOList(org.opennms.web.rest.v2.status.model.ApplicationDTOList) UriInfo(javax.ws.rs.core.UriInfo) Comparator(java.util.Comparator) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) SeverityFilter(org.opennms.features.status.api.SeverityFilter) NodeQuery(org.opennms.features.status.api.node.NodeQuery) Query(org.opennms.features.status.api.Query) BusinessServiceDTOList(org.opennms.web.rest.v2.status.model.BusinessServiceDTOList) BusinessServiceDTO(org.opennms.web.rest.v2.status.model.BusinessServiceDTO) QueryParameters(org.opennms.web.utils.QueryParameters) StatusEntity(org.opennms.features.status.api.StatusEntity) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

Strings (com.google.common.base.Strings)1 Arrays (java.util.Arrays)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 PathParam (javax.ws.rs.PathParam)1 Produces (javax.ws.rs.Produces)1 Context (javax.ws.rs.core.Context)1 MediaType (javax.ws.rs.core.MediaType)1 Response (javax.ws.rs.core.Response)1 UriInfo (javax.ws.rs.core.UriInfo)1 JaxbListWrapper (org.opennms.core.config.api.JaxbListWrapper)1 Query (org.opennms.features.status.api.Query)1 SeverityFilter (org.opennms.features.status.api.SeverityFilter)1 StatusEntity (org.opennms.features.status.api.StatusEntity)1 StatusSummary (org.opennms.features.status.api.StatusSummary)1 ApplicationStatusService (org.opennms.features.status.api.application.ApplicationStatusService)1