Showing
82 changed files
with
922 additions
and
1419 deletions
Too many changes to show.
To preserve performance only 82 of 132 files are displayed.
application/src/main/java/org/thingsboard/server/actors/shared/rulechain/SystemRuleChainManager.java
... | ... | @@ -18,8 +18,8 @@ package org.thingsboard.server.actors.shared.rulechain; |
18 | 18 | import org.thingsboard.server.actors.ActorSystemContext; |
19 | 19 | import org.thingsboard.server.actors.service.DefaultActorService; |
20 | 20 | import org.thingsboard.server.common.data.id.TenantId; |
21 | +import org.thingsboard.server.common.data.page.PageData; | |
21 | 22 | import org.thingsboard.server.common.data.page.PageDataIterable.FetchFunction; |
22 | -import org.thingsboard.server.common.data.page.TextPageData; | |
23 | 23 | import org.thingsboard.server.common.data.rule.RuleChain; |
24 | 24 | import org.thingsboard.server.dao.model.ModelConstants; |
25 | 25 | |
... | ... | @@ -33,7 +33,7 @@ public class SystemRuleChainManager extends RuleChainManager { |
33 | 33 | |
34 | 34 | @Override |
35 | 35 | protected FetchFunction<RuleChain> getFetchEntitiesFunction() { |
36 | - return link -> new TextPageData<>(Collections.emptyList(), link); | |
36 | + return link -> new PageData<>(); | |
37 | 37 | } |
38 | 38 | |
39 | 39 | @Override | ... | ... |
... | ... | @@ -39,7 +39,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardErrorCode; |
39 | 39 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
40 | 40 | import org.thingsboard.server.common.data.id.EntityId; |
41 | 41 | import org.thingsboard.server.common.data.id.EntityIdFactory; |
42 | -import org.thingsboard.server.common.data.page.TimePageData; | |
42 | +import org.thingsboard.server.common.data.page.PageData; | |
43 | 43 | import org.thingsboard.server.common.data.page.TimePageLink; |
44 | 44 | import org.thingsboard.server.service.security.permission.Operation; |
45 | 45 | import org.thingsboard.server.service.security.permission.Resource; |
... | ... | @@ -143,16 +143,16 @@ public class AlarmController extends BaseController { |
143 | 143 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
144 | 144 | @RequestMapping(value = "/alarm/{entityType}/{entityId}", method = RequestMethod.GET) |
145 | 145 | @ResponseBody |
146 | - public TimePageData<AlarmInfo> getAlarms( | |
146 | + public PageData<AlarmInfo> getAlarms( | |
147 | 147 | @PathVariable("entityType") String strEntityType, |
148 | 148 | @PathVariable("entityId") String strEntityId, |
149 | 149 | @RequestParam(required = false) String searchStatus, |
150 | 150 | @RequestParam(required = false) String status, |
151 | - @RequestParam int limit, | |
151 | + @RequestParam int pageSize, | |
152 | + @RequestParam int page, | |
152 | 153 | @RequestParam(required = false) Long startTime, |
153 | 154 | @RequestParam(required = false) Long endTime, |
154 | 155 | @RequestParam(required = false, defaultValue = "false") boolean ascOrder, |
155 | - @RequestParam(required = false) String offset, | |
156 | 156 | @RequestParam(required = false) Boolean fetchOriginator |
157 | 157 | ) throws ThingsboardException { |
158 | 158 | checkParameter("EntityId", strEntityId); |
... | ... | @@ -166,7 +166,8 @@ public class AlarmController extends BaseController { |
166 | 166 | } |
167 | 167 | checkEntityId(entityId, Operation.READ); |
168 | 168 | try { |
169 | - TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset); | |
169 | + TimePageLink pageLink = createTimePageLink(pageSize, page, "", | |
170 | + "id", ascOrder ? "asc" : "desc", startTime, endTime); | |
170 | 171 | return checkNotNull(alarmService.findAlarms(getCurrentUser().getTenantId(), new AlarmQuery(entityId, pageLink, alarmSearchStatus, alarmStatus, fetchOriginator)).get()); |
171 | 172 | } catch (Exception e) { |
172 | 173 | throw handleException(e); | ... | ... |
... | ... | @@ -37,8 +37,8 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; |
37 | 37 | import org.thingsboard.server.common.data.id.AssetId; |
38 | 38 | import org.thingsboard.server.common.data.id.CustomerId; |
39 | 39 | import org.thingsboard.server.common.data.id.TenantId; |
40 | -import org.thingsboard.server.common.data.page.TextPageData; | |
41 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
40 | +import org.thingsboard.server.common.data.page.PageData; | |
41 | +import org.thingsboard.server.common.data.page.PageLink; | |
42 | 42 | import org.thingsboard.server.common.data.security.Authority; |
43 | 43 | import org.thingsboard.server.dao.exception.IncorrectParameterException; |
44 | 44 | import org.thingsboard.server.dao.model.ModelConstants; |
... | ... | @@ -207,17 +207,18 @@ public class AssetController extends BaseController { |
207 | 207 | } |
208 | 208 | |
209 | 209 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
210 | - @RequestMapping(value = "/tenant/assets", params = {"limit"}, method = RequestMethod.GET) | |
210 | + @RequestMapping(value = "/tenant/assets", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
211 | 211 | @ResponseBody |
212 | - public TextPageData<Asset> getTenantAssets( | |
213 | - @RequestParam int limit, | |
212 | + public PageData<Asset> getTenantAssets( | |
213 | + @RequestParam int pageSize, | |
214 | + @RequestParam int page, | |
214 | 215 | @RequestParam(required = false) String type, |
215 | 216 | @RequestParam(required = false) String textSearch, |
216 | - @RequestParam(required = false) String idOffset, | |
217 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
217 | + @RequestParam(required = false) String sortProperty, | |
218 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
218 | 219 | try { |
219 | 220 | TenantId tenantId = getCurrentUser().getTenantId(); |
220 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
221 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
221 | 222 | if (type != null && type.trim().length()>0) { |
222 | 223 | return checkNotNull(assetService.findAssetsByTenantIdAndType(tenantId, type, pageLink)); |
223 | 224 | } else { |
... | ... | @@ -242,21 +243,22 @@ public class AssetController extends BaseController { |
242 | 243 | } |
243 | 244 | |
244 | 245 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
245 | - @RequestMapping(value = "/customer/{customerId}/assets", params = {"limit"}, method = RequestMethod.GET) | |
246 | + @RequestMapping(value = "/customer/{customerId}/assets", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
246 | 247 | @ResponseBody |
247 | - public TextPageData<Asset> getCustomerAssets( | |
248 | + public PageData<Asset> getCustomerAssets( | |
248 | 249 | @PathVariable("customerId") String strCustomerId, |
249 | - @RequestParam int limit, | |
250 | + @RequestParam int pageSize, | |
251 | + @RequestParam int page, | |
250 | 252 | @RequestParam(required = false) String type, |
251 | 253 | @RequestParam(required = false) String textSearch, |
252 | - @RequestParam(required = false) String idOffset, | |
253 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
254 | + @RequestParam(required = false) String sortProperty, | |
255 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
254 | 256 | checkParameter("customerId", strCustomerId); |
255 | 257 | try { |
256 | 258 | TenantId tenantId = getCurrentUser().getTenantId(); |
257 | 259 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); |
258 | 260 | checkCustomerId(customerId, Operation.READ); |
259 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
261 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
260 | 262 | if (type != null && type.trim().length()>0) { |
261 | 263 | return checkNotNull(assetService.findAssetsByTenantIdAndCustomerIdAndType(tenantId, customerId, type, pageLink)); |
262 | 264 | } else { | ... | ... |
... | ... | @@ -28,7 +28,7 @@ import org.thingsboard.server.common.data.id.CustomerId; |
28 | 28 | import org.thingsboard.server.common.data.id.EntityIdFactory; |
29 | 29 | import org.thingsboard.server.common.data.id.TenantId; |
30 | 30 | import org.thingsboard.server.common.data.id.UserId; |
31 | -import org.thingsboard.server.common.data.page.TimePageData; | |
31 | +import org.thingsboard.server.common.data.page.PageData; | |
32 | 32 | import org.thingsboard.server.common.data.page.TimePageLink; |
33 | 33 | |
34 | 34 | import java.util.UUID; |
... | ... | @@ -38,19 +38,20 @@ import java.util.UUID; |
38 | 38 | public class AuditLogController extends BaseController { |
39 | 39 | |
40 | 40 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
41 | - @RequestMapping(value = "/audit/logs/customer/{customerId}", params = {"limit"}, method = RequestMethod.GET) | |
41 | + @RequestMapping(value = "/audit/logs/customer/{customerId}", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
42 | 42 | @ResponseBody |
43 | - public TimePageData<AuditLog> getAuditLogsByCustomerId( | |
43 | + public PageData<AuditLog> getAuditLogsByCustomerId( | |
44 | 44 | @PathVariable("customerId") String strCustomerId, |
45 | - @RequestParam int limit, | |
45 | + @RequestParam int pageSize, | |
46 | + @RequestParam int page, | |
46 | 47 | @RequestParam(required = false) Long startTime, |
47 | 48 | @RequestParam(required = false) Long endTime, |
48 | - @RequestParam(required = false, defaultValue = "false") boolean ascOrder, | |
49 | - @RequestParam(required = false) String offset) throws ThingsboardException { | |
49 | + @RequestParam(required = false, defaultValue = "false") boolean ascOrder) throws ThingsboardException { | |
50 | 50 | try { |
51 | 51 | checkParameter("CustomerId", strCustomerId); |
52 | 52 | TenantId tenantId = getCurrentUser().getTenantId(); |
53 | - TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset); | |
53 | + TimePageLink pageLink = createTimePageLink(pageSize, page, "", | |
54 | + "createdTime", ascOrder ? "asc" : "desc", startTime, endTime); | |
54 | 55 | return checkNotNull(auditLogService.findAuditLogsByTenantIdAndCustomerId(tenantId, new CustomerId(UUID.fromString(strCustomerId)), pageLink)); |
55 | 56 | } catch (Exception e) { |
56 | 57 | throw handleException(e); |
... | ... | @@ -58,19 +59,20 @@ public class AuditLogController extends BaseController { |
58 | 59 | } |
59 | 60 | |
60 | 61 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
61 | - @RequestMapping(value = "/audit/logs/user/{userId}", params = {"limit"}, method = RequestMethod.GET) | |
62 | + @RequestMapping(value = "/audit/logs/user/{userId}", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
62 | 63 | @ResponseBody |
63 | - public TimePageData<AuditLog> getAuditLogsByUserId( | |
64 | + public PageData<AuditLog> getAuditLogsByUserId( | |
64 | 65 | @PathVariable("userId") String strUserId, |
65 | - @RequestParam int limit, | |
66 | + @RequestParam int pageSize, | |
67 | + @RequestParam int page, | |
66 | 68 | @RequestParam(required = false) Long startTime, |
67 | 69 | @RequestParam(required = false) Long endTime, |
68 | - @RequestParam(required = false, defaultValue = "false") boolean ascOrder, | |
69 | - @RequestParam(required = false) String offset) throws ThingsboardException { | |
70 | + @RequestParam(required = false, defaultValue = "false") boolean ascOrder) throws ThingsboardException { | |
70 | 71 | try { |
71 | 72 | checkParameter("UserId", strUserId); |
72 | 73 | TenantId tenantId = getCurrentUser().getTenantId(); |
73 | - TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset); | |
74 | + TimePageLink pageLink = createTimePageLink(pageSize, page, "", | |
75 | + "createdTime", ascOrder ? "asc" : "desc", startTime, endTime); | |
74 | 76 | return checkNotNull(auditLogService.findAuditLogsByTenantIdAndUserId(tenantId, new UserId(UUID.fromString(strUserId)), pageLink)); |
75 | 77 | } catch (Exception e) { |
76 | 78 | throw handleException(e); |
... | ... | @@ -78,21 +80,22 @@ public class AuditLogController extends BaseController { |
78 | 80 | } |
79 | 81 | |
80 | 82 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
81 | - @RequestMapping(value = "/audit/logs/entity/{entityType}/{entityId}", params = {"limit"}, method = RequestMethod.GET) | |
83 | + @RequestMapping(value = "/audit/logs/entity/{entityType}/{entityId}", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
82 | 84 | @ResponseBody |
83 | - public TimePageData<AuditLog> getAuditLogsByEntityId( | |
85 | + public PageData<AuditLog> getAuditLogsByEntityId( | |
84 | 86 | @PathVariable("entityType") String strEntityType, |
85 | 87 | @PathVariable("entityId") String strEntityId, |
86 | - @RequestParam int limit, | |
88 | + @RequestParam int pageSize, | |
89 | + @RequestParam int page, | |
87 | 90 | @RequestParam(required = false) Long startTime, |
88 | 91 | @RequestParam(required = false) Long endTime, |
89 | - @RequestParam(required = false, defaultValue = "false") boolean ascOrder, | |
90 | - @RequestParam(required = false) String offset) throws ThingsboardException { | |
92 | + @RequestParam(required = false, defaultValue = "false") boolean ascOrder) throws ThingsboardException { | |
91 | 93 | try { |
92 | 94 | checkParameter("EntityId", strEntityId); |
93 | 95 | checkParameter("EntityType", strEntityType); |
94 | 96 | TenantId tenantId = getCurrentUser().getTenantId(); |
95 | - TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset); | |
97 | + TimePageLink pageLink = createTimePageLink(pageSize, page, "", | |
98 | + "createdTime", ascOrder ? "asc" : "desc", startTime, endTime); | |
96 | 99 | return checkNotNull(auditLogService.findAuditLogsByTenantIdAndEntityId(tenantId, EntityIdFactory.getByTypeAndId(strEntityType, strEntityId), pageLink)); |
97 | 100 | } catch (Exception e) { |
98 | 101 | throw handleException(e); |
... | ... | @@ -100,17 +103,18 @@ public class AuditLogController extends BaseController { |
100 | 103 | } |
101 | 104 | |
102 | 105 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
103 | - @RequestMapping(value = "/audit/logs", params = {"limit"}, method = RequestMethod.GET) | |
106 | + @RequestMapping(value = "/audit/logs", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
104 | 107 | @ResponseBody |
105 | - public TimePageData<AuditLog> getAuditLogs( | |
106 | - @RequestParam int limit, | |
108 | + public PageData<AuditLog> getAuditLogs( | |
109 | + @RequestParam int pageSize, | |
110 | + @RequestParam int page, | |
107 | 111 | @RequestParam(required = false) Long startTime, |
108 | 112 | @RequestParam(required = false) Long endTime, |
109 | - @RequestParam(required = false, defaultValue = "false") boolean ascOrder, | |
110 | - @RequestParam(required = false) String offset) throws ThingsboardException { | |
113 | + @RequestParam(required = false, defaultValue = "false") boolean ascOrder) throws ThingsboardException { | |
111 | 114 | try { |
112 | 115 | TenantId tenantId = getCurrentUser().getTenantId(); |
113 | - TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset); | |
116 | + TimePageLink pageLink = createTimePageLink(pageSize, page, "", | |
117 | + "createdTime", ascOrder ? "asc" : "desc", startTime, endTime); | |
114 | 118 | return checkNotNull(auditLogService.findAuditLogsByTenantId(tenantId, pageLink)); |
115 | 119 | } catch (Exception e) { |
116 | 120 | throw handleException(e); | ... | ... |
... | ... | @@ -60,7 +60,8 @@ import org.thingsboard.server.common.data.id.WidgetTypeId; |
60 | 60 | import org.thingsboard.server.common.data.id.WidgetsBundleId; |
61 | 61 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
62 | 62 | import org.thingsboard.server.common.data.kv.DataType; |
63 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
63 | +import org.thingsboard.server.common.data.page.PageLink; | |
64 | +import org.thingsboard.server.common.data.page.SortOrder; | |
64 | 65 | import org.thingsboard.server.common.data.page.TimePageLink; |
65 | 66 | import org.thingsboard.server.common.data.plugin.ComponentDescriptor; |
66 | 67 | import org.thingsboard.server.common.data.plugin.ComponentType; |
... | ... | @@ -256,21 +257,27 @@ public abstract class BaseController { |
256 | 257 | return UUID.fromString(id); |
257 | 258 | } |
258 | 259 | |
259 | - TimePageLink createPageLink(int limit, Long startTime, Long endTime, boolean ascOrder, String idOffset) { | |
260 | - UUID idOffsetUuid = null; | |
261 | - if (StringUtils.isNotEmpty(idOffset)) { | |
262 | - idOffsetUuid = toUUID(idOffset); | |
260 | + PageLink createPageLink(int pageSize, int page, String textSearch, String sortProperty, String sortOrder) throws ThingsboardException { | |
261 | + if (!StringUtils.isEmpty(sortProperty)) { | |
262 | + SortOrder.Direction direction = SortOrder.Direction.ASC; | |
263 | + if (!StringUtils.isEmpty(sortOrder)) { | |
264 | + try { | |
265 | + direction = SortOrder.Direction.valueOf(sortOrder.toUpperCase()); | |
266 | + } catch (IllegalArgumentException e) { | |
267 | + throw new ThingsboardException("Unsupported sort order '" + sortOrder + "'! Only 'ASC' or 'DESC' types are allowed.", ThingsboardErrorCode.BAD_REQUEST_PARAMS); | |
268 | + } | |
269 | + } | |
270 | + SortOrder sort = new SortOrder(sortProperty, direction); | |
271 | + return new PageLink(pageSize, page, textSearch, sort); | |
272 | + } else { | |
273 | + return new PageLink(pageSize, page, textSearch); | |
263 | 274 | } |
264 | - return new TimePageLink(limit, startTime, endTime, ascOrder, idOffsetUuid); | |
265 | 275 | } |
266 | 276 | |
267 | - | |
268 | - TextPageLink createPageLink(int limit, String textSearch, String idOffset, String textOffset) { | |
269 | - UUID idOffsetUuid = null; | |
270 | - if (StringUtils.isNotEmpty(idOffset)) { | |
271 | - idOffsetUuid = toUUID(idOffset); | |
272 | - } | |
273 | - return new TextPageLink(limit, textSearch, idOffsetUuid, textOffset); | |
277 | + TimePageLink createTimePageLink(int pageSize, int page, String textSearch, | |
278 | + String sortProperty, String sortOrder, Long startTime, Long endTime) throws ThingsboardException { | |
279 | + PageLink pageLink = this.createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
280 | + return new TimePageLink(pageLink, startTime, endTime); | |
274 | 281 | } |
275 | 282 | |
276 | 283 | protected SecurityUser getCurrentUser() throws ThingsboardException { | ... | ... |
... | ... | @@ -34,8 +34,8 @@ import org.thingsboard.server.common.data.audit.ActionType; |
34 | 34 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
35 | 35 | import org.thingsboard.server.common.data.id.CustomerId; |
36 | 36 | import org.thingsboard.server.common.data.id.TenantId; |
37 | -import org.thingsboard.server.common.data.page.TextPageData; | |
38 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
37 | +import org.thingsboard.server.common.data.page.PageData; | |
38 | +import org.thingsboard.server.common.data.page.PageLink; | |
39 | 39 | import org.thingsboard.server.service.security.permission.Operation; |
40 | 40 | import org.thingsboard.server.service.security.permission.Resource; |
41 | 41 | |
... | ... | @@ -143,14 +143,15 @@ public class CustomerController extends BaseController { |
143 | 143 | } |
144 | 144 | |
145 | 145 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
146 | - @RequestMapping(value = "/customers", params = {"limit"}, method = RequestMethod.GET) | |
146 | + @RequestMapping(value = "/customers", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
147 | 147 | @ResponseBody |
148 | - public TextPageData<Customer> getCustomers(@RequestParam int limit, | |
149 | - @RequestParam(required = false) String textSearch, | |
150 | - @RequestParam(required = false) String idOffset, | |
151 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
148 | + public PageData<Customer> getCustomers(@RequestParam int pageSize, | |
149 | + @RequestParam int page, | |
150 | + @RequestParam(required = false) String textSearch, | |
151 | + @RequestParam(required = false) String sortProperty, | |
152 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
152 | 153 | try { |
153 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
154 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
154 | 155 | TenantId tenantId = getCurrentUser().getTenantId(); |
155 | 156 | return checkNotNull(customerService.findCustomersByTenantId(tenantId, pageLink)); |
156 | 157 | } catch (Exception e) { | ... | ... |
... | ... | @@ -37,9 +37,8 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; |
37 | 37 | import org.thingsboard.server.common.data.id.CustomerId; |
38 | 38 | import org.thingsboard.server.common.data.id.DashboardId; |
39 | 39 | import org.thingsboard.server.common.data.id.TenantId; |
40 | -import org.thingsboard.server.common.data.page.TextPageData; | |
41 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
42 | -import org.thingsboard.server.common.data.page.TimePageData; | |
40 | +import org.thingsboard.server.common.data.page.PageData; | |
41 | +import org.thingsboard.server.common.data.page.PageLink; | |
43 | 42 | import org.thingsboard.server.common.data.page.TimePageLink; |
44 | 43 | import org.thingsboard.server.service.security.permission.Operation; |
45 | 44 | import org.thingsboard.server.service.security.permission.Resource; |
... | ... | @@ -417,18 +416,19 @@ public class DashboardController extends BaseController { |
417 | 416 | } |
418 | 417 | |
419 | 418 | @PreAuthorize("hasAuthority('SYS_ADMIN')") |
420 | - @RequestMapping(value = "/tenant/{tenantId}/dashboards", params = { "limit" }, method = RequestMethod.GET) | |
419 | + @RequestMapping(value = "/tenant/{tenantId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
421 | 420 | @ResponseBody |
422 | - public TextPageData<DashboardInfo> getTenantDashboards( | |
421 | + public PageData<DashboardInfo> getTenantDashboards( | |
423 | 422 | @PathVariable("tenantId") String strTenantId, |
424 | - @RequestParam int limit, | |
423 | + @RequestParam int pageSize, | |
424 | + @RequestParam int page, | |
425 | 425 | @RequestParam(required = false) String textSearch, |
426 | - @RequestParam(required = false) String idOffset, | |
427 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
426 | + @RequestParam(required = false) String sortProperty, | |
427 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
428 | 428 | try { |
429 | 429 | TenantId tenantId = new TenantId(toUUID(strTenantId)); |
430 | 430 | checkTenantId(tenantId, Operation.READ); |
431 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
431 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
432 | 432 | return checkNotNull(dashboardService.findDashboardsByTenantId(tenantId, pageLink)); |
433 | 433 | } catch (Exception e) { |
434 | 434 | throw handleException(e); |
... | ... | @@ -436,16 +436,17 @@ public class DashboardController extends BaseController { |
436 | 436 | } |
437 | 437 | |
438 | 438 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
439 | - @RequestMapping(value = "/tenant/dashboards", params = { "limit" }, method = RequestMethod.GET) | |
439 | + @RequestMapping(value = "/tenant/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
440 | 440 | @ResponseBody |
441 | - public TextPageData<DashboardInfo> getTenantDashboards( | |
442 | - @RequestParam int limit, | |
441 | + public PageData<DashboardInfo> getTenantDashboards( | |
442 | + @RequestParam int pageSize, | |
443 | + @RequestParam int page, | |
443 | 444 | @RequestParam(required = false) String textSearch, |
444 | - @RequestParam(required = false) String idOffset, | |
445 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
445 | + @RequestParam(required = false) String sortProperty, | |
446 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
446 | 447 | try { |
447 | 448 | TenantId tenantId = getCurrentUser().getTenantId(); |
448 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
449 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
449 | 450 | return checkNotNull(dashboardService.findDashboardsByTenantId(tenantId, pageLink)); |
450 | 451 | } catch (Exception e) { |
451 | 452 | throw handleException(e); |
... | ... | @@ -453,21 +454,22 @@ public class DashboardController extends BaseController { |
453 | 454 | } |
454 | 455 | |
455 | 456 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
456 | - @RequestMapping(value = "/customer/{customerId}/dashboards", params = { "limit" }, method = RequestMethod.GET) | |
457 | + @RequestMapping(value = "/customer/{customerId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
457 | 458 | @ResponseBody |
458 | - public TimePageData<DashboardInfo> getCustomerDashboards( | |
459 | + public PageData<DashboardInfo> getCustomerDashboards( | |
459 | 460 | @PathVariable("customerId") String strCustomerId, |
460 | - @RequestParam int limit, | |
461 | + @RequestParam int pageSize, | |
462 | + @RequestParam int page, | |
461 | 463 | @RequestParam(required = false) Long startTime, |
462 | 464 | @RequestParam(required = false) Long endTime, |
463 | - @RequestParam(required = false, defaultValue = "false") boolean ascOrder, | |
464 | - @RequestParam(required = false) String offset) throws ThingsboardException { | |
465 | + @RequestParam(required = false, defaultValue = "false") boolean ascOrder) throws ThingsboardException { | |
465 | 466 | checkParameter("customerId", strCustomerId); |
466 | 467 | try { |
467 | 468 | TenantId tenantId = getCurrentUser().getTenantId(); |
468 | 469 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); |
469 | 470 | checkCustomerId(customerId, Operation.READ); |
470 | - TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset); | |
471 | + TimePageLink pageLink = createTimePageLink(pageSize, page, "", | |
472 | + "createdTime", ascOrder ? "asc" : "desc", startTime, endTime); | |
471 | 473 | return checkNotNull(dashboardService.findDashboardsByTenantIdAndCustomerId(tenantId, customerId, pageLink).get()); |
472 | 474 | } catch (Exception e) { |
473 | 475 | throw handleException(e); | ... | ... |
... | ... | @@ -41,8 +41,8 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; |
41 | 41 | import org.thingsboard.server.common.data.id.CustomerId; |
42 | 42 | import org.thingsboard.server.common.data.id.DeviceId; |
43 | 43 | import org.thingsboard.server.common.data.id.TenantId; |
44 | -import org.thingsboard.server.common.data.page.TextPageData; | |
45 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
44 | +import org.thingsboard.server.common.data.page.PageData; | |
45 | +import org.thingsboard.server.common.data.page.PageLink; | |
46 | 46 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
47 | 47 | import org.thingsboard.server.controller.claim.data.ClaimRequest; |
48 | 48 | import org.thingsboard.server.dao.device.claim.ClaimResponse; |
... | ... | @@ -265,17 +265,18 @@ public class DeviceController extends BaseController { |
265 | 265 | } |
266 | 266 | |
267 | 267 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
268 | - @RequestMapping(value = "/tenant/devices", params = {"limit"}, method = RequestMethod.GET) | |
268 | + @RequestMapping(value = "/tenant/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
269 | 269 | @ResponseBody |
270 | - public TextPageData<Device> getTenantDevices( | |
271 | - @RequestParam int limit, | |
270 | + public PageData<Device> getTenantDevices( | |
271 | + @RequestParam int pageSize, | |
272 | + @RequestParam int page, | |
272 | 273 | @RequestParam(required = false) String type, |
273 | 274 | @RequestParam(required = false) String textSearch, |
274 | - @RequestParam(required = false) String idOffset, | |
275 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
275 | + @RequestParam(required = false) String sortProperty, | |
276 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
276 | 277 | try { |
277 | 278 | TenantId tenantId = getCurrentUser().getTenantId(); |
278 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
279 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
279 | 280 | if (type != null && type.trim().length() > 0) { |
280 | 281 | return checkNotNull(deviceService.findDevicesByTenantIdAndType(tenantId, type, pageLink)); |
281 | 282 | } else { |
... | ... | @@ -300,21 +301,22 @@ public class DeviceController extends BaseController { |
300 | 301 | } |
301 | 302 | |
302 | 303 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
303 | - @RequestMapping(value = "/customer/{customerId}/devices", params = {"limit"}, method = RequestMethod.GET) | |
304 | + @RequestMapping(value = "/customer/{customerId}/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
304 | 305 | @ResponseBody |
305 | - public TextPageData<Device> getCustomerDevices( | |
306 | + public PageData<Device> getCustomerDevices( | |
306 | 307 | @PathVariable("customerId") String strCustomerId, |
307 | - @RequestParam int limit, | |
308 | + @RequestParam int pageSize, | |
309 | + @RequestParam int page, | |
308 | 310 | @RequestParam(required = false) String type, |
309 | 311 | @RequestParam(required = false) String textSearch, |
310 | - @RequestParam(required = false) String idOffset, | |
311 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
312 | + @RequestParam(required = false) String sortProperty, | |
313 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
312 | 314 | checkParameter("customerId", strCustomerId); |
313 | 315 | try { |
314 | 316 | TenantId tenantId = getCurrentUser().getTenantId(); |
315 | 317 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); |
316 | 318 | checkCustomerId(customerId, Operation.READ); |
317 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
319 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
318 | 320 | if (type != null && type.trim().length() > 0) { |
319 | 321 | return checkNotNull(deviceService.findDevicesByTenantIdAndCustomerIdAndType(tenantId, customerId, type, pageLink)); |
320 | 322 | } else { | ... | ... |
... | ... | @@ -43,8 +43,8 @@ import org.thingsboard.server.common.data.id.EntityViewId; |
43 | 43 | import org.thingsboard.server.common.data.id.TenantId; |
44 | 44 | import org.thingsboard.server.common.data.id.UUIDBased; |
45 | 45 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
46 | -import org.thingsboard.server.common.data.page.TextPageData; | |
47 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
46 | +import org.thingsboard.server.common.data.page.PageData; | |
47 | +import org.thingsboard.server.common.data.page.PageLink; | |
48 | 48 | import org.thingsboard.server.dao.exception.IncorrectParameterException; |
49 | 49 | import org.thingsboard.server.dao.model.ModelConstants; |
50 | 50 | import org.thingsboard.server.service.security.model.SecurityUser; |
... | ... | @@ -256,21 +256,22 @@ public class EntityViewController extends BaseController { |
256 | 256 | } |
257 | 257 | |
258 | 258 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
259 | - @RequestMapping(value = "/customer/{customerId}/entityViews", params = {"limit"}, method = RequestMethod.GET) | |
259 | + @RequestMapping(value = "/customer/{customerId}/entityViews", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
260 | 260 | @ResponseBody |
261 | - public TextPageData<EntityView> getCustomerEntityViews( | |
261 | + public PageData<EntityView> getCustomerEntityViews( | |
262 | 262 | @PathVariable("customerId") String strCustomerId, |
263 | - @RequestParam int limit, | |
263 | + @RequestParam int pageSize, | |
264 | + @RequestParam int page, | |
264 | 265 | @RequestParam(required = false) String type, |
265 | 266 | @RequestParam(required = false) String textSearch, |
266 | - @RequestParam(required = false) String idOffset, | |
267 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
267 | + @RequestParam(required = false) String sortProperty, | |
268 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
268 | 269 | checkParameter("customerId", strCustomerId); |
269 | 270 | try { |
270 | 271 | TenantId tenantId = getCurrentUser().getTenantId(); |
271 | 272 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); |
272 | 273 | checkCustomerId(customerId, Operation.READ); |
273 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
274 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
274 | 275 | if (type != null && type.trim().length() > 0) { |
275 | 276 | return checkNotNull(entityViewService.findEntityViewsByTenantIdAndCustomerIdAndType(tenantId, customerId, pageLink, type)); |
276 | 277 | } else { |
... | ... | @@ -282,17 +283,18 @@ public class EntityViewController extends BaseController { |
282 | 283 | } |
283 | 284 | |
284 | 285 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
285 | - @RequestMapping(value = "/tenant/entityViews", params = {"limit"}, method = RequestMethod.GET) | |
286 | + @RequestMapping(value = "/tenant/entityViews", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
286 | 287 | @ResponseBody |
287 | - public TextPageData<EntityView> getTenantEntityViews( | |
288 | - @RequestParam int limit, | |
288 | + public PageData<EntityView> getTenantEntityViews( | |
289 | + @RequestParam int pageSize, | |
290 | + @RequestParam int page, | |
289 | 291 | @RequestParam(required = false) String type, |
290 | 292 | @RequestParam(required = false) String textSearch, |
291 | - @RequestParam(required = false) String idOffset, | |
292 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
293 | + @RequestParam(required = false) String sortProperty, | |
294 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
293 | 295 | try { |
294 | 296 | TenantId tenantId = getCurrentUser().getTenantId(); |
295 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
297 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
296 | 298 | |
297 | 299 | if (type != null && type.trim().length() > 0) { |
298 | 300 | return checkNotNull(entityViewService.findEntityViewByTenantIdAndType(tenantId, pageLink, type)); | ... | ... |
... | ... | @@ -29,7 +29,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; |
29 | 29 | import org.thingsboard.server.common.data.id.EntityId; |
30 | 30 | import org.thingsboard.server.common.data.id.EntityIdFactory; |
31 | 31 | import org.thingsboard.server.common.data.id.TenantId; |
32 | -import org.thingsboard.server.common.data.page.TimePageData; | |
32 | +import org.thingsboard.server.common.data.page.PageData; | |
33 | 33 | import org.thingsboard.server.common.data.page.TimePageLink; |
34 | 34 | import org.thingsboard.server.dao.event.EventService; |
35 | 35 | import org.thingsboard.server.dao.model.ModelConstants; |
... | ... | @@ -46,16 +46,16 @@ public class EventController extends BaseController { |
46 | 46 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
47 | 47 | @RequestMapping(value = "/events/{entityType}/{entityId}/{eventType}", method = RequestMethod.GET) |
48 | 48 | @ResponseBody |
49 | - public TimePageData<Event> getEvents( | |
49 | + public PageData<Event> getEvents( | |
50 | 50 | @PathVariable("entityType") String strEntityType, |
51 | 51 | @PathVariable("entityId") String strEntityId, |
52 | 52 | @PathVariable("eventType") String eventType, |
53 | 53 | @RequestParam("tenantId") String strTenantId, |
54 | - @RequestParam int limit, | |
54 | + @RequestParam int pageSize, | |
55 | + @RequestParam int page, | |
55 | 56 | @RequestParam(required = false) Long startTime, |
56 | 57 | @RequestParam(required = false) Long endTime, |
57 | - @RequestParam(required = false, defaultValue = "false") boolean ascOrder, | |
58 | - @RequestParam(required = false) String offset | |
58 | + @RequestParam(required = false, defaultValue = "false") boolean ascOrder | |
59 | 59 | ) throws ThingsboardException { |
60 | 60 | checkParameter("EntityId", strEntityId); |
61 | 61 | checkParameter("EntityType", strEntityType); |
... | ... | @@ -64,8 +64,8 @@ public class EventController extends BaseController { |
64 | 64 | |
65 | 65 | EntityId entityId = EntityIdFactory.getByTypeAndId(strEntityType, strEntityId); |
66 | 66 | checkEntityId(entityId, Operation.READ); |
67 | - | |
68 | - TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset); | |
67 | + TimePageLink pageLink = createTimePageLink(pageSize, page, "", | |
68 | + "createdTime", ascOrder ? "asc" : "desc", startTime, endTime); | |
69 | 69 | return checkNotNull(eventService.findEvents(tenantId, entityId, eventType, pageLink)); |
70 | 70 | } catch (Exception e) { |
71 | 71 | throw handleException(e); |
... | ... | @@ -75,15 +75,15 @@ public class EventController extends BaseController { |
75 | 75 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
76 | 76 | @RequestMapping(value = "/events/{entityType}/{entityId}", method = RequestMethod.GET) |
77 | 77 | @ResponseBody |
78 | - public TimePageData<Event> getEvents( | |
78 | + public PageData<Event> getEvents( | |
79 | 79 | @PathVariable("entityType") String strEntityType, |
80 | 80 | @PathVariable("entityId") String strEntityId, |
81 | 81 | @RequestParam("tenantId") String strTenantId, |
82 | - @RequestParam int limit, | |
82 | + @RequestParam int pageSize, | |
83 | + @RequestParam int page, | |
83 | 84 | @RequestParam(required = false) Long startTime, |
84 | 85 | @RequestParam(required = false) Long endTime, |
85 | - @RequestParam(required = false, defaultValue = "false") boolean ascOrder, | |
86 | - @RequestParam(required = false) String offset | |
86 | + @RequestParam(required = false, defaultValue = "false") boolean ascOrder | |
87 | 87 | ) throws ThingsboardException { |
88 | 88 | checkParameter("EntityId", strEntityId); |
89 | 89 | checkParameter("EntityType", strEntityType); |
... | ... | @@ -93,7 +93,9 @@ public class EventController extends BaseController { |
93 | 93 | EntityId entityId = EntityIdFactory.getByTypeAndId(strEntityType, strEntityId); |
94 | 94 | checkEntityId(entityId, Operation.READ); |
95 | 95 | |
96 | - TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset); | |
96 | + TimePageLink pageLink = createTimePageLink(pageSize, page, "", | |
97 | + "createdTime", ascOrder ? "asc" : "desc", startTime, endTime); | |
98 | + | |
97 | 99 | return checkNotNull(eventService.findEvents(tenantId, entityId, pageLink)); |
98 | 100 | } catch (Exception e) { |
99 | 101 | throw handleException(e); | ... | ... |
... | ... | @@ -45,8 +45,8 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; |
45 | 45 | import org.thingsboard.server.common.data.id.RuleChainId; |
46 | 46 | import org.thingsboard.server.common.data.id.RuleNodeId; |
47 | 47 | import org.thingsboard.server.common.data.id.TenantId; |
48 | -import org.thingsboard.server.common.data.page.TextPageData; | |
49 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
48 | +import org.thingsboard.server.common.data.page.PageData; | |
49 | +import org.thingsboard.server.common.data.page.PageLink; | |
50 | 50 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent; |
51 | 51 | import org.thingsboard.server.common.data.rule.RuleChain; |
52 | 52 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; |
... | ... | @@ -220,16 +220,17 @@ public class RuleChainController extends BaseController { |
220 | 220 | } |
221 | 221 | |
222 | 222 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
223 | - @RequestMapping(value = "/ruleChains", params = {"limit"}, method = RequestMethod.GET) | |
223 | + @RequestMapping(value = "/ruleChains", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
224 | 224 | @ResponseBody |
225 | - public TextPageData<RuleChain> getRuleChains( | |
226 | - @RequestParam int limit, | |
225 | + public PageData<RuleChain> getRuleChains( | |
226 | + @RequestParam int pageSize, | |
227 | + @RequestParam int page, | |
227 | 228 | @RequestParam(required = false) String textSearch, |
228 | - @RequestParam(required = false) String idOffset, | |
229 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
229 | + @RequestParam(required = false) String sortProperty, | |
230 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
230 | 231 | try { |
231 | 232 | TenantId tenantId = getCurrentUser().getTenantId(); |
232 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
233 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
233 | 234 | return checkNotNull(ruleChainService.findTenantRuleChains(tenantId, pageLink)); |
234 | 235 | } catch (Exception e) { |
235 | 236 | throw handleException(e); | ... | ... |
... | ... | @@ -30,8 +30,8 @@ import org.springframework.web.bind.annotation.RestController; |
30 | 30 | import org.thingsboard.server.common.data.Tenant; |
31 | 31 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
32 | 32 | import org.thingsboard.server.common.data.id.TenantId; |
33 | -import org.thingsboard.server.common.data.page.TextPageData; | |
34 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
33 | +import org.thingsboard.server.common.data.page.PageData; | |
34 | +import org.thingsboard.server.common.data.page.PageLink; | |
35 | 35 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent; |
36 | 36 | import org.thingsboard.server.dao.tenant.TenantService; |
37 | 37 | import org.thingsboard.server.service.install.InstallScripts; |
... | ... | @@ -102,14 +102,15 @@ public class TenantController extends BaseController { |
102 | 102 | } |
103 | 103 | |
104 | 104 | @PreAuthorize("hasAuthority('SYS_ADMIN')") |
105 | - @RequestMapping(value = "/tenants", params = {"limit"}, method = RequestMethod.GET) | |
105 | + @RequestMapping(value = "/tenants", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
106 | 106 | @ResponseBody |
107 | - public TextPageData<Tenant> getTenants(@RequestParam int limit, | |
108 | - @RequestParam(required = false) String textSearch, | |
109 | - @RequestParam(required = false) String idOffset, | |
110 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
107 | + public PageData<Tenant> getTenants(@RequestParam int pageSize, | |
108 | + @RequestParam int page, | |
109 | + @RequestParam(required = false) String textSearch, | |
110 | + @RequestParam(required = false) String sortProperty, | |
111 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
111 | 112 | try { |
112 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
113 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
113 | 114 | return checkNotNull(tenantService.findTenants(pageLink)); |
114 | 115 | } catch (Exception e) { |
115 | 116 | throw handleException(e); | ... | ... |
... | ... | @@ -40,8 +40,8 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; |
40 | 40 | import org.thingsboard.server.common.data.id.CustomerId; |
41 | 41 | import org.thingsboard.server.common.data.id.TenantId; |
42 | 42 | import org.thingsboard.server.common.data.id.UserId; |
43 | -import org.thingsboard.server.common.data.page.TextPageData; | |
44 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
43 | +import org.thingsboard.server.common.data.page.PageData; | |
44 | +import org.thingsboard.server.common.data.page.PageLink; | |
45 | 45 | import org.thingsboard.server.common.data.security.Authority; |
46 | 46 | import org.thingsboard.server.common.data.security.UserCredentials; |
47 | 47 | import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository; |
... | ... | @@ -247,18 +247,19 @@ public class UserController extends BaseController { |
247 | 247 | } |
248 | 248 | |
249 | 249 | @PreAuthorize("hasAuthority('SYS_ADMIN')") |
250 | - @RequestMapping(value = "/tenant/{tenantId}/users", params = { "limit" }, method = RequestMethod.GET) | |
250 | + @RequestMapping(value = "/tenant/{tenantId}/users", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
251 | 251 | @ResponseBody |
252 | - public TextPageData<User> getTenantAdmins( | |
252 | + public PageData<User> getTenantAdmins( | |
253 | 253 | @PathVariable("tenantId") String strTenantId, |
254 | - @RequestParam int limit, | |
254 | + @RequestParam int pageSize, | |
255 | + @RequestParam int page, | |
255 | 256 | @RequestParam(required = false) String textSearch, |
256 | - @RequestParam(required = false) String idOffset, | |
257 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
257 | + @RequestParam(required = false) String sortProperty, | |
258 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
258 | 259 | checkParameter("tenantId", strTenantId); |
259 | 260 | try { |
260 | 261 | TenantId tenantId = new TenantId(toUUID(strTenantId)); |
261 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
262 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
262 | 263 | return checkNotNull(userService.findTenantAdmins(tenantId, pageLink)); |
263 | 264 | } catch (Exception e) { |
264 | 265 | throw handleException(e); |
... | ... | @@ -266,19 +267,20 @@ public class UserController extends BaseController { |
266 | 267 | } |
267 | 268 | |
268 | 269 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
269 | - @RequestMapping(value = "/customer/{customerId}/users", params = { "limit" }, method = RequestMethod.GET) | |
270 | + @RequestMapping(value = "/customer/{customerId}/users", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
270 | 271 | @ResponseBody |
271 | - public TextPageData<User> getCustomerUsers( | |
272 | + public PageData<User> getCustomerUsers( | |
272 | 273 | @PathVariable("customerId") String strCustomerId, |
273 | - @RequestParam int limit, | |
274 | + @RequestParam int pageSize, | |
275 | + @RequestParam int page, | |
274 | 276 | @RequestParam(required = false) String textSearch, |
275 | - @RequestParam(required = false) String idOffset, | |
276 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
277 | + @RequestParam(required = false) String sortProperty, | |
278 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
277 | 279 | checkParameter("customerId", strCustomerId); |
278 | 280 | try { |
279 | 281 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); |
280 | 282 | checkCustomerId(customerId, Operation.READ); |
281 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
283 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
282 | 284 | TenantId tenantId = getCurrentUser().getTenantId(); |
283 | 285 | return checkNotNull(userService.findCustomerUsers(tenantId, customerId, pageLink)); |
284 | 286 | } catch (Exception e) { | ... | ... |
... | ... | @@ -28,8 +28,8 @@ import org.springframework.web.bind.annotation.RestController; |
28 | 28 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
29 | 29 | import org.thingsboard.server.common.data.id.TenantId; |
30 | 30 | import org.thingsboard.server.common.data.id.WidgetsBundleId; |
31 | -import org.thingsboard.server.common.data.page.TextPageData; | |
32 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
31 | +import org.thingsboard.server.common.data.page.PageData; | |
32 | +import org.thingsboard.server.common.data.page.PageLink; | |
33 | 33 | import org.thingsboard.server.common.data.security.Authority; |
34 | 34 | import org.thingsboard.server.common.data.widget.WidgetsBundle; |
35 | 35 | import org.thingsboard.server.dao.model.ModelConstants; |
... | ... | @@ -92,15 +92,16 @@ public class WidgetsBundleController extends BaseController { |
92 | 92 | } |
93 | 93 | |
94 | 94 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
95 | - @RequestMapping(value = "/widgetsBundles", params = { "limit" }, method = RequestMethod.GET) | |
95 | + @RequestMapping(value = "/widgetsBundles", params = {"pageSize", "page"}, method = RequestMethod.GET) | |
96 | 96 | @ResponseBody |
97 | - public TextPageData<WidgetsBundle> getWidgetsBundles( | |
98 | - @RequestParam int limit, | |
97 | + public PageData<WidgetsBundle> getWidgetsBundles( | |
98 | + @RequestParam int pageSize, | |
99 | + @RequestParam int page, | |
99 | 100 | @RequestParam(required = false) String textSearch, |
100 | - @RequestParam(required = false) String idOffset, | |
101 | - @RequestParam(required = false) String textOffset) throws ThingsboardException { | |
101 | + @RequestParam(required = false) String sortProperty, | |
102 | + @RequestParam(required = false) String sortOrder) throws ThingsboardException { | |
102 | 103 | try { |
103 | - TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset); | |
104 | + PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | |
104 | 105 | if (getCurrentUser().getAuthority() == Authority.SYS_ADMIN) { |
105 | 106 | return checkNotNull(widgetsBundleService.findSystemWidgetsBundlesByPageLink(getTenantId(), pageLink)); |
106 | 107 | } else { | ... | ... |
... | ... | @@ -22,8 +22,8 @@ import org.springframework.stereotype.Service; |
22 | 22 | import org.thingsboard.server.common.data.SearchTextBased; |
23 | 23 | import org.thingsboard.server.common.data.Tenant; |
24 | 24 | import org.thingsboard.server.common.data.id.UUIDBased; |
25 | -import org.thingsboard.server.common.data.page.TextPageData; | |
26 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
25 | +import org.thingsboard.server.common.data.page.PageData; | |
26 | +import org.thingsboard.server.common.data.page.PageLink; | |
27 | 27 | import org.thingsboard.server.common.data.rule.RuleChain; |
28 | 28 | import org.thingsboard.server.dao.rule.RuleChainService; |
29 | 29 | import org.thingsboard.server.dao.tenant.TenantService; |
... | ... | @@ -59,7 +59,7 @@ public class DefaultDataUpdateService implements DataUpdateService { |
59 | 59 | new PaginatedUpdater<String, Tenant>() { |
60 | 60 | |
61 | 61 | @Override |
62 | - protected TextPageData<Tenant> findEntities(String region, TextPageLink pageLink) { | |
62 | + protected PageData<Tenant> findEntities(String region, PageLink pageLink) { | |
63 | 63 | return tenantService.findTenants(pageLink); |
64 | 64 | } |
65 | 65 | ... | ... |
... | ... | @@ -17,29 +17,29 @@ package org.thingsboard.server.service.install.update; |
17 | 17 | |
18 | 18 | import org.thingsboard.server.common.data.SearchTextBased; |
19 | 19 | import org.thingsboard.server.common.data.id.UUIDBased; |
20 | -import org.thingsboard.server.common.data.page.TextPageData; | |
21 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
20 | +import org.thingsboard.server.common.data.page.PageData; | |
21 | +import org.thingsboard.server.common.data.page.PageLink; | |
22 | 22 | |
23 | 23 | public abstract class PaginatedUpdater<I, D extends SearchTextBased<? extends UUIDBased>> { |
24 | 24 | |
25 | 25 | private static final int DEFAULT_LIMIT = 100; |
26 | 26 | |
27 | 27 | public void updateEntities(I id) { |
28 | - TextPageLink pageLink = new TextPageLink(DEFAULT_LIMIT); | |
28 | + PageLink pageLink = new PageLink(DEFAULT_LIMIT); | |
29 | 29 | boolean hasNext = true; |
30 | 30 | while (hasNext) { |
31 | - TextPageData<D> entities = findEntities(id, pageLink); | |
31 | + PageData<D> entities = findEntities(id, pageLink); | |
32 | 32 | for (D entity : entities.getData()) { |
33 | 33 | updateEntity(entity); |
34 | 34 | } |
35 | 35 | hasNext = entities.hasNext(); |
36 | 36 | if (hasNext) { |
37 | - pageLink = entities.getNextPageLink(); | |
37 | + pageLink = pageLink.nextPageLink(); | |
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | - protected abstract TextPageData<D> findEntities(I id, TextPageLink pageLink); | |
42 | + protected abstract PageData<D> findEntities(I id, PageLink pageLink); | |
43 | 43 | |
44 | 44 | protected abstract void updateEntity(D entity); |
45 | 45 | ... | ... |
... | ... | @@ -38,7 +38,7 @@ import org.thingsboard.server.common.data.Tenant; |
38 | 38 | import org.thingsboard.server.common.data.id.DeviceId; |
39 | 39 | import org.thingsboard.server.common.data.id.TenantId; |
40 | 40 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
41 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
41 | +import org.thingsboard.server.common.data.page.PageLink; | |
42 | 42 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleState; |
43 | 43 | import org.thingsboard.server.common.msg.TbMsg; |
44 | 44 | import org.thingsboard.server.common.msg.TbMsgDataType; |
... | ... | @@ -219,10 +219,10 @@ public class DefaultDeviceStateService implements DeviceStateService { |
219 | 219 | } |
220 | 220 | |
221 | 221 | private void onClusterUpdateSync() { |
222 | - List<Tenant> tenants = tenantService.findTenants(new TextPageLink(Integer.MAX_VALUE)).getData(); | |
222 | + List<Tenant> tenants = tenantService.findTenants(new PageLink(Integer.MAX_VALUE)).getData(); | |
223 | 223 | for (Tenant tenant : tenants) { |
224 | 224 | List<ListenableFuture<DeviceStateData>> fetchFutures = new ArrayList<>(); |
225 | - List<Device> devices = deviceService.findDevicesByTenantId(tenant.getId(), new TextPageLink(Integer.MAX_VALUE)).getData(); | |
225 | + List<Device> devices = deviceService.findDevicesByTenantId(tenant.getId(), new PageLink(Integer.MAX_VALUE)).getData(); | |
226 | 226 | for (Device device : devices) { |
227 | 227 | if (!routingService.resolveById(device.getId()).isPresent()) { |
228 | 228 | if (!deviceStates.containsKey(device.getId())) { |
... | ... | @@ -245,10 +245,10 @@ public class DefaultDeviceStateService implements DeviceStateService { |
245 | 245 | } |
246 | 246 | |
247 | 247 | private void initStateFromDB() { |
248 | - List<Tenant> tenants = tenantService.findTenants(new TextPageLink(Integer.MAX_VALUE)).getData(); | |
248 | + List<Tenant> tenants = tenantService.findTenants(new PageLink(Integer.MAX_VALUE)).getData(); | |
249 | 249 | for (Tenant tenant : tenants) { |
250 | 250 | List<ListenableFuture<DeviceStateData>> fetchFutures = new ArrayList<>(); |
251 | - List<Device> devices = deviceService.findDevicesByTenantId(tenant.getId(), new TextPageLink(Integer.MAX_VALUE)).getData(); | |
251 | + List<Device> devices = deviceService.findDevicesByTenantId(tenant.getId(), new PageLink(Integer.MAX_VALUE)).getData(); | |
252 | 252 | for (Device device : devices) { |
253 | 253 | if (!routingService.resolveById(device.getId()).isPresent()) { |
254 | 254 | fetchFutures.add(fetchDeviceState(device)); | ... | ... |
... | ... | @@ -65,7 +65,8 @@ import org.thingsboard.server.common.data.Tenant; |
65 | 65 | import org.thingsboard.server.common.data.User; |
66 | 66 | import org.thingsboard.server.common.data.id.TenantId; |
67 | 67 | import org.thingsboard.server.common.data.id.UUIDBased; |
68 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
68 | +import org.thingsboard.server.common.data.page.PageLink; | |
69 | +import org.thingsboard.server.common.data.page.SortOrder; | |
69 | 70 | import org.thingsboard.server.common.data.page.TimePageLink; |
70 | 71 | import org.thingsboard.server.common.data.security.Authority; |
71 | 72 | import org.thingsboard.server.config.ThingsboardSecurityConfiguration; |
... | ... | @@ -314,22 +315,20 @@ public abstract class AbstractControllerTest { |
314 | 315 | } |
315 | 316 | |
316 | 317 | protected <T> T doGetTypedWithPageLink(String urlTemplate, TypeReference<T> responseType, |
317 | - TextPageLink pageLink, | |
318 | + PageLink pageLink, | |
318 | 319 | Object... urlVariables) throws Exception { |
319 | 320 | List<Object> pageLinkVariables = new ArrayList<>(); |
320 | - urlTemplate += "limit={limit}"; | |
321 | - pageLinkVariables.add(pageLink.getLimit()); | |
321 | + urlTemplate += "pageSize={pageSize}&page={page}"; | |
322 | + pageLinkVariables.add(pageLink.getPageSize()); | |
323 | + pageLinkVariables.add(pageLink.getPage()); | |
322 | 324 | if (StringUtils.isNotEmpty(pageLink.getTextSearch())) { |
323 | 325 | urlTemplate += "&textSearch={textSearch}"; |
324 | 326 | pageLinkVariables.add(pageLink.getTextSearch()); |
325 | 327 | } |
326 | - if (pageLink.getIdOffset() != null) { | |
327 | - urlTemplate += "&idOffset={idOffset}"; | |
328 | - pageLinkVariables.add(pageLink.getIdOffset().toString()); | |
329 | - } | |
330 | - if (StringUtils.isNotEmpty(pageLink.getTextOffset())) { | |
331 | - urlTemplate += "&textOffset={textOffset}"; | |
332 | - pageLinkVariables.add(pageLink.getTextOffset()); | |
328 | + if (pageLink.getSortOrder() != null) { | |
329 | + urlTemplate += "&sortProperty={sortProperty}&sortOrder={sortOrder}"; | |
330 | + pageLinkVariables.add(pageLink.getSortOrder().getProperty()); | |
331 | + pageLinkVariables.add(pageLink.getSortOrder().getDirection().name()); | |
333 | 332 | } |
334 | 333 | |
335 | 334 | Object[] vars = new Object[urlVariables.length + pageLinkVariables.size()]; |
... | ... | @@ -343,8 +342,10 @@ public abstract class AbstractControllerTest { |
343 | 342 | TimePageLink pageLink, |
344 | 343 | Object... urlVariables) throws Exception { |
345 | 344 | List<Object> pageLinkVariables = new ArrayList<>(); |
346 | - urlTemplate += "limit={limit}"; | |
347 | - pageLinkVariables.add(pageLink.getLimit()); | |
345 | + urlTemplate += "pageSize={pageSize}&page={page}"; | |
346 | + pageLinkVariables.add(pageLink.getPageSize()); | |
347 | + pageLinkVariables.add(pageLink.getPage()); | |
348 | + | |
348 | 349 | if (pageLink.getStartTime() != null) { |
349 | 350 | urlTemplate += "&startTime={startTime}"; |
350 | 351 | pageLinkVariables.add(pageLink.getStartTime()); |
... | ... | @@ -353,13 +354,9 @@ public abstract class AbstractControllerTest { |
353 | 354 | urlTemplate += "&endTime={endTime}"; |
354 | 355 | pageLinkVariables.add(pageLink.getEndTime()); |
355 | 356 | } |
356 | - if (pageLink.getIdOffset() != null) { | |
357 | - urlTemplate += "&offset={offset}"; | |
358 | - pageLinkVariables.add(pageLink.getIdOffset().toString()); | |
359 | - } | |
360 | - if (pageLink.isAscOrder()) { | |
357 | + if (pageLink.getSortOrder() != null) { | |
361 | 358 | urlTemplate += "&ascOrder={ascOrder}"; |
362 | - pageLinkVariables.add(pageLink.isAscOrder()); | |
359 | + pageLinkVariables.add(pageLink.getSortOrder().getDirection() == SortOrder.Direction.ASC); | |
363 | 360 | } |
364 | 361 | Object[] vars = new Object[urlVariables.length + pageLinkVariables.size()]; |
365 | 362 | System.arraycopy(urlVariables, 0, vars, 0, urlVariables.length); | ... | ... |
... | ... | @@ -23,7 +23,7 @@ import org.thingsboard.server.common.data.Event; |
23 | 23 | import org.thingsboard.server.common.data.id.EntityId; |
24 | 24 | import org.thingsboard.server.common.data.id.RuleChainId; |
25 | 25 | import org.thingsboard.server.common.data.id.TenantId; |
26 | -import org.thingsboard.server.common.data.page.TimePageData; | |
26 | +import org.thingsboard.server.common.data.page.PageData; | |
27 | 27 | import org.thingsboard.server.common.data.page.TimePageLink; |
28 | 28 | import org.thingsboard.server.common.data.rule.RuleChain; |
29 | 29 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; |
... | ... | @@ -56,10 +56,10 @@ public class AbstractRuleEngineControllerTest extends AbstractControllerTest { |
56 | 56 | return doGet("/api/ruleChain/metadata/" + ruleChainId.getId().toString(), RuleChainMetaData.class); |
57 | 57 | } |
58 | 58 | |
59 | - protected TimePageData<Event> getDebugEvents(TenantId tenantId, EntityId entityId, int limit) throws Exception { | |
59 | + protected PageData<Event> getDebugEvents(TenantId tenantId, EntityId entityId, int limit) throws Exception { | |
60 | 60 | TimePageLink pageLink = new TimePageLink(limit); |
61 | 61 | return doGetTypedWithTimePageLink("/api/events/{entityType}/{entityId}/{eventType}?tenantId={tenantId}&", |
62 | - new TypeReference<TimePageData<Event>>() { | |
62 | + new TypeReference<PageData<Event>>() { | |
63 | 63 | }, pageLink, entityId.getEntityType(), entityId.getId(), DataConstants.DEBUG_RULE_NODE, tenantId.getId()); |
64 | 64 | } |
65 | 65 | ... | ... |
... | ... | @@ -28,8 +28,8 @@ import org.thingsboard.server.common.data.Tenant; |
28 | 28 | import org.thingsboard.server.common.data.User; |
29 | 29 | import org.thingsboard.server.common.data.asset.Asset; |
30 | 30 | import org.thingsboard.server.common.data.id.CustomerId; |
31 | -import org.thingsboard.server.common.data.page.TextPageData; | |
32 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
31 | +import org.thingsboard.server.common.data.page.PageData; | |
32 | +import org.thingsboard.server.common.data.page.PageLink; | |
33 | 33 | import org.thingsboard.server.common.data.security.Authority; |
34 | 34 | import org.thingsboard.server.dao.model.ModelConstants; |
35 | 35 | |
... | ... | @@ -258,14 +258,14 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
258 | 258 | assets.add(doPost("/api/asset", asset, Asset.class)); |
259 | 259 | } |
260 | 260 | List<Asset> loadedAssets = new ArrayList<>(); |
261 | - TextPageLink pageLink = new TextPageLink(23); | |
262 | - TextPageData<Asset> pageData = null; | |
261 | + PageLink pageLink = new PageLink(23); | |
262 | + PageData<Asset> pageData = null; | |
263 | 263 | do { |
264 | 264 | pageData = doGetTypedWithPageLink("/api/tenant/assets?", |
265 | - new TypeReference<TextPageData<Asset>>(){}, pageLink); | |
265 | + new TypeReference<PageData<Asset>>(){}, pageLink); | |
266 | 266 | loadedAssets.addAll(pageData.getData()); |
267 | 267 | if (pageData.hasNext()) { |
268 | - pageLink = pageData.getNextPageLink(); | |
268 | + pageLink = pageLink.nextPageLink(); | |
269 | 269 | } |
270 | 270 | } while (pageData.hasNext()); |
271 | 271 | |
... | ... | @@ -301,14 +301,14 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
301 | 301 | } |
302 | 302 | |
303 | 303 | List<Asset> loadedAssetsTitle1 = new ArrayList<>(); |
304 | - TextPageLink pageLink = new TextPageLink(15, title1); | |
305 | - TextPageData<Asset> pageData = null; | |
304 | + PageLink pageLink = new PageLink(15, 0, title1); | |
305 | + PageData<Asset> pageData = null; | |
306 | 306 | do { |
307 | 307 | pageData = doGetTypedWithPageLink("/api/tenant/assets?", |
308 | - new TypeReference<TextPageData<Asset>>(){}, pageLink); | |
308 | + new TypeReference<PageData<Asset>>(){}, pageLink); | |
309 | 309 | loadedAssetsTitle1.addAll(pageData.getData()); |
310 | 310 | if (pageData.hasNext()) { |
311 | - pageLink = pageData.getNextPageLink(); | |
311 | + pageLink = pageLink.nextPageLink(); | |
312 | 312 | } |
313 | 313 | } while (pageData.hasNext()); |
314 | 314 | |
... | ... | @@ -318,13 +318,13 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
318 | 318 | Assert.assertEquals(assetsTitle1, loadedAssetsTitle1); |
319 | 319 | |
320 | 320 | List<Asset> loadedAssetsTitle2 = new ArrayList<>(); |
321 | - pageLink = new TextPageLink(4, title2); | |
321 | + pageLink = new PageLink(4, 0, title2); | |
322 | 322 | do { |
323 | 323 | pageData = doGetTypedWithPageLink("/api/tenant/assets?", |
324 | - new TypeReference<TextPageData<Asset>>(){}, pageLink); | |
324 | + new TypeReference<PageData<Asset>>(){}, pageLink); | |
325 | 325 | loadedAssetsTitle2.addAll(pageData.getData()); |
326 | 326 | if (pageData.hasNext()) { |
327 | - pageLink = pageData.getNextPageLink(); | |
327 | + pageLink = pageLink.nextPageLink(); | |
328 | 328 | } |
329 | 329 | } while (pageData.hasNext()); |
330 | 330 | |
... | ... | @@ -338,9 +338,9 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
338 | 338 | .andExpect(status().isOk()); |
339 | 339 | } |
340 | 340 | |
341 | - pageLink = new TextPageLink(4, title1); | |
341 | + pageLink = new PageLink(4, 0, title1); | |
342 | 342 | pageData = doGetTypedWithPageLink("/api/tenant/assets?", |
343 | - new TypeReference<TextPageData<Asset>>(){}, pageLink); | |
343 | + new TypeReference<PageData<Asset>>(){}, pageLink); | |
344 | 344 | Assert.assertFalse(pageData.hasNext()); |
345 | 345 | Assert.assertEquals(0, pageData.getData().size()); |
346 | 346 | |
... | ... | @@ -349,9 +349,9 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
349 | 349 | .andExpect(status().isOk()); |
350 | 350 | } |
351 | 351 | |
352 | - pageLink = new TextPageLink(4, title2); | |
352 | + pageLink = new PageLink(4, 0, title2); | |
353 | 353 | pageData = doGetTypedWithPageLink("/api/tenant/assets?", |
354 | - new TypeReference<TextPageData<Asset>>(){}, pageLink); | |
354 | + new TypeReference<PageData<Asset>>(){}, pageLink); | |
355 | 355 | Assert.assertFalse(pageData.hasNext()); |
356 | 356 | Assert.assertEquals(0, pageData.getData().size()); |
357 | 357 | } |
... | ... | @@ -384,14 +384,14 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
384 | 384 | } |
385 | 385 | |
386 | 386 | List<Asset> loadedAssetsType1 = new ArrayList<>(); |
387 | - TextPageLink pageLink = new TextPageLink(15); | |
388 | - TextPageData<Asset> pageData = null; | |
387 | + PageLink pageLink = new PageLink(15); | |
388 | + PageData<Asset> pageData = null; | |
389 | 389 | do { |
390 | 390 | pageData = doGetTypedWithPageLink("/api/tenant/assets?type={type}&", |
391 | - new TypeReference<TextPageData<Asset>>(){}, pageLink, type1); | |
391 | + new TypeReference<PageData<Asset>>(){}, pageLink, type1); | |
392 | 392 | loadedAssetsType1.addAll(pageData.getData()); |
393 | 393 | if (pageData.hasNext()) { |
394 | - pageLink = pageData.getNextPageLink(); | |
394 | + pageLink = pageLink.nextPageLink(); | |
395 | 395 | } |
396 | 396 | } while (pageData.hasNext()); |
397 | 397 | |
... | ... | @@ -401,13 +401,13 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
401 | 401 | Assert.assertEquals(assetsType1, loadedAssetsType1); |
402 | 402 | |
403 | 403 | List<Asset> loadedAssetsType2 = new ArrayList<>(); |
404 | - pageLink = new TextPageLink(4); | |
404 | + pageLink = new PageLink(4); | |
405 | 405 | do { |
406 | 406 | pageData = doGetTypedWithPageLink("/api/tenant/assets?type={type}&", |
407 | - new TypeReference<TextPageData<Asset>>(){}, pageLink, type2); | |
407 | + new TypeReference<PageData<Asset>>(){}, pageLink, type2); | |
408 | 408 | loadedAssetsType2.addAll(pageData.getData()); |
409 | 409 | if (pageData.hasNext()) { |
410 | - pageLink = pageData.getNextPageLink(); | |
410 | + pageLink = pageLink.nextPageLink(); | |
411 | 411 | } |
412 | 412 | } while (pageData.hasNext()); |
413 | 413 | |
... | ... | @@ -421,9 +421,9 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
421 | 421 | .andExpect(status().isOk()); |
422 | 422 | } |
423 | 423 | |
424 | - pageLink = new TextPageLink(4); | |
424 | + pageLink = new PageLink(4); | |
425 | 425 | pageData = doGetTypedWithPageLink("/api/tenant/assets?type={type}&", |
426 | - new TypeReference<TextPageData<Asset>>(){}, pageLink, type1); | |
426 | + new TypeReference<PageData<Asset>>(){}, pageLink, type1); | |
427 | 427 | Assert.assertFalse(pageData.hasNext()); |
428 | 428 | Assert.assertEquals(0, pageData.getData().size()); |
429 | 429 | |
... | ... | @@ -432,9 +432,9 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
432 | 432 | .andExpect(status().isOk()); |
433 | 433 | } |
434 | 434 | |
435 | - pageLink = new TextPageLink(4); | |
435 | + pageLink = new PageLink(4); | |
436 | 436 | pageData = doGetTypedWithPageLink("/api/tenant/assets?type={type}&", |
437 | - new TypeReference<TextPageData<Asset>>(){}, pageLink, type2); | |
437 | + new TypeReference<PageData<Asset>>(){}, pageLink, type2); | |
438 | 438 | Assert.assertFalse(pageData.hasNext()); |
439 | 439 | Assert.assertEquals(0, pageData.getData().size()); |
440 | 440 | } |
... | ... | @@ -457,14 +457,14 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
457 | 457 | } |
458 | 458 | |
459 | 459 | List<Asset> loadedAssets = new ArrayList<>(); |
460 | - TextPageLink pageLink = new TextPageLink(23); | |
461 | - TextPageData<Asset> pageData = null; | |
460 | + PageLink pageLink = new PageLink(23); | |
461 | + PageData<Asset> pageData = null; | |
462 | 462 | do { |
463 | 463 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/assets?", |
464 | - new TypeReference<TextPageData<Asset>>(){}, pageLink); | |
464 | + new TypeReference<PageData<Asset>>(){}, pageLink); | |
465 | 465 | loadedAssets.addAll(pageData.getData()); |
466 | 466 | if (pageData.hasNext()) { |
467 | - pageLink = pageData.getNextPageLink(); | |
467 | + pageLink = pageLink.nextPageLink(); | |
468 | 468 | } |
469 | 469 | } while (pageData.hasNext()); |
470 | 470 | |
... | ... | @@ -509,14 +509,14 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
509 | 509 | } |
510 | 510 | |
511 | 511 | List<Asset> loadedAssetsTitle1 = new ArrayList<>(); |
512 | - TextPageLink pageLink = new TextPageLink(15, title1); | |
513 | - TextPageData<Asset> pageData = null; | |
512 | + PageLink pageLink = new PageLink(15, 0, title1); | |
513 | + PageData<Asset> pageData = null; | |
514 | 514 | do { |
515 | 515 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/assets?", |
516 | - new TypeReference<TextPageData<Asset>>(){}, pageLink); | |
516 | + new TypeReference<PageData<Asset>>(){}, pageLink); | |
517 | 517 | loadedAssetsTitle1.addAll(pageData.getData()); |
518 | 518 | if (pageData.hasNext()) { |
519 | - pageLink = pageData.getNextPageLink(); | |
519 | + pageLink = pageLink.nextPageLink(); | |
520 | 520 | } |
521 | 521 | } while (pageData.hasNext()); |
522 | 522 | |
... | ... | @@ -526,13 +526,13 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
526 | 526 | Assert.assertEquals(assetsTitle1, loadedAssetsTitle1); |
527 | 527 | |
528 | 528 | List<Asset> loadedAssetsTitle2 = new ArrayList<>(); |
529 | - pageLink = new TextPageLink(4, title2); | |
529 | + pageLink = new PageLink(4, 0, title2); | |
530 | 530 | do { |
531 | 531 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/assets?", |
532 | - new TypeReference<TextPageData<Asset>>(){}, pageLink); | |
532 | + new TypeReference<PageData<Asset>>(){}, pageLink); | |
533 | 533 | loadedAssetsTitle2.addAll(pageData.getData()); |
534 | 534 | if (pageData.hasNext()) { |
535 | - pageLink = pageData.getNextPageLink(); | |
535 | + pageLink = pageLink.nextPageLink(); | |
536 | 536 | } |
537 | 537 | } while (pageData.hasNext()); |
538 | 538 | |
... | ... | @@ -546,9 +546,9 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
546 | 546 | .andExpect(status().isOk()); |
547 | 547 | } |
548 | 548 | |
549 | - pageLink = new TextPageLink(4, title1); | |
549 | + pageLink = new PageLink(4, 0, title1); | |
550 | 550 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/assets?", |
551 | - new TypeReference<TextPageData<Asset>>(){}, pageLink); | |
551 | + new TypeReference<PageData<Asset>>(){}, pageLink); | |
552 | 552 | Assert.assertFalse(pageData.hasNext()); |
553 | 553 | Assert.assertEquals(0, pageData.getData().size()); |
554 | 554 | |
... | ... | @@ -557,9 +557,9 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
557 | 557 | .andExpect(status().isOk()); |
558 | 558 | } |
559 | 559 | |
560 | - pageLink = new TextPageLink(4, title2); | |
560 | + pageLink = new PageLink(4, 0, title2); | |
561 | 561 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/assets?", |
562 | - new TypeReference<TextPageData<Asset>>(){}, pageLink); | |
562 | + new TypeReference<PageData<Asset>>(){}, pageLink); | |
563 | 563 | Assert.assertFalse(pageData.hasNext()); |
564 | 564 | Assert.assertEquals(0, pageData.getData().size()); |
565 | 565 | } |
... | ... | @@ -601,14 +601,14 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
601 | 601 | } |
602 | 602 | |
603 | 603 | List<Asset> loadedAssetsType1 = new ArrayList<>(); |
604 | - TextPageLink pageLink = new TextPageLink(15); | |
605 | - TextPageData<Asset> pageData = null; | |
604 | + PageLink pageLink = new PageLink(15); | |
605 | + PageData<Asset> pageData = null; | |
606 | 606 | do { |
607 | 607 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/assets?type={type}&", |
608 | - new TypeReference<TextPageData<Asset>>(){}, pageLink, type1); | |
608 | + new TypeReference<PageData<Asset>>(){}, pageLink, type1); | |
609 | 609 | loadedAssetsType1.addAll(pageData.getData()); |
610 | 610 | if (pageData.hasNext()) { |
611 | - pageLink = pageData.getNextPageLink(); | |
611 | + pageLink = pageLink.nextPageLink(); | |
612 | 612 | } |
613 | 613 | } while (pageData.hasNext()); |
614 | 614 | |
... | ... | @@ -618,13 +618,13 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
618 | 618 | Assert.assertEquals(assetsType1, loadedAssetsType1); |
619 | 619 | |
620 | 620 | List<Asset> loadedAssetsType2 = new ArrayList<>(); |
621 | - pageLink = new TextPageLink(4); | |
621 | + pageLink = new PageLink(4); | |
622 | 622 | do { |
623 | 623 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/assets?type={type}&", |
624 | - new TypeReference<TextPageData<Asset>>(){}, pageLink, type2); | |
624 | + new TypeReference<PageData<Asset>>(){}, pageLink, type2); | |
625 | 625 | loadedAssetsType2.addAll(pageData.getData()); |
626 | 626 | if (pageData.hasNext()) { |
627 | - pageLink = pageData.getNextPageLink(); | |
627 | + pageLink = pageLink.nextPageLink(); | |
628 | 628 | } |
629 | 629 | } while (pageData.hasNext()); |
630 | 630 | |
... | ... | @@ -638,9 +638,9 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
638 | 638 | .andExpect(status().isOk()); |
639 | 639 | } |
640 | 640 | |
641 | - pageLink = new TextPageLink(4); | |
641 | + pageLink = new PageLink(4); | |
642 | 642 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/assets?type={type}&", |
643 | - new TypeReference<TextPageData<Asset>>(){}, pageLink, type1); | |
643 | + new TypeReference<PageData<Asset>>(){}, pageLink, type1); | |
644 | 644 | Assert.assertFalse(pageData.hasNext()); |
645 | 645 | Assert.assertEquals(0, pageData.getData().size()); |
646 | 646 | |
... | ... | @@ -649,9 +649,9 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
649 | 649 | .andExpect(status().isOk()); |
650 | 650 | } |
651 | 651 | |
652 | - pageLink = new TextPageLink(4); | |
652 | + pageLink = new PageLink(4); | |
653 | 653 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/assets?type={type}&", |
654 | - new TypeReference<TextPageData<Asset>>(){}, pageLink, type2); | |
654 | + new TypeReference<PageData<Asset>>(){}, pageLink, type2); | |
655 | 655 | Assert.assertFalse(pageData.hasNext()); |
656 | 656 | Assert.assertEquals(0, pageData.getData().size()); |
657 | 657 | } | ... | ... |
... | ... | @@ -24,7 +24,7 @@ import org.thingsboard.server.common.data.Device; |
24 | 24 | import org.thingsboard.server.common.data.Tenant; |
25 | 25 | import org.thingsboard.server.common.data.User; |
26 | 26 | import org.thingsboard.server.common.data.audit.AuditLog; |
27 | -import org.thingsboard.server.common.data.page.TimePageData; | |
27 | +import org.thingsboard.server.common.data.page.PageData; | |
28 | 28 | import org.thingsboard.server.common.data.page.TimePageLink; |
29 | 29 | import org.thingsboard.server.common.data.security.Authority; |
30 | 30 | import org.thingsboard.server.dao.model.ModelConstants; |
... | ... | @@ -77,14 +77,14 @@ public abstract class BaseAuditLogControllerTest extends AbstractControllerTest |
77 | 77 | |
78 | 78 | List<AuditLog> loadedAuditLogs = new ArrayList<>(); |
79 | 79 | TimePageLink pageLink = new TimePageLink(23); |
80 | - TimePageData<AuditLog> pageData; | |
80 | + PageData<AuditLog> pageData; | |
81 | 81 | do { |
82 | 82 | pageData = doGetTypedWithTimePageLink("/api/audit/logs?", |
83 | - new TypeReference<TimePageData<AuditLog>>() { | |
83 | + new TypeReference<PageData<AuditLog>>() { | |
84 | 84 | }, pageLink); |
85 | 85 | loadedAuditLogs.addAll(pageData.getData()); |
86 | 86 | if (pageData.hasNext()) { |
87 | - pageLink = pageData.getNextPageLink(); | |
87 | + pageLink = pageLink.nextPageLink(); | |
88 | 88 | } |
89 | 89 | } while (pageData.hasNext()); |
90 | 90 | |
... | ... | @@ -94,11 +94,11 @@ public abstract class BaseAuditLogControllerTest extends AbstractControllerTest |
94 | 94 | pageLink = new TimePageLink(23); |
95 | 95 | do { |
96 | 96 | pageData = doGetTypedWithTimePageLink("/api/audit/logs/customer/" + ModelConstants.NULL_UUID + "?", |
97 | - new TypeReference<TimePageData<AuditLog>>() { | |
97 | + new TypeReference<PageData<AuditLog>>() { | |
98 | 98 | }, pageLink); |
99 | 99 | loadedAuditLogs.addAll(pageData.getData()); |
100 | 100 | if (pageData.hasNext()) { |
101 | - pageLink = pageData.getNextPageLink(); | |
101 | + pageLink = pageLink.nextPageLink(); | |
102 | 102 | } |
103 | 103 | } while (pageData.hasNext()); |
104 | 104 | |
... | ... | @@ -108,11 +108,11 @@ public abstract class BaseAuditLogControllerTest extends AbstractControllerTest |
108 | 108 | pageLink = new TimePageLink(23); |
109 | 109 | do { |
110 | 110 | pageData = doGetTypedWithTimePageLink("/api/audit/logs/user/" + tenantAdmin.getId().getId().toString() + "?", |
111 | - new TypeReference<TimePageData<AuditLog>>() { | |
111 | + new TypeReference<PageData<AuditLog>>() { | |
112 | 112 | }, pageLink); |
113 | 113 | loadedAuditLogs.addAll(pageData.getData()); |
114 | 114 | if (pageData.hasNext()) { |
115 | - pageLink = pageData.getNextPageLink(); | |
115 | + pageLink = pageLink.nextPageLink(); | |
116 | 116 | } |
117 | 117 | } while (pageData.hasNext()); |
118 | 118 | |
... | ... | @@ -132,14 +132,14 @@ public abstract class BaseAuditLogControllerTest extends AbstractControllerTest |
132 | 132 | |
133 | 133 | List<AuditLog> loadedAuditLogs = new ArrayList<>(); |
134 | 134 | TimePageLink pageLink = new TimePageLink(23); |
135 | - TimePageData<AuditLog> pageData; | |
135 | + PageData<AuditLog> pageData; | |
136 | 136 | do { |
137 | 137 | pageData = doGetTypedWithTimePageLink("/api/audit/logs/entity/DEVICE/" + savedDevice.getId().getId() + "?", |
138 | - new TypeReference<TimePageData<AuditLog>>() { | |
138 | + new TypeReference<PageData<AuditLog>>() { | |
139 | 139 | }, pageLink); |
140 | 140 | loadedAuditLogs.addAll(pageData.getData()); |
141 | 141 | if (pageData.hasNext()) { |
142 | - pageLink = pageData.getNextPageLink(); | |
142 | + pageLink = pageLink.nextPageLink(); | |
143 | 143 | } |
144 | 144 | } while (pageData.hasNext()); |
145 | 145 | ... | ... |
... | ... | @@ -27,8 +27,8 @@ import org.thingsboard.server.common.data.Customer; |
27 | 27 | import org.thingsboard.server.common.data.Tenant; |
28 | 28 | import org.thingsboard.server.common.data.User; |
29 | 29 | import org.thingsboard.server.common.data.id.TenantId; |
30 | -import org.thingsboard.server.common.data.page.TextPageData; | |
31 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
30 | +import org.thingsboard.server.common.data.page.PageData; | |
31 | +import org.thingsboard.server.common.data.page.PageLink; | |
32 | 32 | import org.thingsboard.server.common.data.security.Authority; |
33 | 33 | import org.junit.Assert; |
34 | 34 | import org.junit.Test; |
... | ... | @@ -241,13 +241,13 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest |
241 | 241 | } |
242 | 242 | |
243 | 243 | List<Customer> loadedCustomers = new ArrayList<>(); |
244 | - TextPageLink pageLink = new TextPageLink(23); | |
245 | - TextPageData<Customer> pageData = null; | |
244 | + PageLink pageLink = new PageLink(23); | |
245 | + PageData<Customer> pageData = null; | |
246 | 246 | do { |
247 | - pageData = doGetTypedWithPageLink("/api/customers?", new TypeReference<TextPageData<Customer>>(){}, pageLink); | |
247 | + pageData = doGetTypedWithPageLink("/api/customers?", new TypeReference<PageData<Customer>>(){}, pageLink); | |
248 | 248 | loadedCustomers.addAll(pageData.getData()); |
249 | 249 | if (pageData.hasNext()) { |
250 | - pageLink = pageData.getNextPageLink(); | |
250 | + pageLink = pageLink.nextPageLink(); | |
251 | 251 | } |
252 | 252 | } while (pageData.hasNext()); |
253 | 253 | |
... | ... | @@ -307,13 +307,13 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest |
307 | 307 | } |
308 | 308 | |
309 | 309 | List<Customer> loadedCustomersTitle1 = new ArrayList<>(); |
310 | - TextPageLink pageLink = new TextPageLink(15, title1); | |
311 | - TextPageData<Customer> pageData = null; | |
310 | + PageLink pageLink = new PageLink(15, 0, title1); | |
311 | + PageData<Customer> pageData = null; | |
312 | 312 | do { |
313 | - pageData = doGetTypedWithPageLink("/api/customers?", new TypeReference<TextPageData<Customer>>(){}, pageLink); | |
313 | + pageData = doGetTypedWithPageLink("/api/customers?", new TypeReference<PageData<Customer>>(){}, pageLink); | |
314 | 314 | loadedCustomersTitle1.addAll(pageData.getData()); |
315 | 315 | if (pageData.hasNext()) { |
316 | - pageLink = pageData.getNextPageLink(); | |
316 | + pageLink = pageLink.nextPageLink(); | |
317 | 317 | } |
318 | 318 | } while (pageData.hasNext()); |
319 | 319 | |
... | ... | @@ -323,12 +323,12 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest |
323 | 323 | Assert.assertEquals(customersTitle1, loadedCustomersTitle1); |
324 | 324 | |
325 | 325 | List<Customer> loadedCustomersTitle2 = new ArrayList<>(); |
326 | - pageLink = new TextPageLink(4, title2); | |
326 | + pageLink = new PageLink(4, 0, title2); | |
327 | 327 | do { |
328 | - pageData = doGetTypedWithPageLink("/api/customers?", new TypeReference<TextPageData<Customer>>(){}, pageLink); | |
328 | + pageData = doGetTypedWithPageLink("/api/customers?", new TypeReference<PageData<Customer>>(){}, pageLink); | |
329 | 329 | loadedCustomersTitle2.addAll(pageData.getData()); |
330 | 330 | if (pageData.hasNext()) { |
331 | - pageLink = pageData.getNextPageLink(); | |
331 | + pageLink = pageLink.nextPageLink(); | |
332 | 332 | } |
333 | 333 | } while (pageData.hasNext()); |
334 | 334 | |
... | ... | @@ -342,8 +342,8 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest |
342 | 342 | .andExpect(status().isOk()); |
343 | 343 | } |
344 | 344 | |
345 | - pageLink = new TextPageLink(4, title1); | |
346 | - pageData = doGetTypedWithPageLink("/api/customers?", new TypeReference<TextPageData<Customer>>(){}, pageLink); | |
345 | + pageLink = new PageLink(4, 0, title1); | |
346 | + pageData = doGetTypedWithPageLink("/api/customers?", new TypeReference<PageData<Customer>>(){}, pageLink); | |
347 | 347 | Assert.assertFalse(pageData.hasNext()); |
348 | 348 | Assert.assertEquals(0, pageData.getData().size()); |
349 | 349 | |
... | ... | @@ -352,8 +352,8 @@ public abstract class BaseCustomerControllerTest extends AbstractControllerTest |
352 | 352 | .andExpect(status().isOk()); |
353 | 353 | } |
354 | 354 | |
355 | - pageLink = new TextPageLink(4, title2); | |
356 | - pageData = doGetTypedWithPageLink("/api/customers?", new TypeReference<TextPageData<Customer>>(){}, pageLink); | |
355 | + pageLink = new PageLink(4, 0, title2); | |
356 | + pageData = doGetTypedWithPageLink("/api/customers?", new TypeReference<PageData<Customer>>(){}, pageLink); | |
357 | 357 | Assert.assertFalse(pageData.hasNext()); |
358 | 358 | Assert.assertEquals(0, pageData.getData().size()); |
359 | 359 | ... | ... |
... | ... | @@ -28,9 +28,8 @@ import com.datastax.driver.core.utils.UUIDs; |
28 | 28 | import org.apache.commons.lang3.RandomStringUtils; |
29 | 29 | import org.thingsboard.server.common.data.*; |
30 | 30 | import org.thingsboard.server.common.data.id.CustomerId; |
31 | -import org.thingsboard.server.common.data.page.TextPageData; | |
32 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
33 | -import org.thingsboard.server.common.data.page.TimePageData; | |
31 | +import org.thingsboard.server.common.data.page.PageData; | |
32 | +import org.thingsboard.server.common.data.page.PageLink; | |
34 | 33 | import org.thingsboard.server.common.data.page.TimePageLink; |
35 | 34 | import org.thingsboard.server.common.data.security.Authority; |
36 | 35 | import org.thingsboard.server.dao.model.ModelConstants; |
... | ... | @@ -211,14 +210,14 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest |
211 | 210 | dashboards.add(new DashboardInfo(doPost("/api/dashboard", dashboard, Dashboard.class))); |
212 | 211 | } |
213 | 212 | List<DashboardInfo> loadedDashboards = new ArrayList<>(); |
214 | - TextPageLink pageLink = new TextPageLink(24); | |
215 | - TextPageData<DashboardInfo> pageData = null; | |
213 | + PageLink pageLink = new PageLink(24); | |
214 | + PageData<DashboardInfo> pageData = null; | |
216 | 215 | do { |
217 | 216 | pageData = doGetTypedWithPageLink("/api/tenant/dashboards?", |
218 | - new TypeReference<TextPageData<DashboardInfo>>(){}, pageLink); | |
217 | + new TypeReference<PageData<DashboardInfo>>(){}, pageLink); | |
219 | 218 | loadedDashboards.addAll(pageData.getData()); |
220 | 219 | if (pageData.hasNext()) { |
221 | - pageLink = pageData.getNextPageLink(); | |
220 | + pageLink = pageLink.nextPageLink(); | |
222 | 221 | } |
223 | 222 | } while (pageData.hasNext()); |
224 | 223 | |
... | ... | @@ -252,14 +251,14 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest |
252 | 251 | } |
253 | 252 | |
254 | 253 | List<DashboardInfo> loadedDashboardsTitle1 = new ArrayList<>(); |
255 | - TextPageLink pageLink = new TextPageLink(15, title1); | |
256 | - TextPageData<DashboardInfo> pageData = null; | |
254 | + PageLink pageLink = new PageLink(15, 0, title1); | |
255 | + PageData<DashboardInfo> pageData = null; | |
257 | 256 | do { |
258 | 257 | pageData = doGetTypedWithPageLink("/api/tenant/dashboards?", |
259 | - new TypeReference<TextPageData<DashboardInfo>>(){}, pageLink); | |
258 | + new TypeReference<PageData<DashboardInfo>>(){}, pageLink); | |
260 | 259 | loadedDashboardsTitle1.addAll(pageData.getData()); |
261 | 260 | if (pageData.hasNext()) { |
262 | - pageLink = pageData.getNextPageLink(); | |
261 | + pageLink = pageLink.nextPageLink(); | |
263 | 262 | } |
264 | 263 | } while (pageData.hasNext()); |
265 | 264 | |
... | ... | @@ -269,13 +268,13 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest |
269 | 268 | Assert.assertEquals(dashboardsTitle1, loadedDashboardsTitle1); |
270 | 269 | |
271 | 270 | List<DashboardInfo> loadedDashboardsTitle2 = new ArrayList<>(); |
272 | - pageLink = new TextPageLink(4, title2); | |
271 | + pageLink = new PageLink(4, 0, title2); | |
273 | 272 | do { |
274 | 273 | pageData = doGetTypedWithPageLink("/api/tenant/dashboards?", |
275 | - new TypeReference<TextPageData<DashboardInfo>>(){}, pageLink); | |
274 | + new TypeReference<PageData<DashboardInfo>>(){}, pageLink); | |
276 | 275 | loadedDashboardsTitle2.addAll(pageData.getData()); |
277 | 276 | if (pageData.hasNext()) { |
278 | - pageLink = pageData.getNextPageLink(); | |
277 | + pageLink = pageLink.nextPageLink(); | |
279 | 278 | } |
280 | 279 | } while (pageData.hasNext()); |
281 | 280 | |
... | ... | @@ -289,9 +288,9 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest |
289 | 288 | .andExpect(status().isOk()); |
290 | 289 | } |
291 | 290 | |
292 | - pageLink = new TextPageLink(4, title1); | |
291 | + pageLink = new PageLink(4, 0, title1); | |
293 | 292 | pageData = doGetTypedWithPageLink("/api/tenant/dashboards?", |
294 | - new TypeReference<TextPageData<DashboardInfo>>(){}, pageLink); | |
293 | + new TypeReference<PageData<DashboardInfo>>(){}, pageLink); | |
295 | 294 | Assert.assertFalse(pageData.hasNext()); |
296 | 295 | Assert.assertEquals(0, pageData.getData().size()); |
297 | 296 | |
... | ... | @@ -300,9 +299,9 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest |
300 | 299 | .andExpect(status().isOk()); |
301 | 300 | } |
302 | 301 | |
303 | - pageLink = new TextPageLink(4, title2); | |
302 | + pageLink = new PageLink(4, 0, title2); | |
304 | 303 | pageData = doGetTypedWithPageLink("/api/tenant/dashboards?", |
305 | - new TypeReference<TextPageData<DashboardInfo>>(){}, pageLink); | |
304 | + new TypeReference<PageData<DashboardInfo>>(){}, pageLink); | |
306 | 305 | Assert.assertFalse(pageData.hasNext()); |
307 | 306 | Assert.assertEquals(0, pageData.getData().size()); |
308 | 307 | } |
... | ... | @@ -325,13 +324,13 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest |
325 | 324 | |
326 | 325 | List<DashboardInfo> loadedDashboards = new ArrayList<>(); |
327 | 326 | TimePageLink pageLink = new TimePageLink(21); |
328 | - TimePageData<DashboardInfo> pageData = null; | |
327 | + PageData<DashboardInfo> pageData = null; | |
329 | 328 | do { |
330 | 329 | pageData = doGetTypedWithTimePageLink("/api/customer/" + customerId.getId().toString() + "/dashboards?", |
331 | - new TypeReference<TimePageData<DashboardInfo>>(){}, pageLink); | |
330 | + new TypeReference<PageData<DashboardInfo>>(){}, pageLink); | |
332 | 331 | loadedDashboards.addAll(pageData.getData()); |
333 | 332 | if (pageData.hasNext()) { |
334 | - pageLink = pageData.getNextPageLink(); | |
333 | + pageLink = pageLink.nextPageLink(); | |
335 | 334 | } |
336 | 335 | } while (pageData.hasNext()); |
337 | 336 | ... | ... |
... | ... | @@ -29,8 +29,8 @@ import org.thingsboard.server.common.data.*; |
29 | 29 | import org.thingsboard.server.common.data.id.CustomerId; |
30 | 30 | import org.thingsboard.server.common.data.id.DeviceCredentialsId; |
31 | 31 | import org.thingsboard.server.common.data.id.DeviceId; |
32 | -import org.thingsboard.server.common.data.page.TextPageData; | |
33 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
32 | +import org.thingsboard.server.common.data.page.PageData; | |
33 | +import org.thingsboard.server.common.data.page.PageLink; | |
34 | 34 | import org.thingsboard.server.common.data.security.Authority; |
35 | 35 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
36 | 36 | import org.thingsboard.server.common.data.security.DeviceCredentialsType; |
... | ... | @@ -366,14 +366,14 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
366 | 366 | devices.add(doPost("/api/device", device, Device.class)); |
367 | 367 | } |
368 | 368 | List<Device> loadedDevices = new ArrayList<>(); |
369 | - TextPageLink pageLink = new TextPageLink(23); | |
370 | - TextPageData<Device> pageData = null; | |
369 | + PageLink pageLink = new PageLink(23); | |
370 | + PageData<Device> pageData = null; | |
371 | 371 | do { |
372 | 372 | pageData = doGetTypedWithPageLink("/api/tenant/devices?", |
373 | - new TypeReference<TextPageData<Device>>(){}, pageLink); | |
373 | + new TypeReference<PageData<Device>>(){}, pageLink); | |
374 | 374 | loadedDevices.addAll(pageData.getData()); |
375 | 375 | if (pageData.hasNext()) { |
376 | - pageLink = pageData.getNextPageLink(); | |
376 | + pageLink = pageLink.nextPageLink(); | |
377 | 377 | } |
378 | 378 | } while (pageData.hasNext()); |
379 | 379 | |
... | ... | @@ -409,14 +409,14 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
409 | 409 | } |
410 | 410 | |
411 | 411 | List<Device> loadedDevicesTitle1 = new ArrayList<>(); |
412 | - TextPageLink pageLink = new TextPageLink(15, title1); | |
413 | - TextPageData<Device> pageData = null; | |
412 | + PageLink pageLink = new PageLink(15, 0, title1); | |
413 | + PageData<Device> pageData = null; | |
414 | 414 | do { |
415 | 415 | pageData = doGetTypedWithPageLink("/api/tenant/devices?", |
416 | - new TypeReference<TextPageData<Device>>(){}, pageLink); | |
416 | + new TypeReference<PageData<Device>>(){}, pageLink); | |
417 | 417 | loadedDevicesTitle1.addAll(pageData.getData()); |
418 | 418 | if (pageData.hasNext()) { |
419 | - pageLink = pageData.getNextPageLink(); | |
419 | + pageLink = pageLink.nextPageLink(); | |
420 | 420 | } |
421 | 421 | } while (pageData.hasNext()); |
422 | 422 | |
... | ... | @@ -426,13 +426,13 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
426 | 426 | Assert.assertEquals(devicesTitle1, loadedDevicesTitle1); |
427 | 427 | |
428 | 428 | List<Device> loadedDevicesTitle2 = new ArrayList<>(); |
429 | - pageLink = new TextPageLink(4, title2); | |
429 | + pageLink = new PageLink(4, 0, title2); | |
430 | 430 | do { |
431 | 431 | pageData = doGetTypedWithPageLink("/api/tenant/devices?", |
432 | - new TypeReference<TextPageData<Device>>(){}, pageLink); | |
432 | + new TypeReference<PageData<Device>>(){}, pageLink); | |
433 | 433 | loadedDevicesTitle2.addAll(pageData.getData()); |
434 | 434 | if (pageData.hasNext()) { |
435 | - pageLink = pageData.getNextPageLink(); | |
435 | + pageLink = pageLink.nextPageLink(); | |
436 | 436 | } |
437 | 437 | } while (pageData.hasNext()); |
438 | 438 | |
... | ... | @@ -446,9 +446,9 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
446 | 446 | .andExpect(status().isOk()); |
447 | 447 | } |
448 | 448 | |
449 | - pageLink = new TextPageLink(4, title1); | |
449 | + pageLink = new PageLink(4, 0, title1); | |
450 | 450 | pageData = doGetTypedWithPageLink("/api/tenant/devices?", |
451 | - new TypeReference<TextPageData<Device>>(){}, pageLink); | |
451 | + new TypeReference<PageData<Device>>(){}, pageLink); | |
452 | 452 | Assert.assertFalse(pageData.hasNext()); |
453 | 453 | Assert.assertEquals(0, pageData.getData().size()); |
454 | 454 | |
... | ... | @@ -457,9 +457,9 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
457 | 457 | .andExpect(status().isOk()); |
458 | 458 | } |
459 | 459 | |
460 | - pageLink = new TextPageLink(4, title2); | |
460 | + pageLink = new PageLink(4, 0, title2); | |
461 | 461 | pageData = doGetTypedWithPageLink("/api/tenant/devices?", |
462 | - new TypeReference<TextPageData<Device>>(){}, pageLink); | |
462 | + new TypeReference<PageData<Device>>(){}, pageLink); | |
463 | 463 | Assert.assertFalse(pageData.hasNext()); |
464 | 464 | Assert.assertEquals(0, pageData.getData().size()); |
465 | 465 | } |
... | ... | @@ -492,14 +492,14 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
492 | 492 | } |
493 | 493 | |
494 | 494 | List<Device> loadedDevicesType1 = new ArrayList<>(); |
495 | - TextPageLink pageLink = new TextPageLink(15); | |
496 | - TextPageData<Device> pageData = null; | |
495 | + PageLink pageLink = new PageLink(15); | |
496 | + PageData<Device> pageData = null; | |
497 | 497 | do { |
498 | 498 | pageData = doGetTypedWithPageLink("/api/tenant/devices?type={type}&", |
499 | - new TypeReference<TextPageData<Device>>(){}, pageLink, type1); | |
499 | + new TypeReference<PageData<Device>>(){}, pageLink, type1); | |
500 | 500 | loadedDevicesType1.addAll(pageData.getData()); |
501 | 501 | if (pageData.hasNext()) { |
502 | - pageLink = pageData.getNextPageLink(); | |
502 | + pageLink = pageLink.nextPageLink(); | |
503 | 503 | } |
504 | 504 | } while (pageData.hasNext()); |
505 | 505 | |
... | ... | @@ -509,13 +509,13 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
509 | 509 | Assert.assertEquals(devicesType1, loadedDevicesType1); |
510 | 510 | |
511 | 511 | List<Device> loadedDevicesType2 = new ArrayList<>(); |
512 | - pageLink = new TextPageLink(4); | |
512 | + pageLink = new PageLink(4); | |
513 | 513 | do { |
514 | 514 | pageData = doGetTypedWithPageLink("/api/tenant/devices?type={type}&", |
515 | - new TypeReference<TextPageData<Device>>(){}, pageLink, type2); | |
515 | + new TypeReference<PageData<Device>>(){}, pageLink, type2); | |
516 | 516 | loadedDevicesType2.addAll(pageData.getData()); |
517 | 517 | if (pageData.hasNext()) { |
518 | - pageLink = pageData.getNextPageLink(); | |
518 | + pageLink = pageLink.nextPageLink(); | |
519 | 519 | } |
520 | 520 | } while (pageData.hasNext()); |
521 | 521 | |
... | ... | @@ -529,9 +529,9 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
529 | 529 | .andExpect(status().isOk()); |
530 | 530 | } |
531 | 531 | |
532 | - pageLink = new TextPageLink(4); | |
532 | + pageLink = new PageLink(4); | |
533 | 533 | pageData = doGetTypedWithPageLink("/api/tenant/devices?type={type}&", |
534 | - new TypeReference<TextPageData<Device>>(){}, pageLink, type1); | |
534 | + new TypeReference<PageData<Device>>(){}, pageLink, type1); | |
535 | 535 | Assert.assertFalse(pageData.hasNext()); |
536 | 536 | Assert.assertEquals(0, pageData.getData().size()); |
537 | 537 | |
... | ... | @@ -540,9 +540,9 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
540 | 540 | .andExpect(status().isOk()); |
541 | 541 | } |
542 | 542 | |
543 | - pageLink = new TextPageLink(4); | |
543 | + pageLink = new PageLink(4); | |
544 | 544 | pageData = doGetTypedWithPageLink("/api/tenant/devices?type={type}&", |
545 | - new TypeReference<TextPageData<Device>>(){}, pageLink, type2); | |
545 | + new TypeReference<PageData<Device>>(){}, pageLink, type2); | |
546 | 546 | Assert.assertFalse(pageData.hasNext()); |
547 | 547 | Assert.assertEquals(0, pageData.getData().size()); |
548 | 548 | } |
... | ... | @@ -565,14 +565,14 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
565 | 565 | } |
566 | 566 | |
567 | 567 | List<Device> loadedDevices = new ArrayList<>(); |
568 | - TextPageLink pageLink = new TextPageLink(23); | |
569 | - TextPageData<Device> pageData = null; | |
568 | + PageLink pageLink = new PageLink(23); | |
569 | + PageData<Device> pageData = null; | |
570 | 570 | do { |
571 | 571 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/devices?", |
572 | - new TypeReference<TextPageData<Device>>(){}, pageLink); | |
572 | + new TypeReference<PageData<Device>>(){}, pageLink); | |
573 | 573 | loadedDevices.addAll(pageData.getData()); |
574 | 574 | if (pageData.hasNext()) { |
575 | - pageLink = pageData.getNextPageLink(); | |
575 | + pageLink = pageLink.nextPageLink(); | |
576 | 576 | } |
577 | 577 | } while (pageData.hasNext()); |
578 | 578 | |
... | ... | @@ -617,14 +617,14 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
617 | 617 | } |
618 | 618 | |
619 | 619 | List<Device> loadedDevicesTitle1 = new ArrayList<>(); |
620 | - TextPageLink pageLink = new TextPageLink(15, title1); | |
621 | - TextPageData<Device> pageData = null; | |
620 | + PageLink pageLink = new PageLink(15, 0, title1); | |
621 | + PageData<Device> pageData = null; | |
622 | 622 | do { |
623 | 623 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/devices?", |
624 | - new TypeReference<TextPageData<Device>>(){}, pageLink); | |
624 | + new TypeReference<PageData<Device>>(){}, pageLink); | |
625 | 625 | loadedDevicesTitle1.addAll(pageData.getData()); |
626 | 626 | if (pageData.hasNext()) { |
627 | - pageLink = pageData.getNextPageLink(); | |
627 | + pageLink = pageLink.nextPageLink(); | |
628 | 628 | } |
629 | 629 | } while (pageData.hasNext()); |
630 | 630 | |
... | ... | @@ -634,13 +634,13 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
634 | 634 | Assert.assertEquals(devicesTitle1, loadedDevicesTitle1); |
635 | 635 | |
636 | 636 | List<Device> loadedDevicesTitle2 = new ArrayList<>(); |
637 | - pageLink = new TextPageLink(4, title2); | |
637 | + pageLink = new PageLink(4, 0, title2); | |
638 | 638 | do { |
639 | 639 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/devices?", |
640 | - new TypeReference<TextPageData<Device>>(){}, pageLink); | |
640 | + new TypeReference<PageData<Device>>(){}, pageLink); | |
641 | 641 | loadedDevicesTitle2.addAll(pageData.getData()); |
642 | 642 | if (pageData.hasNext()) { |
643 | - pageLink = pageData.getNextPageLink(); | |
643 | + pageLink = pageLink.nextPageLink(); | |
644 | 644 | } |
645 | 645 | } while (pageData.hasNext()); |
646 | 646 | |
... | ... | @@ -654,9 +654,9 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
654 | 654 | .andExpect(status().isOk()); |
655 | 655 | } |
656 | 656 | |
657 | - pageLink = new TextPageLink(4, title1); | |
657 | + pageLink = new PageLink(4, 0, title1); | |
658 | 658 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/devices?", |
659 | - new TypeReference<TextPageData<Device>>(){}, pageLink); | |
659 | + new TypeReference<PageData<Device>>(){}, pageLink); | |
660 | 660 | Assert.assertFalse(pageData.hasNext()); |
661 | 661 | Assert.assertEquals(0, pageData.getData().size()); |
662 | 662 | |
... | ... | @@ -665,9 +665,9 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
665 | 665 | .andExpect(status().isOk()); |
666 | 666 | } |
667 | 667 | |
668 | - pageLink = new TextPageLink(4, title2); | |
668 | + pageLink = new PageLink(4, 0, title2); | |
669 | 669 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/devices?", |
670 | - new TypeReference<TextPageData<Device>>(){}, pageLink); | |
670 | + new TypeReference<PageData<Device>>(){}, pageLink); | |
671 | 671 | Assert.assertFalse(pageData.hasNext()); |
672 | 672 | Assert.assertEquals(0, pageData.getData().size()); |
673 | 673 | } |
... | ... | @@ -709,14 +709,14 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
709 | 709 | } |
710 | 710 | |
711 | 711 | List<Device> loadedDevicesType1 = new ArrayList<>(); |
712 | - TextPageLink pageLink = new TextPageLink(15); | |
713 | - TextPageData<Device> pageData = null; | |
712 | + PageLink pageLink = new PageLink(15); | |
713 | + PageData<Device> pageData = null; | |
714 | 714 | do { |
715 | 715 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/devices?type={type}&", |
716 | - new TypeReference<TextPageData<Device>>(){}, pageLink, type1); | |
716 | + new TypeReference<PageData<Device>>(){}, pageLink, type1); | |
717 | 717 | loadedDevicesType1.addAll(pageData.getData()); |
718 | 718 | if (pageData.hasNext()) { |
719 | - pageLink = pageData.getNextPageLink(); | |
719 | + pageLink = pageLink.nextPageLink(); | |
720 | 720 | } |
721 | 721 | } while (pageData.hasNext()); |
722 | 722 | |
... | ... | @@ -726,13 +726,13 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
726 | 726 | Assert.assertEquals(devicesType1, loadedDevicesType1); |
727 | 727 | |
728 | 728 | List<Device> loadedDevicesType2 = new ArrayList<>(); |
729 | - pageLink = new TextPageLink(4); | |
729 | + pageLink = new PageLink(4); | |
730 | 730 | do { |
731 | 731 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/devices?type={type}&", |
732 | - new TypeReference<TextPageData<Device>>(){}, pageLink, type2); | |
732 | + new TypeReference<PageData<Device>>(){}, pageLink, type2); | |
733 | 733 | loadedDevicesType2.addAll(pageData.getData()); |
734 | 734 | if (pageData.hasNext()) { |
735 | - pageLink = pageData.getNextPageLink(); | |
735 | + pageLink = pageLink.nextPageLink(); | |
736 | 736 | } |
737 | 737 | } while (pageData.hasNext()); |
738 | 738 | |
... | ... | @@ -746,9 +746,9 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
746 | 746 | .andExpect(status().isOk()); |
747 | 747 | } |
748 | 748 | |
749 | - pageLink = new TextPageLink(4); | |
749 | + pageLink = new PageLink(4); | |
750 | 750 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/devices?type={type}&", |
751 | - new TypeReference<TextPageData<Device>>(){}, pageLink, type1); | |
751 | + new TypeReference<PageData<Device>>(){}, pageLink, type1); | |
752 | 752 | Assert.assertFalse(pageData.hasNext()); |
753 | 753 | Assert.assertEquals(0, pageData.getData().size()); |
754 | 754 | |
... | ... | @@ -757,9 +757,9 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
757 | 757 | .andExpect(status().isOk()); |
758 | 758 | } |
759 | 759 | |
760 | - pageLink = new TextPageLink(4); | |
760 | + pageLink = new PageLink(4); | |
761 | 761 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/devices?type={type}&", |
762 | - new TypeReference<TextPageData<Device>>(){}, pageLink, type2); | |
762 | + new TypeReference<PageData<Device>>(){}, pageLink, type2); | |
763 | 763 | Assert.assertFalse(pageData.hasNext()); |
764 | 764 | Assert.assertEquals(0, pageData.getData().size()); |
765 | 765 | } | ... | ... |
... | ... | @@ -33,8 +33,8 @@ import org.thingsboard.server.common.data.User; |
33 | 33 | import org.thingsboard.server.common.data.id.CustomerId; |
34 | 34 | import org.thingsboard.server.common.data.objects.AttributesEntityView; |
35 | 35 | import org.thingsboard.server.common.data.objects.TelemetryEntityView; |
36 | -import org.thingsboard.server.common.data.page.TextPageData; | |
37 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
36 | +import org.thingsboard.server.common.data.page.PageData; | |
37 | +import org.thingsboard.server.common.data.page.PageLink; | |
38 | 38 | import org.thingsboard.server.common.data.security.Authority; |
39 | 39 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
40 | 40 | import org.thingsboard.server.dao.model.ModelConstants; |
... | ... | @@ -223,7 +223,7 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
223 | 223 | + getNewSavedEntityView("Test entity view " + i).getId().getId().toString(), EntityView.class)); |
224 | 224 | } |
225 | 225 | |
226 | - List<EntityView> loadedViews = loadListOf(new TextPageLink(23), urlTemplate); | |
226 | + List<EntityView> loadedViews = loadListOf(new PageLink(23), urlTemplate); | |
227 | 227 | |
228 | 228 | Collections.sort(views, idComparator); |
229 | 229 | Collections.sort(loadedViews, idComparator); |
... | ... | @@ -239,7 +239,7 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
239 | 239 | String name1 = "Entity view name1"; |
240 | 240 | List<EntityView> namesOfView1 = fillListOf(125, name1, "/api/customer/" + customerId.getId().toString() |
241 | 241 | + "/entityView/"); |
242 | - List<EntityView> loadedNamesOfView1 = loadListOf(new TextPageLink(15, name1), urlTemplate); | |
242 | + List<EntityView> loadedNamesOfView1 = loadListOf(new PageLink(15, 0, name1), urlTemplate); | |
243 | 243 | Collections.sort(namesOfView1, idComparator); |
244 | 244 | Collections.sort(loadedNamesOfView1, idComparator); |
245 | 245 | assertEquals(namesOfView1, loadedNamesOfView1); |
... | ... | @@ -247,7 +247,7 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
247 | 247 | String name2 = "Entity view name2"; |
248 | 248 | List<EntityView> NamesOfView2 = fillListOf(143, name2, "/api/customer/" + customerId.getId().toString() |
249 | 249 | + "/entityView/"); |
250 | - List<EntityView> loadedNamesOfView2 = loadListOf(new TextPageLink(4, name2), urlTemplate); | |
250 | + List<EntityView> loadedNamesOfView2 = loadListOf(new PageLink(4, 0, name2), urlTemplate); | |
251 | 251 | Collections.sort(NamesOfView2, idComparator); |
252 | 252 | Collections.sort(loadedNamesOfView2, idComparator); |
253 | 253 | assertEquals(NamesOfView2, loadedNamesOfView2); |
... | ... | @@ -255,18 +255,18 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
255 | 255 | for (EntityView view : loadedNamesOfView1) { |
256 | 256 | doDelete("/api/customer/entityView/" + view.getId().getId().toString()).andExpect(status().isOk()); |
257 | 257 | } |
258 | - TextPageData<EntityView> pageData = doGetTypedWithPageLink(urlTemplate, | |
259 | - new TypeReference<TextPageData<EntityView>>() { | |
260 | - }, new TextPageLink(4, name1)); | |
258 | + PageData<EntityView> pageData = doGetTypedWithPageLink(urlTemplate, | |
259 | + new TypeReference<PageData<EntityView>>() { | |
260 | + }, new PageLink(4, 0, name1)); | |
261 | 261 | Assert.assertFalse(pageData.hasNext()); |
262 | 262 | assertEquals(0, pageData.getData().size()); |
263 | 263 | |
264 | 264 | for (EntityView view : loadedNamesOfView2) { |
265 | 265 | doDelete("/api/customer/entityView/" + view.getId().getId().toString()).andExpect(status().isOk()); |
266 | 266 | } |
267 | - pageData = doGetTypedWithPageLink(urlTemplate, new TypeReference<TextPageData<EntityView>>() { | |
267 | + pageData = doGetTypedWithPageLink(urlTemplate, new TypeReference<PageData<EntityView>>() { | |
268 | 268 | }, |
269 | - new TextPageLink(4, name2)); | |
269 | + new PageLink(4, 0, name2)); | |
270 | 270 | Assert.assertFalse(pageData.hasNext()); |
271 | 271 | assertEquals(0, pageData.getData().size()); |
272 | 272 | } |
... | ... | @@ -278,7 +278,7 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
278 | 278 | for (int i = 0; i < 178; i++) { |
279 | 279 | views.add(getNewSavedEntityView("Test entity view" + i)); |
280 | 280 | } |
281 | - List<EntityView> loadedViews = loadListOf(new TextPageLink(23), "/api/tenant/entityViews?"); | |
281 | + List<EntityView> loadedViews = loadListOf(new PageLink(23), "/api/tenant/entityViews?"); | |
282 | 282 | |
283 | 283 | Collections.sort(views, idComparator); |
284 | 284 | Collections.sort(loadedViews, idComparator); |
... | ... | @@ -290,14 +290,14 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
290 | 290 | public void testGetTenantEntityViewsByName() throws Exception { |
291 | 291 | String name1 = "Entity view name1"; |
292 | 292 | List<EntityView> namesOfView1 = fillListOf(143, name1); |
293 | - List<EntityView> loadedNamesOfView1 = loadListOf(new TextPageLink(15, name1), "/api/tenant/entityViews?"); | |
293 | + List<EntityView> loadedNamesOfView1 = loadListOf(new PageLink(15, 0, name1), "/api/tenant/entityViews?"); | |
294 | 294 | Collections.sort(namesOfView1, idComparator); |
295 | 295 | Collections.sort(loadedNamesOfView1, idComparator); |
296 | 296 | assertEquals(namesOfView1, loadedNamesOfView1); |
297 | 297 | |
298 | 298 | String name2 = "Entity view name2"; |
299 | 299 | List<EntityView> NamesOfView2 = fillListOf(75, name2); |
300 | - List<EntityView> loadedNamesOfView2 = loadListOf(new TextPageLink(4, name2), "/api/tenant/entityViews?"); | |
300 | + List<EntityView> loadedNamesOfView2 = loadListOf(new PageLink(4, 0, name2), "/api/tenant/entityViews?"); | |
301 | 301 | Collections.sort(NamesOfView2, idComparator); |
302 | 302 | Collections.sort(loadedNamesOfView2, idComparator); |
303 | 303 | assertEquals(NamesOfView2, loadedNamesOfView2); |
... | ... | @@ -305,18 +305,18 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
305 | 305 | for (EntityView view : loadedNamesOfView1) { |
306 | 306 | doDelete("/api/entityView/" + view.getId().getId().toString()).andExpect(status().isOk()); |
307 | 307 | } |
308 | - TextPageData<EntityView> pageData = doGetTypedWithPageLink("/api/tenant/entityViews?", | |
309 | - new TypeReference<TextPageData<EntityView>>() { | |
310 | - }, new TextPageLink(4, name1)); | |
308 | + PageData<EntityView> pageData = doGetTypedWithPageLink("/api/tenant/entityViews?", | |
309 | + new TypeReference<PageData<EntityView>>() { | |
310 | + }, new PageLink(4, 0, name1)); | |
311 | 311 | Assert.assertFalse(pageData.hasNext()); |
312 | 312 | assertEquals(0, pageData.getData().size()); |
313 | 313 | |
314 | 314 | for (EntityView view : loadedNamesOfView2) { |
315 | 315 | doDelete("/api/entityView/" + view.getId().getId().toString()).andExpect(status().isOk()); |
316 | 316 | } |
317 | - pageData = doGetTypedWithPageLink("/api/tenant/entityViews?", new TypeReference<TextPageData<EntityView>>() { | |
317 | + pageData = doGetTypedWithPageLink("/api/tenant/entityViews?", new TypeReference<PageData<EntityView>>() { | |
318 | 318 | }, |
319 | - new TextPageLink(4, name2)); | |
319 | + new PageLink(4, 0, name2)); | |
320 | 320 | Assert.assertFalse(pageData.hasNext()); |
321 | 321 | assertEquals(0, pageData.getData().size()); |
322 | 322 | } |
... | ... | @@ -516,15 +516,15 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
516 | 516 | return viewNames; |
517 | 517 | } |
518 | 518 | |
519 | - private List<EntityView> loadListOf(TextPageLink pageLink, String urlTemplate) throws Exception { | |
519 | + private List<EntityView> loadListOf(PageLink pageLink, String urlTemplate) throws Exception { | |
520 | 520 | List<EntityView> loadedItems = new ArrayList<>(); |
521 | - TextPageData<EntityView> pageData; | |
521 | + PageData<EntityView> pageData; | |
522 | 522 | do { |
523 | - pageData = doGetTypedWithPageLink(urlTemplate, new TypeReference<TextPageData<EntityView>>() { | |
523 | + pageData = doGetTypedWithPageLink(urlTemplate, new TypeReference<PageData<EntityView>>() { | |
524 | 524 | }, pageLink); |
525 | 525 | loadedItems.addAll(pageData.getData()); |
526 | 526 | if (pageData.hasNext()) { |
527 | - pageLink = pageData.getNextPageLink(); | |
527 | + pageLink = pageLink.nextPageLink(); | |
528 | 528 | } |
529 | 529 | } while (pageData.hasNext()); |
530 | 530 | ... | ... |
... | ... | @@ -24,8 +24,8 @@ import java.util.List; |
24 | 24 | |
25 | 25 | import org.apache.commons.lang3.RandomStringUtils; |
26 | 26 | import org.thingsboard.server.common.data.Tenant; |
27 | -import org.thingsboard.server.common.data.page.TextPageData; | |
28 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
27 | +import org.thingsboard.server.common.data.page.PageData; | |
28 | +import org.thingsboard.server.common.data.page.PageLink; | |
29 | 29 | import org.junit.Assert; |
30 | 30 | import org.junit.Test; |
31 | 31 | |
... | ... | @@ -102,8 +102,8 @@ public abstract class BaseTenantControllerTest extends AbstractControllerTest { |
102 | 102 | public void testFindTenants() throws Exception { |
103 | 103 | loginSysAdmin(); |
104 | 104 | List<Tenant> tenants = new ArrayList<>(); |
105 | - TextPageLink pageLink = new TextPageLink(17); | |
106 | - TextPageData<Tenant> pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<TextPageData<Tenant>>(){}, pageLink); | |
105 | + PageLink pageLink = new PageLink(17); | |
106 | + PageData<Tenant> pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<PageData<Tenant>>(){}, pageLink); | |
107 | 107 | Assert.assertFalse(pageData.hasNext()); |
108 | 108 | Assert.assertEquals(1, pageData.getData().size()); |
109 | 109 | tenants.addAll(pageData.getData()); |
... | ... | @@ -115,12 +115,12 @@ public abstract class BaseTenantControllerTest extends AbstractControllerTest { |
115 | 115 | } |
116 | 116 | |
117 | 117 | List<Tenant> loadedTenants = new ArrayList<>(); |
118 | - pageLink = new TextPageLink(17); | |
118 | + pageLink = new PageLink(17); | |
119 | 119 | do { |
120 | - pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<TextPageData<Tenant>>(){}, pageLink); | |
120 | + pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<PageData<Tenant>>(){}, pageLink); | |
121 | 121 | loadedTenants.addAll(pageData.getData()); |
122 | 122 | if (pageData.hasNext()) { |
123 | - pageLink = pageData.getNextPageLink(); | |
123 | + pageLink = pageLink.nextPageLink(); | |
124 | 124 | } |
125 | 125 | } while (pageData.hasNext()); |
126 | 126 | |
... | ... | @@ -136,8 +136,8 @@ public abstract class BaseTenantControllerTest extends AbstractControllerTest { |
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | - pageLink = new TextPageLink(17); | |
140 | - pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<TextPageData<Tenant>>(){}, pageLink); | |
139 | + pageLink = new PageLink(17); | |
140 | + pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<PageData<Tenant>>(){}, pageLink); | |
141 | 141 | Assert.assertFalse(pageData.hasNext()); |
142 | 142 | Assert.assertEquals(1, pageData.getData().size()); |
143 | 143 | } |
... | ... | @@ -167,13 +167,13 @@ public abstract class BaseTenantControllerTest extends AbstractControllerTest { |
167 | 167 | } |
168 | 168 | |
169 | 169 | List<Tenant> loadedTenantsTitle1 = new ArrayList<>(); |
170 | - TextPageLink pageLink = new TextPageLink(15, title1); | |
171 | - TextPageData<Tenant> pageData = null; | |
170 | + PageLink pageLink = new PageLink(15, 0, title1); | |
171 | + PageData<Tenant> pageData = null; | |
172 | 172 | do { |
173 | - pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<TextPageData<Tenant>>(){}, pageLink); | |
173 | + pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<PageData<Tenant>>(){}, pageLink); | |
174 | 174 | loadedTenantsTitle1.addAll(pageData.getData()); |
175 | 175 | if (pageData.hasNext()) { |
176 | - pageLink = pageData.getNextPageLink(); | |
176 | + pageLink = pageLink.nextPageLink(); | |
177 | 177 | } |
178 | 178 | } while (pageData.hasNext()); |
179 | 179 | |
... | ... | @@ -183,12 +183,12 @@ public abstract class BaseTenantControllerTest extends AbstractControllerTest { |
183 | 183 | Assert.assertEquals(tenantsTitle1, loadedTenantsTitle1); |
184 | 184 | |
185 | 185 | List<Tenant> loadedTenantsTitle2 = new ArrayList<>(); |
186 | - pageLink = new TextPageLink(4, title2); | |
186 | + pageLink = new PageLink(4, 0, title2); | |
187 | 187 | do { |
188 | - pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<TextPageData<Tenant>>(){}, pageLink); | |
188 | + pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<PageData<Tenant>>(){}, pageLink); | |
189 | 189 | loadedTenantsTitle2.addAll(pageData.getData()); |
190 | 190 | if (pageData.hasNext()) { |
191 | - pageLink = pageData.getNextPageLink(); | |
191 | + pageLink = pageLink.nextPageLink(); | |
192 | 192 | } |
193 | 193 | } while (pageData.hasNext()); |
194 | 194 | |
... | ... | @@ -202,8 +202,8 @@ public abstract class BaseTenantControllerTest extends AbstractControllerTest { |
202 | 202 | .andExpect(status().isOk()); |
203 | 203 | } |
204 | 204 | |
205 | - pageLink = new TextPageLink(4, title1); | |
206 | - pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<TextPageData<Tenant>>(){}, pageLink); | |
205 | + pageLink = new PageLink(4, 0, title1); | |
206 | + pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<PageData<Tenant>>(){}, pageLink); | |
207 | 207 | Assert.assertFalse(pageData.hasNext()); |
208 | 208 | Assert.assertEquals(0, pageData.getData().size()); |
209 | 209 | |
... | ... | @@ -212,8 +212,8 @@ public abstract class BaseTenantControllerTest extends AbstractControllerTest { |
212 | 212 | .andExpect(status().isOk()); |
213 | 213 | } |
214 | 214 | |
215 | - pageLink = new TextPageLink(4, title2); | |
216 | - pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<TextPageData<Tenant>>(){}, pageLink); | |
215 | + pageLink = new PageLink(4, 0, title2); | |
216 | + pageData = doGetTypedWithPageLink("/api/tenants?", new TypeReference<PageData<Tenant>>(){}, pageLink); | |
217 | 217 | Assert.assertFalse(pageData.hasNext()); |
218 | 218 | Assert.assertEquals(0, pageData.getData().size()); |
219 | 219 | } | ... | ... |
... | ... | @@ -27,8 +27,8 @@ import org.thingsboard.server.common.data.Tenant; |
27 | 27 | import org.thingsboard.server.common.data.User; |
28 | 28 | import org.thingsboard.server.common.data.id.CustomerId; |
29 | 29 | import org.thingsboard.server.common.data.id.TenantId; |
30 | -import org.thingsboard.server.common.data.page.TextPageData; | |
31 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
30 | +import org.thingsboard.server.common.data.page.PageData; | |
31 | +import org.thingsboard.server.common.data.page.PageLink; | |
32 | 32 | import org.thingsboard.server.common.data.security.Authority; |
33 | 33 | import org.thingsboard.server.service.mail.TestMailService; |
34 | 34 | |
... | ... | @@ -326,14 +326,14 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
326 | 326 | } |
327 | 327 | |
328 | 328 | List<User> loadedTenantAdmins = new ArrayList<>(); |
329 | - TextPageLink pageLink = new TextPageLink(33); | |
330 | - TextPageData<User> pageData = null; | |
329 | + PageLink pageLink = new PageLink(33); | |
330 | + PageData<User> pageData = null; | |
331 | 331 | do { |
332 | 332 | pageData = doGetTypedWithPageLink("/api/tenant/" + tenantId.getId().toString() + "/users?", |
333 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
333 | + new TypeReference<PageData<User>>(){}, pageLink); | |
334 | 334 | loadedTenantAdmins.addAll(pageData.getData()); |
335 | 335 | if (pageData.hasNext()) { |
336 | - pageLink = pageData.getNextPageLink(); | |
336 | + pageLink = pageLink.nextPageLink(); | |
337 | 337 | } |
338 | 338 | } while (pageData.hasNext()); |
339 | 339 | |
... | ... | @@ -345,9 +345,9 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
345 | 345 | doDelete("/api/tenant/"+savedTenant.getId().getId().toString()) |
346 | 346 | .andExpect(status().isOk()); |
347 | 347 | |
348 | - pageLink = new TextPageLink(33); | |
348 | + pageLink = new PageLink(33); | |
349 | 349 | pageData = doGetTypedWithPageLink("/api/tenant/" + tenantId.getId().toString() + "/users?", |
350 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
350 | + new TypeReference<PageData<User>>(){}, pageLink); | |
351 | 351 | Assert.assertFalse(pageData.hasNext()); |
352 | 352 | Assert.assertTrue(pageData.getData().isEmpty()); |
353 | 353 | } |
... | ... | @@ -393,14 +393,14 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
393 | 393 | } |
394 | 394 | |
395 | 395 | List<User> loadedTenantAdminsEmail1 = new ArrayList<>(); |
396 | - TextPageLink pageLink = new TextPageLink(33, email1); | |
397 | - TextPageData<User> pageData = null; | |
396 | + PageLink pageLink = new PageLink(33, 0, email1); | |
397 | + PageData<User> pageData = null; | |
398 | 398 | do { |
399 | 399 | pageData = doGetTypedWithPageLink("/api/tenant/" + tenantId.getId().toString() + "/users?", |
400 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
400 | + new TypeReference<PageData<User>>(){}, pageLink); | |
401 | 401 | loadedTenantAdminsEmail1.addAll(pageData.getData()); |
402 | 402 | if (pageData.hasNext()) { |
403 | - pageLink = pageData.getNextPageLink(); | |
403 | + pageLink = pageLink.nextPageLink(); | |
404 | 404 | } |
405 | 405 | } while (pageData.hasNext()); |
406 | 406 | |
... | ... | @@ -410,13 +410,13 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
410 | 410 | Assert.assertEquals(tenantAdminsEmail1, loadedTenantAdminsEmail1); |
411 | 411 | |
412 | 412 | List<User> loadedTenantAdminsEmail2 = new ArrayList<>(); |
413 | - pageLink = new TextPageLink(16, email2); | |
413 | + pageLink = new PageLink(16, 0, email2); | |
414 | 414 | do { |
415 | 415 | pageData = doGetTypedWithPageLink("/api/tenant/" + tenantId.getId().toString() + "/users?", |
416 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
416 | + new TypeReference<PageData<User>>(){}, pageLink); | |
417 | 417 | loadedTenantAdminsEmail2.addAll(pageData.getData()); |
418 | 418 | if (pageData.hasNext()) { |
419 | - pageLink = pageData.getNextPageLink(); | |
419 | + pageLink = pageLink.nextPageLink(); | |
420 | 420 | } |
421 | 421 | } while (pageData.hasNext()); |
422 | 422 | |
... | ... | @@ -430,9 +430,9 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
430 | 430 | .andExpect(status().isOk()); |
431 | 431 | } |
432 | 432 | |
433 | - pageLink = new TextPageLink(4, email1); | |
433 | + pageLink = new PageLink(4, 0, email1); | |
434 | 434 | pageData = doGetTypedWithPageLink("/api/tenant/" + tenantId.getId().toString() + "/users?", |
435 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
435 | + new TypeReference<PageData<User>>(){}, pageLink); | |
436 | 436 | Assert.assertFalse(pageData.hasNext()); |
437 | 437 | Assert.assertEquals(0, pageData.getData().size()); |
438 | 438 | |
... | ... | @@ -441,9 +441,9 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
441 | 441 | .andExpect(status().isOk()); |
442 | 442 | } |
443 | 443 | |
444 | - pageLink = new TextPageLink(4, email2); | |
444 | + pageLink = new PageLink(4, 0, email2); | |
445 | 445 | pageData = doGetTypedWithPageLink("/api/tenant/" + tenantId.getId().toString() + "/users?", |
446 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
446 | + new TypeReference<PageData<User>>(){}, pageLink); | |
447 | 447 | Assert.assertFalse(pageData.hasNext()); |
448 | 448 | Assert.assertEquals(0, pageData.getData().size()); |
449 | 449 | |
... | ... | @@ -486,14 +486,14 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
486 | 486 | } |
487 | 487 | |
488 | 488 | List<User> loadedCustomerUsers = new ArrayList<>(); |
489 | - TextPageLink pageLink = new TextPageLink(33); | |
490 | - TextPageData<User> pageData = null; | |
489 | + PageLink pageLink = new PageLink(33); | |
490 | + PageData<User> pageData = null; | |
491 | 491 | do { |
492 | 492 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/users?", |
493 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
493 | + new TypeReference<PageData<User>>(){}, pageLink); | |
494 | 494 | loadedCustomerUsers.addAll(pageData.getData()); |
495 | 495 | if (pageData.hasNext()) { |
496 | - pageLink = pageData.getNextPageLink(); | |
496 | + pageLink = pageLink.nextPageLink(); | |
497 | 497 | } |
498 | 498 | } while (pageData.hasNext()); |
499 | 499 | |
... | ... | @@ -565,14 +565,14 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
565 | 565 | } |
566 | 566 | |
567 | 567 | List<User> loadedCustomerUsersEmail1 = new ArrayList<>(); |
568 | - TextPageLink pageLink = new TextPageLink(33, email1); | |
569 | - TextPageData<User> pageData = null; | |
568 | + PageLink pageLink = new PageLink(33, 0, email1); | |
569 | + PageData<User> pageData = null; | |
570 | 570 | do { |
571 | 571 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/users?", |
572 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
572 | + new TypeReference<PageData<User>>(){}, pageLink); | |
573 | 573 | loadedCustomerUsersEmail1.addAll(pageData.getData()); |
574 | 574 | if (pageData.hasNext()) { |
575 | - pageLink = pageData.getNextPageLink(); | |
575 | + pageLink = pageLink.nextPageLink(); | |
576 | 576 | } |
577 | 577 | } while (pageData.hasNext()); |
578 | 578 | |
... | ... | @@ -582,13 +582,13 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
582 | 582 | Assert.assertEquals(customerUsersEmail1, loadedCustomerUsersEmail1); |
583 | 583 | |
584 | 584 | List<User> loadedCustomerUsersEmail2 = new ArrayList<>(); |
585 | - pageLink = new TextPageLink(16, email2); | |
585 | + pageLink = new PageLink(16, 0, email2); | |
586 | 586 | do { |
587 | 587 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/users?", |
588 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
588 | + new TypeReference<PageData<User>>(){}, pageLink); | |
589 | 589 | loadedCustomerUsersEmail2.addAll(pageData.getData()); |
590 | 590 | if (pageData.hasNext()) { |
591 | - pageLink = pageData.getNextPageLink(); | |
591 | + pageLink = pageLink.nextPageLink(); | |
592 | 592 | } |
593 | 593 | } while (pageData.hasNext()); |
594 | 594 | |
... | ... | @@ -602,9 +602,9 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
602 | 602 | .andExpect(status().isOk()); |
603 | 603 | } |
604 | 604 | |
605 | - pageLink = new TextPageLink(4, email1); | |
605 | + pageLink = new PageLink(4, 0, email1); | |
606 | 606 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/users?", |
607 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
607 | + new TypeReference<PageData<User>>(){}, pageLink); | |
608 | 608 | Assert.assertFalse(pageData.hasNext()); |
609 | 609 | Assert.assertEquals(0, pageData.getData().size()); |
610 | 610 | |
... | ... | @@ -613,9 +613,9 @@ public abstract class BaseUserControllerTest extends AbstractControllerTest { |
613 | 613 | .andExpect(status().isOk()); |
614 | 614 | } |
615 | 615 | |
616 | - pageLink = new TextPageLink(4, email2); | |
616 | + pageLink = new PageLink(4, 0, email2); | |
617 | 617 | pageData = doGetTypedWithPageLink("/api/customer/" + customerId.getId().toString() + "/users?", |
618 | - new TypeReference<TextPageData<User>>(){}, pageLink); | |
618 | + new TypeReference<PageData<User>>(){}, pageLink); | |
619 | 619 | Assert.assertFalse(pageData.hasNext()); |
620 | 620 | Assert.assertEquals(0, pageData.getData().size()); |
621 | 621 | ... | ... |
... | ... | @@ -22,8 +22,8 @@ import org.junit.Before; |
22 | 22 | import org.junit.Test; |
23 | 23 | import org.thingsboard.server.common.data.Tenant; |
24 | 24 | import org.thingsboard.server.common.data.User; |
25 | -import org.thingsboard.server.common.data.page.TextPageData; | |
26 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
25 | +import org.thingsboard.server.common.data.page.PageData; | |
26 | +import org.thingsboard.server.common.data.page.PageLink; | |
27 | 27 | import org.thingsboard.server.common.data.security.Authority; |
28 | 28 | import org.thingsboard.server.common.data.widget.WidgetsBundle; |
29 | 29 | |
... | ... | @@ -150,14 +150,14 @@ public abstract class BaseWidgetsBundleControllerTest extends AbstractController |
150 | 150 | widgetsBundles.addAll(sysWidgetsBundles); |
151 | 151 | |
152 | 152 | List<WidgetsBundle> loadedWidgetsBundles = new ArrayList<>(); |
153 | - TextPageLink pageLink = new TextPageLink(14); | |
154 | - TextPageData<WidgetsBundle> pageData; | |
153 | + PageLink pageLink = new PageLink(14); | |
154 | + PageData<WidgetsBundle> pageData; | |
155 | 155 | do { |
156 | 156 | pageData = doGetTypedWithPageLink("/api/widgetsBundles?", |
157 | - new TypeReference<TextPageData<WidgetsBundle>>(){}, pageLink); | |
157 | + new TypeReference<PageData<WidgetsBundle>>(){}, pageLink); | |
158 | 158 | loadedWidgetsBundles.addAll(pageData.getData()); |
159 | 159 | if (pageData.hasNext()) { |
160 | - pageLink = pageData.getNextPageLink(); | |
160 | + pageLink = pageLink.nextPageLink(); | |
161 | 161 | } |
162 | 162 | } while (pageData.hasNext()); |
163 | 163 | |
... | ... | @@ -186,14 +186,14 @@ public abstract class BaseWidgetsBundleControllerTest extends AbstractController |
186 | 186 | widgetsBundles.addAll(sysWidgetsBundles); |
187 | 187 | |
188 | 188 | List<WidgetsBundle> loadedWidgetsBundles = new ArrayList<>(); |
189 | - TextPageLink pageLink = new TextPageLink(14); | |
190 | - TextPageData<WidgetsBundle> pageData; | |
189 | + PageLink pageLink = new PageLink(14); | |
190 | + PageData<WidgetsBundle> pageData; | |
191 | 191 | do { |
192 | 192 | pageData = doGetTypedWithPageLink("/api/widgetsBundles?", |
193 | - new TypeReference<TextPageData<WidgetsBundle>>(){}, pageLink); | |
193 | + new TypeReference<PageData<WidgetsBundle>>(){}, pageLink); | |
194 | 194 | loadedWidgetsBundles.addAll(pageData.getData()); |
195 | 195 | if (pageData.hasNext()) { |
196 | - pageLink = pageData.getNextPageLink(); | |
196 | + pageLink = pageLink.nextPageLink(); | |
197 | 197 | } |
198 | 198 | } while (pageData.hasNext()); |
199 | 199 | |
... | ... | @@ -207,14 +207,14 @@ public abstract class BaseWidgetsBundleControllerTest extends AbstractController |
207 | 207 | .andExpect(status().isOk()); |
208 | 208 | } |
209 | 209 | |
210 | - pageLink = new TextPageLink(17); | |
210 | + pageLink = new PageLink(17); | |
211 | 211 | loadedWidgetsBundles.clear(); |
212 | 212 | do { |
213 | 213 | pageData = doGetTypedWithPageLink("/api/widgetsBundles?", |
214 | - new TypeReference<TextPageData<WidgetsBundle>>(){}, pageLink); | |
214 | + new TypeReference<PageData<WidgetsBundle>>(){}, pageLink); | |
215 | 215 | loadedWidgetsBundles.addAll(pageData.getData()); |
216 | 216 | if (pageData.hasNext()) { |
217 | - pageLink = pageData.getNextPageLink(); | |
217 | + pageLink = pageLink.nextPageLink(); | |
218 | 218 | } |
219 | 219 | } while (pageData.hasNext()); |
220 | 220 | ... | ... |
... | ... | @@ -30,8 +30,7 @@ import org.thingsboard.server.actors.service.ActorService; |
30 | 30 | import org.thingsboard.server.common.data.*; |
31 | 31 | import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; |
32 | 32 | import org.thingsboard.server.common.data.kv.StringDataEntry; |
33 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
34 | -import org.thingsboard.server.common.data.page.TimePageData; | |
33 | +import org.thingsboard.server.common.data.page.PageData; | |
35 | 34 | import org.thingsboard.server.common.data.rule.RuleChain; |
36 | 35 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; |
37 | 36 | import org.thingsboard.server.common.data.rule.RuleNode; |
... | ... | @@ -160,7 +159,7 @@ public abstract class AbstractRuleEngineFlowIntegrationTest extends AbstractRule |
160 | 159 | |
161 | 160 | Thread.sleep(3000); |
162 | 161 | |
163 | - TimePageData<Event> eventsPage = getDebugEvents(savedTenant.getId(), ruleChain.getFirstRuleNodeId(), 1000); | |
162 | + PageData<Event> eventsPage = getDebugEvents(savedTenant.getId(), ruleChain.getFirstRuleNodeId(), 1000); | |
164 | 163 | List<Event> events = eventsPage.getData().stream().filter(filterByCustomEvent()).collect(Collectors.toList()); |
165 | 164 | Assert.assertEquals(2, events.size()); |
166 | 165 | |
... | ... | @@ -275,7 +274,7 @@ public abstract class AbstractRuleEngineFlowIntegrationTest extends AbstractRule |
275 | 274 | |
276 | 275 | Thread.sleep(3000); |
277 | 276 | |
278 | - TimePageData<Event> eventsPage = getDebugEvents(savedTenant.getId(), rootRuleChain.getFirstRuleNodeId(), 1000); | |
277 | + PageData<Event> eventsPage = getDebugEvents(savedTenant.getId(), rootRuleChain.getFirstRuleNodeId(), 1000); | |
279 | 278 | List<Event> events = eventsPage.getData().stream().filter(filterByCustomEvent()).collect(Collectors.toList()); |
280 | 279 | |
281 | 280 | Assert.assertEquals(2, events.size()); | ... | ... |
... | ... | @@ -32,7 +32,7 @@ import org.thingsboard.server.common.data.Tenant; |
32 | 32 | import org.thingsboard.server.common.data.User; |
33 | 33 | import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; |
34 | 34 | import org.thingsboard.server.common.data.kv.StringDataEntry; |
35 | -import org.thingsboard.server.common.data.page.TimePageData; | |
35 | +import org.thingsboard.server.common.data.page.PageData; | |
36 | 36 | import org.thingsboard.server.common.data.rule.RuleChain; |
37 | 37 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; |
38 | 38 | import org.thingsboard.server.common.data.rule.RuleNode; |
... | ... | @@ -147,7 +147,7 @@ public abstract class AbstractRuleEngineLifecycleIntegrationTest extends Abstrac |
147 | 147 | |
148 | 148 | Thread.sleep(3000); |
149 | 149 | |
150 | - TimePageData<Event> eventsPage = getDebugEvents(savedTenant.getId(), ruleChain.getFirstRuleNodeId(), 1000); | |
150 | + PageData<Event> eventsPage = getDebugEvents(savedTenant.getId(), ruleChain.getFirstRuleNodeId(), 1000); | |
151 | 151 | List<Event> events = eventsPage.getData().stream().filter(filterByCustomEvent()).collect(Collectors.toList()); |
152 | 152 | |
153 | 153 | Assert.assertEquals(2, events.size()); | ... | ... |
... | ... | @@ -26,7 +26,7 @@ import org.thingsboard.server.common.data.alarm.AlarmSeverity; |
26 | 26 | import org.thingsboard.server.common.data.alarm.AlarmStatus; |
27 | 27 | import org.thingsboard.server.common.data.id.EntityId; |
28 | 28 | import org.thingsboard.server.common.data.id.TenantId; |
29 | -import org.thingsboard.server.common.data.page.TimePageData; | |
29 | +import org.thingsboard.server.common.data.page.PageData; | |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Created by ashvayka on 11.05.17. |
... | ... | @@ -45,7 +45,7 @@ public interface AlarmService { |
45 | 45 | |
46 | 46 | ListenableFuture<AlarmInfo> findAlarmInfoByIdAsync(TenantId tenantId, AlarmId alarmId); |
47 | 47 | |
48 | - ListenableFuture<TimePageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query); | |
48 | + ListenableFuture<PageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query); | |
49 | 49 | |
50 | 50 | AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus, |
51 | 51 | AlarmStatus alarmStatus); | ... | ... |
... | ... | @@ -22,8 +22,8 @@ import org.thingsboard.server.common.data.asset.AssetSearchQuery; |
22 | 22 | import org.thingsboard.server.common.data.id.AssetId; |
23 | 23 | import org.thingsboard.server.common.data.id.CustomerId; |
24 | 24 | import org.thingsboard.server.common.data.id.TenantId; |
25 | -import org.thingsboard.server.common.data.page.TextPageData; | |
26 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
25 | +import org.thingsboard.server.common.data.page.PageData; | |
26 | +import org.thingsboard.server.common.data.page.PageLink; | |
27 | 27 | |
28 | 28 | import java.util.List; |
29 | 29 | import java.util.Optional; |
... | ... | @@ -44,17 +44,17 @@ public interface AssetService { |
44 | 44 | |
45 | 45 | void deleteAsset(TenantId tenantId, AssetId assetId); |
46 | 46 | |
47 | - TextPageData<Asset> findAssetsByTenantId(TenantId tenantId, TextPageLink pageLink); | |
47 | + PageData<Asset> findAssetsByTenantId(TenantId tenantId, PageLink pageLink); | |
48 | 48 | |
49 | - TextPageData<Asset> findAssetsByTenantIdAndType(TenantId tenantId, String type, TextPageLink pageLink); | |
49 | + PageData<Asset> findAssetsByTenantIdAndType(TenantId tenantId, String type, PageLink pageLink); | |
50 | 50 | |
51 | 51 | ListenableFuture<List<Asset>> findAssetsByTenantIdAndIdsAsync(TenantId tenantId, List<AssetId> assetIds); |
52 | 52 | |
53 | 53 | void deleteAssetsByTenantId(TenantId tenantId); |
54 | 54 | |
55 | - TextPageData<Asset> findAssetsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TextPageLink pageLink); | |
55 | + PageData<Asset> findAssetsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, PageLink pageLink); | |
56 | 56 | |
57 | - TextPageData<Asset> findAssetsByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, String type, TextPageLink pageLink); | |
57 | + PageData<Asset> findAssetsByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, String type, PageLink pageLink); | |
58 | 58 | |
59 | 59 | ListenableFuture<List<Asset>> findAssetsByTenantIdCustomerIdAndIdsAsync(TenantId tenantId, CustomerId customerId, List<AssetId> assetIds); |
60 | 60 | ... | ... |
... | ... | @@ -25,20 +25,20 @@ import org.thingsboard.server.common.data.id.EntityId; |
25 | 25 | import org.thingsboard.server.common.data.id.TenantId; |
26 | 26 | import org.thingsboard.server.common.data.id.UUIDBased; |
27 | 27 | import org.thingsboard.server.common.data.id.UserId; |
28 | -import org.thingsboard.server.common.data.page.TimePageData; | |
28 | +import org.thingsboard.server.common.data.page.PageData; | |
29 | 29 | import org.thingsboard.server.common.data.page.TimePageLink; |
30 | 30 | |
31 | 31 | import java.util.List; |
32 | 32 | |
33 | 33 | public interface AuditLogService { |
34 | 34 | |
35 | - TimePageData<AuditLog> findAuditLogsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TimePageLink pageLink); | |
35 | + PageData<AuditLog> findAuditLogsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TimePageLink pageLink); | |
36 | 36 | |
37 | - TimePageData<AuditLog> findAuditLogsByTenantIdAndUserId(TenantId tenantId, UserId userId, TimePageLink pageLink); | |
37 | + PageData<AuditLog> findAuditLogsByTenantIdAndUserId(TenantId tenantId, UserId userId, TimePageLink pageLink); | |
38 | 38 | |
39 | - TimePageData<AuditLog> findAuditLogsByTenantIdAndEntityId(TenantId tenantId, EntityId entityId, TimePageLink pageLink); | |
39 | + PageData<AuditLog> findAuditLogsByTenantIdAndEntityId(TenantId tenantId, EntityId entityId, TimePageLink pageLink); | |
40 | 40 | |
41 | - TimePageData<AuditLog> findAuditLogsByTenantId(TenantId tenantId, TimePageLink pageLink); | |
41 | + PageData<AuditLog> findAuditLogsByTenantId(TenantId tenantId, TimePageLink pageLink); | |
42 | 42 | |
43 | 43 | <E extends HasName, I extends EntityId> ListenableFuture<List<Void>> logEntityAction( |
44 | 44 | TenantId tenantId, | ... | ... |
... | ... | @@ -18,8 +18,8 @@ package org.thingsboard.server.dao.component; |
18 | 18 | import com.fasterxml.jackson.databind.JsonNode; |
19 | 19 | import org.thingsboard.server.common.data.id.ComponentDescriptorId; |
20 | 20 | import org.thingsboard.server.common.data.id.TenantId; |
21 | -import org.thingsboard.server.common.data.page.TextPageData; | |
22 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
21 | +import org.thingsboard.server.common.data.page.PageData; | |
22 | +import org.thingsboard.server.common.data.page.PageLink; | |
23 | 23 | import org.thingsboard.server.common.data.plugin.ComponentDescriptor; |
24 | 24 | import org.thingsboard.server.common.data.plugin.ComponentScope; |
25 | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
... | ... | @@ -35,9 +35,9 @@ public interface ComponentDescriptorService { |
35 | 35 | |
36 | 36 | ComponentDescriptor findByClazz(TenantId tenantId, String clazz); |
37 | 37 | |
38 | - TextPageData<ComponentDescriptor> findByTypeAndPageLink(TenantId tenantId, ComponentType type, TextPageLink pageLink); | |
38 | + PageData<ComponentDescriptor> findByTypeAndPageLink(TenantId tenantId, ComponentType type, PageLink pageLink); | |
39 | 39 | |
40 | - TextPageData<ComponentDescriptor> findByScopeAndTypeAndPageLink(TenantId tenantId, ComponentScope scope, ComponentType type, TextPageLink pageLink); | |
40 | + PageData<ComponentDescriptor> findByScopeAndTypeAndPageLink(TenantId tenantId, ComponentScope scope, ComponentType type, PageLink pageLink); | |
41 | 41 | |
42 | 42 | boolean validate(TenantId tenantId, ComponentDescriptor component, JsonNode configuration); |
43 | 43 | ... | ... |
... | ... | @@ -19,8 +19,8 @@ import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import org.thingsboard.server.common.data.Customer; |
20 | 20 | import org.thingsboard.server.common.data.id.CustomerId; |
21 | 21 | import org.thingsboard.server.common.data.id.TenantId; |
22 | -import org.thingsboard.server.common.data.page.TextPageData; | |
23 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
22 | +import org.thingsboard.server.common.data.page.PageData; | |
23 | +import org.thingsboard.server.common.data.page.PageLink; | |
24 | 24 | |
25 | 25 | import java.util.Optional; |
26 | 26 | |
... | ... | @@ -38,7 +38,7 @@ public interface CustomerService { |
38 | 38 | |
39 | 39 | Customer findOrCreatePublicCustomer(TenantId tenantId); |
40 | 40 | |
41 | - TextPageData<Customer> findCustomersByTenantId(TenantId tenantId, TextPageLink pageLink); | |
41 | + PageData<Customer> findCustomersByTenantId(TenantId tenantId, PageLink pageLink); | |
42 | 42 | |
43 | 43 | void deleteCustomersByTenantId(TenantId tenantId); |
44 | 44 | ... | ... |
... | ... | @@ -21,9 +21,8 @@ import org.thingsboard.server.common.data.DashboardInfo; |
21 | 21 | import org.thingsboard.server.common.data.id.CustomerId; |
22 | 22 | import org.thingsboard.server.common.data.id.DashboardId; |
23 | 23 | import org.thingsboard.server.common.data.id.TenantId; |
24 | -import org.thingsboard.server.common.data.page.TextPageData; | |
25 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
26 | -import org.thingsboard.server.common.data.page.TimePageData; | |
24 | +import org.thingsboard.server.common.data.page.PageData; | |
25 | +import org.thingsboard.server.common.data.page.PageLink; | |
27 | 26 | import org.thingsboard.server.common.data.page.TimePageLink; |
28 | 27 | |
29 | 28 | public interface DashboardService { |
... | ... | @@ -44,11 +43,11 @@ public interface DashboardService { |
44 | 43 | |
45 | 44 | void deleteDashboard(TenantId tenantId, DashboardId dashboardId); |
46 | 45 | |
47 | - TextPageData<DashboardInfo> findDashboardsByTenantId(TenantId tenantId, TextPageLink pageLink); | |
46 | + PageData<DashboardInfo> findDashboardsByTenantId(TenantId tenantId, PageLink pageLink); | |
48 | 47 | |
49 | 48 | void deleteDashboardsByTenantId(TenantId tenantId); |
50 | 49 | |
51 | - ListenableFuture<TimePageData<DashboardInfo>> findDashboardsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TimePageLink pageLink); | |
50 | + ListenableFuture<PageData<DashboardInfo>> findDashboardsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TimePageLink pageLink); | |
52 | 51 | |
53 | 52 | void unassignCustomerDashboards(TenantId tenantId, CustomerId customerId); |
54 | 53 | ... | ... |
... | ... | @@ -22,8 +22,8 @@ import org.thingsboard.server.common.data.device.DeviceSearchQuery; |
22 | 22 | import org.thingsboard.server.common.data.id.CustomerId; |
23 | 23 | import org.thingsboard.server.common.data.id.DeviceId; |
24 | 24 | import org.thingsboard.server.common.data.id.TenantId; |
25 | -import org.thingsboard.server.common.data.page.TextPageData; | |
26 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
25 | +import org.thingsboard.server.common.data.page.PageData; | |
26 | +import org.thingsboard.server.common.data.page.PageLink; | |
27 | 27 | |
28 | 28 | import java.util.List; |
29 | 29 | |
... | ... | @@ -43,17 +43,17 @@ public interface DeviceService { |
43 | 43 | |
44 | 44 | void deleteDevice(TenantId tenantId, DeviceId deviceId); |
45 | 45 | |
46 | - TextPageData<Device> findDevicesByTenantId(TenantId tenantId, TextPageLink pageLink); | |
46 | + PageData<Device> findDevicesByTenantId(TenantId tenantId, PageLink pageLink); | |
47 | 47 | |
48 | - TextPageData<Device> findDevicesByTenantIdAndType(TenantId tenantId, String type, TextPageLink pageLink); | |
48 | + PageData<Device> findDevicesByTenantIdAndType(TenantId tenantId, String type, PageLink pageLink); | |
49 | 49 | |
50 | 50 | ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(TenantId tenantId, List<DeviceId> deviceIds); |
51 | 51 | |
52 | 52 | void deleteDevicesByTenantId(TenantId tenantId); |
53 | 53 | |
54 | - TextPageData<Device> findDevicesByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TextPageLink pageLink); | |
54 | + PageData<Device> findDevicesByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, PageLink pageLink); | |
55 | 55 | |
56 | - TextPageData<Device> findDevicesByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, String type, TextPageLink pageLink); | |
56 | + PageData<Device> findDevicesByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, String type, PageLink pageLink); | |
57 | 57 | |
58 | 58 | ListenableFuture<List<Device>> findDevicesByTenantIdCustomerIdAndIdsAsync(TenantId tenantId, CustomerId customerId, List<DeviceId> deviceIds); |
59 | 59 | ... | ... |
... | ... | @@ -24,8 +24,8 @@ import org.thingsboard.server.common.data.id.CustomerId; |
24 | 24 | import org.thingsboard.server.common.data.id.EntityId; |
25 | 25 | import org.thingsboard.server.common.data.id.EntityViewId; |
26 | 26 | import org.thingsboard.server.common.data.id.TenantId; |
27 | -import org.thingsboard.server.common.data.page.TextPageData; | |
28 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
27 | +import org.thingsboard.server.common.data.page.PageData; | |
28 | +import org.thingsboard.server.common.data.page.PageLink; | |
29 | 29 | |
30 | 30 | import java.util.List; |
31 | 31 | |
... | ... | @@ -46,13 +46,13 @@ public interface EntityViewService { |
46 | 46 | |
47 | 47 | EntityView findEntityViewByTenantIdAndName(TenantId tenantId, String name); |
48 | 48 | |
49 | - TextPageData<EntityView> findEntityViewByTenantId(TenantId tenantId, TextPageLink pageLink); | |
49 | + PageData<EntityView> findEntityViewByTenantId(TenantId tenantId, PageLink pageLink); | |
50 | 50 | |
51 | - TextPageData<EntityView> findEntityViewByTenantIdAndType(TenantId tenantId, TextPageLink pageLink, String type); | |
51 | + PageData<EntityView> findEntityViewByTenantIdAndType(TenantId tenantId, PageLink pageLink, String type); | |
52 | 52 | |
53 | - TextPageData<EntityView> findEntityViewsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TextPageLink pageLink); | |
53 | + PageData<EntityView> findEntityViewsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, PageLink pageLink); | |
54 | 54 | |
55 | - TextPageData<EntityView> findEntityViewsByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, TextPageLink pageLink, String type); | |
55 | + PageData<EntityView> findEntityViewsByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, PageLink pageLink, String type); | |
56 | 56 | |
57 | 57 | ListenableFuture<List<EntityView>> findEntityViewsByQuery(TenantId tenantId, EntityViewSearchQuery query); |
58 | 58 | ... | ... |
... | ... | @@ -19,7 +19,7 @@ import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import org.thingsboard.server.common.data.Event; |
20 | 20 | import org.thingsboard.server.common.data.id.EntityId; |
21 | 21 | import org.thingsboard.server.common.data.id.TenantId; |
22 | -import org.thingsboard.server.common.data.page.TimePageData; | |
22 | +import org.thingsboard.server.common.data.page.PageData; | |
23 | 23 | import org.thingsboard.server.common.data.page.TimePageLink; |
24 | 24 | |
25 | 25 | import java.util.List; |
... | ... | @@ -35,9 +35,9 @@ public interface EventService { |
35 | 35 | |
36 | 36 | Optional<Event> findEvent(TenantId tenantId, EntityId entityId, String eventType, String eventUid); |
37 | 37 | |
38 | - TimePageData<Event> findEvents(TenantId tenantId, EntityId entityId, TimePageLink pageLink); | |
38 | + PageData<Event> findEvents(TenantId tenantId, EntityId entityId, TimePageLink pageLink); | |
39 | 39 | |
40 | - TimePageData<Event> findEvents(TenantId tenantId, EntityId entityId, String eventType, TimePageLink pageLink); | |
40 | + PageData<Event> findEvents(TenantId tenantId, EntityId entityId, String eventType, TimePageLink pageLink); | |
41 | 41 | |
42 | 42 | List<Event> findLatestEvents(TenantId tenantId, EntityId entityId, String eventType, int limit); |
43 | 43 | ... | ... |
... | ... | @@ -19,8 +19,8 @@ import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import org.thingsboard.server.common.data.id.RuleChainId; |
20 | 20 | import org.thingsboard.server.common.data.id.RuleNodeId; |
21 | 21 | import org.thingsboard.server.common.data.id.TenantId; |
22 | -import org.thingsboard.server.common.data.page.TextPageData; | |
23 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
22 | +import org.thingsboard.server.common.data.page.PageData; | |
23 | +import org.thingsboard.server.common.data.page.PageLink; | |
24 | 24 | import org.thingsboard.server.common.data.relation.EntityRelation; |
25 | 25 | import org.thingsboard.server.common.data.rule.RuleChain; |
26 | 26 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; |
... | ... | @@ -57,7 +57,7 @@ public interface RuleChainService { |
57 | 57 | |
58 | 58 | List<EntityRelation> getRuleNodeRelations(TenantId tenantId, RuleNodeId ruleNodeId); |
59 | 59 | |
60 | - TextPageData<RuleChain> findTenantRuleChains(TenantId tenantId, TextPageLink pageLink); | |
60 | + PageData<RuleChain> findTenantRuleChains(TenantId tenantId, PageLink pageLink); | |
61 | 61 | |
62 | 62 | void deleteRuleChainById(TenantId tenantId, RuleChainId ruleChainId); |
63 | 63 | ... | ... |
... | ... | @@ -18,8 +18,8 @@ package org.thingsboard.server.dao.tenant; |
18 | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import org.thingsboard.server.common.data.Tenant; |
20 | 20 | import org.thingsboard.server.common.data.id.TenantId; |
21 | -import org.thingsboard.server.common.data.page.TextPageData; | |
22 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
21 | +import org.thingsboard.server.common.data.page.PageData; | |
22 | +import org.thingsboard.server.common.data.page.PageLink; | |
23 | 23 | |
24 | 24 | public interface TenantService { |
25 | 25 | |
... | ... | @@ -31,7 +31,7 @@ public interface TenantService { |
31 | 31 | |
32 | 32 | void deleteTenant(TenantId tenantId); |
33 | 33 | |
34 | - TextPageData<Tenant> findTenants(TextPageLink pageLink); | |
34 | + PageData<Tenant> findTenants(PageLink pageLink); | |
35 | 35 | |
36 | 36 | void deleteTenants(); |
37 | 37 | } | ... | ... |
... | ... | @@ -21,8 +21,8 @@ import org.thingsboard.server.common.data.id.CustomerId; |
21 | 21 | import org.thingsboard.server.common.data.id.TenantId; |
22 | 22 | import org.thingsboard.server.common.data.id.UserCredentialsId; |
23 | 23 | import org.thingsboard.server.common.data.id.UserId; |
24 | -import org.thingsboard.server.common.data.page.TextPageData; | |
25 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
24 | +import org.thingsboard.server.common.data.page.PageData; | |
25 | +import org.thingsboard.server.common.data.page.PageLink; | |
26 | 26 | import org.thingsboard.server.common.data.security.UserCredentials; |
27 | 27 | |
28 | 28 | public interface UserService { |
... | ... | @@ -53,11 +53,11 @@ public interface UserService { |
53 | 53 | |
54 | 54 | void deleteUser(TenantId tenantId, UserId userId); |
55 | 55 | |
56 | - TextPageData<User> findTenantAdmins(TenantId tenantId, TextPageLink pageLink); | |
56 | + PageData<User> findTenantAdmins(TenantId tenantId, PageLink pageLink); | |
57 | 57 | |
58 | 58 | void deleteTenantAdmins(TenantId tenantId); |
59 | - | |
60 | - TextPageData<User> findCustomerUsers(TenantId tenantId, CustomerId customerId, TextPageLink pageLink); | |
59 | + | |
60 | + PageData<User> findCustomerUsers(TenantId tenantId, CustomerId customerId, PageLink pageLink); | |
61 | 61 | |
62 | 62 | void deleteCustomerUsers(TenantId tenantId, CustomerId customerId); |
63 | 63 | ... | ... |
... | ... | @@ -17,8 +17,8 @@ package org.thingsboard.server.dao.widget; |
17 | 17 | |
18 | 18 | import org.thingsboard.server.common.data.id.TenantId; |
19 | 19 | import org.thingsboard.server.common.data.id.WidgetsBundleId; |
20 | -import org.thingsboard.server.common.data.page.TextPageData; | |
21 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
20 | +import org.thingsboard.server.common.data.page.PageData; | |
21 | +import org.thingsboard.server.common.data.page.PageLink; | |
22 | 22 | import org.thingsboard.server.common.data.widget.WidgetsBundle; |
23 | 23 | |
24 | 24 | import java.util.List; |
... | ... | @@ -33,13 +33,13 @@ public interface WidgetsBundleService { |
33 | 33 | |
34 | 34 | WidgetsBundle findWidgetsBundleByTenantIdAndAlias(TenantId tenantId, String alias); |
35 | 35 | |
36 | - TextPageData<WidgetsBundle> findSystemWidgetsBundlesByPageLink(TenantId tenantId, TextPageLink pageLink); | |
36 | + PageData<WidgetsBundle> findSystemWidgetsBundlesByPageLink(TenantId tenantId, PageLink pageLink); | |
37 | 37 | |
38 | 38 | List<WidgetsBundle> findSystemWidgetsBundles(TenantId tenantId); |
39 | 39 | |
40 | - TextPageData<WidgetsBundle> findTenantWidgetsBundlesByTenantId(TenantId tenantId, TextPageLink pageLink); | |
40 | + PageData<WidgetsBundle> findTenantWidgetsBundlesByTenantId(TenantId tenantId, PageLink pageLink); | |
41 | 41 | |
42 | - TextPageData<WidgetsBundle> findAllTenantWidgetsBundlesByTenantIdAndPageLink(TenantId tenantId, TextPageLink pageLink); | |
42 | + PageData<WidgetsBundle> findAllTenantWidgetsBundlesByTenantIdAndPageLink(TenantId tenantId, PageLink pageLink); | |
43 | 43 | |
44 | 44 | List<WidgetsBundle> findAllTenantWidgetsBundlesByTenantId(TenantId tenantId); |
45 | 45 | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/page/PageData.java
renamed from
common/data/src/main/java/org/thingsboard/server/common/data/page/TimePageData.java
... | ... | @@ -18,39 +18,29 @@ package org.thingsboard.server.common.data.page; |
18 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; |
19 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; |
20 | 20 | import org.thingsboard.server.common.data.BaseData; |
21 | -import org.thingsboard.server.common.data.SearchTextBased; | |
22 | -import org.thingsboard.server.common.data.id.UUIDBased; | |
23 | 21 | |
22 | +import java.util.Collections; | |
24 | 23 | import java.util.List; |
25 | -import java.util.UUID; | |
26 | 24 | |
27 | -public class TimePageData<T extends BaseData<? extends UUIDBased>> { | |
25 | +public class PageData<T> { | |
28 | 26 | |
29 | 27 | private final List<T> data; |
30 | - private final TimePageLink nextPageLink; | |
28 | + private final int totalPages; | |
29 | + private final long totalElements; | |
31 | 30 | private final boolean hasNext; |
32 | 31 | |
33 | - public TimePageData(List<T> data, TimePageLink pageLink) { | |
34 | - super(); | |
35 | - this.data = data; | |
36 | - int limit = pageLink.getLimit(); | |
37 | - if (data != null && data.size() == limit) { | |
38 | - int index = data.size() - 1; | |
39 | - UUID idOffset = data.get(index).getId().getId(); | |
40 | - nextPageLink = new TimePageLink(limit, pageLink.getStartTime(), pageLink.getEndTime(), pageLink.isAscOrder(), idOffset); | |
41 | - hasNext = true; | |
42 | - } else { | |
43 | - nextPageLink = null; | |
44 | - hasNext = false; | |
45 | - } | |
32 | + public PageData() { | |
33 | + this(Collections.emptyList(), 0, 0, false); | |
46 | 34 | } |
47 | 35 | |
48 | 36 | @JsonCreator |
49 | - public TimePageData(@JsonProperty("data") List<T> data, | |
50 | - @JsonProperty("nextPageLink") TimePageLink nextPageLink, | |
51 | - @JsonProperty("hasNext") boolean hasNext) { | |
37 | + public PageData(@JsonProperty("data") List<T> data, | |
38 | + @JsonProperty("totalPages") int totalPages, | |
39 | + @JsonProperty("totalElements") long totalElements, | |
40 | + @JsonProperty("hasNext") boolean hasNext) { | |
52 | 41 | this.data = data; |
53 | - this.nextPageLink = nextPageLink; | |
42 | + this.totalPages = totalPages; | |
43 | + this.totalElements = totalElements; | |
54 | 44 | this.hasNext = hasNext; |
55 | 45 | } |
56 | 46 | |
... | ... | @@ -58,13 +48,17 @@ public class TimePageData<T extends BaseData<? extends UUIDBased>> { |
58 | 48 | return data; |
59 | 49 | } |
60 | 50 | |
51 | + public int getTotalPages() { | |
52 | + return totalPages; | |
53 | + } | |
54 | + | |
55 | + public long getTotalElements() { | |
56 | + return totalElements; | |
57 | + } | |
58 | + | |
61 | 59 | @JsonProperty("hasNext") |
62 | 60 | public boolean hasNext() { |
63 | 61 | return hasNext; |
64 | 62 | } |
65 | 63 | |
66 | - public TimePageLink getNextPageLink() { | |
67 | - return nextPageLink; | |
68 | - } | |
69 | - | |
70 | 64 | } | ... | ... |
... | ... | @@ -19,11 +19,12 @@ import java.util.Iterator; |
19 | 19 | import java.util.List; |
20 | 20 | import java.util.NoSuchElementException; |
21 | 21 | |
22 | +import org.thingsboard.server.common.data.BaseData; | |
22 | 23 | import org.thingsboard.server.common.data.SearchTextBased; |
23 | 24 | import org.thingsboard.server.common.data.id.EntityId; |
24 | 25 | import org.thingsboard.server.common.data.id.UUIDBased; |
25 | 26 | |
26 | -public class PageDataIterable<T extends SearchTextBased<? extends UUIDBased>> implements Iterable<T>, Iterator<T> { | |
27 | +public class PageDataIterable<T> implements Iterable<T>, Iterator<T> { | |
27 | 28 | |
28 | 29 | private final FetchFunction<T> function; |
29 | 30 | private final int fetchSize; |
... | ... | @@ -31,7 +32,7 @@ public class PageDataIterable<T extends SearchTextBased<? extends UUIDBased>> im |
31 | 32 | private List<T> currentItems; |
32 | 33 | private int currentIdx; |
33 | 34 | private boolean hasNextPack; |
34 | - private TextPageLink nextPackLink; | |
35 | + private PageLink nextPackLink; | |
35 | 36 | private boolean initialized; |
36 | 37 | |
37 | 38 | public PageDataIterable(FetchFunction<T> function, int fetchSize) { |
... | ... | @@ -48,7 +49,7 @@ public class PageDataIterable<T extends SearchTextBased<? extends UUIDBased>> im |
48 | 49 | @Override |
49 | 50 | public boolean hasNext() { |
50 | 51 | if(!initialized){ |
51 | - fetch(new TextPageLink(fetchSize)); | |
52 | + fetch(new PageLink(fetchSize)); | |
52 | 53 | initialized = true; |
53 | 54 | } |
54 | 55 | if(currentIdx == currentItems.size()){ |
... | ... | @@ -59,12 +60,12 @@ public class PageDataIterable<T extends SearchTextBased<? extends UUIDBased>> im |
59 | 60 | return currentIdx < currentItems.size(); |
60 | 61 | } |
61 | 62 | |
62 | - private void fetch(TextPageLink link) { | |
63 | - TextPageData<T> pageData = function.fetch(link); | |
63 | + private void fetch(PageLink link) { | |
64 | + PageData<T> pageData = function.fetch(link); | |
64 | 65 | currentIdx = 0; |
65 | 66 | currentItems = pageData.getData(); |
66 | 67 | hasNextPack = pageData.hasNext(); |
67 | - nextPackLink = pageData.getNextPageLink(); | |
68 | + nextPackLink = link.nextPageLink(); | |
68 | 69 | } |
69 | 70 | |
70 | 71 | @Override |
... | ... | @@ -75,9 +76,9 @@ public class PageDataIterable<T extends SearchTextBased<? extends UUIDBased>> im |
75 | 76 | return currentItems.get(currentIdx++); |
76 | 77 | } |
77 | 78 | |
78 | - public static interface FetchFunction<T extends SearchTextBased<? extends UUIDBased>> { | |
79 | + public static interface FetchFunction<T> { | |
79 | 80 | |
80 | - TextPageData<T> fetch(TextPageLink link); | |
81 | + PageData<T> fetch(PageLink link); | |
81 | 82 | |
82 | 83 | } |
83 | 84 | } | ... | ... |
1 | +/** | |
2 | + * Copyright © 2016-2019 The Thingsboard Authors | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | + * See the License for the specific language governing permissions and | |
14 | + * limitations under the License. | |
15 | + */ | |
16 | +package org.thingsboard.server.common.data.page; | |
17 | + | |
18 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
19 | +import lombok.Data; | |
20 | + | |
21 | +@Data | |
22 | +public class PageLink { | |
23 | + | |
24 | + private final String textSearch; | |
25 | + private final int pageSize; | |
26 | + private final int page; | |
27 | + private final SortOrder sortOrder; | |
28 | + | |
29 | + public PageLink(PageLink pageLink) { | |
30 | + this.pageSize = pageLink.getPageSize(); | |
31 | + this.page = pageLink.getPage(); | |
32 | + this.textSearch = pageLink.getTextSearch(); | |
33 | + this.sortOrder = pageLink.getSortOrder(); | |
34 | + } | |
35 | + | |
36 | + public PageLink(int pageSize) { | |
37 | + this(pageSize, 0); | |
38 | + } | |
39 | + | |
40 | + public PageLink(int pageSize, int page) { | |
41 | + this(pageSize, page, null, null); | |
42 | + } | |
43 | + | |
44 | + public PageLink(int pageSize, int page, String textSearch) { | |
45 | + this(pageSize, page, textSearch, null); | |
46 | + } | |
47 | + | |
48 | + public PageLink(int pageSize, int page, String textSearch, SortOrder sortOrder) { | |
49 | + this.pageSize = pageSize; | |
50 | + this.page = page; | |
51 | + this.textSearch = textSearch; | |
52 | + this.sortOrder = sortOrder; | |
53 | + } | |
54 | + | |
55 | + @JsonIgnore | |
56 | + public PageLink nextPageLink() { | |
57 | + return new PageLink(this.pageSize, this.page+1, this.textSearch, this.sortOrder); | |
58 | + } | |
59 | + | |
60 | +} | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/page/SortOrder.java
renamed from
common/data/src/main/java/org/thingsboard/server/common/data/page/BasePageLink.java
... | ... | @@ -15,23 +15,25 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.data.page; |
17 | 17 | |
18 | -import lombok.AllArgsConstructor; | |
19 | -import lombok.Getter; | |
20 | -import lombok.RequiredArgsConstructor; | |
21 | -import lombok.Setter; | |
18 | +import lombok.Data; | |
22 | 19 | |
23 | -import java.io.Serializable; | |
24 | -import java.util.Arrays; | |
25 | -import java.util.UUID; | |
20 | +@Data | |
21 | +public class SortOrder { | |
26 | 22 | |
27 | -@RequiredArgsConstructor | |
28 | -@AllArgsConstructor | |
29 | -public abstract class BasePageLink implements Serializable { | |
23 | + private final String property; | |
24 | + private final Direction direction; | |
30 | 25 | |
31 | - private static final long serialVersionUID = -4189954843653250481L; | |
26 | + public SortOrder(String property) { | |
27 | + this(property, Direction.ASC); | |
28 | + } | |
32 | 29 | |
33 | - @Getter protected final int limit; | |
30 | + public SortOrder(String property, Direction direction) { | |
31 | + this.property = property; | |
32 | + this.direction = direction; | |
33 | + } | |
34 | 34 | |
35 | - @Getter @Setter protected UUID idOffset; | |
35 | + public static enum Direction { | |
36 | + ASC, DESC | |
37 | + } | |
36 | 38 | |
37 | 39 | } | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/page/TextPageData.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2019 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.data.page; | |
17 | - | |
18 | -import java.util.List; | |
19 | -import java.util.UUID; | |
20 | - | |
21 | -import org.thingsboard.server.common.data.SearchTextBased; | |
22 | -import org.thingsboard.server.common.data.id.UUIDBased; | |
23 | - | |
24 | -import com.fasterxml.jackson.annotation.JsonCreator; | |
25 | -import com.fasterxml.jackson.annotation.JsonProperty; | |
26 | - | |
27 | -public class TextPageData<T extends SearchTextBased<? extends UUIDBased>> { | |
28 | - | |
29 | - private final List<T> data; | |
30 | - private final TextPageLink nextPageLink; | |
31 | - private final boolean hasNext; | |
32 | - | |
33 | - public TextPageData(List<T> data, TextPageLink pageLink) { | |
34 | - super(); | |
35 | - this.data = data; | |
36 | - int limit = pageLink.getLimit(); | |
37 | - if (data != null && data.size() == limit) { | |
38 | - int index = data.size()-1; | |
39 | - UUID idOffset = data.get(index).getId().getId(); | |
40 | - String textOffset = data.get(index).getSearchText(); | |
41 | - nextPageLink = new TextPageLink(limit, pageLink.getTextSearch(), idOffset, textOffset); | |
42 | - hasNext = true; | |
43 | - } else { | |
44 | - nextPageLink = null; | |
45 | - hasNext = false; | |
46 | - } | |
47 | - } | |
48 | - | |
49 | - @JsonCreator | |
50 | - public TextPageData(@JsonProperty("data") List<T> data, | |
51 | - @JsonProperty("nextPageLink") TextPageLink nextPageLink, | |
52 | - @JsonProperty("hasNext") boolean hasNext) { | |
53 | - this.data = data; | |
54 | - this.nextPageLink = nextPageLink; | |
55 | - this.hasNext = hasNext; | |
56 | - } | |
57 | - | |
58 | - public List<T> getData() { | |
59 | - return data; | |
60 | - } | |
61 | - | |
62 | - @JsonProperty("hasNext") | |
63 | - public boolean hasNext() { | |
64 | - return hasNext; | |
65 | - } | |
66 | - | |
67 | - public TextPageLink getNextPageLink() { | |
68 | - return nextPageLink; | |
69 | - } | |
70 | - | |
71 | -} |
common/data/src/main/java/org/thingsboard/server/common/data/page/TextPageLink.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2019 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.data.page; | |
17 | - | |
18 | -import com.fasterxml.jackson.annotation.JsonCreator; | |
19 | -import com.fasterxml.jackson.annotation.JsonProperty; | |
20 | -import lombok.Getter; | |
21 | -import lombok.ToString; | |
22 | - | |
23 | -import java.io.Serializable; | |
24 | -import java.util.Arrays; | |
25 | -import java.util.UUID; | |
26 | - | |
27 | -@ToString | |
28 | -public class TextPageLink extends BasePageLink implements Serializable { | |
29 | - | |
30 | - private static final long serialVersionUID = -4189954843653250480L; | |
31 | - | |
32 | - @Getter private final String textSearch; | |
33 | - @Getter private final String textSearchBound; | |
34 | - @Getter private final String textOffset; | |
35 | - | |
36 | - public TextPageLink(int limit) { | |
37 | - this(limit, null, null, null); | |
38 | - } | |
39 | - | |
40 | - public TextPageLink(int limit, String textSearch) { | |
41 | - this(limit, textSearch, null, null); | |
42 | - } | |
43 | - | |
44 | - public TextPageLink(int limit, String textSearch, UUID idOffset, String textOffset) { | |
45 | - super(limit, idOffset); | |
46 | - this.textSearch = textSearch != null ? textSearch.toLowerCase() : null; | |
47 | - this.textSearchBound = nextSequence(this.textSearch); | |
48 | - this.textOffset = textOffset != null ? textOffset.toLowerCase() : null; | |
49 | - } | |
50 | - | |
51 | - @JsonCreator | |
52 | - public TextPageLink(@JsonProperty("limit") int limit, | |
53 | - @JsonProperty("textSearch") String textSearch, | |
54 | - @JsonProperty("textSearchBound") String textSearchBound, | |
55 | - @JsonProperty("textOffset") String textOffset, | |
56 | - @JsonProperty("idOffset") UUID idOffset) { | |
57 | - super(limit, idOffset); | |
58 | - this.textSearch = textSearch; | |
59 | - this.textSearchBound = textSearchBound; | |
60 | - this.textOffset = textOffset; | |
61 | - this.idOffset = idOffset; | |
62 | - } | |
63 | - | |
64 | - private static String nextSequence(String input) { | |
65 | - if (input != null && input.length() > 0) { | |
66 | - char[] chars = input.toCharArray(); | |
67 | - int i = chars.length - 1; | |
68 | - while (i >= 0 && ++chars[i--] == Character.MIN_VALUE) ; | |
69 | - if (i == -1 && (chars.length == 0 || chars[0] == Character.MIN_VALUE)) { | |
70 | - char buf[] = Arrays.copyOf(input.toCharArray(), input.length() + 1); | |
71 | - buf[buf.length - 1] = Character.MIN_VALUE; | |
72 | - return new String(buf); | |
73 | - } | |
74 | - return new String(chars); | |
75 | - } else { | |
76 | - return null; | |
77 | - } | |
78 | - } | |
79 | - | |
80 | -} |
... | ... | @@ -16,7 +16,9 @@ |
16 | 16 | package org.thingsboard.server.common.data.page; |
17 | 17 | |
18 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; |
19 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
19 | 20 | import com.fasterxml.jackson.annotation.JsonProperty; |
21 | +import lombok.Data; | |
20 | 22 | import lombok.Getter; |
21 | 23 | import lombok.ToString; |
22 | 24 | |
... | ... | @@ -24,40 +26,43 @@ import java.io.Serializable; |
24 | 26 | import java.util.Arrays; |
25 | 27 | import java.util.UUID; |
26 | 28 | |
27 | -@ToString | |
28 | -public class TimePageLink extends BasePageLink implements Serializable { | |
29 | +@Data | |
30 | +public class TimePageLink extends PageLink { | |
29 | 31 | |
30 | - private static final long serialVersionUID = -4189954843653250480L; | |
32 | + private final Long startTime; | |
33 | + private final Long endTime; | |
31 | 34 | |
32 | - @Getter private final Long startTime; | |
33 | - @Getter private final Long endTime; | |
34 | - @Getter private final boolean ascOrder; | |
35 | + public TimePageLink(PageLink pageLink, Long startTime, Long endTime) { | |
36 | + super(pageLink); | |
37 | + this.startTime = startTime; | |
38 | + this.endTime = endTime; | |
39 | + } | |
35 | 40 | |
36 | - public TimePageLink(int limit) { | |
37 | - this(limit, null, null, false, null); | |
41 | + public TimePageLink(int pageSize) { | |
42 | + this(pageSize, 0); | |
38 | 43 | } |
39 | 44 | |
40 | - public TimePageLink(int limit, Long startTime) { | |
41 | - this(limit, startTime, null, false, null); | |
45 | + public TimePageLink(int pageSize, int page) { | |
46 | + this(pageSize, page, null); | |
42 | 47 | } |
43 | 48 | |
44 | - public TimePageLink(int limit, Long startTime, Long endTime) { | |
45 | - this(limit, startTime, endTime, false, null); | |
49 | + public TimePageLink(int pageSize, int page, String textSearch) { | |
50 | + this(pageSize, page, textSearch, null, null, null); | |
46 | 51 | } |
47 | 52 | |
48 | - public TimePageLink(int limit, Long startTime, Long endTime, boolean ascOrder) { | |
49 | - this(limit, startTime, endTime, ascOrder, null); | |
53 | + public TimePageLink(int pageSize, int page, String textSearch, SortOrder sortOrder) { | |
54 | + this(pageSize, page, textSearch, sortOrder, null, null); | |
50 | 55 | } |
51 | 56 | |
52 | - @JsonCreator | |
53 | - public TimePageLink(@JsonProperty("limit") int limit, | |
54 | - @JsonProperty("startTime") Long startTime, | |
55 | - @JsonProperty("endTime") Long endTime, | |
56 | - @JsonProperty("ascOrder") boolean ascOrder, | |
57 | - @JsonProperty("idOffset") UUID idOffset) { | |
58 | - super(limit, idOffset); | |
57 | + public TimePageLink(int pageSize, int page, String textSearch, SortOrder sortOrder, Long startTime, Long endTime) { | |
58 | + super(pageSize, page, textSearch, sortOrder); | |
59 | 59 | this.startTime = startTime; |
60 | 60 | this.endTime = endTime; |
61 | - this.ascOrder = ascOrder; | |
61 | + } | |
62 | + | |
63 | + @JsonIgnore | |
64 | + public TimePageLink nextPageLink() { | |
65 | + return new TimePageLink(this.getPageSize(), this.getPage()+1, this.getTextSearch(), this.getSortOrder(), | |
66 | + this.startTime, this.endTime); | |
62 | 67 | } |
63 | 68 | } | ... | ... |
... | ... | @@ -15,7 +15,16 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.dao; |
17 | 17 | |
18 | +import com.datastax.driver.core.utils.UUIDs; | |
19 | +import org.springframework.data.domain.Page; | |
20 | +import org.springframework.data.domain.PageRequest; | |
21 | +import org.springframework.data.domain.Pageable; | |
22 | +import org.springframework.data.domain.Sort; | |
23 | +import org.thingsboard.server.common.data.UUIDConverter; | |
18 | 24 | import org.thingsboard.server.common.data.id.UUIDBased; |
25 | +import org.thingsboard.server.common.data.page.PageData; | |
26 | +import org.thingsboard.server.common.data.page.PageLink; | |
27 | +import org.thingsboard.server.common.data.page.SortOrder; | |
19 | 28 | import org.thingsboard.server.dao.model.ToData; |
20 | 29 | |
21 | 30 | import java.util.*; |
... | ... | @@ -25,6 +34,56 @@ public abstract class DaoUtil { |
25 | 34 | private DaoUtil() { |
26 | 35 | } |
27 | 36 | |
37 | + public static <T> PageData<T> toPageData(Page<? extends ToData<T>> page) { | |
38 | + List<T> data = convertDataList(page.getContent()); | |
39 | + return new PageData(data, page.getTotalPages(), page.getTotalElements(), page.hasNext()); | |
40 | + } | |
41 | + | |
42 | + public static Pageable toPageable(PageLink pageLink) { | |
43 | + return toPageable(pageLink, Collections.emptyMap()); | |
44 | + } | |
45 | + | |
46 | + public static Pageable toPageable(PageLink pageLink, Map<String,String> columnMap) { | |
47 | + return PageRequest.of(pageLink.getPage(), pageLink.getPageSize(), toSort(pageLink.getSortOrder(), columnMap)); | |
48 | + } | |
49 | + | |
50 | + public static String startTimeToId(Long startTime) { | |
51 | + if (startTime != null) { | |
52 | + UUID startOf = UUIDs.startOf(startTime); | |
53 | + return UUIDConverter.fromTimeUUID(startOf); | |
54 | + } else { | |
55 | + return null; | |
56 | + } | |
57 | + } | |
58 | + | |
59 | + public static String endTimeToId(Long endTime) { | |
60 | + if (endTime != null) { | |
61 | + UUID endOf = UUIDs.endOf(endTime); | |
62 | + return UUIDConverter.fromTimeUUID(endOf); | |
63 | + } else { | |
64 | + return null; | |
65 | + } | |
66 | + } | |
67 | + | |
68 | + public static Sort toSort(SortOrder sortOrder) { | |
69 | + return toSort(sortOrder, Collections.emptyMap()); | |
70 | + } | |
71 | + | |
72 | + public static Sort toSort(SortOrder sortOrder, Map<String,String> columnMap) { | |
73 | + if (sortOrder == null) { | |
74 | + return Sort.unsorted(); | |
75 | + } else { | |
76 | + String property = sortOrder.getProperty(); | |
77 | + if (columnMap.containsKey(property)) { | |
78 | + property = columnMap.get(property); | |
79 | + } | |
80 | + if (property.equals("createdTime")) { | |
81 | + property = "id"; | |
82 | + } | |
83 | + return Sort.by(Sort.Direction.fromString(sortOrder.getDirection().name()), property); | |
84 | + } | |
85 | + } | |
86 | + | |
28 | 87 | public static <T> List<T> convertDataList(Collection<? extends ToData<T>> toDataList) { |
29 | 88 | List<T> list = Collections.emptyList(); |
30 | 89 | if (toDataList != null && !toDataList.isEmpty()) { | ... | ... |
dao/src/main/java/org/thingsboard/server/dao/NoSqlDaoConfig.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2019 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.dao; | |
17 | - | |
18 | -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |
19 | -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | |
20 | -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; | |
21 | -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; | |
22 | -import org.springframework.context.annotation.Configuration; | |
23 | -import org.thingsboard.server.dao.util.NoSqlDao; | |
24 | - | |
25 | -@Configuration | |
26 | -@EnableAutoConfiguration( | |
27 | - exclude = { | |
28 | - DataSourceAutoConfiguration.class, | |
29 | - DataSourceTransactionManagerAutoConfiguration.class, | |
30 | - HibernateJpaAutoConfiguration.class}) | |
31 | -@NoSqlDao | |
32 | -public class NoSqlDaoConfig { | |
33 | -} |
... | ... | @@ -21,6 +21,7 @@ import org.thingsboard.server.common.data.alarm.AlarmInfo; |
21 | 21 | import org.thingsboard.server.common.data.alarm.AlarmQuery; |
22 | 22 | import org.thingsboard.server.common.data.id.EntityId; |
23 | 23 | import org.thingsboard.server.common.data.id.TenantId; |
24 | +import org.thingsboard.server.common.data.page.PageData; | |
24 | 25 | import org.thingsboard.server.dao.Dao; |
25 | 26 | |
26 | 27 | import java.util.List; |
... | ... | @@ -39,5 +40,5 @@ public interface AlarmDao extends Dao<Alarm> { |
39 | 40 | |
40 | 41 | Alarm save(TenantId tenantId, Alarm alarm); |
41 | 42 | |
42 | - ListenableFuture<List<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query); | |
43 | + ListenableFuture<PageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query); | |
43 | 44 | } | ... | ... |
... | ... | @@ -35,7 +35,7 @@ import org.thingsboard.server.common.data.alarm.AlarmSeverity; |
35 | 35 | import org.thingsboard.server.common.data.alarm.AlarmStatus; |
36 | 36 | import org.thingsboard.server.common.data.id.EntityId; |
37 | 37 | import org.thingsboard.server.common.data.id.TenantId; |
38 | -import org.thingsboard.server.common.data.page.TimePageData; | |
38 | +import org.thingsboard.server.common.data.page.PageData; | |
39 | 39 | import org.thingsboard.server.common.data.page.TimePageLink; |
40 | 40 | import org.thingsboard.server.common.data.relation.EntityRelation; |
41 | 41 | import org.thingsboard.server.common.data.relation.EntityRelationsQuery; |
... | ... | @@ -260,12 +260,12 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ |
260 | 260 | } |
261 | 261 | |
262 | 262 | @Override |
263 | - public ListenableFuture<TimePageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query) { | |
264 | - ListenableFuture<List<AlarmInfo>> alarms = alarmDao.findAlarms(tenantId, query); | |
263 | + public ListenableFuture<PageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query) { | |
264 | + ListenableFuture<PageData<AlarmInfo>> alarms = alarmDao.findAlarms(tenantId, query); | |
265 | 265 | if (query.getFetchOriginator() != null && query.getFetchOriginator().booleanValue()) { |
266 | 266 | alarms = Futures.transformAsync(alarms, input -> { |
267 | - List<ListenableFuture<AlarmInfo>> alarmFutures = new ArrayList<>(input.size()); | |
268 | - for (AlarmInfo alarmInfo : input) { | |
267 | + List<ListenableFuture<AlarmInfo>> alarmFutures = new ArrayList<>(input.getData().size()); | |
268 | + for (AlarmInfo alarmInfo : input.getData()) { | |
269 | 269 | alarmFutures.add(Futures.transform( |
270 | 270 | entityService.fetchEntityNameAsync(tenantId, alarmInfo.getOriginator()), originatorName -> { |
271 | 271 | if (originatorName == null) { |
... | ... | @@ -276,16 +276,12 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ |
276 | 276 | } |
277 | 277 | )); |
278 | 278 | } |
279 | - return Futures.successfulAsList(alarmFutures); | |
279 | + return Futures.transform(Futures.successfulAsList(alarmFutures), alarmInfos -> { | |
280 | + return new PageData(alarmInfos, input.getTotalPages(), input.getTotalElements(), input.hasNext()); | |
281 | + }); | |
280 | 282 | }); |
281 | 283 | } |
282 | - return Futures.transform(alarms, new Function<List<AlarmInfo>, TimePageData<AlarmInfo>>() { | |
283 | - @Nullable | |
284 | - @Override | |
285 | - public TimePageData<AlarmInfo> apply(@Nullable List<AlarmInfo> alarms) { | |
286 | - return new TimePageData<>(alarms, query.getPageLink()); | |
287 | - } | |
288 | - }); | |
284 | + return alarms; | |
289 | 285 | } |
290 | 286 | |
291 | 287 | @Override |
... | ... | @@ -297,7 +293,7 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ |
297 | 293 | AlarmQuery query; |
298 | 294 | while (hasNext && AlarmSeverity.CRITICAL != highestSeverity) { |
299 | 295 | query = new AlarmQuery(entityId, nextPageLink, alarmSearchStatus, alarmStatus, false); |
300 | - List<AlarmInfo> alarms; | |
296 | + PageData<AlarmInfo> alarms; | |
301 | 297 | try { |
302 | 298 | alarms = alarmDao.findAlarms(tenantId, query).get(); |
303 | 299 | } catch (ExecutionException | InterruptedException e) { |
... | ... | @@ -305,11 +301,10 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ |
305 | 301 | entityId, alarmSearchStatus, alarmStatus); |
306 | 302 | throw new RuntimeException(e); |
307 | 303 | } |
308 | - hasNext = alarms.size() == nextPageLink.getLimit(); | |
309 | - if (hasNext) { | |
310 | - nextPageLink = new TimePageData<>(alarms, nextPageLink).getNextPageLink(); | |
304 | + if (alarms.hasNext()) { | |
305 | + nextPageLink = nextPageLink.nextPageLink(); | |
311 | 306 | } |
312 | - AlarmSeverity severity = detectHighestSeverity(alarms); | |
307 | + AlarmSeverity severity = detectHighestSeverity(alarms.getData()); | |
313 | 308 | if (severity == null) { |
314 | 309 | continue; |
315 | 310 | } | ... | ... |
... | ... | @@ -19,7 +19,8 @@ import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import org.thingsboard.server.common.data.EntitySubtype; |
20 | 20 | import org.thingsboard.server.common.data.asset.Asset; |
21 | 21 | import org.thingsboard.server.common.data.id.TenantId; |
22 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
22 | +import org.thingsboard.server.common.data.page.PageData; | |
23 | +import org.thingsboard.server.common.data.page.PageLink; | |
23 | 24 | import org.thingsboard.server.dao.Dao; |
24 | 25 | |
25 | 26 | import java.util.List; |
... | ... | @@ -47,7 +48,7 @@ public interface AssetDao extends Dao<Asset> { |
47 | 48 | * @param pageLink the page link |
48 | 49 | * @return the list of asset objects |
49 | 50 | */ |
50 | - List<Asset> findAssetsByTenantId(UUID tenantId, TextPageLink pageLink); | |
51 | + PageData<Asset> findAssetsByTenantId(UUID tenantId, PageLink pageLink); | |
51 | 52 | |
52 | 53 | /** |
53 | 54 | * Find assets by tenantId, type and page link. |
... | ... | @@ -57,7 +58,7 @@ public interface AssetDao extends Dao<Asset> { |
57 | 58 | * @param pageLink the page link |
58 | 59 | * @return the list of asset objects |
59 | 60 | */ |
60 | - List<Asset> findAssetsByTenantIdAndType(UUID tenantId, String type, TextPageLink pageLink); | |
61 | + PageData<Asset> findAssetsByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); | |
61 | 62 | |
62 | 63 | /** |
63 | 64 | * Find assets by tenantId and assets Ids. |
... | ... | @@ -76,7 +77,7 @@ public interface AssetDao extends Dao<Asset> { |
76 | 77 | * @param pageLink the page link |
77 | 78 | * @return the list of asset objects |
78 | 79 | */ |
79 | - List<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink); | |
80 | + PageData<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); | |
80 | 81 | |
81 | 82 | /** |
82 | 83 | * Find assets by tenantId, customerId, type and page link. |
... | ... | @@ -87,7 +88,7 @@ public interface AssetDao extends Dao<Asset> { |
87 | 88 | * @param pageLink the page link |
88 | 89 | * @return the list of asset objects |
89 | 90 | */ |
90 | - List<Asset> findAssetsByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, TextPageLink pageLink); | |
91 | + PageData<Asset> findAssetsByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); | |
91 | 92 | |
92 | 93 | /** |
93 | 94 | * Find assets by tenantId, customerId and assets Ids. | ... | ... |
... | ... | @@ -38,8 +38,8 @@ import org.thingsboard.server.common.data.id.AssetId; |
38 | 38 | import org.thingsboard.server.common.data.id.CustomerId; |
39 | 39 | import org.thingsboard.server.common.data.id.EntityId; |
40 | 40 | import org.thingsboard.server.common.data.id.TenantId; |
41 | -import org.thingsboard.server.common.data.page.TextPageData; | |
42 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
41 | +import org.thingsboard.server.common.data.page.PageData; | |
42 | +import org.thingsboard.server.common.data.page.PageLink; | |
43 | 43 | import org.thingsboard.server.common.data.relation.EntityRelation; |
44 | 44 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
45 | 45 | import org.thingsboard.server.dao.customer.CustomerDao; |
... | ... | @@ -157,22 +157,20 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ |
157 | 157 | } |
158 | 158 | |
159 | 159 | @Override |
160 | - public TextPageData<Asset> findAssetsByTenantId(TenantId tenantId, TextPageLink pageLink) { | |
160 | + public PageData<Asset> findAssetsByTenantId(TenantId tenantId, PageLink pageLink) { | |
161 | 161 | log.trace("Executing findAssetsByTenantId, tenantId [{}], pageLink [{}]", tenantId, pageLink); |
162 | 162 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
163 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
164 | - List<Asset> assets = assetDao.findAssetsByTenantId(tenantId.getId(), pageLink); | |
165 | - return new TextPageData<>(assets, pageLink); | |
163 | + validatePageLink(pageLink); | |
164 | + return assetDao.findAssetsByTenantId(tenantId.getId(), pageLink); | |
166 | 165 | } |
167 | 166 | |
168 | 167 | @Override |
169 | - public TextPageData<Asset> findAssetsByTenantIdAndType(TenantId tenantId, String type, TextPageLink pageLink) { | |
168 | + public PageData<Asset> findAssetsByTenantIdAndType(TenantId tenantId, String type, PageLink pageLink) { | |
170 | 169 | log.trace("Executing findAssetsByTenantIdAndType, tenantId [{}], type [{}], pageLink [{}]", tenantId, type, pageLink); |
171 | 170 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
172 | 171 | validateString(type, "Incorrect type " + type); |
173 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
174 | - List<Asset> assets = assetDao.findAssetsByTenantIdAndType(tenantId.getId(), type, pageLink); | |
175 | - return new TextPageData<>(assets, pageLink); | |
172 | + validatePageLink(pageLink); | |
173 | + return assetDao.findAssetsByTenantIdAndType(tenantId.getId(), type, pageLink); | |
176 | 174 | } |
177 | 175 | |
178 | 176 | @Override |
... | ... | @@ -191,24 +189,22 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ |
191 | 189 | } |
192 | 190 | |
193 | 191 | @Override |
194 | - public TextPageData<Asset> findAssetsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TextPageLink pageLink) { | |
192 | + public PageData<Asset> findAssetsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, PageLink pageLink) { | |
195 | 193 | log.trace("Executing findAssetsByTenantIdAndCustomerId, tenantId [{}], customerId [{}], pageLink [{}]", tenantId, customerId, pageLink); |
196 | 194 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
197 | 195 | validateId(customerId, INCORRECT_CUSTOMER_ID + customerId); |
198 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
199 | - List<Asset> assets = assetDao.findAssetsByTenantIdAndCustomerId(tenantId.getId(), customerId.getId(), pageLink); | |
200 | - return new TextPageData<>(assets, pageLink); | |
196 | + validatePageLink(pageLink); | |
197 | + return assetDao.findAssetsByTenantIdAndCustomerId(tenantId.getId(), customerId.getId(), pageLink); | |
201 | 198 | } |
202 | 199 | |
203 | 200 | @Override |
204 | - public TextPageData<Asset> findAssetsByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, String type, TextPageLink pageLink) { | |
201 | + public PageData<Asset> findAssetsByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, String type, PageLink pageLink) { | |
205 | 202 | log.trace("Executing findAssetsByTenantIdAndCustomerIdAndType, tenantId [{}], customerId [{}], type [{}], pageLink [{}]", tenantId, customerId, type, pageLink); |
206 | 203 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
207 | 204 | validateId(customerId, INCORRECT_CUSTOMER_ID + customerId); |
208 | 205 | validateString(type, "Incorrect type " + type); |
209 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
210 | - List<Asset> assets = assetDao.findAssetsByTenantIdAndCustomerIdAndType(tenantId.getId(), customerId.getId(), type, pageLink); | |
211 | - return new TextPageData<>(assets, pageLink); | |
206 | + validatePageLink(pageLink); | |
207 | + return assetDao.findAssetsByTenantIdAndCustomerIdAndType(tenantId.getId(), customerId.getId(), type, pageLink); | |
212 | 208 | } |
213 | 209 | |
214 | 210 | @Override |
... | ... | @@ -317,7 +313,7 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ |
317 | 313 | new PaginatedRemover<TenantId, Asset>() { |
318 | 314 | |
319 | 315 | @Override |
320 | - protected List<Asset> findEntities(TenantId tenantId, TenantId id, TextPageLink pageLink) { | |
316 | + protected PageData<Asset> findEntities(TenantId tenantId, TenantId id, PageLink pageLink) { | |
321 | 317 | return assetDao.findAssetsByTenantId(id.getId(), pageLink); |
322 | 318 | } |
323 | 319 | |
... | ... | @@ -330,7 +326,7 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ |
330 | 326 | private PaginatedRemover<CustomerId, Asset> customerAssetsUnasigner = new PaginatedRemover<CustomerId, Asset>() { |
331 | 327 | |
332 | 328 | @Override |
333 | - protected List<Asset> findEntities(TenantId tenantId, CustomerId id, TextPageLink pageLink) { | |
329 | + protected PageData<Asset> findEntities(TenantId tenantId, CustomerId id, PageLink pageLink) { | |
334 | 330 | return assetDao.findAssetsByTenantIdAndCustomerId(tenantId.getId(), id.getId(), pageLink); |
335 | 331 | } |
336 | 332 | ... | ... |
... | ... | @@ -20,6 +20,7 @@ import org.thingsboard.server.common.data.audit.AuditLog; |
20 | 20 | import org.thingsboard.server.common.data.id.CustomerId; |
21 | 21 | import org.thingsboard.server.common.data.id.EntityId; |
22 | 22 | import org.thingsboard.server.common.data.id.UserId; |
23 | +import org.thingsboard.server.common.data.page.PageData; | |
23 | 24 | import org.thingsboard.server.common.data.page.TimePageLink; |
24 | 25 | |
25 | 26 | import java.util.List; |
... | ... | @@ -29,19 +30,11 @@ public interface AuditLogDao { |
29 | 30 | |
30 | 31 | ListenableFuture<Void> saveByTenantId(AuditLog auditLog); |
31 | 32 | |
32 | - ListenableFuture<Void> saveByTenantIdAndEntityId(AuditLog auditLog); | |
33 | + PageData<AuditLog> findAuditLogsByTenantIdAndEntityId(UUID tenantId, EntityId entityId, TimePageLink pageLink); | |
33 | 34 | |
34 | - ListenableFuture<Void> saveByTenantIdAndCustomerId(AuditLog auditLog); | |
35 | + PageData<AuditLog> findAuditLogsByTenantIdAndCustomerId(UUID tenantId, CustomerId customerId, TimePageLink pageLink); | |
35 | 36 | |
36 | - ListenableFuture<Void> saveByTenantIdAndUserId(AuditLog auditLog); | |
37 | + PageData<AuditLog> findAuditLogsByTenantIdAndUserId(UUID tenantId, UserId userId, TimePageLink pageLink); | |
37 | 38 | |
38 | - ListenableFuture<Void> savePartitionsByTenantId(AuditLog auditLog); | |
39 | - | |
40 | - List<AuditLog> findAuditLogsByTenantIdAndEntityId(UUID tenantId, EntityId entityId, TimePageLink pageLink); | |
41 | - | |
42 | - List<AuditLog> findAuditLogsByTenantIdAndCustomerId(UUID tenantId, CustomerId customerId, TimePageLink pageLink); | |
43 | - | |
44 | - List<AuditLog> findAuditLogsByTenantIdAndUserId(UUID tenantId, UserId userId, TimePageLink pageLink); | |
45 | - | |
46 | - List<AuditLog> findAuditLogsByTenantId(UUID tenantId, TimePageLink pageLink); | |
39 | + PageData<AuditLog> findAuditLogsByTenantId(UUID tenantId, TimePageLink pageLink); | |
47 | 40 | } | ... | ... |
... | ... | @@ -41,7 +41,7 @@ import org.thingsboard.server.common.data.id.TenantId; |
41 | 41 | import org.thingsboard.server.common.data.id.UUIDBased; |
42 | 42 | import org.thingsboard.server.common.data.id.UserId; |
43 | 43 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
44 | -import org.thingsboard.server.common.data.page.TimePageData; | |
44 | +import org.thingsboard.server.common.data.page.PageData; | |
45 | 45 | import org.thingsboard.server.common.data.page.TimePageLink; |
46 | 46 | import org.thingsboard.server.common.data.relation.EntityRelation; |
47 | 47 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; |
... | ... | @@ -81,38 +81,34 @@ public class AuditLogServiceImpl implements AuditLogService { |
81 | 81 | private AuditLogSink auditLogSink; |
82 | 82 | |
83 | 83 | @Override |
84 | - public TimePageData<AuditLog> findAuditLogsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TimePageLink pageLink) { | |
84 | + public PageData<AuditLog> findAuditLogsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TimePageLink pageLink) { | |
85 | 85 | log.trace("Executing findAuditLogsByTenantIdAndCustomerId [{}], [{}], [{}]", tenantId, customerId, pageLink); |
86 | 86 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
87 | 87 | validateId(customerId, "Incorrect customerId " + customerId); |
88 | - List<AuditLog> auditLogs = auditLogDao.findAuditLogsByTenantIdAndCustomerId(tenantId.getId(), customerId, pageLink); | |
89 | - return new TimePageData<>(auditLogs, pageLink); | |
88 | + return auditLogDao.findAuditLogsByTenantIdAndCustomerId(tenantId.getId(), customerId, pageLink); | |
90 | 89 | } |
91 | 90 | |
92 | 91 | @Override |
93 | - public TimePageData<AuditLog> findAuditLogsByTenantIdAndUserId(TenantId tenantId, UserId userId, TimePageLink pageLink) { | |
92 | + public PageData<AuditLog> findAuditLogsByTenantIdAndUserId(TenantId tenantId, UserId userId, TimePageLink pageLink) { | |
94 | 93 | log.trace("Executing findAuditLogsByTenantIdAndUserId [{}], [{}], [{}]", tenantId, userId, pageLink); |
95 | 94 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
96 | 95 | validateId(userId, "Incorrect userId" + userId); |
97 | - List<AuditLog> auditLogs = auditLogDao.findAuditLogsByTenantIdAndUserId(tenantId.getId(), userId, pageLink); | |
98 | - return new TimePageData<>(auditLogs, pageLink); | |
96 | + return auditLogDao.findAuditLogsByTenantIdAndUserId(tenantId.getId(), userId, pageLink); | |
99 | 97 | } |
100 | 98 | |
101 | 99 | @Override |
102 | - public TimePageData<AuditLog> findAuditLogsByTenantIdAndEntityId(TenantId tenantId, EntityId entityId, TimePageLink pageLink) { | |
100 | + public PageData<AuditLog> findAuditLogsByTenantIdAndEntityId(TenantId tenantId, EntityId entityId, TimePageLink pageLink) { | |
103 | 101 | log.trace("Executing findAuditLogsByTenantIdAndEntityId [{}], [{}], [{}]", tenantId, entityId, pageLink); |
104 | 102 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
105 | 103 | validateEntityId(entityId, INCORRECT_TENANT_ID + entityId); |
106 | - List<AuditLog> auditLogs = auditLogDao.findAuditLogsByTenantIdAndEntityId(tenantId.getId(), entityId, pageLink); | |
107 | - return new TimePageData<>(auditLogs, pageLink); | |
104 | + return auditLogDao.findAuditLogsByTenantIdAndEntityId(tenantId.getId(), entityId, pageLink); | |
108 | 105 | } |
109 | 106 | |
110 | 107 | @Override |
111 | - public TimePageData<AuditLog> findAuditLogsByTenantId(TenantId tenantId, TimePageLink pageLink) { | |
108 | + public PageData<AuditLog> findAuditLogsByTenantId(TenantId tenantId, TimePageLink pageLink) { | |
112 | 109 | log.trace("Executing findAuditLogs [{}]", pageLink); |
113 | 110 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
114 | - List<AuditLog> auditLogs = auditLogDao.findAuditLogsByTenantId(tenantId.getId(), pageLink); | |
115 | - return new TimePageData<>(auditLogs, pageLink); | |
111 | + return auditLogDao.findAuditLogsByTenantId(tenantId.getId(), pageLink); | |
116 | 112 | } |
117 | 113 | |
118 | 114 | @Override |
... | ... | @@ -328,11 +324,7 @@ public class AuditLogServiceImpl implements AuditLogService { |
328 | 324 | log.trace("Executing logAction [{}]", auditLogEntry); |
329 | 325 | auditLogValidator.validate(auditLogEntry, AuditLog::getTenantId); |
330 | 326 | List<ListenableFuture<Void>> futures = Lists.newArrayListWithExpectedSize(INSERTS_PER_ENTRY); |
331 | - futures.add(auditLogDao.savePartitionsByTenantId(auditLogEntry)); | |
332 | 327 | futures.add(auditLogDao.saveByTenantId(auditLogEntry)); |
333 | - futures.add(auditLogDao.saveByTenantIdAndEntityId(auditLogEntry)); | |
334 | - futures.add(auditLogDao.saveByTenantIdAndCustomerId(auditLogEntry)); | |
335 | - futures.add(auditLogDao.saveByTenantIdAndUserId(auditLogEntry)); | |
336 | 328 | |
337 | 329 | auditLogSink.logAction(auditLogEntry); |
338 | 330 | ... | ... |
... | ... | @@ -27,7 +27,7 @@ import org.thingsboard.server.common.data.id.EntityId; |
27 | 27 | import org.thingsboard.server.common.data.id.TenantId; |
28 | 28 | import org.thingsboard.server.common.data.id.UUIDBased; |
29 | 29 | import org.thingsboard.server.common.data.id.UserId; |
30 | -import org.thingsboard.server.common.data.page.TimePageData; | |
30 | +import org.thingsboard.server.common.data.page.PageData; | |
31 | 31 | import org.thingsboard.server.common.data.page.TimePageLink; |
32 | 32 | |
33 | 33 | import java.util.List; |
... | ... | @@ -37,23 +37,23 @@ import java.util.List; |
37 | 37 | public class DummyAuditLogServiceImpl implements AuditLogService { |
38 | 38 | |
39 | 39 | @Override |
40 | - public TimePageData<AuditLog> findAuditLogsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TimePageLink pageLink) { | |
41 | - return new TimePageData<>(null, pageLink); | |
40 | + public PageData<AuditLog> findAuditLogsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TimePageLink pageLink) { | |
41 | + return new PageData(); | |
42 | 42 | } |
43 | 43 | |
44 | 44 | @Override |
45 | - public TimePageData<AuditLog> findAuditLogsByTenantIdAndUserId(TenantId tenantId, UserId userId, TimePageLink pageLink) { | |
46 | - return new TimePageData<>(null, pageLink); | |
45 | + public PageData<AuditLog> findAuditLogsByTenantIdAndUserId(TenantId tenantId, UserId userId, TimePageLink pageLink) { | |
46 | + return new PageData(); | |
47 | 47 | } |
48 | 48 | |
49 | 49 | @Override |
50 | - public TimePageData<AuditLog> findAuditLogsByTenantIdAndEntityId(TenantId tenantId, EntityId entityId, TimePageLink pageLink) { | |
51 | - return new TimePageData<>(null, pageLink); | |
50 | + public PageData<AuditLog> findAuditLogsByTenantIdAndEntityId(TenantId tenantId, EntityId entityId, TimePageLink pageLink) { | |
51 | + return new PageData(); | |
52 | 52 | } |
53 | 53 | |
54 | 54 | @Override |
55 | - public TimePageData<AuditLog> findAuditLogsByTenantId(TenantId tenantId, TimePageLink pageLink) { | |
56 | - return new TimePageData<>(null, pageLink); | |
55 | + public PageData<AuditLog> findAuditLogsByTenantId(TenantId tenantId, TimePageLink pageLink) { | |
56 | + return new PageData(); | |
57 | 57 | } |
58 | 58 | |
59 | 59 | @Override | ... | ... |
... | ... | @@ -27,8 +27,8 @@ import org.springframework.stereotype.Service; |
27 | 27 | import org.thingsboard.server.common.data.id.ComponentDescriptorId; |
28 | 28 | import org.thingsboard.server.common.data.id.EntityId; |
29 | 29 | import org.thingsboard.server.common.data.id.TenantId; |
30 | -import org.thingsboard.server.common.data.page.TextPageData; | |
31 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
30 | +import org.thingsboard.server.common.data.page.PageData; | |
31 | +import org.thingsboard.server.common.data.page.PageLink; | |
32 | 32 | import org.thingsboard.server.common.data.plugin.ComponentDescriptor; |
33 | 33 | import org.thingsboard.server.common.data.plugin.ComponentScope; |
34 | 34 | import org.thingsboard.server.common.data.plugin.ComponentType; |
... | ... | @@ -74,17 +74,15 @@ public class BaseComponentDescriptorService implements ComponentDescriptorServic |
74 | 74 | } |
75 | 75 | |
76 | 76 | @Override |
77 | - public TextPageData<ComponentDescriptor> findByTypeAndPageLink(TenantId tenantId, ComponentType type, TextPageLink pageLink) { | |
78 | - Validator.validatePageLink(pageLink, "Incorrect PageLink object for search plugin components request."); | |
79 | - List<ComponentDescriptor> components = componentDescriptorDao.findByTypeAndPageLink(tenantId, type, pageLink); | |
80 | - return new TextPageData<>(components, pageLink); | |
77 | + public PageData<ComponentDescriptor> findByTypeAndPageLink(TenantId tenantId, ComponentType type, PageLink pageLink) { | |
78 | + Validator.validatePageLink(pageLink); | |
79 | + return componentDescriptorDao.findByTypeAndPageLink(tenantId, type, pageLink); | |
81 | 80 | } |
82 | 81 | |
83 | 82 | @Override |
84 | - public TextPageData<ComponentDescriptor> findByScopeAndTypeAndPageLink(TenantId tenantId, ComponentScope scope, ComponentType type, TextPageLink pageLink) { | |
85 | - Validator.validatePageLink(pageLink, "Incorrect PageLink object for search plugin components request."); | |
86 | - List<ComponentDescriptor> components = componentDescriptorDao.findByScopeAndTypeAndPageLink(tenantId, scope, type, pageLink); | |
87 | - return new TextPageData<>(components, pageLink); | |
83 | + public PageData<ComponentDescriptor> findByScopeAndTypeAndPageLink(TenantId tenantId, ComponentScope scope, ComponentType type, PageLink pageLink) { | |
84 | + Validator.validatePageLink(pageLink); | |
85 | + return componentDescriptorDao.findByScopeAndTypeAndPageLink(tenantId, scope, type, pageLink); | |
88 | 86 | } |
89 | 87 | |
90 | 88 | @Override | ... | ... |
... | ... | @@ -17,7 +17,8 @@ package org.thingsboard.server.dao.component; |
17 | 17 | |
18 | 18 | import org.thingsboard.server.common.data.id.ComponentDescriptorId; |
19 | 19 | import org.thingsboard.server.common.data.id.TenantId; |
20 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
20 | +import org.thingsboard.server.common.data.page.PageData; | |
21 | +import org.thingsboard.server.common.data.page.PageLink; | |
21 | 22 | import org.thingsboard.server.common.data.plugin.ComponentDescriptor; |
22 | 23 | import org.thingsboard.server.common.data.plugin.ComponentScope; |
23 | 24 | import org.thingsboard.server.common.data.plugin.ComponentType; |
... | ... | @@ -37,9 +38,9 @@ public interface ComponentDescriptorDao extends Dao<ComponentDescriptor> { |
37 | 38 | |
38 | 39 | ComponentDescriptor findByClazz(TenantId tenantId, String clazz); |
39 | 40 | |
40 | - List<ComponentDescriptor> findByTypeAndPageLink(TenantId tenantId, ComponentType type, TextPageLink pageLink); | |
41 | + PageData<ComponentDescriptor> findByTypeAndPageLink(TenantId tenantId, ComponentType type, PageLink pageLink); | |
41 | 42 | |
42 | - List<ComponentDescriptor> findByScopeAndTypeAndPageLink(TenantId tenantId, ComponentScope scope, ComponentType type, TextPageLink pageLink); | |
43 | + PageData<ComponentDescriptor> findByScopeAndTypeAndPageLink(TenantId tenantId, ComponentScope scope, ComponentType type, PageLink pageLink); | |
43 | 44 | |
44 | 45 | void deleteById(TenantId tenantId, ComponentDescriptorId componentId); |
45 | 46 | ... | ... |
... | ... | @@ -17,7 +17,8 @@ package org.thingsboard.server.dao.customer; |
17 | 17 | |
18 | 18 | import org.thingsboard.server.common.data.Customer; |
19 | 19 | import org.thingsboard.server.common.data.id.TenantId; |
20 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
20 | +import org.thingsboard.server.common.data.page.PageData; | |
21 | +import org.thingsboard.server.common.data.page.PageLink; | |
21 | 22 | import org.thingsboard.server.dao.Dao; |
22 | 23 | |
23 | 24 | import java.util.List; |
... | ... | @@ -44,7 +45,7 @@ public interface CustomerDao extends Dao<Customer> { |
44 | 45 | * @param pageLink the page link |
45 | 46 | * @return the list of customer objects |
46 | 47 | */ |
47 | - List<Customer> findCustomersByTenantId(UUID tenantId, TextPageLink pageLink); | |
48 | + PageData<Customer> findCustomersByTenantId(UUID tenantId, PageLink pageLink); | |
48 | 49 | |
49 | 50 | /** |
50 | 51 | * Find customers by tenantId and customer title. | ... | ... |
... | ... | @@ -26,8 +26,8 @@ import org.thingsboard.server.common.data.Customer; |
26 | 26 | import org.thingsboard.server.common.data.Tenant; |
27 | 27 | import org.thingsboard.server.common.data.id.CustomerId; |
28 | 28 | import org.thingsboard.server.common.data.id.TenantId; |
29 | -import org.thingsboard.server.common.data.page.TextPageData; | |
30 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
29 | +import org.thingsboard.server.common.data.page.PageData; | |
30 | +import org.thingsboard.server.common.data.page.PageLink; | |
31 | 31 | import org.thingsboard.server.dao.asset.AssetService; |
32 | 32 | import org.thingsboard.server.dao.dashboard.DashboardService; |
33 | 33 | import org.thingsboard.server.dao.device.DeviceService; |
... | ... | @@ -144,12 +144,11 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom |
144 | 144 | } |
145 | 145 | |
146 | 146 | @Override |
147 | - public TextPageData<Customer> findCustomersByTenantId(TenantId tenantId, TextPageLink pageLink) { | |
147 | + public PageData<Customer> findCustomersByTenantId(TenantId tenantId, PageLink pageLink) { | |
148 | 148 | log.trace("Executing findCustomersByTenantId, tenantId [{}], pageLink [{}]", tenantId, pageLink); |
149 | 149 | Validator.validateId(tenantId, "Incorrect tenantId " + tenantId); |
150 | - Validator.validatePageLink(pageLink, "Incorrect page link " + pageLink); | |
151 | - List<Customer> customers = customerDao.findCustomersByTenantId(tenantId.getId(), pageLink); | |
152 | - return new TextPageData<>(customers, pageLink); | |
150 | + Validator.validatePageLink(pageLink); | |
151 | + return customerDao.findCustomersByTenantId(tenantId.getId(), pageLink); | |
153 | 152 | } |
154 | 153 | |
155 | 154 | @Override |
... | ... | @@ -208,7 +207,7 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom |
208 | 207 | new PaginatedRemover<TenantId, Customer>() { |
209 | 208 | |
210 | 209 | @Override |
211 | - protected List<Customer> findEntities(TenantId tenantId, TenantId id, TextPageLink pageLink) { | |
210 | + protected PageData<Customer> findEntities(TenantId tenantId, TenantId id, PageLink pageLink) { | |
212 | 211 | return customerDao.findCustomersByTenantId(id.getId(), pageLink); |
213 | 212 | } |
214 | 213 | ... | ... |
... | ... | @@ -17,7 +17,8 @@ package org.thingsboard.server.dao.dashboard; |
17 | 17 | |
18 | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import org.thingsboard.server.common.data.DashboardInfo; |
20 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
20 | +import org.thingsboard.server.common.data.page.PageData; | |
21 | +import org.thingsboard.server.common.data.page.PageLink; | |
21 | 22 | import org.thingsboard.server.common.data.page.TimePageLink; |
22 | 23 | import org.thingsboard.server.dao.Dao; |
23 | 24 | |
... | ... | @@ -36,7 +37,7 @@ public interface DashboardInfoDao extends Dao<DashboardInfo> { |
36 | 37 | * @param pageLink the page link |
37 | 38 | * @return the list of dashboard objects |
38 | 39 | */ |
39 | - List<DashboardInfo> findDashboardsByTenantId(UUID tenantId, TextPageLink pageLink); | |
40 | + PageData<DashboardInfo> findDashboardsByTenantId(UUID tenantId, PageLink pageLink); | |
40 | 41 | |
41 | 42 | /** |
42 | 43 | * Find dashboards by tenantId, customerId and page link. |
... | ... | @@ -46,6 +47,6 @@ public interface DashboardInfoDao extends Dao<DashboardInfo> { |
46 | 47 | * @param pageLink the page link |
47 | 48 | * @return the list of dashboard objects |
48 | 49 | */ |
49 | - ListenableFuture<List<DashboardInfo>> findDashboardsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TimePageLink pageLink); | |
50 | + ListenableFuture<PageData<DashboardInfo>> findDashboardsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TimePageLink pageLink); | |
50 | 51 | |
51 | 52 | } | ... | ... |
... | ... | @@ -29,9 +29,8 @@ import org.thingsboard.server.common.data.Tenant; |
29 | 29 | import org.thingsboard.server.common.data.id.CustomerId; |
30 | 30 | import org.thingsboard.server.common.data.id.DashboardId; |
31 | 31 | import org.thingsboard.server.common.data.id.TenantId; |
32 | -import org.thingsboard.server.common.data.page.TextPageData; | |
33 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
34 | -import org.thingsboard.server.common.data.page.TimePageData; | |
32 | +import org.thingsboard.server.common.data.page.PageData; | |
33 | +import org.thingsboard.server.common.data.page.PageLink; | |
35 | 34 | import org.thingsboard.server.common.data.page.TimePageLink; |
36 | 35 | import org.thingsboard.server.common.data.relation.EntityRelation; |
37 | 36 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
... | ... | @@ -174,12 +173,11 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb |
174 | 173 | } |
175 | 174 | |
176 | 175 | @Override |
177 | - public TextPageData<DashboardInfo> findDashboardsByTenantId(TenantId tenantId, TextPageLink pageLink) { | |
176 | + public PageData<DashboardInfo> findDashboardsByTenantId(TenantId tenantId, PageLink pageLink) { | |
178 | 177 | log.trace("Executing findDashboardsByTenantId, tenantId [{}], pageLink [{}]", tenantId, pageLink); |
179 | 178 | Validator.validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
180 | - Validator.validatePageLink(pageLink, "Incorrect page link " + pageLink); | |
181 | - List<DashboardInfo> dashboards = dashboardInfoDao.findDashboardsByTenantId(tenantId.getId(), pageLink); | |
182 | - return new TextPageData<>(dashboards, pageLink); | |
179 | + Validator.validatePageLink(pageLink); | |
180 | + return dashboardInfoDao.findDashboardsByTenantId(tenantId.getId(), pageLink); | |
183 | 181 | } |
184 | 182 | |
185 | 183 | @Override |
... | ... | @@ -190,20 +188,12 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb |
190 | 188 | } |
191 | 189 | |
192 | 190 | @Override |
193 | - public ListenableFuture<TimePageData<DashboardInfo>> findDashboardsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TimePageLink pageLink) { | |
191 | + public ListenableFuture<PageData<DashboardInfo>> findDashboardsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TimePageLink pageLink) { | |
194 | 192 | log.trace("Executing findDashboardsByTenantIdAndCustomerId, tenantId [{}], customerId [{}], pageLink [{}]", tenantId, customerId, pageLink); |
195 | 193 | Validator.validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
196 | 194 | Validator.validateId(customerId, "Incorrect customerId " + customerId); |
197 | - Validator.validatePageLink(pageLink, "Incorrect page link " + pageLink); | |
198 | - ListenableFuture<List<DashboardInfo>> dashboards = dashboardInfoDao.findDashboardsByTenantIdAndCustomerId(tenantId.getId(), customerId.getId(), pageLink); | |
199 | - | |
200 | - return Futures.transform(dashboards, new Function<List<DashboardInfo>, TimePageData<DashboardInfo>>() { | |
201 | - @Nullable | |
202 | - @Override | |
203 | - public TimePageData<DashboardInfo> apply(@Nullable List<DashboardInfo> dashboards) { | |
204 | - return new TimePageData<>(dashboards, pageLink); | |
205 | - } | |
206 | - }); | |
195 | + Validator.validatePageLink(pageLink); | |
196 | + return dashboardInfoDao.findDashboardsByTenantIdAndCustomerId(tenantId.getId(), customerId.getId(), pageLink); | |
207 | 197 | } |
208 | 198 | |
209 | 199 | @Override |
... | ... | @@ -250,7 +240,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb |
250 | 240 | new PaginatedRemover<TenantId, DashboardInfo>() { |
251 | 241 | |
252 | 242 | @Override |
253 | - protected List<DashboardInfo> findEntities(TenantId tenantId, TenantId id, TextPageLink pageLink) { | |
243 | + protected PageData<DashboardInfo> findEntities(TenantId tenantId, TenantId id, PageLink pageLink) { | |
254 | 244 | return dashboardInfoDao.findDashboardsByTenantId(id.getId(), pageLink); |
255 | 245 | } |
256 | 246 | |
... | ... | @@ -269,7 +259,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb |
269 | 259 | } |
270 | 260 | |
271 | 261 | @Override |
272 | - protected List<DashboardInfo> findEntities(TenantId tenantId, Customer customer, TimePageLink pageLink) { | |
262 | + protected PageData<DashboardInfo> findEntities(TenantId tenantId, Customer customer, TimePageLink pageLink) { | |
273 | 263 | try { |
274 | 264 | return dashboardInfoDao.findDashboardsByTenantIdAndCustomerId(customer.getTenantId().getId(), customer.getId().getId(), pageLink).get(); |
275 | 265 | } catch (InterruptedException | ExecutionException e) { |
... | ... | @@ -294,7 +284,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb |
294 | 284 | } |
295 | 285 | |
296 | 286 | @Override |
297 | - protected List<DashboardInfo> findEntities(TenantId tenantId, Customer customer, TimePageLink pageLink) { | |
287 | + protected PageData<DashboardInfo> findEntities(TenantId tenantId, Customer customer, TimePageLink pageLink) { | |
298 | 288 | try { |
299 | 289 | return dashboardInfoDao.findDashboardsByTenantIdAndCustomerId(customer.getTenantId().getId(), customer.getId().getId(), pageLink).get(); |
300 | 290 | } catch (InterruptedException | ExecutionException e) { | ... | ... |
... | ... | @@ -19,7 +19,8 @@ import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import org.thingsboard.server.common.data.Device; |
20 | 20 | import org.thingsboard.server.common.data.EntitySubtype; |
21 | 21 | import org.thingsboard.server.common.data.id.TenantId; |
22 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
22 | +import org.thingsboard.server.common.data.page.PageData; | |
23 | +import org.thingsboard.server.common.data.page.PageLink; | |
23 | 24 | import org.thingsboard.server.dao.Dao; |
24 | 25 | |
25 | 26 | import java.util.List; |
... | ... | @@ -47,7 +48,7 @@ public interface DeviceDao extends Dao<Device> { |
47 | 48 | * @param pageLink the page link |
48 | 49 | * @return the list of device objects |
49 | 50 | */ |
50 | - List<Device> findDevicesByTenantId(UUID tenantId, TextPageLink pageLink); | |
51 | + PageData<Device> findDevicesByTenantId(UUID tenantId, PageLink pageLink); | |
51 | 52 | |
52 | 53 | /** |
53 | 54 | * Find devices by tenantId, type and page link. |
... | ... | @@ -57,7 +58,7 @@ public interface DeviceDao extends Dao<Device> { |
57 | 58 | * @param pageLink the page link |
58 | 59 | * @return the list of device objects |
59 | 60 | */ |
60 | - List<Device> findDevicesByTenantIdAndType(UUID tenantId, String type, TextPageLink pageLink); | |
61 | + PageData<Device> findDevicesByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); | |
61 | 62 | |
62 | 63 | /** |
63 | 64 | * Find devices by tenantId and devices Ids. |
... | ... | @@ -76,7 +77,7 @@ public interface DeviceDao extends Dao<Device> { |
76 | 77 | * @param pageLink the page link |
77 | 78 | * @return the list of device objects |
78 | 79 | */ |
79 | - List<Device> findDevicesByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink); | |
80 | + PageData<Device> findDevicesByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); | |
80 | 81 | |
81 | 82 | /** |
82 | 83 | * Find devices by tenantId, customerId, type and page link. |
... | ... | @@ -87,7 +88,7 @@ public interface DeviceDao extends Dao<Device> { |
87 | 88 | * @param pageLink the page link |
88 | 89 | * @return the list of device objects |
89 | 90 | */ |
90 | - List<Device> findDevicesByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, TextPageLink pageLink); | |
91 | + PageData<Device> findDevicesByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); | |
91 | 92 | |
92 | 93 | |
93 | 94 | /** | ... | ... |
... | ... | @@ -38,8 +38,8 @@ import org.thingsboard.server.common.data.id.CustomerId; |
38 | 38 | import org.thingsboard.server.common.data.id.DeviceId; |
39 | 39 | import org.thingsboard.server.common.data.id.EntityId; |
40 | 40 | import org.thingsboard.server.common.data.id.TenantId; |
41 | -import org.thingsboard.server.common.data.page.TextPageData; | |
42 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
41 | +import org.thingsboard.server.common.data.page.PageData; | |
42 | +import org.thingsboard.server.common.data.page.PageLink; | |
43 | 43 | import org.thingsboard.server.common.data.relation.EntityRelation; |
44 | 44 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
45 | 45 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
... | ... | @@ -180,22 +180,20 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe |
180 | 180 | } |
181 | 181 | |
182 | 182 | @Override |
183 | - public TextPageData<Device> findDevicesByTenantId(TenantId tenantId, TextPageLink pageLink) { | |
183 | + public PageData<Device> findDevicesByTenantId(TenantId tenantId, PageLink pageLink) { | |
184 | 184 | log.trace("Executing findDevicesByTenantId, tenantId [{}], pageLink [{}]", tenantId, pageLink); |
185 | 185 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
186 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
187 | - List<Device> devices = deviceDao.findDevicesByTenantId(tenantId.getId(), pageLink); | |
188 | - return new TextPageData<>(devices, pageLink); | |
186 | + validatePageLink(pageLink); | |
187 | + return deviceDao.findDevicesByTenantId(tenantId.getId(), pageLink); | |
189 | 188 | } |
190 | 189 | |
191 | 190 | @Override |
192 | - public TextPageData<Device> findDevicesByTenantIdAndType(TenantId tenantId, String type, TextPageLink pageLink) { | |
191 | + public PageData<Device> findDevicesByTenantIdAndType(TenantId tenantId, String type, PageLink pageLink) { | |
193 | 192 | log.trace("Executing findDevicesByTenantIdAndType, tenantId [{}], type [{}], pageLink [{}]", tenantId, type, pageLink); |
194 | 193 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
195 | 194 | validateString(type, "Incorrect type " + type); |
196 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
197 | - List<Device> devices = deviceDao.findDevicesByTenantIdAndType(tenantId.getId(), type, pageLink); | |
198 | - return new TextPageData<>(devices, pageLink); | |
195 | + validatePageLink(pageLink); | |
196 | + return deviceDao.findDevicesByTenantIdAndType(tenantId.getId(), type, pageLink); | |
199 | 197 | } |
200 | 198 | |
201 | 199 | @Override |
... | ... | @@ -215,24 +213,22 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe |
215 | 213 | } |
216 | 214 | |
217 | 215 | @Override |
218 | - public TextPageData<Device> findDevicesByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, TextPageLink pageLink) { | |
216 | + public PageData<Device> findDevicesByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, PageLink pageLink) { | |
219 | 217 | log.trace("Executing findDevicesByTenantIdAndCustomerId, tenantId [{}], customerId [{}], pageLink [{}]", tenantId, customerId, pageLink); |
220 | 218 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
221 | 219 | validateId(customerId, INCORRECT_CUSTOMER_ID + customerId); |
222 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
223 | - List<Device> devices = deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), customerId.getId(), pageLink); | |
224 | - return new TextPageData<>(devices, pageLink); | |
220 | + validatePageLink(pageLink); | |
221 | + return deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), customerId.getId(), pageLink); | |
225 | 222 | } |
226 | 223 | |
227 | 224 | @Override |
228 | - public TextPageData<Device> findDevicesByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, String type, TextPageLink pageLink) { | |
225 | + public PageData<Device> findDevicesByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, String type, PageLink pageLink) { | |
229 | 226 | log.trace("Executing findDevicesByTenantIdAndCustomerIdAndType, tenantId [{}], customerId [{}], type [{}], pageLink [{}]", tenantId, customerId, type, pageLink); |
230 | 227 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
231 | 228 | validateId(customerId, INCORRECT_CUSTOMER_ID + customerId); |
232 | 229 | validateString(type, "Incorrect type " + type); |
233 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
234 | - List<Device> devices = deviceDao.findDevicesByTenantIdAndCustomerIdAndType(tenantId.getId(), customerId.getId(), type, pageLink); | |
235 | - return new TextPageData<>(devices, pageLink); | |
230 | + validatePageLink(pageLink); | |
231 | + return deviceDao.findDevicesByTenantIdAndCustomerIdAndType(tenantId.getId(), customerId.getId(), type, pageLink); | |
236 | 232 | } |
237 | 233 | |
238 | 234 | @Override |
... | ... | @@ -348,7 +344,7 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe |
348 | 344 | new PaginatedRemover<TenantId, Device>() { |
349 | 345 | |
350 | 346 | @Override |
351 | - protected List<Device> findEntities(TenantId tenantId, TenantId id, TextPageLink pageLink) { | |
347 | + protected PageData<Device> findEntities(TenantId tenantId, TenantId id, PageLink pageLink) { | |
352 | 348 | return deviceDao.findDevicesByTenantId(id.getId(), pageLink); |
353 | 349 | } |
354 | 350 | |
... | ... | @@ -361,7 +357,7 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe |
361 | 357 | private PaginatedRemover<CustomerId, Device> customerDeviceUnasigner = new PaginatedRemover<CustomerId, Device>() { |
362 | 358 | |
363 | 359 | @Override |
364 | - protected List<Device> findEntities(TenantId tenantId, CustomerId id, TextPageLink pageLink) { | |
360 | + protected PageData<Device> findEntities(TenantId tenantId, CustomerId id, PageLink pageLink) { | |
365 | 361 | return deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), id.getId(), pageLink); |
366 | 362 | } |
367 | 363 | ... | ... |
... | ... | @@ -20,7 +20,8 @@ import org.thingsboard.server.common.data.Device; |
20 | 20 | import org.thingsboard.server.common.data.EntitySubtype; |
21 | 21 | import org.thingsboard.server.common.data.EntityView; |
22 | 22 | import org.thingsboard.server.common.data.id.TenantId; |
23 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
23 | +import org.thingsboard.server.common.data.page.PageData; | |
24 | +import org.thingsboard.server.common.data.page.PageLink; | |
24 | 25 | import org.thingsboard.server.dao.Dao; |
25 | 26 | |
26 | 27 | import java.util.List; |
... | ... | @@ -47,7 +48,7 @@ public interface EntityViewDao extends Dao<EntityView> { |
47 | 48 | * @param pageLink the page link |
48 | 49 | * @return the list of entity view objects |
49 | 50 | */ |
50 | - List<EntityView> findEntityViewsByTenantId(UUID tenantId, TextPageLink pageLink); | |
51 | + PageData<EntityView> findEntityViewsByTenantId(UUID tenantId, PageLink pageLink); | |
51 | 52 | |
52 | 53 | /** |
53 | 54 | * Find entity views by tenantId, type and page link. |
... | ... | @@ -57,7 +58,7 @@ public interface EntityViewDao extends Dao<EntityView> { |
57 | 58 | * @param pageLink the page link |
58 | 59 | * @return the list of entity view objects |
59 | 60 | */ |
60 | - List<EntityView> findEntityViewsByTenantIdAndType(UUID tenantId, String type, TextPageLink pageLink); | |
61 | + PageData<EntityView> findEntityViewsByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); | |
61 | 62 | |
62 | 63 | /** |
63 | 64 | * Find entity views by tenantId and entity view name. |
... | ... | @@ -76,9 +77,9 @@ public interface EntityViewDao extends Dao<EntityView> { |
76 | 77 | * @param pageLink the page link |
77 | 78 | * @return the list of entity view objects |
78 | 79 | */ |
79 | - List<EntityView> findEntityViewsByTenantIdAndCustomerId(UUID tenantId, | |
80 | + PageData<EntityView> findEntityViewsByTenantIdAndCustomerId(UUID tenantId, | |
80 | 81 | UUID customerId, |
81 | - TextPageLink pageLink); | |
82 | + PageLink pageLink); | |
82 | 83 | |
83 | 84 | /** |
84 | 85 | * Find entity views by tenantId, customerId, type and page link. |
... | ... | @@ -89,10 +90,10 @@ public interface EntityViewDao extends Dao<EntityView> { |
89 | 90 | * @param pageLink the page link |
90 | 91 | * @return the list of entity view objects |
91 | 92 | */ |
92 | - List<EntityView> findEntityViewsByTenantIdAndCustomerIdAndType(UUID tenantId, | |
93 | + PageData<EntityView> findEntityViewsByTenantIdAndCustomerIdAndType(UUID tenantId, | |
93 | 94 | UUID customerId, |
94 | 95 | String type, |
95 | - TextPageLink pageLink); | |
96 | + PageLink pageLink); | |
96 | 97 | |
97 | 98 | ListenableFuture<List<EntityView>> findEntityViewsByTenantIdAndEntityIdAsync(UUID tenantId, UUID entityId); |
98 | 99 | ... | ... |
... | ... | @@ -38,8 +38,8 @@ import org.thingsboard.server.common.data.id.CustomerId; |
38 | 38 | import org.thingsboard.server.common.data.id.EntityId; |
39 | 39 | import org.thingsboard.server.common.data.id.EntityViewId; |
40 | 40 | import org.thingsboard.server.common.data.id.TenantId; |
41 | -import org.thingsboard.server.common.data.page.TextPageData; | |
42 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
41 | +import org.thingsboard.server.common.data.page.PageData; | |
42 | +import org.thingsboard.server.common.data.page.PageLink; | |
43 | 43 | import org.thingsboard.server.common.data.relation.EntityRelation; |
44 | 44 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
45 | 45 | import org.thingsboard.server.dao.customer.CustomerDao; |
... | ... | @@ -142,48 +142,44 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
142 | 142 | } |
143 | 143 | |
144 | 144 | @Override |
145 | - public TextPageData<EntityView> findEntityViewByTenantId(TenantId tenantId, TextPageLink pageLink) { | |
145 | + public PageData<EntityView> findEntityViewByTenantId(TenantId tenantId, PageLink pageLink) { | |
146 | 146 | log.trace("Executing findEntityViewsByTenantId, tenantId [{}], pageLink [{}]", tenantId, pageLink); |
147 | 147 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
148 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
149 | - List<EntityView> entityViews = entityViewDao.findEntityViewsByTenantId(tenantId.getId(), pageLink); | |
150 | - return new TextPageData<>(entityViews, pageLink); | |
148 | + validatePageLink(pageLink); | |
149 | + return entityViewDao.findEntityViewsByTenantId(tenantId.getId(), pageLink); | |
151 | 150 | } |
152 | 151 | |
153 | 152 | @Override |
154 | - public TextPageData<EntityView> findEntityViewByTenantIdAndType(TenantId tenantId, TextPageLink pageLink, String type) { | |
153 | + public PageData<EntityView> findEntityViewByTenantIdAndType(TenantId tenantId, PageLink pageLink, String type) { | |
155 | 154 | log.trace("Executing findEntityViewByTenantIdAndType, tenantId [{}], pageLink [{}], type [{}]", tenantId, pageLink, type); |
156 | 155 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
157 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
156 | + validatePageLink(pageLink); | |
158 | 157 | validateString(type, "Incorrect type " + type); |
159 | - List<EntityView> entityViews = entityViewDao.findEntityViewsByTenantIdAndType(tenantId.getId(), type, pageLink); | |
160 | - return new TextPageData<>(entityViews, pageLink); | |
158 | + return entityViewDao.findEntityViewsByTenantIdAndType(tenantId.getId(), type, pageLink); | |
161 | 159 | } |
162 | 160 | |
163 | 161 | @Override |
164 | - public TextPageData<EntityView> findEntityViewsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, | |
165 | - TextPageLink pageLink) { | |
162 | + public PageData<EntityView> findEntityViewsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, | |
163 | + PageLink pageLink) { | |
166 | 164 | log.trace("Executing findEntityViewByTenantIdAndCustomerId, tenantId [{}], customerId [{}]," + |
167 | 165 | " pageLink [{}]", tenantId, customerId, pageLink); |
168 | 166 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
169 | 167 | validateId(customerId, INCORRECT_CUSTOMER_ID + customerId); |
170 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
171 | - List<EntityView> entityViews = entityViewDao.findEntityViewsByTenantIdAndCustomerId(tenantId.getId(), | |
168 | + validatePageLink(pageLink); | |
169 | + return entityViewDao.findEntityViewsByTenantIdAndCustomerId(tenantId.getId(), | |
172 | 170 | customerId.getId(), pageLink); |
173 | - return new TextPageData<>(entityViews, pageLink); | |
174 | 171 | } |
175 | 172 | |
176 | 173 | @Override |
177 | - public TextPageData<EntityView> findEntityViewsByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, TextPageLink pageLink, String type) { | |
174 | + public PageData<EntityView> findEntityViewsByTenantIdAndCustomerIdAndType(TenantId tenantId, CustomerId customerId, PageLink pageLink, String type) { | |
178 | 175 | log.trace("Executing findEntityViewsByTenantIdAndCustomerIdAndType, tenantId [{}], customerId [{}]," + |
179 | 176 | " pageLink [{}], type [{}]", tenantId, customerId, pageLink, type); |
180 | 177 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
181 | 178 | validateId(customerId, INCORRECT_CUSTOMER_ID + customerId); |
182 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
179 | + validatePageLink(pageLink); | |
183 | 180 | validateString(type, "Incorrect type " + type); |
184 | - List<EntityView> entityViews = entityViewDao.findEntityViewsByTenantIdAndCustomerIdAndType(tenantId.getId(), | |
181 | + return entityViewDao.findEntityViewsByTenantIdAndCustomerIdAndType(tenantId.getId(), | |
185 | 182 | customerId.getId(), type, pageLink); |
186 | - return new TextPageData<>(entityViews, pageLink); | |
187 | 183 | } |
188 | 184 | |
189 | 185 | @Override |
... | ... | @@ -335,7 +331,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
335 | 331 | |
336 | 332 | private PaginatedRemover<TenantId, EntityView> tenantEntityViewRemover = new PaginatedRemover<TenantId, EntityView>() { |
337 | 333 | @Override |
338 | - protected List<EntityView> findEntities(TenantId tenantId, TenantId id, TextPageLink pageLink) { | |
334 | + protected PageData<EntityView> findEntities(TenantId tenantId, TenantId id, PageLink pageLink) { | |
339 | 335 | return entityViewDao.findEntityViewsByTenantId(id.getId(), pageLink); |
340 | 336 | } |
341 | 337 | |
... | ... | @@ -347,7 +343,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
347 | 343 | |
348 | 344 | private PaginatedRemover<CustomerId, EntityView> customerEntityViewsUnAssigner = new PaginatedRemover<CustomerId, EntityView>() { |
349 | 345 | @Override |
350 | - protected List<EntityView> findEntities(TenantId tenantId, CustomerId id, TextPageLink pageLink) { | |
346 | + protected PageData<EntityView> findEntities(TenantId tenantId, CustomerId id, PageLink pageLink) { | |
351 | 347 | return entityViewDao.findEntityViewsByTenantIdAndCustomerId(tenantId.getId(), id.getId(), pageLink); |
352 | 348 | } |
353 | 349 | ... | ... |
... | ... | @@ -23,7 +23,7 @@ import org.springframework.stereotype.Service; |
23 | 23 | import org.thingsboard.server.common.data.Event; |
24 | 24 | import org.thingsboard.server.common.data.id.EntityId; |
25 | 25 | import org.thingsboard.server.common.data.id.TenantId; |
26 | -import org.thingsboard.server.common.data.page.TimePageData; | |
26 | +import org.thingsboard.server.common.data.page.PageData; | |
27 | 27 | import org.thingsboard.server.common.data.page.TimePageLink; |
28 | 28 | import org.thingsboard.server.dao.exception.DataValidationException; |
29 | 29 | import org.thingsboard.server.dao.service.DataValidator; |
... | ... | @@ -78,15 +78,13 @@ public class BaseEventService implements EventService { |
78 | 78 | } |
79 | 79 | |
80 | 80 | @Override |
81 | - public TimePageData<Event> findEvents(TenantId tenantId, EntityId entityId, TimePageLink pageLink) { | |
82 | - List<Event> events = eventDao.findEvents(tenantId.getId(), entityId, pageLink); | |
83 | - return new TimePageData<>(events, pageLink); | |
81 | + public PageData<Event> findEvents(TenantId tenantId, EntityId entityId, TimePageLink pageLink) { | |
82 | + return eventDao.findEvents(tenantId.getId(), entityId, pageLink); | |
84 | 83 | } |
85 | 84 | |
86 | 85 | @Override |
87 | - public TimePageData<Event> findEvents(TenantId tenantId, EntityId entityId, String eventType, TimePageLink pageLink) { | |
88 | - List<Event> events = eventDao.findEvents(tenantId.getId(), entityId, eventType, pageLink); | |
89 | - return new TimePageData<>(events, pageLink); | |
86 | + public PageData<Event> findEvents(TenantId tenantId, EntityId entityId, String eventType, TimePageLink pageLink) { | |
87 | + return eventDao.findEvents(tenantId.getId(), entityId, eventType, pageLink); | |
90 | 88 | } |
91 | 89 | |
92 | 90 | @Override | ... | ... |
... | ... | @@ -19,6 +19,7 @@ import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import org.thingsboard.server.common.data.Event; |
20 | 20 | import org.thingsboard.server.common.data.id.EntityId; |
21 | 21 | import org.thingsboard.server.common.data.id.TenantId; |
22 | +import org.thingsboard.server.common.data.page.PageData; | |
22 | 23 | import org.thingsboard.server.common.data.page.TimePageLink; |
23 | 24 | import org.thingsboard.server.dao.Dao; |
24 | 25 | |
... | ... | @@ -74,7 +75,7 @@ public interface EventDao extends Dao<Event> { |
74 | 75 | * @param pageLink the pageLink |
75 | 76 | * @return the event list |
76 | 77 | */ |
77 | - List<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink); | |
78 | + PageData<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink); | |
78 | 79 | |
79 | 80 | /** |
80 | 81 | * Find events by tenantId, entityId, eventType and pageLink. |
... | ... | @@ -85,7 +86,7 @@ public interface EventDao extends Dao<Event> { |
85 | 86 | * @param pageLink the pageLink |
86 | 87 | * @return the event list |
87 | 88 | */ |
88 | - List<Event> findEvents(UUID tenantId, EntityId entityId, String eventType, TimePageLink pageLink); | |
89 | + PageData<Event> findEvents(UUID tenantId, EntityId entityId, String eventType, TimePageLink pageLink); | |
89 | 90 | |
90 | 91 | /** |
91 | 92 | * Find latest events by tenantId, entityId and eventType. | ... | ... |
dao/src/main/java/org/thingsboard/server/dao/nosql/CassandraAbstractModelDao.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2019 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.dao.nosql; | |
17 | - | |
18 | -import com.datastax.driver.core.ResultSet; | |
19 | -import com.datastax.driver.core.ResultSetFuture; | |
20 | -import com.datastax.driver.core.Statement; | |
21 | -import com.datastax.driver.core.querybuilder.QueryBuilder; | |
22 | -import com.datastax.driver.core.querybuilder.Select; | |
23 | -import com.datastax.driver.core.utils.UUIDs; | |
24 | -import com.datastax.driver.mapping.Mapper; | |
25 | -import com.datastax.driver.mapping.Result; | |
26 | -import com.google.common.base.Function; | |
27 | -import com.google.common.util.concurrent.Futures; | |
28 | -import com.google.common.util.concurrent.ListenableFuture; | |
29 | -import lombok.extern.slf4j.Slf4j; | |
30 | -import org.thingsboard.server.common.data.id.TenantId; | |
31 | -import org.thingsboard.server.dao.Dao; | |
32 | -import org.thingsboard.server.dao.DaoUtil; | |
33 | -import org.thingsboard.server.dao.model.BaseEntity; | |
34 | -import org.thingsboard.server.dao.model.ModelConstants; | |
35 | -import org.thingsboard.server.dao.model.wrapper.EntityResultSet; | |
36 | - | |
37 | -import javax.annotation.Nullable; | |
38 | -import java.util.Collections; | |
39 | -import java.util.List; | |
40 | -import java.util.UUID; | |
41 | - | |
42 | -import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; | |
43 | -import static com.datastax.driver.core.querybuilder.QueryBuilder.select; | |
44 | - | |
45 | -@Slf4j | |
46 | -public abstract class CassandraAbstractModelDao<E extends BaseEntity<D>, D> extends CassandraAbstractDao implements Dao<D> { | |
47 | - | |
48 | - protected abstract Class<E> getColumnFamilyClass(); | |
49 | - | |
50 | - protected abstract String getColumnFamilyName(); | |
51 | - | |
52 | - protected E updateSearchTextIfPresent(E entity) { | |
53 | - return entity; | |
54 | - } | |
55 | - | |
56 | - protected Mapper<E> getMapper() { | |
57 | - return cluster.getMapper(getColumnFamilyClass()); | |
58 | - } | |
59 | - | |
60 | - protected List<E> findListByStatement(TenantId tenantId, Statement statement) { | |
61 | - List<E> list = Collections.emptyList(); | |
62 | - if (statement != null) { | |
63 | - statement.setConsistencyLevel(cluster.getDefaultReadConsistencyLevel()); | |
64 | - ResultSet resultSet = executeRead(tenantId, statement); | |
65 | - Result<E> result = getMapper().map(resultSet); | |
66 | - if (result != null) { | |
67 | - list = result.all(); | |
68 | - } | |
69 | - } | |
70 | - return list; | |
71 | - } | |
72 | - | |
73 | - protected ListenableFuture<List<D>> findListByStatementAsync(TenantId tenantId, Statement statement) { | |
74 | - if (statement != null) { | |
75 | - statement.setConsistencyLevel(cluster.getDefaultReadConsistencyLevel()); | |
76 | - ResultSetFuture resultSetFuture = executeAsyncRead(tenantId, statement); | |
77 | - return Futures.transform(resultSetFuture, new Function<ResultSet, List<D>>() { | |
78 | - @Nullable | |
79 | - @Override | |
80 | - public List<D> apply(@Nullable ResultSet resultSet) { | |
81 | - Result<E> result = getMapper().map(resultSet); | |
82 | - if (result != null) { | |
83 | - List<E> entities = result.all(); | |
84 | - return DaoUtil.convertDataList(entities); | |
85 | - } else { | |
86 | - return Collections.emptyList(); | |
87 | - } | |
88 | - } | |
89 | - }); | |
90 | - } | |
91 | - return Futures.immediateFuture(Collections.emptyList()); | |
92 | - } | |
93 | - | |
94 | - protected E findOneByStatement(TenantId tenantId, Statement statement) { | |
95 | - E object = null; | |
96 | - if (statement != null) { | |
97 | - statement.setConsistencyLevel(cluster.getDefaultReadConsistencyLevel()); | |
98 | - ResultSet resultSet = executeRead(tenantId, statement); | |
99 | - Result<E> result = getMapper().map(resultSet); | |
100 | - if (result != null) { | |
101 | - object = result.one(); | |
102 | - } | |
103 | - } | |
104 | - return object; | |
105 | - } | |
106 | - | |
107 | - protected ListenableFuture<D> findOneByStatementAsync(TenantId tenantId, Statement statement) { | |
108 | - if (statement != null) { | |
109 | - statement.setConsistencyLevel(cluster.getDefaultReadConsistencyLevel()); | |
110 | - ResultSetFuture resultSetFuture = executeAsyncRead(tenantId, statement); | |
111 | - return Futures.transform(resultSetFuture, new Function<ResultSet, D>() { | |
112 | - @Nullable | |
113 | - @Override | |
114 | - public D apply(@Nullable ResultSet resultSet) { | |
115 | - Result<E> result = getMapper().map(resultSet); | |
116 | - if (result != null) { | |
117 | - E entity = result.one(); | |
118 | - return DaoUtil.getData(entity); | |
119 | - } else { | |
120 | - return null; | |
121 | - } | |
122 | - } | |
123 | - }); | |
124 | - } | |
125 | - return Futures.immediateFuture(null); | |
126 | - } | |
127 | - | |
128 | - protected Statement getSaveQuery(E dto) { | |
129 | - return getMapper().saveQuery(dto); | |
130 | - } | |
131 | - | |
132 | - protected EntityResultSet<E> saveWithResult(TenantId tenantId, E entity) { | |
133 | - log.debug("Save entity {}", entity); | |
134 | - if (entity.getId() == null) { | |
135 | - entity.setId(UUIDs.timeBased()); | |
136 | - } else if (isDeleteOnSave()) { | |
137 | - removeById(tenantId, entity.getId()); | |
138 | - } | |
139 | - Statement saveStatement = getSaveQuery(entity); | |
140 | - saveStatement.setConsistencyLevel(cluster.getDefaultWriteConsistencyLevel()); | |
141 | - ResultSet resultSet = executeWrite(tenantId, saveStatement); | |
142 | - return new EntityResultSet<>(resultSet, entity); | |
143 | - } | |
144 | - | |
145 | - protected boolean isDeleteOnSave() { | |
146 | - return true; | |
147 | - } | |
148 | - | |
149 | - @Override | |
150 | - public D save(TenantId tenantId, D domain) { | |
151 | - E entity; | |
152 | - try { | |
153 | - entity = getColumnFamilyClass().getConstructor(domain.getClass()).newInstance(domain); | |
154 | - } catch (Exception e) { | |
155 | - log.error("Can't create entity for domain object {}", domain, e); | |
156 | - throw new IllegalArgumentException("Can't create entity for domain object {" + domain + "}", e); | |
157 | - } | |
158 | - entity = updateSearchTextIfPresent(entity); | |
159 | - log.debug("Saving entity {}", entity); | |
160 | - entity = saveWithResult(tenantId, entity).getEntity(); | |
161 | - return DaoUtil.getData(entity); | |
162 | - } | |
163 | - | |
164 | - @Override | |
165 | - public D findById(TenantId tenantId, UUID key) { | |
166 | - log.debug("Get entity by key {}", key); | |
167 | - Select.Where query = select().from(getColumnFamilyName()).where(eq(ModelConstants.ID_PROPERTY, key)); | |
168 | - log.trace("Execute query {}", query); | |
169 | - E entity = findOneByStatement(tenantId, query); | |
170 | - return DaoUtil.getData(entity); | |
171 | - } | |
172 | - | |
173 | - @Override | |
174 | - public ListenableFuture<D> findByIdAsync(TenantId tenantId, UUID key) { | |
175 | - log.debug("Get entity by key {}", key); | |
176 | - Select.Where query = select().from(getColumnFamilyName()).where(eq(ModelConstants.ID_PROPERTY, key)); | |
177 | - log.trace("Execute query {}", query); | |
178 | - return findOneByStatementAsync(tenantId, query); | |
179 | - } | |
180 | - | |
181 | - @Override | |
182 | - public boolean removeById(TenantId tenantId, UUID key) { | |
183 | - Statement delete = QueryBuilder.delete().all().from(getColumnFamilyName()).where(eq(ModelConstants.ID_PROPERTY, key)); | |
184 | - log.debug("Remove request: {}", delete.toString()); | |
185 | - return executeWrite(tenantId, delete).wasApplied(); | |
186 | - } | |
187 | - | |
188 | - @Override | |
189 | - public List<D> find(TenantId tenantId) { | |
190 | - log.debug("Get all entities from column family {}", getColumnFamilyName()); | |
191 | - List<E> entities = findListByStatement(tenantId, QueryBuilder.select().all().from(getColumnFamilyName()).setConsistencyLevel(cluster.getDefaultReadConsistencyLevel())); | |
192 | - return DaoUtil.convertDataList(entities); | |
193 | - } | |
194 | - | |
195 | -} |
dao/src/main/java/org/thingsboard/server/dao/nosql/CassandraAbstractSearchTextDao.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2019 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.dao.nosql; | |
17 | - | |
18 | -import com.datastax.driver.core.querybuilder.Clause; | |
19 | -import com.datastax.driver.core.querybuilder.QueryBuilder; | |
20 | -import com.datastax.driver.core.querybuilder.Select; | |
21 | -import com.datastax.driver.core.querybuilder.Select.Where; | |
22 | -import lombok.extern.slf4j.Slf4j; | |
23 | -import org.apache.commons.lang3.StringUtils; | |
24 | -import org.thingsboard.server.common.data.id.TenantId; | |
25 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
26 | -import org.thingsboard.server.dao.model.ModelConstants; | |
27 | -import org.thingsboard.server.dao.model.SearchTextEntity; | |
28 | - | |
29 | -import java.util.List; | |
30 | - | |
31 | -import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; | |
32 | -import static com.datastax.driver.core.querybuilder.QueryBuilder.select; | |
33 | - | |
34 | -@Slf4j | |
35 | -public abstract class CassandraAbstractSearchTextDao<E extends SearchTextEntity<D>, D> extends CassandraAbstractModelDao<E, D> { | |
36 | - | |
37 | - @Override | |
38 | - protected E updateSearchTextIfPresent(E entity) { | |
39 | - if (entity.getSearchTextSource() != null) { | |
40 | - entity.setSearchText(entity.getSearchTextSource().toLowerCase()); | |
41 | - } else { | |
42 | - log.trace("Entity [{}] has null SearchTextSource", entity); | |
43 | - } | |
44 | - return entity; | |
45 | - } | |
46 | - | |
47 | - protected List<E> findPageWithTextSearch(TenantId tenantId, String searchView, List<Clause> clauses, TextPageLink pageLink) { | |
48 | - Select select = select().from(searchView); | |
49 | - Where query = select.where(); | |
50 | - for (Clause clause : clauses) { | |
51 | - query.and(clause); | |
52 | - } | |
53 | - query.limit(pageLink.getLimit()); | |
54 | - if (!StringUtils.isEmpty(pageLink.getTextOffset())) { | |
55 | - query.and(eq(ModelConstants.SEARCH_TEXT_PROPERTY, pageLink.getTextOffset())); | |
56 | - query.and(QueryBuilder.lt(ModelConstants.ID_PROPERTY, pageLink.getIdOffset())); | |
57 | - List<E> result = findListByStatement(tenantId, query); | |
58 | - if (result.size() < pageLink.getLimit()) { | |
59 | - select = select().from(searchView); | |
60 | - query = select.where(); | |
61 | - for (Clause clause : clauses) { | |
62 | - query.and(clause); | |
63 | - } | |
64 | - query.and(QueryBuilder.gt(ModelConstants.SEARCH_TEXT_PROPERTY, pageLink.getTextOffset())); | |
65 | - if (!StringUtils.isEmpty(pageLink.getTextSearch())) { | |
66 | - query.and(QueryBuilder.lt(ModelConstants.SEARCH_TEXT_PROPERTY, pageLink.getTextSearchBound())); | |
67 | - } | |
68 | - int limit = pageLink.getLimit() - result.size(); | |
69 | - query.limit(limit); | |
70 | - result.addAll(findListByStatement(tenantId, query)); | |
71 | - } | |
72 | - return result; | |
73 | - } else if (!StringUtils.isEmpty(pageLink.getTextSearch())) { | |
74 | - query.and(QueryBuilder.gte(ModelConstants.SEARCH_TEXT_PROPERTY, pageLink.getTextSearch())); | |
75 | - query.and(QueryBuilder.lt(ModelConstants.SEARCH_TEXT_PROPERTY, pageLink.getTextSearchBound())); | |
76 | - return findListByStatement(tenantId, query); | |
77 | - } else { | |
78 | - return findListByStatement(tenantId, query); | |
79 | - } | |
80 | - } | |
81 | - | |
82 | - | |
83 | -} |
dao/src/main/java/org/thingsboard/server/dao/nosql/CassandraAbstractSearchTimeDao.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2019 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.dao.nosql; | |
17 | - | |
18 | -import com.datastax.driver.core.querybuilder.Clause; | |
19 | -import com.datastax.driver.core.querybuilder.Ordering; | |
20 | -import com.datastax.driver.core.querybuilder.QueryBuilder; | |
21 | -import com.datastax.driver.core.querybuilder.Select; | |
22 | -import com.datastax.driver.core.querybuilder.Select.Where; | |
23 | -import com.datastax.driver.core.utils.UUIDs; | |
24 | -import org.thingsboard.server.common.data.id.TenantId; | |
25 | -import org.thingsboard.server.common.data.page.TimePageLink; | |
26 | -import org.thingsboard.server.dao.model.BaseEntity; | |
27 | -import org.thingsboard.server.dao.model.ModelConstants; | |
28 | - | |
29 | -import java.util.ArrayList; | |
30 | -import java.util.Collections; | |
31 | -import java.util.List; | |
32 | -import java.util.UUID; | |
33 | - | |
34 | -import static com.datastax.driver.core.querybuilder.QueryBuilder.select; | |
35 | - | |
36 | -public abstract class CassandraAbstractSearchTimeDao<E extends BaseEntity<D>, D> extends CassandraAbstractModelDao<E, D> { | |
37 | - | |
38 | - | |
39 | - protected List<E> findPageWithTimeSearch(TenantId tenantId, String searchView, List<Clause> clauses, TimePageLink pageLink) { | |
40 | - return findPageWithTimeSearch(tenantId, searchView, clauses, Collections.emptyList(), pageLink); | |
41 | - } | |
42 | - | |
43 | - protected List<E> findPageWithTimeSearch(TenantId tenantId, String searchView, List<Clause> clauses, Ordering ordering, TimePageLink pageLink) { | |
44 | - return findPageWithTimeSearch(tenantId, searchView, clauses, Collections.singletonList(ordering), pageLink); | |
45 | - } | |
46 | - | |
47 | - protected List<E> findPageWithTimeSearch(TenantId tenantId, String searchView, List<Clause> clauses, List<Ordering> topLevelOrderings, TimePageLink pageLink) { | |
48 | - return findPageWithTimeSearch(tenantId, searchView, clauses, topLevelOrderings, pageLink, ModelConstants.ID_PROPERTY); | |
49 | - } | |
50 | - | |
51 | - protected List<E> findPageWithTimeSearch(TenantId tenantId, String searchView, List<Clause> clauses, TimePageLink pageLink, String idColumn) { | |
52 | - return findPageWithTimeSearch(tenantId, searchView, clauses, Collections.emptyList(), pageLink, idColumn); | |
53 | - } | |
54 | - | |
55 | - protected List<E> findPageWithTimeSearch(TenantId tenantId, String searchView, List<Clause> clauses, List<Ordering> topLevelOrderings, TimePageLink pageLink, String idColumn) { | |
56 | - return findListByStatement(tenantId, buildQuery(searchView, clauses, topLevelOrderings, pageLink, idColumn)); | |
57 | - } | |
58 | - | |
59 | - public static Where buildQuery(String searchView, List<Clause> clauses, TimePageLink pageLink, String idColumn) { | |
60 | - return buildQuery(searchView, clauses, Collections.emptyList(), pageLink, idColumn); | |
61 | - } | |
62 | - | |
63 | - public static Where buildQuery(String searchView, List<Clause> clauses, Ordering order, TimePageLink pageLink, String idColumn) { | |
64 | - return buildQuery(searchView, clauses, Collections.singletonList(order), pageLink, idColumn); | |
65 | - } | |
66 | - | |
67 | - public static Where buildQuery(String searchView, List<Clause> clauses, List<Ordering> topLevelOrderings, TimePageLink pageLink, String idColumn) { | |
68 | - Select select = select().from(searchView); | |
69 | - Where query = select.where(); | |
70 | - for (Clause clause : clauses) { | |
71 | - query.and(clause); | |
72 | - } | |
73 | - query.limit(pageLink.getLimit()); | |
74 | - if (pageLink.isAscOrder()) { | |
75 | - if (pageLink.getIdOffset() != null) { | |
76 | - query.and(QueryBuilder.gt(idColumn, pageLink.getIdOffset())); | |
77 | - } else if (pageLink.getStartTime() != null) { | |
78 | - final UUID startOf = UUIDs.startOf(pageLink.getStartTime()); | |
79 | - query.and(QueryBuilder.gte(idColumn, startOf)); | |
80 | - } | |
81 | - if (pageLink.getEndTime() != null) { | |
82 | - final UUID endOf = UUIDs.endOf(pageLink.getEndTime()); | |
83 | - query.and(QueryBuilder.lte(idColumn, endOf)); | |
84 | - } | |
85 | - } else { | |
86 | - if (pageLink.getIdOffset() != null) { | |
87 | - query.and(QueryBuilder.lt(idColumn, pageLink.getIdOffset())); | |
88 | - } else if (pageLink.getEndTime() != null) { | |
89 | - final UUID endOf = UUIDs.endOf(pageLink.getEndTime()); | |
90 | - query.and(QueryBuilder.lte(idColumn, endOf)); | |
91 | - } | |
92 | - if (pageLink.getStartTime() != null) { | |
93 | - final UUID startOf = UUIDs.startOf(pageLink.getStartTime()); | |
94 | - query.and(QueryBuilder.gte(idColumn, startOf)); | |
95 | - } | |
96 | - } | |
97 | - List<Ordering> orderings = new ArrayList<>(topLevelOrderings); | |
98 | - if (pageLink.isAscOrder()) { | |
99 | - orderings.add(QueryBuilder.asc(idColumn)); | |
100 | - } else { | |
101 | - orderings.add(QueryBuilder.desc(idColumn)); | |
102 | - } | |
103 | - query.orderBy(orderings.toArray(new Ordering[orderings.size()])); | |
104 | - return query; | |
105 | - } | |
106 | - | |
107 | -} |
... | ... | @@ -19,6 +19,7 @@ import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import org.thingsboard.server.common.data.EntityType; |
20 | 20 | import org.thingsboard.server.common.data.id.EntityId; |
21 | 21 | import org.thingsboard.server.common.data.id.TenantId; |
22 | +import org.thingsboard.server.common.data.page.PageData; | |
22 | 23 | import org.thingsboard.server.common.data.page.TimePageLink; |
23 | 24 | import org.thingsboard.server.common.data.relation.EntityRelation; |
24 | 25 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
... | ... | @@ -58,6 +59,6 @@ public interface RelationDao { |
58 | 59 | |
59 | 60 | ListenableFuture<Boolean> deleteOutboundRelationsAsync(TenantId tenantId, EntityId entity); |
60 | 61 | |
61 | - ListenableFuture<List<EntityRelation>> findRelations(TenantId tenantId, EntityId from, String relationType, RelationTypeGroup typeGroup, EntityType toType, TimePageLink pageLink); | |
62 | + ListenableFuture<PageData<EntityRelation>> findRelations(TenantId tenantId, EntityId from, String relationType, RelationTypeGroup typeGroup, EntityType toType, TimePageLink pageLink); | |
62 | 63 | |
63 | 64 | } | ... | ... |
... | ... | @@ -27,8 +27,8 @@ import org.thingsboard.server.common.data.id.EntityId; |
27 | 27 | import org.thingsboard.server.common.data.id.RuleChainId; |
28 | 28 | import org.thingsboard.server.common.data.id.RuleNodeId; |
29 | 29 | import org.thingsboard.server.common.data.id.TenantId; |
30 | -import org.thingsboard.server.common.data.page.TextPageData; | |
31 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
30 | +import org.thingsboard.server.common.data.page.PageData; | |
31 | +import org.thingsboard.server.common.data.page.PageLink; | |
32 | 32 | import org.thingsboard.server.common.data.relation.EntityRelation; |
33 | 33 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
34 | 34 | import org.thingsboard.server.common.data.rule.NodeConnectionInfo; |
... | ... | @@ -329,11 +329,10 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC |
329 | 329 | } |
330 | 330 | |
331 | 331 | @Override |
332 | - public TextPageData<RuleChain> findTenantRuleChains(TenantId tenantId, TextPageLink pageLink) { | |
332 | + public PageData<RuleChain> findTenantRuleChains(TenantId tenantId, PageLink pageLink) { | |
333 | 333 | Validator.validateId(tenantId, "Incorrect tenant id for search rule chain request."); |
334 | - Validator.validatePageLink(pageLink, "Incorrect PageLink object for search rule chain request."); | |
335 | - List<RuleChain> ruleChains = ruleChainDao.findRuleChainsByTenantId(tenantId.getId(), pageLink); | |
336 | - return new TextPageData<>(ruleChains, pageLink); | |
334 | + Validator.validatePageLink(pageLink); | |
335 | + return ruleChainDao.findRuleChainsByTenantId(tenantId.getId(), pageLink); | |
337 | 336 | } |
338 | 337 | |
339 | 338 | @Override |
... | ... | @@ -411,7 +410,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC |
411 | 410 | new PaginatedRemover<TenantId, RuleChain>() { |
412 | 411 | |
413 | 412 | @Override |
414 | - protected List<RuleChain> findEntities(TenantId tenantId, TenantId id, TextPageLink pageLink) { | |
413 | + protected PageData<RuleChain> findEntities(TenantId tenantId, TenantId id, PageLink pageLink) { | |
415 | 414 | return ruleChainDao.findRuleChainsByTenantId(id.getId(), pageLink); |
416 | 415 | } |
417 | 416 | ... | ... |
... | ... | @@ -15,7 +15,8 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.dao.rule; |
17 | 17 | |
18 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
18 | +import org.thingsboard.server.common.data.page.PageData; | |
19 | +import org.thingsboard.server.common.data.page.PageLink; | |
19 | 20 | import org.thingsboard.server.common.data.rule.RuleChain; |
20 | 21 | import org.thingsboard.server.dao.Dao; |
21 | 22 | |
... | ... | @@ -34,6 +35,6 @@ public interface RuleChainDao extends Dao<RuleChain> { |
34 | 35 | * @param pageLink the page link |
35 | 36 | * @return the list of rule chain objects |
36 | 37 | */ |
37 | - List<RuleChain> findRuleChainsByTenantId(UUID tenantId, TextPageLink pageLink); | |
38 | + PageData<RuleChain> findRuleChainsByTenantId(UUID tenantId, PageLink pageLink); | |
38 | 39 | |
39 | 40 | } | ... | ... |
... | ... | @@ -17,7 +17,8 @@ package org.thingsboard.server.dao.service; |
17 | 17 | |
18 | 18 | import org.thingsboard.server.common.data.id.IdBased; |
19 | 19 | import org.thingsboard.server.common.data.id.TenantId; |
20 | -import org.thingsboard.server.common.data.page.TextPageLink; | |
20 | +import org.thingsboard.server.common.data.page.PageData; | |
21 | +import org.thingsboard.server.common.data.page.PageLink; | |
21 | 22 | |
22 | 23 | import java.util.List; |
23 | 24 | import java.util.UUID; |
... | ... | @@ -27,23 +28,18 @@ public abstract class PaginatedRemover<I, D extends IdBased<?>> { |
27 | 28 | private static final int DEFAULT_LIMIT = 100; |
28 | 29 | |
29 | 30 | public void removeEntities(TenantId tenantId, I id) { |
30 | - TextPageLink pageLink = new TextPageLink(DEFAULT_LIMIT); | |
31 | + PageLink pageLink = new PageLink(DEFAULT_LIMIT); | |
31 | 32 | boolean hasNext = true; |
32 | 33 | while (hasNext) { |
33 | - List<D> entities = findEntities(tenantId, id, pageLink); | |
34 | - for (D entity : entities) { | |
34 | + PageData<D> entities = findEntities(tenantId, id, pageLink); | |
35 | + for (D entity : entities.getData()) { | |
35 | 36 | removeEntity(tenantId, entity); |
36 | 37 | } |
37 | - hasNext = entities.size() == pageLink.getLimit(); | |
38 | - if (hasNext) { | |
39 | - int index = entities.size() - 1; | |
40 | - UUID idOffset = entities.get(index).getUuidId(); | |
41 | - pageLink.setIdOffset(idOffset); | |
42 | - } | |
38 | + hasNext = entities.hasNext(); | |
43 | 39 | } |
44 | 40 | } |
45 | 41 | |
46 | - protected abstract List<D> findEntities(TenantId tenantId,I id, TextPageLink pageLink); | |
42 | + protected abstract PageData<D> findEntities(TenantId tenantId, I id, PageLink pageLink); | |
47 | 43 | |
48 | 44 | protected abstract void removeEntity(TenantId tenantId, D entity); |
49 | 45 | ... | ... |
... | ... | @@ -17,6 +17,7 @@ package org.thingsboard.server.dao.service; |
17 | 17 | |
18 | 18 | import org.thingsboard.server.common.data.id.IdBased; |
19 | 19 | import org.thingsboard.server.common.data.id.TenantId; |
20 | +import org.thingsboard.server.common.data.page.PageData; | |
20 | 21 | import org.thingsboard.server.common.data.page.TimePageLink; |
21 | 22 | |
22 | 23 | import java.util.List; |
... | ... | @@ -30,20 +31,15 @@ public abstract class TimePaginatedRemover<I, D extends IdBased<?>> { |
30 | 31 | TimePageLink pageLink = new TimePageLink(DEFAULT_LIMIT); |
31 | 32 | boolean hasNext = true; |
32 | 33 | while (hasNext) { |
33 | - List<D> entities = findEntities(tenantId, id, pageLink); | |
34 | - for (D entity : entities) { | |
34 | + PageData<D> entities = findEntities(tenantId, id, pageLink); | |
35 | + for (D entity : entities.getData()) { | |
35 | 36 | removeEntity(tenantId, entity); |
36 | 37 | } |
37 | - hasNext = entities.size() == pageLink.getLimit(); | |
38 | - if (hasNext) { | |
39 | - int index = entities.size() - 1; | |
40 | - UUID idOffset = entities.get(index).getUuidId(); | |
41 | - pageLink.setIdOffset(idOffset); | |
42 | - } | |
38 | + hasNext = entities.hasNext(); | |
43 | 39 | } |
44 | 40 | } |
45 | 41 | |
46 | - protected abstract List<D> findEntities(TenantId tenantId, I id, TimePageLink pageLink); | |
42 | + protected abstract PageData<D> findEntities(TenantId tenantId, I id, TimePageLink pageLink); | |
47 | 43 | |
48 | 44 | protected abstract void removeEntity(TenantId tenantId, D entity); |
49 | 45 | ... | ... |
... | ... | @@ -17,7 +17,7 @@ package org.thingsboard.server.dao.service; |
17 | 17 | |
18 | 18 | import org.thingsboard.server.common.data.id.EntityId; |
19 | 19 | import org.thingsboard.server.common.data.id.UUIDBased; |
20 | -import org.thingsboard.server.common.data.page.BasePageLink; | |
20 | +import org.thingsboard.server.common.data.page.PageLink; | |
21 | 21 | import org.thingsboard.server.dao.exception.IncorrectParameterException; |
22 | 22 | |
23 | 23 | import java.util.List; |
... | ... | @@ -116,9 +116,13 @@ public class Validator { |
116 | 116 | * @param pageLink the page link |
117 | 117 | * @param errorMessage the error message for exception |
118 | 118 | */ |
119 | - public static void validatePageLink(BasePageLink pageLink, String errorMessage) { | |
120 | - if (pageLink == null || pageLink.getLimit() < 1 || (pageLink.getIdOffset() != null && pageLink.getIdOffset().version() != 1)) { | |
121 | - throw new IncorrectParameterException(errorMessage); | |
119 | + public static void validatePageLink(PageLink pageLink) { | |
120 | + if (pageLink == null) { | |
121 | + throw new IncorrectParameterException("Page link must be specified."); | |
122 | + } else if (pageLink.getPageSize() < 1) { | |
123 | + throw new IncorrectParameterException("Incorrect page link page size '"+pageLink.getPageSize()+"'. Page size must be greater than zero."); | |
124 | + } else if (pageLink.getPage() < 0) { | |
125 | + throw new IncorrectParameterException("Incorrect page link page '"+pageLink.getPage()+"'. Page must be positive integer."); | |
122 | 126 | } |
123 | 127 | } |
124 | 128 | ... | ... |
... | ... | @@ -38,51 +38,19 @@ public abstract class JpaAbstractSearchTimeDao<E extends BaseEntity<D>, D> exten |
38 | 38 | return new Specification<T>() { |
39 | 39 | @Override |
40 | 40 | public Predicate toPredicate(Root<T> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) { |
41 | - List<Predicate> predicates; | |
42 | - if (pageLink.isAscOrder()) { | |
43 | - predicates = createAscPredicates(pageLink, idColumn, root, criteriaBuilder); | |
44 | - } else { | |
45 | - predicates = createDescPredicates(pageLink, idColumn, root, criteriaBuilder); | |
41 | + List<Predicate> predicates = new ArrayList<>(); | |
42 | + if (pageLink.getStartTime() != null) { | |
43 | + UUID startOf = UUIDs.startOf(pageLink.getStartTime()); | |
44 | + Predicate lowerBound = criteriaBuilder.greaterThanOrEqualTo(root.get(idColumn), UUIDConverter.fromTimeUUID(startOf)); | |
45 | + predicates.add(lowerBound); | |
46 | + } | |
47 | + if (pageLink.getEndTime() != null) { | |
48 | + UUID endOf = UUIDs.endOf(pageLink.getEndTime()); | |
49 | + Predicate upperBound = criteriaBuilder.lessThanOrEqualTo(root.get(idColumn), UUIDConverter.fromTimeUUID(endOf)); | |
50 | + predicates.add(upperBound); | |
46 | 51 | } |
47 | 52 | return criteriaBuilder.and(predicates.toArray(new Predicate[0])); |
48 | 53 | } |
49 | 54 | }; |
50 | 55 | } |
51 | - | |
52 | - private static <T> List<Predicate> createAscPredicates(TimePageLink pageLink, String idColumn, Root<T> root, CriteriaBuilder criteriaBuilder) { | |
53 | - List<Predicate> predicates = new ArrayList<>(); | |
54 | - if (pageLink.getIdOffset() != null) { | |
55 | - Predicate lowerBound = criteriaBuilder.greaterThan(root.get(idColumn), UUIDConverter.fromTimeUUID(pageLink.getIdOffset())); | |
56 | - predicates.add(lowerBound); | |
57 | - } else if (pageLink.getStartTime() != null) { | |
58 | - UUID startOf = UUIDs.startOf(pageLink.getStartTime()); | |
59 | - Predicate lowerBound = criteriaBuilder.greaterThanOrEqualTo(root.get(idColumn), UUIDConverter.fromTimeUUID(startOf)); | |
60 | - predicates.add(lowerBound); | |
61 | - } | |
62 | - if (pageLink.getEndTime() != null) { | |
63 | - UUID endOf = UUIDs.endOf(pageLink.getEndTime()); | |
64 | - Predicate upperBound = criteriaBuilder.lessThanOrEqualTo(root.get(idColumn), UUIDConverter.fromTimeUUID(endOf)); | |
65 | - predicates.add(upperBound); | |
66 | - } | |
67 | - return predicates; | |
68 | - } | |
69 | - | |
70 | - private static <T> List<Predicate> createDescPredicates(TimePageLink pageLink, String idColumn, Root<T> root, CriteriaBuilder criteriaBuilder) { | |
71 | - List<Predicate> predicates = new ArrayList<>(); | |
72 | - if (pageLink.getIdOffset() != null) { | |
73 | - Predicate lowerBound = criteriaBuilder.lessThan(root.get(idColumn), UUIDConverter.fromTimeUUID(pageLink.getIdOffset())); | |
74 | - predicates.add(lowerBound); | |
75 | - } else if (pageLink.getEndTime() != null) { | |
76 | - UUID endOf = UUIDs.endOf(pageLink.getEndTime()); | |
77 | - Predicate lowerBound = criteriaBuilder.lessThanOrEqualTo(root.get(idColumn), UUIDConverter.fromTimeUUID(endOf)); | |
78 | - predicates.add(lowerBound); | |
79 | - } | |
80 | - if (pageLink.getStartTime() != null) { | |
81 | - UUID startOf = UUIDs.startOf(pageLink.getStartTime()); | |
82 | - Predicate upperBound = criteriaBuilder.greaterThanOrEqualTo(root.get(idColumn), UUIDConverter.fromTimeUUID(startOf)); | |
83 | - predicates.add(upperBound); | |
84 | - } | |
85 | - return predicates; | |
86 | - } | |
87 | - | |
88 | 56 | } | ... | ... |
... | ... | @@ -30,6 +30,7 @@ import org.thingsboard.server.common.data.alarm.AlarmQuery; |
30 | 30 | import org.thingsboard.server.common.data.alarm.AlarmSearchStatus; |
31 | 31 | import org.thingsboard.server.common.data.id.EntityId; |
32 | 32 | import org.thingsboard.server.common.data.id.TenantId; |
33 | +import org.thingsboard.server.common.data.page.PageData; | |
33 | 34 | import org.thingsboard.server.common.data.relation.EntityRelation; |
34 | 35 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
35 | 36 | import org.thingsboard.server.dao.DaoUtil; |
... | ... | @@ -92,7 +93,7 @@ public class JpaAlarmDao extends JpaAbstractDao<AlarmEntity, Alarm> implements A |
92 | 93 | } |
93 | 94 | |
94 | 95 | @Override |
95 | - public ListenableFuture<List<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query) { | |
96 | + public ListenableFuture<PageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query) { | |
96 | 97 | log.trace("Try to find alarms by entity [{}], status [{}] and pageLink [{}]", query.getAffectedEntityId(), query.getStatus(), query.getPageLink()); |
97 | 98 | EntityId affectedEntity = query.getAffectedEntityId(); |
98 | 99 | String searchStatusName; |
... | ... | @@ -104,15 +105,17 @@ public class JpaAlarmDao extends JpaAbstractDao<AlarmEntity, Alarm> implements A |
104 | 105 | searchStatusName = query.getStatus().name(); |
105 | 106 | } |
106 | 107 | String relationType = BaseAlarmService.ALARM_RELATION_PREFIX + searchStatusName; |
107 | - ListenableFuture<List<EntityRelation>> relations = relationDao.findRelations(tenantId, affectedEntity, relationType, RelationTypeGroup.ALARM, EntityType.ALARM, query.getPageLink()); | |
108 | + ListenableFuture<PageData<EntityRelation>> relations = relationDao.findRelations(tenantId, affectedEntity, relationType, RelationTypeGroup.ALARM, EntityType.ALARM, query.getPageLink()); | |
108 | 109 | return Futures.transformAsync(relations, input -> { |
109 | - List<ListenableFuture<AlarmInfo>> alarmFutures = new ArrayList<>(input.size()); | |
110 | - for (EntityRelation relation : input) { | |
110 | + List<ListenableFuture<AlarmInfo>> alarmFutures = new ArrayList<>(input.getData().size()); | |
111 | + for (EntityRelation relation : input.getData()) { | |
111 | 112 | alarmFutures.add(Futures.transform( |
112 | 113 | findAlarmByIdAsync(tenantId, relation.getTo().getId()), |
113 | 114 | AlarmInfo::new)); |
114 | 115 | } |
115 | - return Futures.successfulAsList(alarmFutures); | |
116 | + return Futures.transform(Futures.successfulAsList(alarmFutures), alarmInfos -> { | |
117 | + return new PageData(alarmInfos, input.getTotalPages(), input.getTotalElements(), input.hasNext()); | |
118 | + }); | |
116 | 119 | }); |
117 | 120 | } |
118 | 121 | } | ... | ... |