use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class NetworkElementFactory method getSnmpInterface.
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getSnmpInterface(int, int)
*/
@Override
public Interface getSnmpInterface(int nodeId, int ifIndex) {
OnmsCriteria criteria = new OnmsCriteria(OnmsSnmpInterface.class);
criteria.createAlias("node", "node");
criteria.add(Restrictions.eq("node.id", nodeId));
criteria.add(Restrictions.eq("ifIndex", ifIndex));
List<OnmsSnmpInterface> snmpIfaces = m_snmpInterfaceDao.findMatching(criteria);
if (snmpIfaces.size() > 0) {
return new Interface(snmpIfaces.get(0));
}
return null;
}
use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class NetworkElementFactory method getNodesLikeAndIpLike.
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getNodesLikeAndIpLike(java.lang.String, java.lang.String, int)
*/
@Override
public List<OnmsNode> getNodesLikeAndIpLike(String nodeLabel, String iplike, int serviceId) {
if (nodeLabel == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
OnmsCriteria nodeCrit = new OnmsCriteria(OnmsNode.class);
nodeCrit.createAlias("assetRecord", "assetRecord");
nodeCrit.add(Restrictions.ilike("label", nodeLabel));
nodeCrit.createCriteria("ipInterfaces").add(OnmsRestrictions.ipLike(iplike)).createAlias("monitoredServices", "monSvcs").createAlias("monSvcs.serviceType", "serviceType").add(Restrictions.eq("serviceType.id", serviceId));
nodeCrit.addOrder(Order.asc("label"));
return m_nodeDao.findMatching(nodeCrit);
}
use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class NetworkElementFactory method getAllInterfacesOnNode.
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getAllInterfacesOnNode(int)
*/
@Override
public Interface[] getAllInterfacesOnNode(int nodeId) {
OnmsCriteria criteria = new OnmsCriteria(OnmsIpInterface.class);
criteria.createAlias("node", "node");
criteria.createAlias("snmpInterface", "snmpIface");
criteria.createAlias("node.assetRecord", "assetRecord");
criteria.add(Restrictions.eq("node.id", nodeId));
return getInterfaceArray(m_ipInterfaceDao.findMatching(criteria));
}
use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class NetworkElementFactory method getServicesOnInterface.
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getServicesOnInterface(int, java.lang.String, boolean)
*/
@Override
public Service[] getServicesOnInterface(int nodeId, String ipAddress, boolean includeDeletions) {
if (ipAddress == null) {
throw new IllegalArgumentException("Cannot take null parameters.");
}
OnmsCriteria criteria = new OnmsCriteria(OnmsMonitoredService.class);
criteria.createAlias("ipInterface", "ipInterface");
criteria.createAlias("ipInterface.node", "node");
criteria.add(Restrictions.eq("node.id", nodeId));
criteria.add(Restrictions.eq("ipInterface.ipAddress", InetAddressUtils.addr(ipAddress)));
if (!includeDeletions) {
criteria.add(Restrictions.ne("status", "D"));
}
return getServiceArray(m_monSvcDao.findMatching(criteria));
}
use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class NetworkElementFactory method getAllNodes.
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getAllNodes(int)
*/
@Override
public List<OnmsNode> getAllNodes(int serviceId) {
OnmsCriteria criteria = new OnmsCriteria(OnmsNode.class);
criteria.createAlias("ipInterfaces", "ipInterfaces");
criteria.createAlias("ipInterfaces.monitoredServices", "monSvcs");
criteria.add(Restrictions.ne("type", "D"));
criteria.add(Restrictions.eq("monSvcs.serviceType.id", serviceId));
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
return m_nodeDao.findMatching(criteria);
}
Aggregations