use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class AlarmStatisticsServiceTest method testCountBySeverity.
@Test
public void testCountBySeverity() {
final CriteriaBuilder cb = new CriteriaBuilder(OnmsAlarm.class);
cb.ge("severity", OnmsSeverity.NORMAL);
cb.fetch("firstEvent", FetchType.EAGER);
cb.fetch("lastEvent", FetchType.EAGER);
cb.alias("node", "node", JoinType.LEFT_JOIN);
cb.alias("node.snmpInterfaces", "snmpInterface", JoinType.LEFT_JOIN);
cb.alias("node.ipInterfaces", "ipInterface", JoinType.LEFT_JOIN);
cb.distinct();
final int count = m_statisticsService.getTotalCount(cb.toCriteria());
assertEquals(1, count);
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class AlarmStatisticsServiceTest method testCount.
@Test
public void testCount() {
final CriteriaBuilder cb = new CriteriaBuilder(OnmsAlarm.class);
cb.fetch("firstEvent", FetchType.EAGER);
cb.fetch("lastEvent", FetchType.EAGER);
cb.alias("node", "node", JoinType.LEFT_JOIN);
cb.alias("node.snmpInterfaces", "snmpInterface", JoinType.LEFT_JOIN);
cb.alias("node.ipInterfaces", "ipInterface", JoinType.LEFT_JOIN);
cb.distinct();
final int count = m_statisticsService.getTotalCount(cb.toCriteria());
assertEquals(1, count);
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class AbstractBusinessServiceRestServiceIT method findEntityByName.
private BusinessServiceEntity findEntityByName(String name) {
Criteria criteria = new CriteriaBuilder(BusinessServiceEntity.class).eq("name", name).toCriteria();
List<BusinessServiceEntity> matching = m_businessServiceDao.findMatching(criteria);
if (matching.isEmpty()) {
throw new NoSuchElementException("Did not find business service with name '" + name + "'.");
}
return matching.get(0);
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class DefaultPollContext method getPollableNodes.
@Override
public List<OnmsIpInterface> getPollableNodes() {
CriteriaBuilder builder = new CriteriaBuilder(OnmsIpInterface.class);
builder.eq("isSnmpPrimary", PrimaryType.PRIMARY).eq("isManaged", "M");
return getIpInterfaceDao().findMatching(builder.toCriteria());
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class DefaultPollContext method getPollableNodesByIp.
@Override
public List<OnmsIpInterface> getPollableNodesByIp(String ipaddr) {
CriteriaBuilder builder = new CriteriaBuilder(OnmsIpInterface.class);
builder.eq("ipAddress", InetAddressUtils.addr(ipaddr)).eq("isSnmpPrimary", PrimaryType.PRIMARY).eq("isManaged", "M");
return getIpInterfaceDao().findMatching(builder.toCriteria());
}
Aggregations