Ejemplo n.º 1
0
  @SuppressWarnings("unchecked")
  private void sortBranches(List<Branch> branches) {
    // sort if requested
    SortInfo sortInfo = RestUtilities.calculateSorting(m_form);

    if (!sortInfo.getSort()) {
      return;
    }

    SortField sortField = SortField.toSortField(sortInfo.getSortField());
    boolean sortForward = sortInfo.getDirectionForward();

    switch (sortField) {
      case CITY:
        if (sortForward) {
          Collections.sort(branches, new CityComparator());
        } else {
          Collections.sort(branches, new ReverseComparator(new CityComparator()));
        }
        break;

      case OFFICEDESIGNATION:
        if (sortForward) {
          Collections.sort(branches, new OfficeDesignationComparator());
        } else {
          Collections.sort(branches, new ReverseComparator(new OfficeDesignationComparator()));
        }
        break;

      case NAME:
        if (sortForward) {
          Collections.sort(branches, new NameComparator());
        } else {
          Collections.sort(branches, new ReverseComparator(new NameComparator()));
        }
        break;

      case DESCRIPTION:
        if (sortForward) {
          Collections.sort(branches, new DescriptionComparator());
        } else {
          Collections.sort(branches, new ReverseComparator(new DescriptionComparator()));
        }
        break;

      default:
        break;
    }
  }
Ejemplo n.º 2
0
  @SuppressWarnings("unchecked")
  private void sortAgents(List<OpenAcdAgent> agents) {
    // sort groups if requested
    SortInfo sortInfo = RestUtilities.calculateSorting(m_form);

    if (!sortInfo.getSort()) {
      return;
    }

    SortField sortField = SortField.toSortField(sortInfo.getSortField());
    boolean sortForward = sortInfo.getDirectionForward();

    switch (sortField) {
      case NAME:
        if (sortForward) {
          Collections.sort(agents, new NameComparator());
        } else {
          Collections.sort(agents, new ReverseComparator(new NameComparator()));
        }
        break;

      case GROUP:
        if (sortForward) {
          Collections.sort(agents, new GroupComparator());
        } else {
          Collections.sort(agents, new ReverseComparator(new GroupComparator()));
        }
        break;

      case SECURITY:
        if (sortForward) {
          Collections.sort(agents, new SecurityComparator());
        } else {
          Collections.sort(agents, new ReverseComparator(new SecurityComparator()));
        }
        break;

      case USERNAME:
        if (sortForward) {
          Collections.sort(agents, new UserNameComparator());
        } else {
          Collections.sort(agents, new ReverseComparator(new UserNameComparator()));
        }
        break;

      case FIRSTNAME:
        if (sortForward) {
          Collections.sort(agents, new FirstNameComparator());
        } else {
          Collections.sort(agents, new ReverseComparator(new FirstNameComparator()));
        }
        break;

      case LASTNAME:
        if (sortForward) {
          Collections.sort(agents, new LastNameComparator());
        } else {
          Collections.sort(agents, new ReverseComparator(new LastNameComparator()));
        }
        break;

      case BRANCH:
        if (sortForward) {
          Collections.sort(agents, new BranchComparator());
        } else {
          Collections.sort(agents, new ReverseComparator(new BranchComparator()));
        }
        break;

      case EXTENSION:
        if (sortForward) {
          Collections.sort(agents, new ExtensionComparator());
        } else {
          Collections.sort(agents, new ReverseComparator(new ExtensionComparator()));
        }
        break;

      default:
        break;
    }
  }