use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class DefaultNodeListService method addCriteriaForIpLike.
private static void addCriteriaForIpLike(OnmsCriteria criteria, String iplike) {
OnmsCriteria ipInterface = criteria.createCriteria("node.ipInterfaces", "ipInterface");
ipInterface.add(Restrictions.ne("isManaged", "D"));
ipInterface.add(OnmsRestrictions.ipLike(iplike));
}
use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class NetworkElementFactory method getHostname.
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getHostname(java.lang.String)
*/
@Override
public String getHostname(String ipAddress) {
OnmsCriteria criteria = new OnmsCriteria(OnmsIpInterface.class);
criteria.add(Restrictions.eq("ipAddress", InetAddressUtils.addr(ipAddress)));
criteria.add(Restrictions.isNotNull("ipHostName"));
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
List<OnmsIpInterface> ipIfaces = m_ipInterfaceDao.findMatching(criteria);
if (ipIfaces.size() > 0) {
OnmsIpInterface iface = ipIfaces.get(0);
return iface.getIpHostName();
}
return null;
}
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()
*/
@Override
public List<OnmsNode> getAllNodes() {
OnmsCriteria criteria = new OnmsCriteria(OnmsNode.class);
criteria.add(Restrictions.or(Restrictions.isNull("type"), Restrictions.ne("type", "D")));
criteria.addOrder(Order.asc("label"));
return m_nodeDao.findMatching(criteria);
}
use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class NetworkElementFactory method getAllInterfaces.
/*
* Returns all interfaces, but only includes SNMP data if includeSNMP is true
* This may be useful for pages that don't need SNMP data and don't want to execute
* a sub-query per interface!
*
* @param includeSNMP a boolean.
* @return an array of {@link org.opennms.web.element.Interface} objects.
*/
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getAllInterfaces(boolean)
*/
@Override
public Interface[] getAllInterfaces(boolean includeSnmp) {
OnmsCriteria criteria = new OnmsCriteria(OnmsIpInterface.class);
criteria.createAlias("snmpInterface", "snmpInterface", OnmsCriteria.LEFT_JOIN);
if (!includeSnmp) {
return getInterfaceArray(m_ipInterfaceDao.findMatching(criteria));
} else {
return getInterfaceArrayWithSnmpData(m_ipInterfaceDao.findMatching(criteria));
}
}
use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class NetworkElementFactory method getNodesWithIfAlias.
/* (non-Javadoc)
* @see org.opennms.web.element.NetworkElementFactoryInterface#getNodesWithIfAlias(java.lang.String)
*/
@Override
public List<OnmsNode> getNodesWithIfAlias(String ifAlias) {
OnmsCriteria criteria = new OnmsCriteria(OnmsNode.class);
criteria.createAlias("snmpInterfaces", "snmpIface");
criteria.add(Restrictions.ne("type", "D"));
criteria.add(Restrictions.ilike("snmpIface.ifAlias", ifAlias, MatchMode.ANYWHERE));
criteria.addOrder(Order.asc("label"));
return m_nodeDao.findMatching(criteria);
}
Aggregations