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 DefaultRtcService method createServiceCriteria.
/**
* <p>Create a {@link OnmsCriteria} that will select {@link OnmsMonitoredService} objects.</p>
*
* <p>CAUTION: This criteria must contain a JOIN alias to the node table called 'node' so that the
* {@link org.opennms.dashboard.server.CriteriaAddingVisitor.addCriteriaForCategories(OnmsCriteria, String...)}
* function can add a category-based restriction on matching node IDs to the criteria.</p>
*
* @return a {@link org.opennms.netmgt.model.OnmsCriteria} object.
*/
@Override
public OnmsCriteria createServiceCriteria() {
OnmsCriteria serviceCriteria = new OnmsCriteria(OnmsMonitoredService.class, "monitoredService");
serviceCriteria.add(Restrictions.eq("monitoredService.status", "A"));
serviceCriteria.createAlias("ipInterface", "ipInterface", OnmsCriteria.INNER_JOIN);
serviceCriteria.add(Restrictions.ne("ipInterface.isManaged", "D"));
// Required for {@link org.opennms.dashboard.server.CriteriaAddingVisitor.addCriteriaForCategories(OnmsCriteria, String...)}
// to work properly.
serviceCriteria.createAlias("ipInterface.node", "node", OnmsCriteria.INNER_JOIN);
serviceCriteria.add(Restrictions.ne("node.type", "D"));
serviceCriteria.createAlias("serviceType", "serviceType", OnmsCriteria.INNER_JOIN);
serviceCriteria.createAlias("currentOutages", "currentOutages", OnmsCriteria.INNER_JOIN);
return serviceCriteria;
}
use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class HibernateCriteriaConverterIT method testNodeQuery.
@Test
@JUnitTemporaryDatabase
public void testNodeQuery() throws Exception {
List<OnmsNode> nodes;
// first, try with OnmsCriteria
final OnmsCriteria crit = new OnmsCriteria(OnmsNode.class);
crit.add(org.hibernate.criterion.Restrictions.isNotNull("id"));
nodes = m_nodeDao.findMatching(crit);
assertEquals(6, nodes.size());
// then the same with the builder
final CriteriaBuilder cb = new CriteriaBuilder(OnmsNode.class);
cb.isNotNull("id");
nodes = m_nodeDao.findMatching(cb.toCriteria());
assertEquals(6, nodes.size());
cb.eq("label", "node1").join("ipInterfaces", "ipInterface").eq("ipInterface.ipAddress", "192.168.1.1");
nodes = m_nodeDao.findMatching(cb.toCriteria());
assertEquals(1, nodes.size());
}
use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class DefaultRtcService method createOutageCriteria.
/**
* <p>Create a {@link OnmsCriteria} that will select {@link OnmsOutage} objects.</p>
*
* <p>CAUTION: This criteria must contain a JOIN alias to the node table called 'node' so that the
* {@link org.opennms.dashboard.server.CriteriaAddingVisitor.addCriteriaForCategories(OnmsCriteria, String...)}
* function can add a category-based restriction on matching node IDs to the criteria.</p>
*
* @return a {@link org.opennms.netmgt.model.OnmsCriteria} object.
*/
@Override
public OnmsCriteria createOutageCriteria() {
OnmsCriteria outageCriteria = new OnmsCriteria(OnmsOutage.class, "outage");
outageCriteria.createAlias("monitoredService", "monitoredService", OnmsCriteria.INNER_JOIN);
outageCriteria.add(Restrictions.eq("monitoredService.status", "A"));
outageCriteria.createAlias("monitoredService.ipInterface", "ipInterface", OnmsCriteria.INNER_JOIN);
outageCriteria.add(Restrictions.ne("ipInterface.isManaged", "D"));
// Required for {@link org.opennms.dashboard.server.CriteriaAddingVisitor.addCriteriaForCategories(OnmsCriteria, String...)}
// to work properly.
outageCriteria.createAlias("monitoredService.ipInterface.node", "node", OnmsCriteria.INNER_JOIN);
outageCriteria.add(Restrictions.ne("node.type", "D"));
return outageCriteria;
}
use of org.opennms.netmgt.model.OnmsCriteria in project opennms by OpenNMS.
the class DefaultRtcService method getNodeList.
/**
* <p>getNodeList</p>
*
* @return a {@link org.opennms.web.svclayer.model.RtcNodeModel} object.
*/
@Override
public RtcNodeModel getNodeList() {
OnmsCriteria serviceCriteria = createServiceCriteria();
OnmsCriteria outageCriteria = createOutageCriteria();
return getNodeListForCriteria(serviceCriteria, outageCriteria);
}
Aggregations