Class FilterArg<O extends Identifiable>

  • All Implemented Interfaces:
    Arg<FilterArg.Filter>

    public class FilterArg<O extends Identifiable>
    extends AbstractArg<FilterArg.Filter>
    Represent a filter argument designed to generate a Filters from user input.

    Filtering can be done on any property or nested property of an entity managed by a FilteringService. E.g: 'curationDetails' or 'curationDetails.lastTroubledEvent.date'.

    Any property of a supported type. Currently, supported types are:

    String
    Property of String type. Strings that contain parenthesis (), comma , or space ' ' characters, or empty strings must be quoted with double-quotes ". Double-quotes can be escaped with a backslash character: \".
    Number
    Any Number implementation (i.e. Float, Double, Integer, Long, and their corresponding primitive types). Required value must be a string parseable to the specific Number type.
    Boolean
    Required value will be parsed to true only if the string matches true, ignoring case.
    Date
    Property of Date, required value must be an ISO 8601 formatted date or datetime, UTC is assumed of no timezone is supplied
    Collection
    Property of a Collection of any type aforementioned, nested collections are not supported

    Accepted operator keywords are:

    =
    Equality
    !=
    Non-equality
    <
    Smaller than (only Number and Date types)
    >
    Larger than (only Number and Date types)
    <=
    Smaller or equal (only Number and Date types)
    >=
    Larger or equal (only Number and Date types)
    like or LIKE
    Similar string, effectively means 'begins with', translates to the SQL LIKE operator where a '%' is appended to the given value (only String type)
    in or IN
    Required value in the given collection with the semantic of the '=' equality operator (only for Collection types)

    See Filter.Operator for more details on the available operators.

    Properties, operators and required values must be delimited by spaces.

    Multiple filters can be chained using conjunctions (i.e. AND, and) or disjunctions (i.e. OR, or, ',') keywords. Example:
    property1 < value1 AND property2 like value2

    Queries mixing conjunctions and disjunctions are interpreted in conjunctive normal form (CNF) without any parentheses. Every AND conjunctions separates blocks of OR disjunctions.

    Example:
    p1 = v1 OR p1 != v2 AND p2 <=v2 AND p3 > v3, p3 < v4

    Above query will translate to:
    (p1 = v1 OR p1 != v2) AND (p2 <= v2) AND (p3 > v3 OR p3 < v4)

    Breaking the CNF results in an error.

    The format of collection is a sequence of comma-delimited values surrounded by parenthesis. The values must be compatible with the type contained in the collection.

    Example:
    id in (1,2,3,4)

    The available filterable properties on an entity can be retrieved from FilteringService.getFilterableProperties().

    Author:
    tesarst, poirigui
    See Also:
    Filters, Filter, Filter.Operator, FilteringService
    • Field Detail

      • MAX_CLAUSES

        public static final int MAX_CLAUSES
        Maximum number of clauses that can appear in a filter expression.
        See Also:
        Constant Field Values
    • Method Detail

      • valueOf

        public static <O extends IdentifiableFilterArg<O> valueOf​(String s)
        Used by RS to parse value of request parameters.

        The filter string may be compressed and base64-encoded.

        Parameters:
        s - the request filter string.
        Returns:
        an instance of DatasetFilterArg representing the filtering options in the given string.