use of org.opennms.features.status.api.StatusEntityWrapper in project opennms by OpenNMS.
the class NodeStatusService method getStatus.
public List<StatusEntity<OnmsNode>> getStatus(NodeQuery query) {
// Build query
final NodeStatusCalculatorConfig config = buildFrom(query);
// Calculate Status
final Status status = statusCalculator.calculateStatus(config);
// Find nodes for node id
final List<OnmsNode> nodes = getNodes(status.getIds());
final Map<Integer, OnmsNode> nodeIdMap = nodes.stream().collect(Collectors.toMap(n -> n.getId(), n -> n));
// convert to wrapper
return status.getIds().stream().map(nodeId -> {
OnmsSeverity nodeStatus = status.getSeverity(nodeId);
OnmsNode node = nodeIdMap.get(nodeId);
if (nodeStatus == null) {
throw new IllegalStateException("nodeStatus should not be null");
}
if (node == null) {
throw new IllegalStateException("node should not be null");
}
return new StatusEntityWrapper<>(node, nodeStatus);
}).collect(Collectors.toList());
}
use of org.opennms.features.status.api.StatusEntityWrapper 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