Search in sources :

Example 1 with OnmsAlarmCollection

use of org.opennms.netmgt.model.OnmsAlarmCollection in project opennms by OpenNMS.

the class AlarmRestService method getAlarms.

/**
 * <p>
 * getAlarms
 * </p>
 *
 * @return a {@link org.opennms.netmgt.model.OnmsAlarmCollection} object.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
@Transactional
public OnmsAlarmCollection getAlarms(@Context final SecurityContext securityContext, @Context final UriInfo uriInfo) {
    SecurityHelper.assertUserReadCredentials(securityContext);
    final CriteriaBuilder builder = getCriteriaBuilder(uriInfo.getQueryParameters(), false);
    builder.distinct();
    final OnmsAlarmCollection coll = new OnmsAlarmCollection(m_alarmDao.findMatching(builder.toCriteria()));
    // For getting totalCount
    coll.setTotalCount(m_alarmDao.countMatching(builder.count().toCriteria()));
    return coll;
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsAlarmCollection(org.opennms.netmgt.model.OnmsAlarmCollection) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)1 OnmsAlarmCollection (org.opennms.netmgt.model.OnmsAlarmCollection)1 Transactional (org.springframework.transaction.annotation.Transactional)1