Search in sources :

Example 41 with OnmsCriteria

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

Example 42 with OnmsCriteria

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

Example 43 with OnmsCriteria

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

Example 44 with OnmsCriteria

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

Example 45 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(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);
}
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