Search in sources :

Example 11 with EqRestriction

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);
}
Also used : EqRestriction(org.opennms.core.criteria.restrictions.EqRestriction) Criteria(org.opennms.core.criteria.Criteria) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with EqRestriction

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;
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) Alias(org.opennms.core.criteria.Alias) OnmsNode(org.opennms.netmgt.model.OnmsNode) ArrayList(java.util.ArrayList) EqRestriction(org.opennms.core.criteria.restrictions.EqRestriction) Criteria(org.opennms.core.criteria.Criteria)

Example 13 with EqRestriction

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);
}
Also used : EqRestriction(org.opennms.core.criteria.restrictions.EqRestriction) Criteria(org.opennms.core.criteria.Criteria) GtRestriction(org.opennms.core.criteria.restrictions.GtRestriction)

Example 14 with EqRestriction

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);
}
Also used : EqRestriction(org.opennms.core.criteria.restrictions.EqRestriction) NeRestriction(org.opennms.core.criteria.restrictions.NeRestriction) Criteria(org.opennms.features.topology.api.topo.Criteria)

Example 15 with EqRestriction

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;
}
Also used : Matcher(java.util.regex.Matcher) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Criteria(org.opennms.features.topology.api.topo.Criteria) EqRestriction(org.opennms.core.criteria.restrictions.EqRestriction)

Aggregations

EqRestriction (org.opennms.core.criteria.restrictions.EqRestriction)23 Criteria (org.opennms.core.criteria.Criteria)16 Alias (org.opennms.core.criteria.Alias)12 OnmsNode (org.opennms.netmgt.model.OnmsNode)7 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)5 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 NullRestriction (org.opennms.core.criteria.restrictions.NullRestriction)4 Test (org.junit.Test)3 NeRestriction (org.opennms.core.criteria.restrictions.NeRestriction)3 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)3 Transactional (org.springframework.transaction.annotation.Transactional)3 InetAddress (java.net.InetAddress)2 Matcher (java.util.regex.Matcher)2 Criteria (org.opennms.features.topology.api.topo.Criteria)2 LldpElement (org.opennms.netmgt.model.LldpElement)2 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)2 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)2 LocalDateTime (java.time.LocalDateTime)1