Package org.cyclos.impl.utils
Class QueryHelper
- java.lang.Object
-
- org.cyclos.impl.utils.QueryHelper
-
public class QueryHelper extends Object
Contains helper methods for querydsl
-
-
Constructor Summary
Constructors Constructor Description QueryHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidapplyMaxResultsOnMap(SessionData sessionData, QueryParameters params)When the given query parameter has no page size, or it is greater than max results on map, set the page size = max results on map.static <T> Page<T>buildPage(SessionData sessionData, List<T> list, Integer _pageSize, Integer _currentPage)Builds a page from an in-memory liststatic <T> Page<T>buildPage(SessionData sessionData, List<T> list, QueryParameters params)Builds a page from an in-memory liststatic com.querydsl.core.types.Expression<Double>days(com.querydsl.core.types.Path<TimeInterval> path)Returns an expression which represents the number of days on this intervalstatic <T> Page<T>emptyPage(SessionData sessionData, Integer _pageSize, Integer _currentPage)Builds an empty pagestatic <T> Page<T>emptyPage(SessionData sessionData, QueryParameters params)Builds an empty pagestatic <E extends Enum<E>>
com.querydsl.core.types.dsl.NumberExpression<Integer>enumOrdinal(com.querydsl.core.types.dsl.EnumPath<E> path)Returns an expression that maps each enum value to its ordinalstatic StringgetUserDisplay(SessionData sessionData, Long userId, String brokerIds, String displayForManagers, String displayForOthers)Resolve the user displaystatic booleanisUnlimited(QueryParameters params)static <Q extends QueryParameters>
QnewQuery(Class<Q> type)Initializes an empty query of the given type, with both current page and page size filled instatic com.querydsl.core.types.OrderSpecifier<?>orderSpecifier(com.querydsl.core.types.EntityPath<?> path)Returns an ascending order specifier suitable for the given entity path.static com.querydsl.core.types.OrderSpecifier<?>orderSpecifier(com.querydsl.core.types.EntityPath<?> path, boolean asc)Returns an order specifier suitable for the given entity path.static <RT,Q extends com.querydsl.jpa.JPAQueryBase<?,Q>>
Page<RT>page(Q query, SessionData sessionData, Integer _currentPage, Integer _pageSize, boolean skipTotalCount, com.querydsl.core.types.Expression<RT> expr)Returns a result page for the given query and page parameters, using the given expression for projectionstatic <RT,Q extends com.querydsl.jpa.JPAQueryBase<?,Q>>
Page<RT>page(Q query, SessionData sessionData, QueryParameters queryParameters, com.querydsl.core.types.Expression<RT> expr)Returns a result page for the given query and page parameters, using the given expression for projectionstatic <T> com.querydsl.core.types.dsl.PathBuilder<T>pathBuilder(Class<T> clazz)Returns a path builder for the given entity classstatic <T> longprocessBatch(BaseEntityManagerHandler entityManagerHandler, Iterator<T> iterator, Consumer<T> closure)Processes the given iterator, by using aCacheFlusher, and invoking the given closure for each iterator element.static booleanuseAnyParameter(Collection<Object> values)Returns true if any of the given values should be used to filter the query.static booleanuseParameter(Object value)Returns whether the parameter should be used to filter the query or not.
-
-
-
Method Detail
-
applyMaxResultsOnMap
public static void applyMaxResultsOnMap(SessionData sessionData, QueryParameters params)
When the given query parameter has no page size, or it is greater than max results on map, set the page size = max results on map.
-
buildPage
public static <T> Page<T> buildPage(SessionData sessionData, List<T> list, Integer _pageSize, Integer _currentPage)
Builds a page from an in-memory list
-
buildPage
public static <T> Page<T> buildPage(SessionData sessionData, List<T> list, QueryParameters params)
Builds a page from an in-memory list
-
days
public static com.querydsl.core.types.Expression<Double> days(com.querydsl.core.types.Path<TimeInterval> path)
Returns an expression which represents the number of days on this interval
-
emptyPage
public static <T> Page<T> emptyPage(SessionData sessionData, Integer _pageSize, Integer _currentPage)
Builds an empty page
-
emptyPage
public static <T> Page<T> emptyPage(SessionData sessionData, QueryParameters params)
Builds an empty page
-
enumOrdinal
public static <E extends Enum<E>> com.querydsl.core.types.dsl.NumberExpression<Integer> enumOrdinal(com.querydsl.core.types.dsl.EnumPath<E> path)
Returns an expression that maps each enum value to its ordinal
-
getUserDisplay
public static String getUserDisplay(SessionData sessionData, Long userId, String brokerIds, String displayForManagers, String displayForOthers)
Resolve the user display- Parameters:
sessionData- The logged user's session datauserId- The user id to checkbrokerIds- The de-normalized list of broker ids of the user to checkdisplayForManagers- The display for managers of the user to checkdisplayForOthers- The display for others of the user to check
-
isUnlimited
public static boolean isUnlimited(QueryParameters params)
-
newQuery
public static <Q extends QueryParameters> Q newQuery(Class<Q> type)
Initializes an empty query of the given type, with both current page and page size filled in
-
orderSpecifier
public static com.querydsl.core.types.OrderSpecifier<?> orderSpecifier(com.querydsl.core.types.EntityPath<?> path)
Returns an ascending order specifier suitable for the given entity path. The attempted properties are .
-
orderSpecifier
public static com.querydsl.core.types.OrderSpecifier<?> orderSpecifier(com.querydsl.core.types.EntityPath<?> path, boolean asc)Returns an order specifier suitable for the given entity path. The attempted properties are .
-
page
public static <RT,Q extends com.querydsl.jpa.JPAQueryBase<?,Q>> Page<RT> page(Q query, SessionData sessionData, Integer _currentPage, Integer _pageSize, boolean skipTotalCount, com.querydsl.core.types.Expression<RT> expr)
Returns a result page for the given query and page parameters, using the given expression for projection
-
page
public static <RT,Q extends com.querydsl.jpa.JPAQueryBase<?,Q>> Page<RT> page(Q query, SessionData sessionData, QueryParameters queryParameters, com.querydsl.core.types.Expression<RT> expr)
Returns a result page for the given query and page parameters, using the given expression for projection
-
pathBuilder
public static <T> com.querydsl.core.types.dsl.PathBuilder<T> pathBuilder(Class<T> clazz)
Returns a path builder for the given entity class
-
processBatch
public static <T> long processBatch(BaseEntityManagerHandler entityManagerHandler, Iterator<T> iterator, Consumer<T> closure)
Processes the given iterator, by using aCacheFlusher, and invoking the given closure for each iterator element. TheCloseableIterator.close()method is guaranteed to be invoked
-
useAnyParameter
public static boolean useAnyParameter(Collection<Object> values)
Returns true if any of the given values should be used to filter the query. See useParameter(Object value)
-
useParameter
public static boolean useParameter(Object value)
Returns whether the parameter should be used to filter the query or not. If the value is "empty" the query must not add a filter with the specified value.
-
-