Search in sources :

Example 1 with PropertyNotFoundException

use of org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException in project opennms by OpenNMS.

the class AbstractDaoRestService method getCriteria.

protected Criteria getCriteria(UriInfo uriInfo, SearchContext searchContext) {
    final MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
    final CriteriaBuilder builder = getCriteriaBuilder();
    if (searchContext != null) {
        try {
            SearchCondition<T> condition = searchContext.getCondition(getDaoClass());
            if (condition != null) {
                SearchConditionVisitor<T, CriteriaBuilder> visitor = new CriteriaBuilderSearchVisitor<T>(builder, getDaoClass());
                condition.accept(visitor);
            }
        } catch (PropertyNotFoundException | ArrayIndexOutOfBoundsException e) {
            LOG.warn(e.getClass().getSimpleName() + " while parsing FIQL search, ignoring: " + e.getMessage(), e);
        }
    }
    // Apply limit, offset, orderBy, order params
    applyLimitOffsetOrderBy(params, builder);
    Criteria crit = builder.toCriteria();
    return crit;
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) PropertyNotFoundException(org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException) GET(javax.ws.rs.GET) POST(javax.ws.rs.POST) PUT(javax.ws.rs.PUT) Criteria(org.opennms.core.criteria.Criteria) CriteriaBuilderSearchVisitor(org.opennms.web.rest.support.CriteriaBuilderSearchVisitor)

Example 2 with PropertyNotFoundException

use of org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException in project opennms by OpenNMS.

the class AbstractDaoRestServiceWithDTO method getCriteria.

protected Criteria getCriteria(UriInfo uriInfo, SearchContext searchContext) {
    final CriteriaBuilder builder = getCriteriaBuilder(uriInfo);
    if (searchContext != null) {
        try {
            SearchCondition<Q> condition = searchContext.getCondition(getQueryBeanClass(), getSearchBeanPropertyMap());
            if (condition != null) {
                SearchConditionVisitor<Q, CriteriaBuilder> visitor = new CriteriaBuilderSearchVisitor<T, Q>(builder, getDaoClass(), getCriteriaBehaviors());
                condition.accept(visitor);
            }
        } catch (PropertyNotFoundException | ArrayIndexOutOfBoundsException e) {
            LOG.warn(e.getClass().getSimpleName() + " while parsing FIQL search, ignoring: " + e.getMessage(), e);
        }
    }
    // Apply limit, offset, orderBy, order parameters
    final MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
    applyLimitOffsetOrderBy(params, builder);
    Criteria crit = builder.toCriteria();
    /*
         * TODO: Figure out how to do stuff like this
         * 
         * // Don't include deleted nodes by default
         * final String type = params.getFirst("type");
         * if (type == null) {
         *     final List<Restriction> restrictions = new ArrayList<Restriction>(crit.getRestrictions());
         *     restrictions.add(Restrictions.ne("type", "D"));
         *     crit.setRestrictions(restrictions);
         * }
         */
    return crit;
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) PropertyNotFoundException(org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException) Criteria(org.opennms.core.criteria.Criteria) CriteriaBuilderSearchVisitor(org.opennms.web.rest.support.CriteriaBuilderSearchVisitor)

Aggregations

PropertyNotFoundException (org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException)2 Criteria (org.opennms.core.criteria.Criteria)2 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)2 CriteriaBuilderSearchVisitor (org.opennms.web.rest.support.CriteriaBuilderSearchVisitor)2 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1