Пример #1
0
  @Override
  public int compare(UserLog log1, UserLog log2) {
    try {
      Object value1 = UserLog.class.getField(this.sortField).get(log1);
      Object value2 = UserLog.class.getField(this.sortField).get(log2);

      int value = ((Comparable) value1).compareTo(value2);

      return SortOrder.ASCENDING.equals(sortOrder) ? value : -1 * value;
    } catch (Exception e) {
      throw new RuntimeException();
    }
  }
  @Override
  public List<Propiedad> load(
      int startingAt,
      int maxPerPage,
      String sortField,
      SortOrder sortOrder,
      Map<String, String> filters) {
    try {
      try {
        // Filtros Avanzados
        filters = getFiltros().agregarFiltros(filters);
        list =
            getEntityService()
                .getList(
                    startingAt,
                    maxPerPage,
                    filters,
                    (sortField == null ? ORDER_DEFAULT : sortField),
                    (sortOrder.name().equals(SortOrder.ASCENDING.toString())));

      } finally {

      }
    } catch (Exception e) {
      e.printStackTrace();
      list = new ArrayList<Propiedad>(0);
    }

    // set the total of list
    if (getRowCount() <= 0) {
      setRowCount(getEntityService().getCount(filters).intValue());
    }

    // set the page dize
    setPageSize(maxPerPage);

    return list;
  }