com.vaadin.data.provider.QuerySortOrder Java Examples
The following examples show how to use
com.vaadin.data.provider.QuerySortOrder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SizelessGridTest.java From viritin with Apache License 2.0 | 6 votes |
@Override public Component getTestComponent() { LazyGrid<Person> grid = new LazyGrid<>(Person.class); grid.setColumns("firstName", "lastName", "age"); grid.setItems((List<QuerySortOrder> sortOrder, int offset, int limit) -> { if(sortOrder.size() > 0) { System.err.println("Getting sorted data..."); QuerySortOrder querySortOrder = sortOrder.get(0); boolean asc = querySortOrder.getDirection() == SortDirection.ASCENDING; String prop = querySortOrder.getSorted(); return Service.findAll(offset, limit, prop, asc).stream(); } return Service.findAll(offset, limit).stream(); }); return grid; }
Example #2
Source File: TableSelectionModel.java From GridExtensionPack with Apache License 2.0 | 5 votes |
public TableSelectionModel() { registerRpc(new ShiftSelectRpc() { @Override public void selectRange(int start, int length) { if (length == 0) { return; } BinaryOperator<SerializableComparator<T>> operator = (comparator1, comparator2) -> { /* * thenComparing is defined to return a serializable * comparator as long as both original comparators are also * serializable */ return comparator1.thenComparing(comparator2)::compare; }; Comparator<T> inMemorySorting = getParent().getSortOrder().stream() .map(order -> order.getSorted().getComparator(order.getDirection())) .reduce((x, y) -> 0, operator); List<QuerySortOrder> sortProperties = new ArrayList<>(); getParent().getSortOrder().stream().map(order -> order.getSorted().getSortOrder(order.getDirection())) .forEach(s -> s.forEach(sortProperties::add)); getParent().getDataProvider().fetch(new Query<>(start, length, sortProperties, inMemorySorting, null)); } }); }
Example #3
Source File: PhoneBookService.java From jpa-addressbook with The Unlicense | 5 votes |
/** * Finds a set of entries from database with given filter, starting from * given row. The "page size" (aka max results limit passed for the query) * is 45. * * @param filter the filters string * @param firstRow the first row to be fetched * @param maxresults maximum number of results * @return */ public List<PhoneBookEntry> getEntriesPaged(String filter, int firstRow, int maxresults, List<QuerySortOrder> sortOrder) { QueryResult<PhoneBookEntry> qr = entryRepo.findByNameLikeIgnoreCase("%" + filter + "%"); for (QuerySortOrder qso : sortOrder) { if(qso.getDirection() == SortDirection.ASCENDING) { qr = qr.orderAsc(qso.getSorted()); } else { qr = qr.orderDesc(qso.getSorted()); } } return qr .firstResult(firstRow).maxResults(maxresults) .getResultList(); }