Package ubic.gemma.persistence.util
Class FilterQueryUtils
- java.lang.Object
-
- ubic.gemma.persistence.util.FilterQueryUtils
-
-
Constructor Summary
Constructors Constructor Description FilterQueryUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addRestrictionParameters(Query query, Filters filters)
Adds all parameters contained in the filters argument to the query by callingQuery.setParameter(String, Object)
orQuery.setParameterList(String, Collection)
as needed.static String
formOrderByClause(Sort sort)
Forms an order by clause for a Hibernate query based on given arguments.static String
formRestrictionClause(Filters filters)
Creates a CNF restriction clause from the given Filters list.
-
-
-
Method Detail
-
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 callingQuery.setParameter(String, Object)
orQuery.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
Filter#getRequiredValue()
is aCollection
, it will be sorted and duplicates will be excluded.- Parameters:
query
- the query that needs parameters populated.filters
- filters that provide the parameter values.
-
-