Class QueryHelper


  • public class QueryHelper
    extends Object
    Contains helper methods for querydsl
    • Constructor Detail

      • QueryHelper

        public QueryHelper()
    • 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
      • 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
      • 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 data
        userId - The user id to check
        brokerIds - The de-normalized list of broker ids of the user to check
        displayForManagers - The display for managers of the user to check
        displayForOthers - 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 a CacheFlusher, and invoking the given closure for each iterator element. The CloseableIterator.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.