Search in sources :

Example 1 with OnmsCriteria

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));
}
Also used : OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria)

Example 2 with OnmsCriteria

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;
}
Also used : OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria)

Example 3 with OnmsCriteria

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);
}
Also used : OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria)

Example 4 with OnmsCriteria

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));
    }
}
Also used : OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria)

Example 5 with OnmsCriteria

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);
}
Also used : OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria)

Aggregations

OnmsCriteria (org.opennms.netmgt.model.OnmsCriteria)51 Transactional (org.springframework.transaction.annotation.Transactional)8 Filter (org.opennms.web.filter.Filter)7 Test (org.junit.Test)6 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)6 OnmsNode (org.opennms.netmgt.model.OnmsNode)5 ArrayList (java.util.ArrayList)4 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)4 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)3 AlarmCriteria (org.opennms.web.alarm.filter.AlarmCriteria)3 Date (java.util.Date)2 List (java.util.List)2 Criteria (org.hibernate.Criteria)2 Session (org.hibernate.Session)2 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)2 OnmsAcknowledgment (org.opennms.netmgt.model.OnmsAcknowledgment)2 AcknowledgedByFilter (org.opennms.web.alarm.filter.AcknowledgedByFilter)2 SeverityFilter (org.opennms.web.alarm.filter.SeverityFilter)2 HibernateCallback (org.springframework.orm.hibernate3.HibernateCallback)2 SyndContent (com.rometools.rome.feed.synd.SyndContent)1