use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class AlarmSearchProvider method findAlarms.
private List<OnmsAlarm> findAlarms(final List<SearchResult> results, final String queryString) {
CriteriaBuilder bldr = new CriteriaBuilder(OnmsAlarm.class);
OnmsSeverity severity = OnmsSeverity.get(queryString);
List<OnmsAlarm> alarms;
if (!OnmsSeverity.INDETERMINATE.equals(severity)) {
bldr = new CriteriaBuilder(OnmsAlarm.class);
bldr.eq("severity", severity);
alarms = alarmProvider.findMatchingAlarms(bldr.toCriteria());
if (alarms.size() > 0) {
AlarmSearchResult result = new AlarmSearchResult(queryString);
result.setSeverityQuery(true);
results.add(result);
}
} else {
bldr.isNotNull("node").ilike("uei", "%" + queryString + "%").orderBy("node");
alarms = alarmProvider.findMatchingAlarms(bldr.toCriteria());
}
return alarms;
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class ApplicationSearchProvider method query.
@Override
public List<SearchResult> query(SearchQuery searchQuery, GraphContainer container) {
LOG.info("ApplicationServiceSearchProvider->query: called with search query: '{}'", searchQuery);
List<SearchResult> results = Lists.newArrayList();
String queryString = searchQuery.getQueryString();
CriteriaBuilder bldr = new CriteriaBuilder(OnmsApplication.class);
if (queryString != null && queryString.length() > 0) {
bldr.ilike("name", String.format("%%%s%%", queryString));
}
bldr.orderBy("name", true);
bldr.limit(10);
Criteria dbQueryCriteria = bldr.toCriteria();
for (OnmsApplication application : applicationDao.findMatching(dbQueryCriteria)) {
final ApplicationVertex applicationVertex = new ApplicationVertex(application);
SearchResult searchResult = new SearchResult(applicationVertex, true, false);
results.add(searchResult);
}
LOG.info("ApplicationServiceSearchProvider->query: found {} results: {}", results.size(), results);
return results;
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class MinionRestService method getMinions.
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
@Transactional
public OnmsMinionCollection getMinions(@Context final UriInfo uriInfo) throws ParseException {
final CriteriaBuilder builder = getCriteriaBuilder(uriInfo.getQueryParameters());
final OnmsMinionCollection coll = new OnmsMinionCollection(m_minionDao.findMatching(builder.toCriteria()));
coll.setTotalCount(m_minionDao.countMatching(builder.clearOrder().toCriteria()));
return coll;
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class IfServicesRestService method getCriteria.
private static Criteria getCriteria(final MultivaluedMap<String, String> params) {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsMonitoredService.class);
builder.alias("ipInterface.snmpInterface", "snmpInterface", JoinType.LEFT_JOIN);
builder.alias("ipInterface", "ipInterface", JoinType.LEFT_JOIN);
builder.alias("ipInterface.node", "node", JoinType.LEFT_JOIN);
builder.alias("ipInterface.node.categories", "category", JoinType.LEFT_JOIN);
builder.alias("serviceType", "serviceType", JoinType.LEFT_JOIN);
builder.orderBy("id");
applyQueryFilters(params, builder);
return builder.toCriteria();
}
use of org.opennms.core.criteria.CriteriaBuilder in project opennms by OpenNMS.
the class NotificationRestService method getCriteriaBuilder.
private static CriteriaBuilder getCriteriaBuilder(final MultivaluedMap<String, String> params) {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsNotification.class);
builder.alias("node", "node", JoinType.LEFT_JOIN);
builder.alias("node.snmpInterfaces", "snmpInterface", JoinType.LEFT_JOIN);
builder.alias("node.ipInterfaces", "ipInterface", JoinType.LEFT_JOIN);
builder.alias("event", "event", JoinType.LEFT_JOIN);
builder.alias("usersNotified", "usersNotified", JoinType.LEFT_JOIN);
applyQueryFilters(params, builder);
return builder;
}
Aggregations