|
25 | 25 | import java.util.function.Consumer; |
26 | 26 | import java.util.stream.Collectors; |
27 | 27 |
|
| 28 | +@Getter |
28 | 29 | public class GridServer<T> implements IGridServer<T> { |
29 | 30 |
|
30 | | - @Getter |
31 | 31 | protected IGrid<T> grid; |
32 | 32 |
|
33 | 33 | public GridServer() |
34 | 34 | { } |
35 | 35 |
|
36 | | - public GridServer(EntityManager entityManager, Class<T> targetType, Predicate predicate, List<Order> orderList, |
37 | | - Map<String, String[]> query, Consumer<IGridColumnCollection<T>> columns) { |
38 | | - this(entityManager, targetType, predicate, orderList, query, true, "", columns, |
39 | | - 0, null); |
| 36 | + public GridServer(EntityManager entityManager, Class<T> targetType, Map<String, String[]> query, |
| 37 | + Consumer<IGridColumnCollection<T>> columns) { |
| 38 | + this(entityManager, targetType, query, columns,0, null); |
40 | 39 | } |
41 | 40 |
|
42 | | - public GridServer(EntityManager entityManager, Class<T> targetType, Predicate predicate, List<Order> orderList, |
43 | | - Map<String, String[]> query, boolean renderOnlyRows, |
44 | | - String gridName, Consumer<IGridColumnCollection<T>> columns, int pageSize) { |
45 | | - this(entityManager, targetType, predicate, orderList, query, renderOnlyRows, gridName, columns, |
46 | | - pageSize, null); |
| 41 | + public GridServer(EntityManager entityManager, Class<T> targetType, Map<String, String[]> query, |
| 42 | + Consumer<IGridColumnCollection<T>> columns, int pageSize) { |
| 43 | + this(entityManager, targetType, query, columns, pageSize, null); |
47 | 44 | } |
48 | 45 |
|
49 | | - public GridServer(EntityManager entityManager, Class<T> targetType, Predicate predicate, List<Order> orderList, |
50 | | - Map<String, String[]> query, boolean renderOnlyRows, |
51 | | - String gridName, Consumer<IGridColumnCollection<T>> columns, int pageSize, |
52 | | - IColumnBuilder<T> columnBuilder) { |
| 46 | + public GridServer(EntityManager entityManager, Class<T> targetType, Map<String, String[]> query, |
| 47 | + Consumer<IGridColumnCollection<T>> columns, int pageSize, IColumnBuilder<T> columnBuilder) { |
53 | 48 |
|
54 | 49 | var map = query.entrySet() |
55 | 50 | .stream() |
56 | 51 | .collect(Collectors.toMap(Map.Entry::getKey, entry -> Arrays.asList(entry.getValue()))); |
57 | 52 |
|
58 | 53 | var linkedHashMap = new LinkedHashMap<>(map); |
59 | 54 |
|
60 | | - this.grid = new Grid<T>(entityManager, targetType, predicate, orderList, linkedHashMap, columnBuilder); |
| 55 | + this.grid = new Grid<T>(entityManager, targetType, linkedHashMap, columnBuilder); |
61 | 56 |
|
62 | 57 | if(columns != null) |
63 | 58 | columns.accept(this.grid.getColumns()); |
@@ -205,6 +200,16 @@ public IGridServer<T> setRemoveDiacritics(String removeDiacritics) { |
205 | 200 | return this; |
206 | 201 | } |
207 | 202 |
|
| 203 | + public IGridServer<T> setPredicate(Predicate predicate) { |
| 204 | + ((Grid<T>)this.grid).setPredicate(predicate); |
| 205 | + return this; |
| 206 | + } |
| 207 | + |
| 208 | + public IGridServer<T> setOrder(List<Order> orderList) { |
| 209 | + ((Grid<T>)this.grid).setOrderList(orderList); |
| 210 | + return this; |
| 211 | + } |
| 212 | + |
208 | 213 | public ItemsDTO<T> getItemsToDisplay() { |
209 | 214 |
|
210 | 215 | var items = this.grid.getItemsToDisplay(); |
|
0 commit comments