Uploaded image for project: '[Read Only] - Hippo Site Toolkit 2'
  1. [Read Only] - Hippo Site Toolkit 2
  2. HSTTWO-3829

Support orderBy[CaseInsensitive](order, fieldNames) in fluent query api

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • 4.1.0
    • None
    • None
    • Platform Sprint 140

    Description

      Currently, you'd be required to write the following code:

      if (sortBy != null && !sortBy.isEmpty()) {
                      if (sortOrder == null || sortOrder.isEmpty() || "descending".equals(sortOrder)) {
                         HstQueryBuilder.create(scope)
                            .ofTypes(docType)
                            .orderByDescending(sortBy)
                            .limit(pageSize)
                            .offset(pageSize * (crPage - 1))
                            .build(); 
                      } else {
                        HstQueryBuilder.create(scope)
                            .ofTypes(docType)
                            .orderByAscescending(sortBy)
                            .limit(pageSize)
                            .offset(pageSize * (crPage - 1))
                            .build(); 
                          hstQuery.addOrderByAscending(sortBy);
                      }
        }
      

      The above is really unhandy. I want to be able to write

       HstQueryBuilder.create(scope)
                            .ofTypes(docType)
                            .sortBy(sortOrder, sortBy)
                            .limit(pageSize)
                            .offset(pageSize * (crPage - 1))
                            .build(); 
      

      and if and only if sortOrder.equals("descending") (case insentive), then sort descending.

      NOTE I also want to rename orderByAscescending to sortByAscescending (also for descending).

      The above logic also goes for sort by case insensitive

      Attachments

        Activity

          People

            Unassigned Unassigned
            aschrijvers Ard Schrijvers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: