use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class ApplicationStatusProvider method getStatusForVertices.
@Override
public Map<VertexRef, Status> getStatusForVertices(VertexProvider vertexProvider, Collection<VertexRef> vertices, Criteria[] criteria) {
Map<VertexRef, Status> returnMap = new HashMap<>();
Map<ApplicationStatusEntity.Key, Status> statusMap = new HashMap<>();
List<ApplicationStatusEntity> result = applicationDao.getAlarmStatus();
for (ApplicationStatusEntity eachRow : result) {
DefaultStatus status = createStatus(eachRow.getSeverity(), eachRow.getCount());
statusMap.put(eachRow.getKey(), status);
}
// status for all known node ids
Collection<VertexRef> vertexRefsForNamespace = getVertexRefsForNamespace(vertices);
Collection<VertexRef> vertexRefsRoot = getRootElements(vertexRefsForNamespace);
Collection<VertexRef> vertexRefs = new ArrayList<>(vertexRefsForNamespace);
vertexRefs.removeAll(vertexRefsRoot);
// calculate status for children
for (VertexRef eachVertex : vertexRefs) {
ApplicationVertex applicationVertex = (ApplicationVertex) eachVertex;
Status alarmStatus = statusMap.get(createKey(applicationVertex));
if (alarmStatus == null) {
alarmStatus = createStatus(OnmsSeverity.NORMAL, 0);
}
returnMap.put(eachVertex, alarmStatus);
}
// calculate status for root
for (VertexRef eachRoot : vertexRefsRoot) {
ApplicationVertex eachRootApplication = (ApplicationVertex) eachRoot;
OnmsSeverity maxSeverity = OnmsSeverity.NORMAL;
int count = 0;
for (VertexRef eachChild : eachRootApplication.getChildren()) {
ApplicationVertex eachChildApplication = (ApplicationVertex) eachChild;
ApplicationStatusEntity.Key childKey = createKey(eachChildApplication);
Status childStatus = statusMap.get(childKey);
if (childStatus != null && maxSeverity.isLessThan(createSeverity(childStatus.computeStatus()))) {
maxSeverity = createSeverity(childStatus.computeStatus());
count = Integer.parseInt(childStatus.getStatusProperties().get("statusCount"));
}
}
returnMap.put(eachRoot, createStatus(maxSeverity, count));
}
return returnMap;
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class ResourceGraphsOperation method execute.
@Override
public void execute(final List<VertexRef> targets, final OperationContext operationContext) {
try {
String label = "";
int nodeID = -1;
if (targets != null) {
for (final VertexRef target : targets) {
final String labelValue = getLabelValue(operationContext, target);
final Integer nodeValue = getNodeIdValue(operationContext, target);
if (nodeValue != null && nodeValue > 0) {
label = labelValue == null ? "" : labelValue;
nodeID = nodeValue.intValue();
break;
}
}
}
final Node node = new Node(nodeID, null, label);
final String url;
if (node.getNodeID() >= 0) {
url = getResourceGraphNodeURL() + "[" + node.getNodeID() + "]";
} else {
url = getResourceGraphListURL();
}
final URL fullUrl = new URL(getFullUrl(url));
operationContext.getMainWindow().addWindow(new ResourceGraphsWindow(node, fullUrl));
} catch (final Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException("Failed to create resource graph window.", e);
}
}
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class SSHOperation method execute.
@Override
public Undoer execute(final List<VertexRef> targets, final OperationContext operationContext) {
String ipAddr = "";
int port = 22;
if (targets != null) {
for (final VertexRef target : targets) {
final Item vertexItem = operationContext.getGraphContainer().getBaseTopology().getVertex(target, operationContext.getGraphContainer().getCriteria()).getItem();
if (vertexItem != null) {
final Property<String> ipAddrProperty = vertexItem.getItemProperty("ipAddr");
ipAddr = ipAddrProperty == null ? "" : (String) ipAddrProperty.getValue();
//Property portProperty = operationContext.getGraphContainer().getVertexItem(target).getItemProperty("port");
//portProperty == null ? -1 : (Integer) portProperty.getValue();
port = 22;
}
}
}
operationContext.getMainWindow().addWindow(new AuthWindow(ipAddr, port));
return null;
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class NodeInfoOperation method execute.
@Override
public void execute(final List<VertexRef> targets, final OperationContext operationContext) {
try {
String label = "";
int nodeID = -1;
if (targets != null) {
for (final VertexRef target : targets) {
final String labelValue = getLabelValue(operationContext, target);
final Integer nodeValue = getNodeIdValue(operationContext, target);
if (nodeValue != null && nodeValue > 0) {
label = labelValue == null ? "" : labelValue;
nodeID = nodeValue.intValue();
break;
}
}
}
final Node node = new Node(nodeID, null, label);
final String url;
if (node.getNodeID() >= 0) {
url = getNodePageURL() + node.getNodeID();
} else {
url = getNodeListURL();
}
final URL fullUrl = new URL(getFullUrl(url));
operationContext.getMainWindow().addWindow(new NodeInfoWindow(node, fullUrl));
} catch (final Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException("Failed to create node window.", e);
}
}
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class LinkdHopCriteria method getVertices.
@Override
public Set<VertexRef> getVertices() {
Integer id = Integer.valueOf(m_nodeId);
OnmsNode node = m_nodeDao.get(id);
Set<VertexRef> vertices = new TreeSet<VertexRef>(new RefComparator());
if (node != null) {
String label = node.getLabel();
vertices.add(new DefaultVertexRef("nodes", m_nodeId, label));
}
return vertices;
}
Aggregations