Search in sources :

Example 16 with OnmsCriteria

use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.

the class NetworkElementFactory method getActiveInterfacesOnNode.

/* (non-Javadoc)
	 * @see org.opennms.web.element.NetworkElementFactoryInterface#getActiveInterfacesOnNode(int)
	 */
@Override
public Interface[] getActiveInterfacesOnNode(int nodeId) {
    OnmsCriteria criteria = new OnmsCriteria(OnmsIpInterface.class);
    criteria.createAlias("node", "node");
    criteria.add(Restrictions.eq("node.id", nodeId));
    criteria.add(Restrictions.ne("isManaged", "D"));
    return getInterfaceArray(m_ipInterfaceDao.findMatching(criteria));
}
Also used : OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria)

Example 17 with OnmsCriteria

use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.

the class NetworkElementFactory method getInterface.

/* (non-Javadoc)
	 * @see org.opennms.web.element.NetworkElementFactoryInterface#getInterface(int)
	 */
@Override
public Interface getInterface(int ipInterfaceId) {
    OnmsCriteria criteria = new OnmsCriteria(OnmsIpInterface.class);
    criteria.add(Restrictions.eq("id", ipInterfaceId));
    criteria.setFetchMode("snmpInterface", FetchMode.JOIN);
    List<OnmsIpInterface> ifaces = m_ipInterfaceDao.findMatching(criteria);
    if (ifaces.size() > 0) {
        return new Interface(ifaces.get(0));
    }
    return null;
}
Also used : OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface)

Example 18 with OnmsCriteria

use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.

the class NetworkElementFactory method getServicesOnNode.

/* (non-Javadoc)
	 * @see org.opennms.web.element.NetworkElementFactoryInterface#getServicesOnNode(int)
	 */
@Override
public Service[] getServicesOnNode(int nodeId) {
    OnmsCriteria criteria = new OnmsCriteria(OnmsMonitoredService.class);
    criteria.createAlias("ipInterface", "ipInterface");
    criteria.createAlias("ipInterface.snmpInterface", "snmpIface", OnmsCriteria.LEFT_JOIN);
    criteria.createAlias("ipInterface.node", "node");
    criteria.createAlias("serviceType", "serviceType");
    criteria.add(Restrictions.eq("node.id", nodeId));
    return getServiceArray(m_monSvcDao.findMatching(criteria));
}
Also used : OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria)

Example 19 with OnmsCriteria

use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.

the class NetworkElementFactory method getNodesLike.

/* (non-Javadoc)
	 * @see org.opennms.web.element.NetworkElementFactoryInterface#getNodesLike(java.lang.String, int)
	 */
@Override
public List<OnmsNode> getNodesLike(String nodeLabel, int serviceId) {
    if (nodeLabel == null) {
        throw new IllegalArgumentException("Cannot take null parameters.");
    }
    OnmsCriteria criteria = new OnmsCriteria(OnmsNode.class);
    criteria.createAlias("assetRecord", "assetRecord");
    criteria.createAlias("ipInterfaces", "iface");
    criteria.createAlias("iface.monitoredServices", "monSvcs");
    criteria.createAlias("monSvcs.serviceType", "serviceType");
    criteria.add(Restrictions.ilike("label", nodeLabel, MatchMode.ANYWHERE));
    criteria.add(Restrictions.eq("serviceType.id", serviceId));
    criteria.add(Restrictions.ne("type", "D"));
    criteria.addOrder(Order.asc("label"));
    return m_nodeDao.findMatching(criteria);
}
Also used : OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria)

Example 20 with OnmsCriteria

use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.

the class NetworkElementFactory method getAllManagedIpInterfaces.

/* (non-Javadoc)
	 * @see org.opennms.web.element.NetworkElementFactoryInterface#getAllManagedIpInterfaces(boolean)
	 */
@Override
public Interface[] getAllManagedIpInterfaces(boolean includeSNMP) {
    OnmsCriteria criteria = new OnmsCriteria(OnmsIpInterface.class);
    criteria.createAlias("snmpInterface", "snmpInterface", OnmsCriteria.LEFT_JOIN);
    criteria.createAlias("node", "node");
    criteria.add(Restrictions.ne("isManaged", "D"));
    criteria.add(Restrictions.ne("ipAddress", InetAddressUtils.addr("0.0.0.0")));
    criteria.add(Restrictions.isNotNull("ipAddress"));
    criteria.addOrder(Order.asc("ipHostName"));
    criteria.addOrder(Order.asc("node.id"));
    criteria.addOrder(Order.asc("ipAddress"));
    if (!includeSNMP) {
        return getInterfaceArray(m_ipInterfaceDao.findMatching(criteria));
    } else {
        return getInterfaceArrayWithSnmpData(m_ipInterfaceDao.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.sun.syndication.feed.synd.SyndContent)1