use of org.opennms.netmgt.model.alarm.AlarmSummary in project opennms by OpenNMS.
the class GraphMLScriptVertexStatusProvider method getStatusForVertices.
@Override
public Map<? extends VertexRef, ? extends Status> getStatusForVertices(final VertexProvider vertexProvider, final Collection<VertexRef> vertices, final Criteria[] criteria) {
// All vertices for the current vertexProvider
final List<GraphMLVertex> graphMLVertices = vertices.stream().filter(eachVertex -> contributesTo(eachVertex.getNamespace()) && eachVertex instanceof GraphMLVertex).map(eachVertex -> (GraphMLVertex) eachVertex).collect(Collectors.toList());
// Alarm summary for each node id
final Map<Integer, AlarmSummary> nodeIdToAlarmSummaryMap = alarmSummaryWrapper.getAlarmSummaries(Lists.transform(graphMLVertices, AbstractVertex::getNodeID)).stream().collect(Collectors.toMap(AlarmSummary::getNodeId, Function.identity()));
// Calculate status via scripts
return serviceAccessor.getTransactionOperations().execute(t -> this.scripting.compute(graphMLVertices.stream(), (vertex) -> {
final SimpleBindings bindings = new SimpleBindings();
bindings.put("vertex", vertex);
if (vertex.getNodeID() != null) {
bindings.put("node", serviceAccessor.getNodeDao().get(vertex.getNodeID()));
bindings.put("alarmSummary", nodeIdToAlarmSummaryMap.get(vertex.getNodeID()));
}
bindings.put("measurements", new MeasurementsWrapper(serviceAccessor.getMeasurementsService()));
bindings.put("nodeDao", serviceAccessor.getNodeDao());
bindings.put("snmpInterfaceDao", serviceAccessor.getSnmpInterfaceDao());
return bindings;
}));
}
Aggregations