Class FilterQueryUtils

java.lang.Object
ubic.gemma.persistence.util.FilterQueryUtils

public class FilterQueryUtils extends Object
Utilities for integrating Filter into Query.
  • Constructor Details

    • FilterQueryUtils

      public FilterQueryUtils()
  • Method Details

    • formOrderByClause

      public static String formOrderByClause(@Nullable Sort sort)
      Forms an order by clause for a Hibernate query based on given arguments.
      Parameters:
      sort - the property and direction the query should be ordered by.
      Returns:
      an order by clause. Empty string if the orderByProperty argument is null or empty.
    • formRestrictionClause

      public static String formRestrictionClause(@Nullable Filters filters)
      Creates a CNF restriction clause from the given Filters list. FIXME The problem with this: it assumes the join is already there.
      Parameters:
      filters - A list of filtering properties arrays. Elements in each array will be in a disjunction (OR) with each other. Arrays will then be in a conjunction (AND) with each other. I.e. The filter will be in a conjunctive normal form. [0 OR 1 OR 2] AND [0 OR 1] AND [0 OR 1 OR 3]
      Returns:
      a string containing the clause, without the leading "WHERE" keyword.
    • addRestrictionParameters

      public static void addRestrictionParameters(Query query, @Nullable Filters filters)
      Adds all parameters contained in the filters argument to the query by calling Query.setParameter(String, Object) or Query.setParameterList(String, Collection) as needed.

      Use this if you've appended formRestrictionClause(Filters) to the query so that the provided filters will be bound.

      If the

      invalid reference
      Filter#getRequiredValue()
      is a Collection, it will be sorted and duplicates will be excluded.
      Parameters:
      query - the query that needs parameters populated.
      filters - filters that provide the parameter values.