private void sortQueueGroups(List<OpenAcdQueueGroup> queueGroups) {
    // sort groups if requested
    SortInfo sortInfo = RestUtilities.calculateSorting(m_form);

    if (!sortInfo.sort) {
      return;
    }

    SortField sortField = SortField.toSortField(sortInfo.sortField);

    if (sortInfo.directionForward) {

      switch (sortField) {
        case NAME:
          Collections.sort(
              queueGroups,
              new Comparator() {

                public int compare(Object object1, Object object2) {
                  OpenAcdQueueGroup queueGroup1 = (OpenAcdQueueGroup) object1;
                  OpenAcdQueueGroup queueGroup2 = (OpenAcdQueueGroup) object2;
                  return RestUtilities.compareIgnoreCaseNullSafe(
                      queueGroup1.getName(), queueGroup2.getName());
                }
              });
          break;

        case DESCRIPTION:
          Collections.sort(
              queueGroups,
              new Comparator() {

                public int compare(Object object1, Object object2) {
                  OpenAcdQueueGroup queueGroup1 = (OpenAcdQueueGroup) object1;
                  OpenAcdQueueGroup queueGroup2 = (OpenAcdQueueGroup) object2;
                  return RestUtilities.compareIgnoreCaseNullSafe(
                      queueGroup1.getDescription(), queueGroup2.getDescription());
                }
              });
          break;
      }
    } else {
      // must be reverse
      switch (sortField) {
        case NAME:
          Collections.sort(
              queueGroups,
              new Comparator() {

                public int compare(Object object1, Object object2) {
                  OpenAcdQueueGroup queueGroup1 = (OpenAcdQueueGroup) object1;
                  OpenAcdQueueGroup queueGroup2 = (OpenAcdQueueGroup) object2;
                  return RestUtilities.compareIgnoreCaseNullSafe(
                      queueGroup2.getName(), queueGroup1.getName());
                }
              });
          break;

        case DESCRIPTION:
          Collections.sort(
              queueGroups,
              new Comparator() {

                public int compare(Object object1, Object object2) {
                  OpenAcdQueueGroup queueGroup1 = (OpenAcdQueueGroup) object1;
                  OpenAcdQueueGroup queueGroup2 = (OpenAcdQueueGroup) object2;
                  return RestUtilities.compareIgnoreCaseNullSafe(
                      queueGroup2.getDescription(), queueGroup1.getDescription());
                }
              });
          break;
      }
    }
  }
Пример #2
0
  private void sortBranches(List<Branch> branches) {
    // sort if requested
    SortInfo sortInfo = RestUtilities.calculateSorting(m_form);

    if (!sortInfo.sort) {
      return;
    }

    SortField sortField = SortField.toSortField(sortInfo.sortField);

    if (sortInfo.directionForward) {

      switch (sortField) {
        case NAME:
          Collections.sort(
              branches,
              new Comparator() {

                public int compare(Object object1, Object object2) {
                  Branch branch1 = (Branch) object1;
                  Branch branch2 = (Branch) object2;
                  return branch1.getName().compareToIgnoreCase(branch2.getName());
                }
              });
          break;

        case DESCRIPTION:
          Collections.sort(
              branches,
              new Comparator() {

                public int compare(Object object1, Object object2) {
                  Branch branch1 = (Branch) object1;
                  Branch branch2 = (Branch) object2;
                  return branch1.getDescription().compareToIgnoreCase(branch2.getDescription());
                }
              });
          break;
      }
    } else {
      // must be reverse
      switch (sortField) {
        case NAME:
          Collections.sort(
              branches,
              new Comparator() {

                public int compare(Object object1, Object object2) {
                  Branch branch1 = (Branch) object1;
                  Branch branch2 = (Branch) object2;
                  return branch2.getName().compareToIgnoreCase(branch1.getName());
                }
              });
          break;

        case DESCRIPTION:
          Collections.sort(
              branches,
              new Comparator() {

                public int compare(Object object1, Object object2) {
                  Branch branch1 = (Branch) object1;
                  Branch branch2 = (Branch) object2;
                  return branch2.getDescription().compareToIgnoreCase(branch1.getDescription());
                }
              });
          break;
      }
    }
  }