/** * Extract constraint from query parameters. * * @param uriInfo contains query parameters if set * @param clz the individual return type expected from the query * @return constraint in correct format */ public static String getConstraint(UriInfo uriInfo, Class<?> clz) { return getConstraint(uriInfo, null, clz); }
/** * Extract constraint from query parameters. * * @param uriInfo contains query parameters if set * @param defaultQuery raw query to use if not present in URI parameters * @param clz the individual return type expected from the query * @param typePrefix true if return type prefix is to be included * @return constraint in correct format */ public static String getConstraint(UriInfo uriInfo, String defaultQuery, Class<?> clz, boolean typePrefix) { MultivaluedMap<String, String> queries = uriInfo.getQueryParameters(); String prefix = typePrefix ? RETURN_TYPES.get(clz) : ""; HashMap<String, String> constraints = getConstraints(queries, CONSTRAINT_PARAMETER); return constraints != null && constraints.containsKey(CONSTRAINT_PARAMETER) ? prefix + constraints.get(CONSTRAINT_PARAMETER) : defaultQuery != null ? prefix + defaultQuery : null; }
/** * Extract constraint from query parameters. * * @param uriInfo contains query parameters if set * @param clz the individual return type expected from the query * @param typePrefix true if return type prefix is to be included * @return constraint in correct format */ public static String getConstraint(UriInfo uriInfo, Class<?> clz, boolean typePrefix) { return getConstraint(uriInfo, null, clz, typePrefix); }
/** * Extract constraint from query parameters. * * @param uriInfo contains query parameters if set * @param defaultQuery raw query to use if not present in URI parameters * @param clz the individual return type expected from the query * @return constraint in correct format */ public static String getConstraint(UriInfo uriInfo, String defaultQuery, Class<?> clz) { return getConstraint(uriInfo, defaultQuery, clz, true); }
public static HashMap<String, String> getConstraints(MultivaluedMap<String, String> queries, String... constraints) { HashMap<String, String> params = new HashMap<String, String>(); if (constraints != null && constraints.length >0) { for (String key : constraints) { String value = getConstraint(queries, key); if (value != null && !value.isEmpty()) { params.put(key, value); } } } return params; } }
protected String getSelectCommand(String root, UriInfo uriInfo, Class<?> collectionType, boolean typePrefix) { String ret = root; String constraint = QueryHelper.getConstraint(uriInfo, collectionType, typePrefix); if (constraint != null) { ret = new StringBuffer(root).append(SEARCH_TEXT) .append(PowerShellUtils.escape(constraint)) .toString(); } return ret; }
protected boolean filter(R resource, UriInfo uriInfo, Class<?> clz) { String constraint = uriInfo != null ? QueryHelper.getConstraint(uriInfo, clz) : null; return constraint != null ? evaluator.satisfies(resource, constraint) : true; } }