use of org.opennms.core.criteria.restrictions.EqRestriction in project opennms by OpenNMS.
the class DefaultLocationDataService method getLocationInfoForMonitor.
/** {@inheritDoc} */
@Transactional
@Override
public LocationInfo getLocationInfoForMonitor(Integer monitorId) {
waitForGeocoding("getLocationInfoForMonitor");
final Criteria criteria = new Criteria(OnmsLocationMonitor.class).addRestriction(new EqRestriction("id", monitorId));
final List<OnmsLocationMonitor> monitors = m_locationDao.findMatching(criteria);
if (monitors == null) {
LOG.warn("unable to get location monitor list for monitor ID '{}'", monitorId);
return null;
}
final String definitionName = monitors.get(0).getLocation();
final OnmsMonitoringLocation def = m_monitoringLocationDao.get(definitionName);
if (def == null) {
LOG.warn("unable to find monitoring location definition for '{}'", definitionName);
return null;
}
return getLocationInfo(def);
}
use of org.opennms.core.criteria.restrictions.EqRestriction in project opennms by OpenNMS.
the class EnhancedLinkdServiceImpl method getSnmpNodeList.
@Override
public List<Node> getSnmpNodeList() {
final List<Node> nodes = new ArrayList<Node>();
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));
for (final OnmsNode node : m_nodeDao.findMatching(criteria)) {
nodes.add(new Node(node.getId(), node.getPrimaryInterface().getIpAddress(), node.getSysObjectId(), node.getSysName(), node.getLocation() == null ? null : node.getLocation().getLocationName()));
}
return nodes;
}
use of org.opennms.core.criteria.restrictions.EqRestriction in project opennms by OpenNMS.
the class HypericAckProcessor method fetchUnclearedHypericAlarms.
/**
* <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));
// Query list of outstanding alerts with remote platform identifiers
return m_alarmDao.findMatching(criteria);
}
use of org.opennms.core.criteria.restrictions.EqRestriction in project opennms by OpenNMS.
the class LinkdEdgeStatusProvider method getLinkdEdgeDownAlarms.
protected List<OnmsAlarm> getLinkdEdgeDownAlarms() {
org.opennms.core.criteria.Criteria criteria = new org.opennms.core.criteria.Criteria(OnmsAlarm.class);
criteria.addRestriction(new EqRestriction("uei", EventConstants.TOPOLOGY_LINK_DOWN_EVENT_UEI));
criteria.addRestriction(new NeRestriction("severity", OnmsSeverity.CLEARED));
return getAlarmDao().findMatching(criteria);
}
use of org.opennms.core.criteria.restrictions.EqRestriction in project opennms by OpenNMS.
the class NCSEdgeStatusProvider method getNCSImpactedAlarms.
private Set<String> getNCSImpactedAlarms() {
org.opennms.core.criteria.Criteria criteria = new org.opennms.core.criteria.Criteria(OnmsAlarm.class);
criteria.addRestriction(new EqRestriction("uei", "uei.opennms.org/internal/ncs/componentImpacted"));
List<OnmsAlarm> alarms = getAlarmDao().findMatching(criteria);
Set<String> alarmsSet = new HashSet<String>();
for (OnmsAlarm alarm : alarms) {
String eventParms = alarm.getEventParms();
Matcher foreignSourceMatcher = m_foreignSourcePattern.matcher(eventParms);
Matcher foreignIdMatcher = m_foreignIdPattern.matcher(eventParms);
String foreignSource = null;
while (foreignSourceMatcher.find()) {
foreignSource = foreignSourceMatcher.group(1);
}
String foreignId = null;
while (foreignIdMatcher.find()) {
foreignId = foreignIdMatcher.group(1);
}
if (foreignSource != null && foreignId != null) {
alarmsSet.add(foreignSource + "::" + foreignId);
}
}
return alarmsSet;
}
Aggregations