use of org.opennms.core.criteria.Criteria in project opennms by OpenNMS.
the class PollerIT method getOutages.
/**
* Retrieves all of the outages (using DAOs) associated with
* the given service.
*/
private List<OnmsOutage> getOutages(MockService svc) {
OnmsMonitoredService monitoredSvc = m_monitoredServiceDao.get(svc.getNodeId(), svc.getAddress(), svc.getSvcName());
Criteria criteria = new CriteriaBuilder(OnmsOutage.class).eq("monitoredService", monitoredSvc).orderBy("ifLostService").toCriteria();
return m_outageDao.findMatching(criteria);
}
use of org.opennms.core.criteria.Criteria in project opennms by OpenNMS.
the class EnhancedLinkdServiceImpl method getSnmpNode.
@Override
public Node getSnmpNode(final int nodeid) {
final Criteria criteria = new Criteria(OnmsNode.class);
criteria.setAliases(Arrays.asList(new Alias[] { new Alias("ipInterfaces", "iface", JoinType.LEFT_JOIN) }));
criteria.addRestriction(new EqRestriction("type", NodeType.ACTIVE));
criteria.addRestriction(new EqRestriction("iface.isSnmpPrimary", PrimaryType.PRIMARY));
criteria.addRestriction(new EqRestriction("id", nodeid));
final List<OnmsNode> nodes = m_nodeDao.findMatching(criteria);
if (nodes.size() > 0) {
final OnmsNode node = nodes.get(0);
return new Node(node.getId(), node.getPrimaryInterface().getIpAddress(), node.getSysObjectId(), node.getSysName(), node.getLocation() == null ? null : node.getLocation().getLocationName());
} else {
return null;
}
}
use of org.opennms.core.criteria.Criteria 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.Criteria in project opennms by OpenNMS.
the class AlarmStatsRestService method getNewestUnacknowledged.
private OnmsAlarm getNewestUnacknowledged(final OnmsSeverity severity) {
final CriteriaBuilder builder = getCriteriaBuilder(severity);
builder.orderBy("lastEventTime").desc();
builder.orderBy("id").desc();
builder.limit(1);
final Criteria criteria = builder.toCriteria();
LOG.debug("getNewestUnacknowledged({}) criteria = {}", severity, criteria);
return m_statisticsService.getUnacknowledged(criteria);
}
use of org.opennms.core.criteria.Criteria in project opennms by OpenNMS.
the class AlarmStatsRestService method getOldestAcknowledged.
protected OnmsAlarm getOldestAcknowledged(final OnmsSeverity severity) {
final CriteriaBuilder builder = getCriteriaBuilder(severity);
builder.orderBy("firstEventTime").asc();
builder.orderBy("id").asc();
builder.limit(1);
final Criteria criteria = builder.toCriteria();
LOG.debug("getOldestAcknowledged({}) criteria = {}", severity, criteria);
return m_statisticsService.getAcknowledged(criteria);
}
Aggregations