Search in sources :

Example 36 with Criteria

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);
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsOutage(org.opennms.netmgt.model.OnmsOutage) Criteria(org.opennms.core.criteria.Criteria) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

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

Example 38 with Criteria

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);
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) Criteria(org.opennms.core.criteria.Criteria) BusinessServiceEntity(org.opennms.netmgt.bsm.persistence.api.BusinessServiceEntity) NoSuchElementException(java.util.NoSuchElementException)

Example 39 with Criteria

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

Example 40 with 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);
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) Criteria(org.opennms.core.criteria.Criteria)

Aggregations

Criteria (org.opennms.core.criteria.Criteria)62 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)31 Test (org.junit.Test)16 EqRestriction (org.opennms.core.criteria.restrictions.EqRestriction)16 Date (java.util.Date)13 Alias (org.opennms.core.criteria.Alias)13 ArrayList (java.util.ArrayList)10 Order (org.opennms.core.criteria.Order)9 Transactional (org.springframework.transaction.annotation.Transactional)9 GET (javax.ws.rs.GET)8 PUT (javax.ws.rs.PUT)7 OnmsNode (org.opennms.netmgt.model.OnmsNode)7 POST (javax.ws.rs.POST)6 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)5 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)5 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)5 Produces (javax.ws.rs.Produces)4 EventDao (org.opennms.netmgt.dao.api.EventDao)4 ScanReport (org.opennms.netmgt.model.ScanReport)4 ScanReportRestService (org.opennms.web.rest.v2.ScanReportRestService)4