public static GtRestriction gt(final String attribute, final Object comparator) { return new GtRestriction(attribute, comparator); }
public static GtRestriction gt(final String attribute, final Object comparator) { return new GtRestriction(attribute, comparator); }
private Map<Integer, List<OnmsOutage>> getOutages(List<Integer> nodeIds, List<String> serviceNames, Date start, Date end) { if (nodeIds == null || nodeIds.size() == 0) { return Maps.newHashMap(); } final CriteriaBuilder builder = new CriteriaBuilder(OnmsOutage.class) // The outage must have started before the end of the window .le("ifLostService", end) .or(new NullRestriction("ifRegainedService"), // The outage is ongoing new AllRestriction( // or the outage was cleared somewhere in the window new GtRestriction("ifRegainedService", start), new LeRestriction("ifRegainedService", end)) ) // Only select outages affecting our nodes .alias("monitoredService", "monitoredService") .alias("monitoredService.ipInterface", "ipInterface") .alias("ipInterface.node", "node") .eq("ipInterface.isManaged", "M") .in("node.id", nodeIds); // Only select outages affecting services with the given names, if set if (serviceNames != null && serviceNames.size() > 0) { builder.alias("monitoredService.serviceType", "serviceType") .in("serviceType.name", serviceNames); } // Retrieve the outages and group them by node id return m_outageDao.findMatching(builder.toCriteria()).stream() .collect(Collectors.groupingBy(OnmsOutage::getNodeId)); }
/** * <p>fetchUnclearedHypericAlarms</p> * * @return a {@link java.util.List} object. */ public List<OnmsAlarm> fetchUnclearedHypericAlarms() { // Query for existing, unacknowledged alarms in OpenNMS that were generated based on Hyperic alerts Criteria criteria = new Criteria(OnmsAlarm.class); // criteria.add(Restrictions.isNull("alarmAckUser")); // Restrict to Hyperic alerts criteria.addRestriction(new EqRestriction("uei", "uei.opennms.org/external/hyperic/alert")); // Only consider alarms that are above severity NORMAL // {@see org.opennms.netmgt.model.OnmsSeverity} criteria.addRestriction(new GtRestriction("severity", OnmsSeverity.NORMAL)); // TODO Figure out how to query by parameters (maybe necessary) // Query list of outstanding alerts with remote platform identifiers return m_alarmDao.findMatching(criteria); }