Commit a670b77251f09e6d4b9c9aa197cf0e8a64ac916a
Committed by
Andrew Shvayka
1 parent
4c3d6a3c
refactored and improvement Rest Client
Showing
1 changed file
with
268 additions
and
281 deletions
@@ -45,10 +45,14 @@ import org.thingsboard.server.common.data.Tenant; | @@ -45,10 +45,14 @@ import org.thingsboard.server.common.data.Tenant; | ||
45 | import org.thingsboard.server.common.data.UpdateMessage; | 45 | import org.thingsboard.server.common.data.UpdateMessage; |
46 | import org.thingsboard.server.common.data.User; | 46 | import org.thingsboard.server.common.data.User; |
47 | import org.thingsboard.server.common.data.alarm.Alarm; | 47 | import org.thingsboard.server.common.data.alarm.Alarm; |
48 | +import org.thingsboard.server.common.data.alarm.AlarmId; | ||
48 | import org.thingsboard.server.common.data.alarm.AlarmInfo; | 49 | import org.thingsboard.server.common.data.alarm.AlarmInfo; |
50 | +import org.thingsboard.server.common.data.alarm.AlarmSearchStatus; | ||
49 | import org.thingsboard.server.common.data.alarm.AlarmSeverity; | 51 | import org.thingsboard.server.common.data.alarm.AlarmSeverity; |
52 | +import org.thingsboard.server.common.data.alarm.AlarmStatus; | ||
50 | import org.thingsboard.server.common.data.asset.Asset; | 53 | import org.thingsboard.server.common.data.asset.Asset; |
51 | import org.thingsboard.server.common.data.asset.AssetSearchQuery; | 54 | import org.thingsboard.server.common.data.asset.AssetSearchQuery; |
55 | +import org.thingsboard.server.common.data.audit.ActionType; | ||
52 | import org.thingsboard.server.common.data.audit.AuditLog; | 56 | import org.thingsboard.server.common.data.audit.AuditLog; |
53 | import org.thingsboard.server.common.data.device.DeviceSearchQuery; | 57 | import org.thingsboard.server.common.data.device.DeviceSearchQuery; |
54 | import org.thingsboard.server.common.data.entityview.EntityViewSearchQuery; | 58 | import org.thingsboard.server.common.data.entityview.EntityViewSearchQuery; |
@@ -57,6 +61,14 @@ import org.thingsboard.server.common.data.id.CustomerId; | @@ -57,6 +61,14 @@ import org.thingsboard.server.common.data.id.CustomerId; | ||
57 | import org.thingsboard.server.common.data.id.DashboardId; | 61 | import org.thingsboard.server.common.data.id.DashboardId; |
58 | import org.thingsboard.server.common.data.id.DeviceId; | 62 | import org.thingsboard.server.common.data.id.DeviceId; |
59 | import org.thingsboard.server.common.data.id.EntityId; | 63 | import org.thingsboard.server.common.data.id.EntityId; |
64 | +import org.thingsboard.server.common.data.id.EntityViewId; | ||
65 | +import org.thingsboard.server.common.data.id.RuleChainId; | ||
66 | +import org.thingsboard.server.common.data.id.RuleNodeId; | ||
67 | +import org.thingsboard.server.common.data.id.TenantId; | ||
68 | +import org.thingsboard.server.common.data.id.UserId; | ||
69 | +import org.thingsboard.server.common.data.id.WidgetTypeId; | ||
70 | +import org.thingsboard.server.common.data.id.WidgetsBundleId; | ||
71 | +import org.thingsboard.server.common.data.kv.Aggregation; | ||
60 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; | 72 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
61 | import org.thingsboard.server.common.data.kv.TsKvEntry; | 73 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
62 | import org.thingsboard.server.common.data.page.TextPageData; | 74 | import org.thingsboard.server.common.data.page.TextPageData; |
@@ -64,9 +76,11 @@ import org.thingsboard.server.common.data.page.TextPageLink; | @@ -64,9 +76,11 @@ import org.thingsboard.server.common.data.page.TextPageLink; | ||
64 | import org.thingsboard.server.common.data.page.TimePageData; | 76 | import org.thingsboard.server.common.data.page.TimePageData; |
65 | import org.thingsboard.server.common.data.page.TimePageLink; | 77 | import org.thingsboard.server.common.data.page.TimePageLink; |
66 | import org.thingsboard.server.common.data.plugin.ComponentDescriptor; | 78 | import org.thingsboard.server.common.data.plugin.ComponentDescriptor; |
79 | +import org.thingsboard.server.common.data.plugin.ComponentType; | ||
67 | import org.thingsboard.server.common.data.relation.EntityRelation; | 80 | import org.thingsboard.server.common.data.relation.EntityRelation; |
68 | import org.thingsboard.server.common.data.relation.EntityRelationInfo; | 81 | import org.thingsboard.server.common.data.relation.EntityRelationInfo; |
69 | import org.thingsboard.server.common.data.relation.EntityRelationsQuery; | 82 | import org.thingsboard.server.common.data.relation.EntityRelationsQuery; |
83 | +import org.thingsboard.server.common.data.relation.RelationTypeGroup; | ||
70 | import org.thingsboard.server.common.data.rule.RuleChain; | 84 | import org.thingsboard.server.common.data.rule.RuleChain; |
71 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; | 85 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; |
72 | import org.thingsboard.server.common.data.security.DeviceCredentials; | 86 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
@@ -87,6 +101,7 @@ import java.util.Optional; | @@ -87,6 +101,7 @@ import java.util.Optional; | ||
87 | import java.util.concurrent.ExecutorService; | 101 | import java.util.concurrent.ExecutorService; |
88 | import java.util.concurrent.Executors; | 102 | import java.util.concurrent.Executors; |
89 | import java.util.concurrent.Future; | 103 | import java.util.concurrent.Future; |
104 | +import java.util.stream.Collectors; | ||
90 | 105 | ||
91 | import static org.springframework.util.StringUtils.isEmpty; | 106 | import static org.springframework.util.StringUtils.isEmpty; |
92 | 107 | ||
@@ -106,8 +121,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -106,8 +121,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
106 | protected static final String ACTIVATE_TOKEN_REGEX = "/api/noauth/activate?activateToken="; | 121 | protected static final String ACTIVATE_TOKEN_REGEX = "/api/noauth/activate?activateToken="; |
107 | 122 | ||
108 | public RestClient(String baseURL) { | 123 | public RestClient(String baseURL) { |
109 | - this.restTemplate = new RestTemplate(); | ||
110 | - this.baseURL = baseURL; | 124 | + this(new RestTemplate(), baseURL); |
111 | } | 125 | } |
112 | 126 | ||
113 | public RestClient(RestTemplate restTemplate, String baseURL) { | 127 | public RestClient(RestTemplate restTemplate, String baseURL) { |
@@ -279,18 +293,6 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -279,18 +293,6 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
279 | return restTemplate.postForEntity(baseURL + "/api/alarm", alarm, Alarm.class).getBody(); | 293 | return restTemplate.postForEntity(baseURL + "/api/alarm", alarm, Alarm.class).getBody(); |
280 | } | 294 | } |
281 | 295 | ||
282 | - public void deleteCustomer(CustomerId customerId) { | ||
283 | - restTemplate.delete(baseURL + "/api/customer/{customerId}", customerId); | ||
284 | - } | ||
285 | - | ||
286 | - public void deleteDevice(DeviceId deviceId) { | ||
287 | - restTemplate.delete(baseURL + "/api/device/{deviceId}", deviceId); | ||
288 | - } | ||
289 | - | ||
290 | - public void deleteAsset(AssetId assetId) { | ||
291 | - restTemplate.delete(baseURL + "/api/asset/{assetId}", assetId); | ||
292 | - } | ||
293 | - | ||
294 | public Device assignDevice(CustomerId customerId, DeviceId deviceId) { | 296 | public Device assignDevice(CustomerId customerId, DeviceId deviceId) { |
295 | return restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/device/{deviceId}", null, Device.class, | 297 | return restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/device/{deviceId}", null, Device.class, |
296 | customerId.toString(), deviceId.toString()).getBody(); | 298 | customerId.toString(), deviceId.toString()).getBody(); |
@@ -313,10 +315,6 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -313,10 +315,6 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
313 | return restTemplate.postForEntity(baseURL + "/api/dashboard", dashboard, Dashboard.class).getBody(); | 315 | return restTemplate.postForEntity(baseURL + "/api/dashboard", dashboard, Dashboard.class).getBody(); |
314 | } | 316 | } |
315 | 317 | ||
316 | - public void deleteDashboard(DashboardId dashboardId) { | ||
317 | - restTemplate.delete(baseURL + "/api/dashboard/{dashboardId}", dashboardId); | ||
318 | - } | ||
319 | - | ||
320 | public List<DashboardInfo> findTenantDashboards() { | 318 | public List<DashboardInfo> findTenantDashboards() { |
321 | try { | 319 | try { |
322 | ResponseEntity<TextPageData<DashboardInfo>> dashboards = | 320 | ResponseEntity<TextPageData<DashboardInfo>> dashboards = |
@@ -391,9 +389,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -391,9 +389,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
391 | } | 389 | } |
392 | } | 390 | } |
393 | 391 | ||
394 | - public Optional<Alarm> getAlarmById(String alarmId) { | 392 | + public Optional<Alarm> getAlarmById(AlarmId alarmId) { |
395 | try { | 393 | try { |
396 | - ResponseEntity<Alarm> alarm = restTemplate.getForEntity(baseURL + "/api/alarm/{alarmId}", Alarm.class, alarmId); | 394 | + ResponseEntity<Alarm> alarm = restTemplate.getForEntity(baseURL + "/api/alarm/{alarmId}", Alarm.class, alarmId.getId()); |
397 | return Optional.ofNullable(alarm.getBody()); | 395 | return Optional.ofNullable(alarm.getBody()); |
398 | } catch (HttpClientErrorException exception) { | 396 | } catch (HttpClientErrorException exception) { |
399 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 397 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -404,9 +402,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -404,9 +402,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
404 | } | 402 | } |
405 | } | 403 | } |
406 | 404 | ||
407 | - public Optional<AlarmInfo> getAlarmInfoById(String alarmId) { | 405 | + public Optional<AlarmInfo> getAlarmInfoById(AlarmId alarmId) { |
408 | try { | 406 | try { |
409 | - ResponseEntity<AlarmInfo> alarmInfo = restTemplate.getForEntity(baseURL + "/api/alarm/info/{alarmId}", AlarmInfo.class, alarmId); | 407 | + ResponseEntity<AlarmInfo> alarmInfo = restTemplate.getForEntity(baseURL + "/api/alarm/info/{alarmId}", AlarmInfo.class, alarmId.getId()); |
410 | return Optional.ofNullable(alarmInfo.getBody()); | 408 | return Optional.ofNullable(alarmInfo.getBody()); |
411 | } catch (HttpClientErrorException exception) { | 409 | } catch (HttpClientErrorException exception) { |
412 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 410 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -421,70 +419,42 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -421,70 +419,42 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
421 | return restTemplate.postForEntity(baseURL + "/api/alarm", alarm, Alarm.class).getBody(); | 419 | return restTemplate.postForEntity(baseURL + "/api/alarm", alarm, Alarm.class).getBody(); |
422 | } | 420 | } |
423 | 421 | ||
424 | - public void deleteAlarm(String alarmId) { | ||
425 | - restTemplate.delete(baseURL + "/api/alarm/{alarmId}", alarmId); | 422 | + public void deleteAlarm(AlarmId alarmId) { |
423 | + restTemplate.delete(baseURL + "/api/alarm/{alarmId}", alarmId.getId()); | ||
426 | } | 424 | } |
427 | 425 | ||
428 | - public void ackAlarm(String alarmId) { | ||
429 | - restTemplate.postForLocation(baseURL + "/api/alarm/{alarmId}/ack", null, alarmId); | 426 | + public void ackAlarm(AlarmId alarmId) { |
427 | + restTemplate.postForLocation(baseURL + "/api/alarm/{alarmId}/ack", null, alarmId.getId()); | ||
430 | } | 428 | } |
431 | 429 | ||
432 | - public void clearAlarm(String alarmId) { | ||
433 | - restTemplate.postForLocation(baseURL + "/api/alarm/{alarmId}/clear", null, alarmId); | 430 | + public void clearAlarm(AlarmId alarmId) { |
431 | + restTemplate.postForLocation(baseURL + "/api/alarm/{alarmId}/clear", null, alarmId.getId()); | ||
434 | } | 432 | } |
435 | 433 | ||
436 | - public TimePageData<AlarmInfo> getAlarms(EntityId entityId, String searchStatus, String status, TimePageLink pageLink, Boolean fetchOriginator) { | 434 | + public TimePageData<AlarmInfo> getAlarms(EntityId entityId, AlarmSearchStatus searchStatus, AlarmStatus status, TimePageLink pageLink, Boolean fetchOriginator) { |
437 | Map<String, String> params = new HashMap<>(); | 435 | Map<String, String> params = new HashMap<>(); |
438 | params.put("entityType", entityId.getEntityType().name()); | 436 | params.put("entityType", entityId.getEntityType().name()); |
439 | params.put("entityId", entityId.getId().toString()); | 437 | params.put("entityId", entityId.getId().toString()); |
440 | - params.put("searchStatus", searchStatus); | ||
441 | - params.put("status", status); | 438 | + params.put("searchStatus", searchStatus.name()); |
439 | + params.put("status", status.name()); | ||
442 | params.put("fetchOriginator", String.valueOf(fetchOriginator)); | 440 | params.put("fetchOriginator", String.valueOf(fetchOriginator)); |
443 | addPageLinkToParam(params, pageLink); | 441 | addPageLinkToParam(params, pageLink); |
444 | 442 | ||
445 | - String urlParams = getUrlParams(pageLink); | ||
446 | return restTemplate.exchange( | 443 | return restTemplate.exchange( |
447 | baseURL + "/api/alarm/{entityType}/{entityId}?searchStatus={searchStatus}&status={status}&fetchOriginator={fetchOriginator}&" + getUrlParams(pageLink), | 444 | baseURL + "/api/alarm/{entityType}/{entityId}?searchStatus={searchStatus}&status={status}&fetchOriginator={fetchOriginator}&" + getUrlParams(pageLink), |
448 | HttpMethod.GET, | 445 | HttpMethod.GET, |
449 | HttpEntity.EMPTY, | 446 | HttpEntity.EMPTY, |
450 | new ParameterizedTypeReference<TimePageData<AlarmInfo>>() { | 447 | new ParameterizedTypeReference<TimePageData<AlarmInfo>>() { |
451 | - }, params).getBody(); | ||
452 | - } | ||
453 | - | ||
454 | - private String getUrlParams(TimePageLink pageLink) { | ||
455 | - String urlParams = "limit={limit}&ascOrder={ascOrder}"; | ||
456 | - if (pageLink.getStartTime() != null) { | ||
457 | - urlParams += "&startTime={startTime}"; | ||
458 | - } | ||
459 | - if (pageLink.getEndTime() != null) { | ||
460 | - urlParams += "&endTime={endTime}"; | ||
461 | - } | ||
462 | - if (pageLink.getIdOffset() != null) { | ||
463 | - urlParams += "&offset={offset}"; | ||
464 | - } | ||
465 | - return urlParams; | ||
466 | - } | ||
467 | - | ||
468 | - private String getUrlParams(TextPageLink pageLink) { | ||
469 | - String urlParams = "limit={limit}"; | ||
470 | - if (!isEmpty(pageLink.getTextSearch())) { | ||
471 | - urlParams += "&textSearch={textSearch}"; | ||
472 | - } | ||
473 | - if (!isEmpty(pageLink.getIdOffset())) { | ||
474 | - urlParams += "&idOffset={idOffset}"; | ||
475 | - } | ||
476 | - if (!isEmpty(pageLink.getTextOffset())) { | ||
477 | - urlParams += "&textOffset={textOffset}"; | ||
478 | - } | ||
479 | - return urlParams; | 448 | + }, |
449 | + params).getBody(); | ||
480 | } | 450 | } |
481 | 451 | ||
482 | - public Optional<AlarmSeverity> getHighestAlarmSeverity(EntityId entityId, String searchStatus, String status) { | 452 | + public Optional<AlarmSeverity> getHighestAlarmSeverity(EntityId entityId, AlarmSearchStatus searchStatus, AlarmStatus status) { |
483 | Map<String, String> params = new HashMap<>(); | 453 | Map<String, String> params = new HashMap<>(); |
484 | params.put("entityType", entityId.getEntityType().name()); | 454 | params.put("entityType", entityId.getEntityType().name()); |
485 | params.put("entityId", entityId.getId().toString()); | 455 | params.put("entityId", entityId.getId().toString()); |
486 | - params.put("searchStatus", searchStatus); | ||
487 | - params.put("status", status); | 456 | + params.put("searchStatus", searchStatus.name()); |
457 | + params.put("status", status.name()); | ||
488 | try { | 458 | try { |
489 | ResponseEntity<AlarmSeverity> alarmSeverity = restTemplate.getForEntity(baseURL + "/api/alarm/highestSeverity/{entityType}/{entityId}?searchStatus={searchStatus}&status={status}", AlarmSeverity.class, params); | 459 | ResponseEntity<AlarmSeverity> alarmSeverity = restTemplate.getForEntity(baseURL + "/api/alarm/highestSeverity/{entityType}/{entityId}?searchStatus={searchStatus}&status={status}", AlarmSeverity.class, params); |
490 | return Optional.ofNullable(alarmSeverity.getBody()); | 460 | return Optional.ofNullable(alarmSeverity.getBody()); |
@@ -497,9 +467,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -497,9 +467,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
497 | } | 467 | } |
498 | } | 468 | } |
499 | 469 | ||
500 | - public Optional<Asset> getAssetById(String assetId) { | 470 | + public Optional<Asset> getAssetById(AssetId assetId) { |
501 | try { | 471 | try { |
502 | - ResponseEntity<Asset> asset = restTemplate.getForEntity(baseURL + "/api/asset/{assetId}", Asset.class, assetId); | 472 | + ResponseEntity<Asset> asset = restTemplate.getForEntity(baseURL + "/api/asset/{assetId}", Asset.class, assetId.getId()); |
503 | return Optional.ofNullable(asset.getBody()); | 473 | return Optional.ofNullable(asset.getBody()); |
504 | } catch (HttpClientErrorException exception) { | 474 | } catch (HttpClientErrorException exception) { |
505 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 475 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -514,15 +484,14 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -514,15 +484,14 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
514 | return restTemplate.postForEntity(baseURL + "/api/asset", asset, Asset.class).getBody(); | 484 | return restTemplate.postForEntity(baseURL + "/api/asset", asset, Asset.class).getBody(); |
515 | } | 485 | } |
516 | 486 | ||
517 | - public void deleteAsset(String assetId) { | ||
518 | - restTemplate.delete(baseURL + "/api/asset/{assetId}", assetId); | 487 | + public void deleteAsset(AssetId assetId) { |
488 | + restTemplate.delete(baseURL + "/api/asset/{assetId}", assetId.getId()); | ||
519 | } | 489 | } |
520 | 490 | ||
521 | - public Optional<Asset> assignAssetToCustomer(String customerId, | ||
522 | - String assetId) { | 491 | + public Optional<Asset> assignAssetToCustomer(CustomerId customerId, AssetId assetId) { |
523 | Map<String, String> params = new HashMap<>(); | 492 | Map<String, String> params = new HashMap<>(); |
524 | - params.put("customerId", customerId); | ||
525 | - params.put("assetId", assetId); | 493 | + params.put("customerId", customerId.getId().toString()); |
494 | + params.put("assetId", assetId.getId().toString()); | ||
526 | 495 | ||
527 | try { | 496 | try { |
528 | ResponseEntity<Asset> asset = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/asset/{assetId}", null, Asset.class, params); | 497 | ResponseEntity<Asset> asset = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/asset/{assetId}", null, Asset.class, params); |
@@ -536,9 +505,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -536,9 +505,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
536 | } | 505 | } |
537 | } | 506 | } |
538 | 507 | ||
539 | - public Optional<Asset> unassignAssetFromCustomer(String assetId) { | 508 | + public Optional<Asset> unassignAssetFromCustomer(AssetId assetId) { |
540 | try { | 509 | try { |
541 | - ResponseEntity<Asset> asset = restTemplate.exchange(baseURL + "/api/customer/asset/{assetId}", HttpMethod.DELETE, HttpEntity.EMPTY, Asset.class, assetId); | 510 | + ResponseEntity<Asset> asset = restTemplate.exchange(baseURL + "/api/customer/asset/{assetId}", HttpMethod.DELETE, HttpEntity.EMPTY, Asset.class, assetId.getId()); |
542 | return Optional.ofNullable(asset.getBody()); | 511 | return Optional.ofNullable(asset.getBody()); |
543 | } catch (HttpClientErrorException exception) { | 512 | } catch (HttpClientErrorException exception) { |
544 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 513 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -549,9 +518,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -549,9 +518,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
549 | } | 518 | } |
550 | } | 519 | } |
551 | 520 | ||
552 | - public Optional<Asset> assignAssetToPublicCustomer(String assetId) { | 521 | + public Optional<Asset> assignAssetToPublicCustomer(AssetId assetId) { |
553 | try { | 522 | try { |
554 | - ResponseEntity<Asset> asset = restTemplate.postForEntity(baseURL + "/api/customer/public/asset/{assetId}", null, Asset.class, assetId); | 523 | + ResponseEntity<Asset> asset = restTemplate.postForEntity(baseURL + "/api/customer/public/asset/{assetId}", null, Asset.class, assetId.getId()); |
555 | return Optional.ofNullable(asset.getBody()); | 524 | return Optional.ofNullable(asset.getBody()); |
556 | } catch (HttpClientErrorException exception) { | 525 | } catch (HttpClientErrorException exception) { |
557 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 526 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -562,9 +531,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -562,9 +531,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
562 | } | 531 | } |
563 | } | 532 | } |
564 | 533 | ||
565 | - public TextPageData<Asset> getTenantAssets(TextPageLink pageLink, String type) { | 534 | + public TextPageData<Asset> getTenantAssets(TextPageLink pageLink, String assetType) { |
566 | Map<String, String> params = new HashMap<>(); | 535 | Map<String, String> params = new HashMap<>(); |
567 | - params.put("type", type); | 536 | + params.put("type", assetType); |
568 | addPageLinkToParam(params, pageLink); | 537 | addPageLinkToParam(params, pageLink); |
569 | 538 | ||
570 | ResponseEntity<TextPageData<Asset>> assets = restTemplate.exchange( | 539 | ResponseEntity<TextPageData<Asset>> assets = restTemplate.exchange( |
@@ -589,10 +558,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -589,10 +558,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
589 | } | 558 | } |
590 | } | 559 | } |
591 | 560 | ||
592 | - public TextPageData<Asset> getCustomerAssets(String customerId, TextPageLink pageLink, String type) { | 561 | + public TextPageData<Asset> getCustomerAssets(CustomerId customerId, TextPageLink pageLink, String assetType) { |
593 | Map<String, String> params = new HashMap<>(); | 562 | Map<String, String> params = new HashMap<>(); |
594 | - params.put("customerId", customerId); | ||
595 | - params.put("type", type); | 563 | + params.put("customerId", customerId.getId().toString()); |
564 | + params.put("type", assetType); | ||
596 | addPageLinkToParam(params, pageLink); | 565 | addPageLinkToParam(params, pageLink); |
597 | 566 | ||
598 | ResponseEntity<TextPageData<Asset>> assets = restTemplate.exchange( | 567 | ResponseEntity<TextPageData<Asset>> assets = restTemplate.exchange( |
@@ -605,14 +574,15 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -605,14 +574,15 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
605 | return assets.getBody(); | 574 | return assets.getBody(); |
606 | } | 575 | } |
607 | 576 | ||
608 | - public List<Asset> getAssetsByIds(List<String> assetIds) { | 577 | + public List<Asset> getAssetsByIds(List<AssetId> assetIds) { |
609 | return restTemplate.exchange( | 578 | return restTemplate.exchange( |
610 | baseURL + "/api/assets?assetIds={assetIds}", | 579 | baseURL + "/api/assets?assetIds={assetIds}", |
611 | HttpMethod.GET, | 580 | HttpMethod.GET, |
612 | HttpEntity.EMPTY, | 581 | HttpEntity.EMPTY, |
613 | new ParameterizedTypeReference<List<Asset>>() { | 582 | new ParameterizedTypeReference<List<Asset>>() { |
614 | }, | 583 | }, |
615 | - listToString(assetIds)).getBody(); | 584 | + listIdsToString(assetIds)) |
585 | + .getBody(); | ||
616 | } | 586 | } |
617 | 587 | ||
618 | public List<Asset> findByQuery(AssetSearchQuery query) { | 588 | public List<Asset> findByQuery(AssetSearchQuery query) { |
@@ -633,10 +603,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -633,10 +603,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
633 | }).getBody(); | 603 | }).getBody(); |
634 | } | 604 | } |
635 | 605 | ||
636 | - public TimePageData<AuditLog> getAuditLogsByCustomerId(String customerId, TimePageLink pageLink, String actionTypes) { | 606 | + public TimePageData<AuditLog> getAuditLogsByCustomerId(CustomerId customerId, TimePageLink pageLink, List<ActionType> actionTypes) { |
637 | Map<String, String> params = new HashMap<>(); | 607 | Map<String, String> params = new HashMap<>(); |
638 | - params.put("customerId", customerId); | ||
639 | - params.put("actionTypes", actionTypes); | 608 | + params.put("customerId", customerId.getId().toString()); |
609 | + params.put("actionTypes", listEnumToString(actionTypes)); | ||
640 | addPageLinkToParam(params, pageLink); | 610 | addPageLinkToParam(params, pageLink); |
641 | 611 | ||
642 | ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( | 612 | ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( |
@@ -649,10 +619,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -649,10 +619,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
649 | return auditLog.getBody(); | 619 | return auditLog.getBody(); |
650 | } | 620 | } |
651 | 621 | ||
652 | - public TimePageData<AuditLog> getAuditLogsByUserId(String userId, TimePageLink pageLink, String actionTypes) { | 622 | + public TimePageData<AuditLog> getAuditLogsByUserId(UserId userId, TimePageLink pageLink, List<ActionType> actionTypes) { |
653 | Map<String, String> params = new HashMap<>(); | 623 | Map<String, String> params = new HashMap<>(); |
654 | - params.put("userId", userId); | ||
655 | - params.put("actionTypes", actionTypes); | 624 | + params.put("userId", userId.getId().toString()); |
625 | + params.put("actionTypes", listEnumToString(actionTypes)); | ||
656 | addPageLinkToParam(params, pageLink); | 626 | addPageLinkToParam(params, pageLink); |
657 | 627 | ||
658 | ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( | 628 | ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( |
@@ -665,11 +635,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -665,11 +635,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
665 | return auditLog.getBody(); | 635 | return auditLog.getBody(); |
666 | } | 636 | } |
667 | 637 | ||
668 | - public TimePageData<AuditLog> getAuditLogsByEntityId(EntityId entityId, String actionTypes, TimePageLink pageLink) { | 638 | + public TimePageData<AuditLog> getAuditLogsByEntityId(EntityId entityId, List<ActionType> actionTypes, TimePageLink pageLink) { |
669 | Map<String, String> params = new HashMap<>(); | 639 | Map<String, String> params = new HashMap<>(); |
670 | params.put("entityType", entityId.getEntityType().name()); | 640 | params.put("entityType", entityId.getEntityType().name()); |
671 | params.put("entityId", entityId.getId().toString()); | 641 | params.put("entityId", entityId.getId().toString()); |
672 | - params.put("actionTypes", actionTypes); | 642 | + params.put("actionTypes", listEnumToString(actionTypes)); |
673 | addPageLinkToParam(params, pageLink); | 643 | addPageLinkToParam(params, pageLink); |
674 | 644 | ||
675 | ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( | 645 | ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( |
@@ -682,9 +652,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -682,9 +652,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
682 | return auditLog.getBody(); | 652 | return auditLog.getBody(); |
683 | } | 653 | } |
684 | 654 | ||
685 | - public TimePageData<AuditLog> getAuditLogs(TimePageLink pageLink, String actionTypes) { | 655 | + public TimePageData<AuditLog> getAuditLogs(TimePageLink pageLink, List<ActionType> actionTypes) { |
686 | Map<String, String> params = new HashMap<>(); | 656 | Map<String, String> params = new HashMap<>(); |
687 | - params.put("actionTypes", actionTypes); | 657 | + params.put("actionTypes", listEnumToString(actionTypes)); |
688 | addPageLinkToParam(params, pageLink); | 658 | addPageLinkToParam(params, pageLink); |
689 | 659 | ||
690 | ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( | 660 | ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( |
@@ -697,7 +667,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -697,7 +667,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
697 | return auditLog.getBody(); | 667 | return auditLog.getBody(); |
698 | } | 668 | } |
699 | 669 | ||
700 | - public String getActivateToken(String userId) { | 670 | + public String getActivateToken(UserId userId) { |
701 | String activationLink = getActivationLink(userId); | 671 | String activationLink = getActivationLink(userId); |
702 | return StringUtils.delete(activationLink, baseURL + ACTIVATE_TOKEN_REGEX); | 672 | return StringUtils.delete(activationLink, baseURL + ACTIVATE_TOKEN_REGEX); |
703 | } | 673 | } |
@@ -731,7 +701,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -731,7 +701,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
731 | } | 701 | } |
732 | } | 702 | } |
733 | 703 | ||
734 | - public ResponseEntity<String> checkActivateToken(String userId) { | 704 | + public ResponseEntity<String> checkActivateToken(UserId userId) { |
735 | String activateToken = getActivateToken(userId); | 705 | String activateToken = getActivateToken(userId); |
736 | return restTemplate.getForEntity(baseURL + "/api/noauth/activate?activateToken={activateToken}", String.class, activateToken); | 706 | return restTemplate.getForEntity(baseURL + "/api/noauth/activate?activateToken={activateToken}", String.class, activateToken); |
737 | } | 707 | } |
@@ -742,7 +712,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -742,7 +712,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
742 | restTemplate.postForLocation(baseURL + "/api/noauth/resetPasswordByEmail", resetPasswordByEmailRequest); | 712 | restTemplate.postForLocation(baseURL + "/api/noauth/resetPasswordByEmail", resetPasswordByEmailRequest); |
743 | } | 713 | } |
744 | 714 | ||
745 | - public Optional<JsonNode> activateUser(String userId, String password) { | 715 | + public Optional<JsonNode> activateUser(UserId userId, String password) { |
746 | ObjectNode activateRequest = objectMapper.createObjectNode(); | 716 | ObjectNode activateRequest = objectMapper.createObjectNode(); |
747 | activateRequest.put("activateToken", getActivateToken(userId)); | 717 | activateRequest.put("activateToken", getActivateToken(userId)); |
748 | activateRequest.put("password", password); | 718 | activateRequest.put("password", password); |
@@ -771,7 +741,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -771,7 +741,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
771 | } | 741 | } |
772 | } | 742 | } |
773 | 743 | ||
774 | - public List<ComponentDescriptor> getComponentDescriptorsByType(String componentType) { | 744 | + public List<ComponentDescriptor> getComponentDescriptorsByType(ComponentType componentType) { |
775 | return restTemplate.exchange( | 745 | return restTemplate.exchange( |
776 | baseURL + "/api/components?componentType={componentType}", | 746 | baseURL + "/api/components?componentType={componentType}", |
777 | HttpMethod.GET, HttpEntity.EMPTY, | 747 | HttpMethod.GET, HttpEntity.EMPTY, |
@@ -780,19 +750,20 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -780,19 +750,20 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
780 | componentType).getBody(); | 750 | componentType).getBody(); |
781 | } | 751 | } |
782 | 752 | ||
783 | - public List<ComponentDescriptor> getComponentDescriptorsByTypes(List<String> componentTypes) { | 753 | + public List<ComponentDescriptor> getComponentDescriptorsByTypes(List<ComponentType> componentTypes) { |
784 | return restTemplate.exchange( | 754 | return restTemplate.exchange( |
785 | baseURL + "/api/components?componentTypes={componentTypes}", | 755 | baseURL + "/api/components?componentTypes={componentTypes}", |
786 | HttpMethod.GET, | 756 | HttpMethod.GET, |
787 | HttpEntity.EMPTY, | 757 | HttpEntity.EMPTY, |
788 | new ParameterizedTypeReference<List<ComponentDescriptor>>() { | 758 | new ParameterizedTypeReference<List<ComponentDescriptor>>() { |
789 | }, | 759 | }, |
790 | - listToString(componentTypes)).getBody(); | 760 | + listEnumToString(componentTypes)) |
761 | + .getBody(); | ||
791 | } | 762 | } |
792 | 763 | ||
793 | - public Optional<Customer> getCustomerById(String customerId) { | 764 | + public Optional<Customer> getCustomerById(CustomerId customerId) { |
794 | try { | 765 | try { |
795 | - ResponseEntity<Customer> customer = restTemplate.getForEntity(baseURL + "/api/customer/{customerId}", Customer.class, customerId); | 766 | + ResponseEntity<Customer> customer = restTemplate.getForEntity(baseURL + "/api/customer/{customerId}", Customer.class, customerId.getId()); |
796 | return Optional.ofNullable(customer.getBody()); | 767 | return Optional.ofNullable(customer.getBody()); |
797 | } catch (HttpClientErrorException exception) { | 768 | } catch (HttpClientErrorException exception) { |
798 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 769 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -803,9 +774,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -803,9 +774,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
803 | } | 774 | } |
804 | } | 775 | } |
805 | 776 | ||
806 | - public Optional<JsonNode> getShortCustomerInfoById(String customerId) { | 777 | + public Optional<JsonNode> getShortCustomerInfoById(CustomerId customerId) { |
807 | try { | 778 | try { |
808 | - ResponseEntity<JsonNode> customerInfo = restTemplate.getForEntity(baseURL + "/api/customer/{customerId}/shortInfo", JsonNode.class, customerId); | 779 | + ResponseEntity<JsonNode> customerInfo = restTemplate.getForEntity(baseURL + "/api/customer/{customerId}/shortInfo", JsonNode.class, customerId.getId()); |
809 | return Optional.ofNullable(customerInfo.getBody()); | 780 | return Optional.ofNullable(customerInfo.getBody()); |
810 | } catch (HttpClientErrorException exception) { | 781 | } catch (HttpClientErrorException exception) { |
811 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 782 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -816,16 +787,16 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -816,16 +787,16 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
816 | } | 787 | } |
817 | } | 788 | } |
818 | 789 | ||
819 | - public String getCustomerTitleById(String customerId) { | ||
820 | - return restTemplate.getForObject(baseURL + "/api/customer/{customerId}/title", String.class, customerId); | 790 | + public String getCustomerTitleById(CustomerId customerId) { |
791 | + return restTemplate.getForObject(baseURL + "/api/customer/{customerId}/title", String.class, customerId.getId()); | ||
821 | } | 792 | } |
822 | 793 | ||
823 | public Customer saveCustomer(Customer customer) { | 794 | public Customer saveCustomer(Customer customer) { |
824 | return restTemplate.postForEntity(baseURL + "/api/customer", customer, Customer.class).getBody(); | 795 | return restTemplate.postForEntity(baseURL + "/api/customer", customer, Customer.class).getBody(); |
825 | } | 796 | } |
826 | 797 | ||
827 | - public void deleteCustomer(String customerId) { | ||
828 | - restTemplate.delete(baseURL + "/api/customer/{customerId}", customerId); | 798 | + public void deleteCustomer(CustomerId customerId) { |
799 | + restTemplate.delete(baseURL + "/api/customer/{customerId}", customerId.getId()); | ||
829 | } | 800 | } |
830 | 801 | ||
831 | public TextPageData<Customer> getCustomers(TextPageLink pageLink) { | 802 | public TextPageData<Customer> getCustomers(TextPageLink pageLink) { |
@@ -863,9 +834,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -863,9 +834,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
863 | return restTemplate.getForObject(baseURL + "/api/dashboard/maxDatapointsLimit", Long.class); | 834 | return restTemplate.getForObject(baseURL + "/api/dashboard/maxDatapointsLimit", Long.class); |
864 | } | 835 | } |
865 | 836 | ||
866 | - public Optional<DashboardInfo> getDashboardInfoById(String dashboardId) { | 837 | + public Optional<DashboardInfo> getDashboardInfoById(DashboardId dashboardId) { |
867 | try { | 838 | try { |
868 | - ResponseEntity<DashboardInfo> dashboardInfo = restTemplate.getForEntity(baseURL + "/api/dashboard/info/{dashboardId}", DashboardInfo.class, dashboardId); | 839 | + ResponseEntity<DashboardInfo> dashboardInfo = restTemplate.getForEntity(baseURL + "/api/dashboard/info/{dashboardId}", DashboardInfo.class, dashboardId.getId()); |
869 | return Optional.ofNullable(dashboardInfo.getBody()); | 840 | return Optional.ofNullable(dashboardInfo.getBody()); |
870 | } catch (HttpClientErrorException exception) { | 841 | } catch (HttpClientErrorException exception) { |
871 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 842 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -876,9 +847,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -876,9 +847,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
876 | } | 847 | } |
877 | } | 848 | } |
878 | 849 | ||
879 | - public Optional<Dashboard> getDashboardById(String dashboardId) { | 850 | + public Optional<Dashboard> getDashboardById(DashboardId dashboardId) { |
880 | try { | 851 | try { |
881 | - ResponseEntity<Dashboard> dashboard = restTemplate.getForEntity(baseURL + "/api/dashboard/{dashboardId}", Dashboard.class, dashboardId); | 852 | + ResponseEntity<Dashboard> dashboard = restTemplate.getForEntity(baseURL + "/api/dashboard/{dashboardId}", Dashboard.class, dashboardId.getId()); |
882 | return Optional.ofNullable(dashboard.getBody()); | 853 | return Optional.ofNullable(dashboard.getBody()); |
883 | } catch (HttpClientErrorException exception) { | 854 | } catch (HttpClientErrorException exception) { |
884 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 855 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -893,13 +864,13 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -893,13 +864,13 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
893 | return restTemplate.postForEntity(baseURL + "/api/dashboard", dashboard, Dashboard.class).getBody(); | 864 | return restTemplate.postForEntity(baseURL + "/api/dashboard", dashboard, Dashboard.class).getBody(); |
894 | } | 865 | } |
895 | 866 | ||
896 | - public void deleteDashboard(String dashboardId) { | ||
897 | - restTemplate.delete(baseURL + "/api/dashboard/{dashboardId}", dashboardId); | 867 | + public void deleteDashboard(DashboardId dashboardId) { |
868 | + restTemplate.delete(baseURL + "/api/dashboard/{dashboardId}", dashboardId.getId()); | ||
898 | } | 869 | } |
899 | 870 | ||
900 | - public Optional<Dashboard> assignDashboardToCustomer(String customerId, String dashboardId) { | 871 | + public Optional<Dashboard> assignDashboardToCustomer(CustomerId customerId, DashboardId dashboardId) { |
901 | try { | 872 | try { |
902 | - ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/dashboard/{dashboardId}", null, Dashboard.class, customerId, dashboardId); | 873 | + ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/dashboard/{dashboardId}", null, Dashboard.class, customerId.getId(), dashboardId.getId()); |
903 | return Optional.ofNullable(dashboard.getBody()); | 874 | return Optional.ofNullable(dashboard.getBody()); |
904 | } catch (HttpClientErrorException exception) { | 875 | } catch (HttpClientErrorException exception) { |
905 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 876 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -910,9 +881,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -910,9 +881,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
910 | } | 881 | } |
911 | } | 882 | } |
912 | 883 | ||
913 | - public Optional<Dashboard> unassignDashboardFromCustomer(String customerId, String dashboardId) { | 884 | + public Optional<Dashboard> unassignDashboardFromCustomer(CustomerId customerId, DashboardId dashboardId) { |
914 | try { | 885 | try { |
915 | - ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/api/customer/{customerId}/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, customerId, dashboardId); | 886 | + ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/api/customer/{customerId}/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, customerId.getId(), dashboardId.getId()); |
916 | return Optional.ofNullable(dashboard.getBody()); | 887 | return Optional.ofNullable(dashboard.getBody()); |
917 | } catch (HttpClientErrorException exception) { | 888 | } catch (HttpClientErrorException exception) { |
918 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 889 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -923,9 +894,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -923,9 +894,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
923 | } | 894 | } |
924 | } | 895 | } |
925 | 896 | ||
926 | - public Optional<Dashboard> updateDashboardCustomers(String dashboardId, List<String> customerIds) { | 897 | + public Optional<Dashboard> updateDashboardCustomers(DashboardId dashboardId, List<CustomerId> customerIds) { |
898 | + Object[] customerIdArray = customerIds.stream().map(customerId -> customerId.getId().toString()).toArray(); | ||
927 | try { | 899 | try { |
928 | - ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers", customerIds, Dashboard.class, dashboardId); | 900 | + ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers", customerIdArray, Dashboard.class, dashboardId.getId()); |
929 | return Optional.ofNullable(dashboard.getBody()); | 901 | return Optional.ofNullable(dashboard.getBody()); |
930 | } catch (HttpClientErrorException exception) { | 902 | } catch (HttpClientErrorException exception) { |
931 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 903 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -936,9 +908,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -936,9 +908,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
936 | } | 908 | } |
937 | } | 909 | } |
938 | 910 | ||
939 | - public Optional<Dashboard> addDashboardCustomers(String dashboardId, List<String> customerIds) { | 911 | + public Optional<Dashboard> addDashboardCustomers(DashboardId dashboardId, List<CustomerId> customerIds) { |
912 | + Object[] customerIdArray = customerIds.stream().map(customerId -> customerId.getId().toString()).toArray(); | ||
940 | try { | 913 | try { |
941 | - ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers/add", customerIds, Dashboard.class, dashboardId); | 914 | + ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers/add", customerIdArray, Dashboard.class, dashboardId.getId()); |
942 | return Optional.ofNullable(dashboard.getBody()); | 915 | return Optional.ofNullable(dashboard.getBody()); |
943 | } catch (HttpClientErrorException exception) { | 916 | } catch (HttpClientErrorException exception) { |
944 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 917 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -949,9 +922,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -949,9 +922,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
949 | } | 922 | } |
950 | } | 923 | } |
951 | 924 | ||
952 | - public Optional<Dashboard> removeDashboardCustomers(String dashboardId, List<String> customerIds) { | 925 | + public Optional<Dashboard> removeDashboardCustomers(DashboardId dashboardId, List<CustomerId> customerIds) { |
926 | + Object[] customerIdArray = customerIds.stream().map(customerId -> customerId.getId().toString()).toArray(); | ||
953 | try { | 927 | try { |
954 | - ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers/remove", customerIds, Dashboard.class, dashboardId); | 928 | + ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers/remove", customerIdArray, Dashboard.class, dashboardId.getId()); |
955 | return Optional.ofNullable(dashboard.getBody()); | 929 | return Optional.ofNullable(dashboard.getBody()); |
956 | } catch (HttpClientErrorException exception) { | 930 | } catch (HttpClientErrorException exception) { |
957 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 931 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -962,9 +936,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -962,9 +936,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
962 | } | 936 | } |
963 | } | 937 | } |
964 | 938 | ||
965 | - public Optional<Dashboard> assignDashboardToPublicCustomer(String dashboardId) { | 939 | + public Optional<Dashboard> assignDashboardToPublicCustomer(DashboardId dashboardId) { |
966 | try { | 940 | try { |
967 | - ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/customer/public/dashboard/{dashboardId}", null, Dashboard.class, dashboardId); | 941 | + ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/customer/public/dashboard/{dashboardId}", null, Dashboard.class, dashboardId.getId()); |
968 | return Optional.ofNullable(dashboard.getBody()); | 942 | return Optional.ofNullable(dashboard.getBody()); |
969 | } catch (HttpClientErrorException exception) { | 943 | } catch (HttpClientErrorException exception) { |
970 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 944 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -975,9 +949,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -975,9 +949,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
975 | } | 949 | } |
976 | } | 950 | } |
977 | 951 | ||
978 | - public Optional<Dashboard> unassignDashboardFromPublicCustomer(String dashboardId) { | 952 | + public Optional<Dashboard> unassignDashboardFromPublicCustomer(DashboardId dashboardId) { |
979 | try { | 953 | try { |
980 | - ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/api/customer/public/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, dashboardId); | 954 | + ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/api/customer/public/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, dashboardId.getId()); |
981 | return Optional.ofNullable(dashboard.getBody()); | 955 | return Optional.ofNullable(dashboard.getBody()); |
982 | } catch (HttpClientErrorException exception) { | 956 | } catch (HttpClientErrorException exception) { |
983 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 957 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -988,17 +962,15 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -988,17 +962,15 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
988 | } | 962 | } |
989 | } | 963 | } |
990 | 964 | ||
991 | - public TextPageData<DashboardInfo> getTenantDashboards(String tenantId, TextPageLink pageLink) { | 965 | + public TextPageData<DashboardInfo> getTenantDashboards(TenantId tenantId, TextPageLink pageLink) { |
992 | Map<String, String> params = new HashMap<>(); | 966 | Map<String, String> params = new HashMap<>(); |
993 | - params.put("tenantId", tenantId); | 967 | + params.put("tenantId", tenantId.getId().toString()); |
994 | addPageLinkToParam(params, pageLink); | 968 | addPageLinkToParam(params, pageLink); |
995 | return restTemplate.exchange( | 969 | return restTemplate.exchange( |
996 | baseURL + "/api/tenant/{tenantId}/dashboards?" + getUrlParams(pageLink), | 970 | baseURL + "/api/tenant/{tenantId}/dashboards?" + getUrlParams(pageLink), |
997 | HttpMethod.GET, HttpEntity.EMPTY, | 971 | HttpMethod.GET, HttpEntity.EMPTY, |
998 | new ParameterizedTypeReference<TextPageData<DashboardInfo>>() { | 972 | new ParameterizedTypeReference<TextPageData<DashboardInfo>>() { |
999 | - }, | ||
1000 | - params | ||
1001 | - ).getBody(); | 973 | + }, params).getBody(); |
1002 | } | 974 | } |
1003 | 975 | ||
1004 | public TextPageData<DashboardInfo> getTenantDashboards(TextPageLink pageLink) { | 976 | public TextPageData<DashboardInfo> getTenantDashboards(TextPageLink pageLink) { |
@@ -1008,27 +980,23 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1008,27 +980,23 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1008 | baseURL + "/api/tenant/dashboards?" + getUrlParams(pageLink), | 980 | baseURL + "/api/tenant/dashboards?" + getUrlParams(pageLink), |
1009 | HttpMethod.GET, HttpEntity.EMPTY, | 981 | HttpMethod.GET, HttpEntity.EMPTY, |
1010 | new ParameterizedTypeReference<TextPageData<DashboardInfo>>() { | 982 | new ParameterizedTypeReference<TextPageData<DashboardInfo>>() { |
1011 | - }, | ||
1012 | - params | ||
1013 | - ).getBody(); | 983 | + }, params).getBody(); |
1014 | } | 984 | } |
1015 | 985 | ||
1016 | - public TimePageData<DashboardInfo> getCustomerDashboards(String customerId, TimePageLink pageLink) { | 986 | + public TimePageData<DashboardInfo> getCustomerDashboards(CustomerId customerId, TimePageLink pageLink) { |
1017 | Map<String, String> params = new HashMap<>(); | 987 | Map<String, String> params = new HashMap<>(); |
1018 | - params.put("customerId", customerId); | 988 | + params.put("customerId", customerId.getId().toString()); |
1019 | addPageLinkToParam(params, pageLink); | 989 | addPageLinkToParam(params, pageLink); |
1020 | return restTemplate.exchange( | 990 | return restTemplate.exchange( |
1021 | baseURL + "/api/customer/{customerId}/dashboards?" + getUrlParams(pageLink), | 991 | baseURL + "/api/customer/{customerId}/dashboards?" + getUrlParams(pageLink), |
1022 | HttpMethod.GET, HttpEntity.EMPTY, | 992 | HttpMethod.GET, HttpEntity.EMPTY, |
1023 | new ParameterizedTypeReference<TimePageData<DashboardInfo>>() { | 993 | new ParameterizedTypeReference<TimePageData<DashboardInfo>>() { |
1024 | - }, | ||
1025 | - params | ||
1026 | - ).getBody(); | 994 | + }, params).getBody(); |
1027 | } | 995 | } |
1028 | 996 | ||
1029 | - public Optional<Device> getDeviceById(String deviceId) { | 997 | + public Optional<Device> getDeviceById(DeviceId deviceId) { |
1030 | try { | 998 | try { |
1031 | - ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/api/device/{deviceId}", Device.class, deviceId); | 999 | + ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/api/device/{deviceId}", Device.class, deviceId.getId()); |
1032 | return Optional.ofNullable(device.getBody()); | 1000 | return Optional.ofNullable(device.getBody()); |
1033 | } catch (HttpClientErrorException exception) { | 1001 | } catch (HttpClientErrorException exception) { |
1034 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1002 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1043,13 +1011,13 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1043,13 +1011,13 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1043 | return restTemplate.postForEntity(baseURL + "/api/device", device, Device.class).getBody(); | 1011 | return restTemplate.postForEntity(baseURL + "/api/device", device, Device.class).getBody(); |
1044 | } | 1012 | } |
1045 | 1013 | ||
1046 | - public void deleteDevice(String deviceId) { | ||
1047 | - restTemplate.delete(baseURL + "/api/device/{deviceId}", deviceId); | 1014 | + public void deleteDevice(DeviceId deviceId) { |
1015 | + restTemplate.delete(baseURL + "/api/device/{deviceId}", deviceId.getId()); | ||
1048 | } | 1016 | } |
1049 | 1017 | ||
1050 | - public Optional<Device> assignDeviceToCustomer(String customerId, String deviceId) { | 1018 | + public Optional<Device> assignDeviceToCustomer(CustomerId customerId, DeviceId deviceId) { |
1051 | try { | 1019 | try { |
1052 | - ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/device/{deviceId}", null, Device.class, customerId, deviceId); | 1020 | + ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/device/{deviceId}", null, Device.class, customerId.getId(), deviceId.getId()); |
1053 | return Optional.ofNullable(device.getBody()); | 1021 | return Optional.ofNullable(device.getBody()); |
1054 | } catch (HttpClientErrorException exception) { | 1022 | } catch (HttpClientErrorException exception) { |
1055 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1023 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1060,9 +1028,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1060,9 +1028,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1060 | } | 1028 | } |
1061 | } | 1029 | } |
1062 | 1030 | ||
1063 | - public Optional<Device> unassignDeviceFromCustomer(String deviceId) { | 1031 | + public Optional<Device> unassignDeviceFromCustomer(DeviceId deviceId) { |
1064 | try { | 1032 | try { |
1065 | - ResponseEntity<Device> device = restTemplate.exchange(baseURL + "/api/customer/device/{deviceId}", HttpMethod.DELETE, HttpEntity.EMPTY, Device.class, deviceId); | 1033 | + ResponseEntity<Device> device = restTemplate.exchange(baseURL + "/api/customer/device/{deviceId}", HttpMethod.DELETE, HttpEntity.EMPTY, Device.class, deviceId.getId()); |
1066 | return Optional.ofNullable(device.getBody()); | 1034 | return Optional.ofNullable(device.getBody()); |
1067 | } catch (HttpClientErrorException exception) { | 1035 | } catch (HttpClientErrorException exception) { |
1068 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1036 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1073,9 +1041,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1073,9 +1041,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1073 | } | 1041 | } |
1074 | } | 1042 | } |
1075 | 1043 | ||
1076 | - public Optional<Device> assignDeviceToPublicCustomer(String deviceId) { | 1044 | + public Optional<Device> assignDeviceToPublicCustomer(DeviceId deviceId) { |
1077 | try { | 1045 | try { |
1078 | - ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/api/customer/public/device/{deviceId}", null, Device.class, deviceId); | 1046 | + ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/api/customer/public/device/{deviceId}", null, Device.class, deviceId.getId()); |
1079 | return Optional.ofNullable(device.getBody()); | 1047 | return Optional.ofNullable(device.getBody()); |
1080 | } catch (HttpClientErrorException exception) { | 1048 | } catch (HttpClientErrorException exception) { |
1081 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1049 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1086,9 +1054,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1086,9 +1054,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1086 | } | 1054 | } |
1087 | } | 1055 | } |
1088 | 1056 | ||
1089 | - public Optional<DeviceCredentials> getDeviceCredentialsByDeviceId(String deviceId) { | 1057 | + public Optional<DeviceCredentials> getDeviceCredentialsByDeviceId(DeviceId deviceId) { |
1090 | try { | 1058 | try { |
1091 | - ResponseEntity<DeviceCredentials> deviceCredentials = restTemplate.getForEntity(baseURL + "/api/device/{deviceId}/credentials", DeviceCredentials.class, deviceId); | 1059 | + ResponseEntity<DeviceCredentials> deviceCredentials = restTemplate.getForEntity(baseURL + "/api/device/{deviceId}/credentials", DeviceCredentials.class, deviceId.getId()); |
1092 | return Optional.ofNullable(deviceCredentials.getBody()); | 1060 | return Optional.ofNullable(deviceCredentials.getBody()); |
1093 | } catch (HttpClientErrorException exception) { | 1061 | } catch (HttpClientErrorException exception) { |
1094 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1062 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1111,9 +1079,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1111,9 +1079,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1111 | baseURL + "/api/tenant/devices?type={type}&" + getUrlParams(pageLink), | 1079 | baseURL + "/api/tenant/devices?type={type}&" + getUrlParams(pageLink), |
1112 | HttpMethod.GET, HttpEntity.EMPTY, | 1080 | HttpMethod.GET, HttpEntity.EMPTY, |
1113 | new ParameterizedTypeReference<TextPageData<Device>>() { | 1081 | new ParameterizedTypeReference<TextPageData<Device>>() { |
1114 | - }, | ||
1115 | - params) | ||
1116 | - .getBody(); | 1082 | + }, params).getBody(); |
1117 | } | 1083 | } |
1118 | 1084 | ||
1119 | public Optional<Device> getTenantDevice(String deviceName) { | 1085 | public Optional<Device> getTenantDevice(String deviceName) { |
@@ -1129,26 +1095,23 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1129,26 +1095,23 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1129 | } | 1095 | } |
1130 | } | 1096 | } |
1131 | 1097 | ||
1132 | - public TextPageData<Device> getCustomerDevices(String customerId, String type, TextPageLink pageLink) { | 1098 | + public TextPageData<Device> getCustomerDevices(CustomerId customerId, String deviceType, TextPageLink pageLink) { |
1133 | Map<String, String> params = new HashMap<>(); | 1099 | Map<String, String> params = new HashMap<>(); |
1134 | - params.put("customerId", customerId); | ||
1135 | - params.put("type", type); | 1100 | + params.put("customerId", customerId.getId().toString()); |
1101 | + params.put("type", deviceType); | ||
1136 | addPageLinkToParam(params, pageLink); | 1102 | addPageLinkToParam(params, pageLink); |
1137 | return restTemplate.exchange( | 1103 | return restTemplate.exchange( |
1138 | baseURL + "/api/customer/{customerId}/devices?type={type}&" + getUrlParams(pageLink), | 1104 | baseURL + "/api/customer/{customerId}/devices?type={type}&" + getUrlParams(pageLink), |
1139 | HttpMethod.GET, HttpEntity.EMPTY, | 1105 | HttpMethod.GET, HttpEntity.EMPTY, |
1140 | new ParameterizedTypeReference<TextPageData<Device>>() { | 1106 | new ParameterizedTypeReference<TextPageData<Device>>() { |
1141 | - }, | ||
1142 | - params) | ||
1143 | - .getBody(); | 1107 | + }, params).getBody(); |
1144 | } | 1108 | } |
1145 | 1109 | ||
1146 | - public List<Device> getDevicesByIds(List<String> deviceIds) { | 1110 | + public List<Device> getDevicesByIds(List<DeviceId> deviceIds) { |
1147 | return restTemplate.exchange(baseURL + "/api/devices?deviceIds={deviceIds}", | 1111 | return restTemplate.exchange(baseURL + "/api/devices?deviceIds={deviceIds}", |
1148 | HttpMethod.GET, | 1112 | HttpMethod.GET, |
1149 | HttpEntity.EMPTY, new ParameterizedTypeReference<List<Device>>() { | 1113 | HttpEntity.EMPTY, new ParameterizedTypeReference<List<Device>>() { |
1150 | - }, | ||
1151 | - listToString(deviceIds)).getBody(); | 1114 | + }, listIdsToString(deviceIds)).getBody(); |
1152 | } | 1115 | } |
1153 | 1116 | ||
1154 | public List<Device> findByQuery(DeviceSearchQuery query) { | 1117 | public List<Device> findByQuery(DeviceSearchQuery query) { |
@@ -1175,8 +1138,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1175,8 +1138,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1175 | HttpMethod.POST, | 1138 | HttpMethod.POST, |
1176 | new HttpEntity<>(claimRequest), | 1139 | new HttpEntity<>(claimRequest), |
1177 | new ParameterizedTypeReference<JsonNode>() { | 1140 | new ParameterizedTypeReference<JsonNode>() { |
1178 | - }, | ||
1179 | - deviceName).getBody(); | 1141 | + }, deviceName).getBody(); |
1180 | } | 1142 | } |
1181 | 1143 | ||
1182 | public void reClaimDevice(String deviceName) { | 1144 | public void reClaimDevice(String deviceName) { |
@@ -1187,14 +1149,14 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1187,14 +1149,14 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1187 | restTemplate.postForLocation(baseURL + "/api/relation", null); | 1149 | restTemplate.postForLocation(baseURL + "/api/relation", null); |
1188 | } | 1150 | } |
1189 | 1151 | ||
1190 | - public void deleteRelation(String fromId, String fromType, String relationType, String relationTypeGroup, String toId, String toType) { | 1152 | + public void deleteRelation(EntityId fromId, String relationType, RelationTypeGroup relationTypeGroup, EntityId toId) { |
1191 | Map<String, String> params = new HashMap<>(); | 1153 | Map<String, String> params = new HashMap<>(); |
1192 | - params.put("fromId", fromId); | ||
1193 | - params.put("fromType", fromType); | 1154 | + params.put("fromId", fromId.getId().toString()); |
1155 | + params.put("fromType", fromId.getEntityType().name()); | ||
1194 | params.put("relationType", relationType); | 1156 | params.put("relationType", relationType); |
1195 | - params.put("relationTypeGroup", relationTypeGroup); | ||
1196 | - params.put("toId", toId); | ||
1197 | - params.put("toType", toType); | 1157 | + params.put("relationTypeGroup", relationTypeGroup.name()); |
1158 | + params.put("toId", toId.getId().toString()); | ||
1159 | + params.put("toType", toId.getEntityType().name()); | ||
1198 | restTemplate.delete(baseURL + "/api/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}&toId={toId}&toType={toType}", params); | 1160 | restTemplate.delete(baseURL + "/api/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}&toId={toId}&toType={toType}", params); |
1199 | } | 1161 | } |
1200 | 1162 | ||
@@ -1202,14 +1164,14 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1202,14 +1164,14 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1202 | restTemplate.delete(baseURL + "/api/relations?entityId={entityId}&entityType={entityType}", entityId.getId().toString(), entityId.getEntityType().name()); | 1164 | restTemplate.delete(baseURL + "/api/relations?entityId={entityId}&entityType={entityType}", entityId.getId().toString(), entityId.getEntityType().name()); |
1203 | } | 1165 | } |
1204 | 1166 | ||
1205 | - public Optional<EntityRelation> getRelation(String fromId, String fromType, String relationType, String relationTypeGroup, String toId, String toType) { | 1167 | + public Optional<EntityRelation> getRelation(EntityId fromId, String relationType, RelationTypeGroup relationTypeGroup, EntityId toId) { |
1206 | Map<String, String> params = new HashMap<>(); | 1168 | Map<String, String> params = new HashMap<>(); |
1207 | - params.put("fromId", fromId); | ||
1208 | - params.put("fromType", fromType); | 1169 | + params.put("fromId", fromId.getId().toString()); |
1170 | + params.put("fromType", fromId.getEntityType().name()); | ||
1209 | params.put("relationType", relationType); | 1171 | params.put("relationType", relationType); |
1210 | - params.put("relationTypeGroup", relationTypeGroup); | ||
1211 | - params.put("toId", toId); | ||
1212 | - params.put("toType", toType); | 1172 | + params.put("relationTypeGroup", relationTypeGroup.name()); |
1173 | + params.put("toId", toId.getId().toString()); | ||
1174 | + params.put("toType", toId.getEntityType().name()); | ||
1213 | 1175 | ||
1214 | try { | 1176 | try { |
1215 | ResponseEntity<EntityRelation> entityRelation = restTemplate.getForEntity( | 1177 | ResponseEntity<EntityRelation> entityRelation = restTemplate.getForEntity( |
@@ -1226,11 +1188,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1226,11 +1188,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1226 | } | 1188 | } |
1227 | } | 1189 | } |
1228 | 1190 | ||
1229 | - public List<EntityRelation> findByFrom(String fromId, String fromType, String relationTypeGroup) { | 1191 | + public List<EntityRelation> findByFrom(EntityId fromId, RelationTypeGroup relationTypeGroup) { |
1230 | Map<String, String> params = new HashMap<>(); | 1192 | Map<String, String> params = new HashMap<>(); |
1231 | - params.put("fromId", fromId); | ||
1232 | - params.put("fromType", fromType); | ||
1233 | - params.put("relationTypeGroup", relationTypeGroup); | 1193 | + params.put("fromId", fromId.getId().toString()); |
1194 | + params.put("fromType", fromId.getEntityType().name()); | ||
1195 | + params.put("relationTypeGroup", relationTypeGroup.name()); | ||
1234 | 1196 | ||
1235 | return restTemplate.exchange( | 1197 | return restTemplate.exchange( |
1236 | baseURL + "/api/relations?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}", | 1198 | baseURL + "/api/relations?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}", |
@@ -1241,11 +1203,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1241,11 +1203,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1241 | params).getBody(); | 1203 | params).getBody(); |
1242 | } | 1204 | } |
1243 | 1205 | ||
1244 | - public List<EntityRelationInfo> findInfoByFrom(String fromId, String fromType, String relationTypeGroup) { | 1206 | + public List<EntityRelationInfo> findInfoByFrom(EntityId fromId, RelationTypeGroup relationTypeGroup) { |
1245 | Map<String, String> params = new HashMap<>(); | 1207 | Map<String, String> params = new HashMap<>(); |
1246 | - params.put("fromId", fromId); | ||
1247 | - params.put("fromType", fromType); | ||
1248 | - params.put("relationTypeGroup", relationTypeGroup); | 1208 | + params.put("fromId", fromId.getId().toString()); |
1209 | + params.put("fromType", fromId.getEntityType().name()); | ||
1210 | + params.put("relationTypeGroup", relationTypeGroup.name()); | ||
1249 | 1211 | ||
1250 | return restTemplate.exchange( | 1212 | return restTemplate.exchange( |
1251 | baseURL + "/api/relations/info?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}", | 1213 | baseURL + "/api/relations/info?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}", |
@@ -1256,12 +1218,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1256,12 +1218,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1256 | params).getBody(); | 1218 | params).getBody(); |
1257 | } | 1219 | } |
1258 | 1220 | ||
1259 | - public List<EntityRelation> findByFrom(String fromId, String fromType, String relationType, String relationTypeGroup) { | 1221 | + public List<EntityRelation> findByFrom(EntityId fromId, String relationType, RelationTypeGroup relationTypeGroup) { |
1260 | Map<String, String> params = new HashMap<>(); | 1222 | Map<String, String> params = new HashMap<>(); |
1261 | - params.put("fromId", fromId); | ||
1262 | - params.put("fromType", fromType); | 1223 | + params.put("fromId", fromId.getId().toString()); |
1224 | + params.put("fromType", fromId.getEntityType().name()); | ||
1263 | params.put("relationType", relationType); | 1225 | params.put("relationType", relationType); |
1264 | - params.put("relationTypeGroup", relationTypeGroup); | 1226 | + params.put("relationTypeGroup", relationTypeGroup.name()); |
1265 | 1227 | ||
1266 | return restTemplate.exchange( | 1228 | return restTemplate.exchange( |
1267 | baseURL + "/api/relations?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}", | 1229 | baseURL + "/api/relations?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}", |
@@ -1272,11 +1234,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1272,11 +1234,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1272 | params).getBody(); | 1234 | params).getBody(); |
1273 | } | 1235 | } |
1274 | 1236 | ||
1275 | - public List<EntityRelation> findByTo(String toId, String toType, String relationTypeGroup) { | 1237 | + public List<EntityRelation> findByTo(EntityId toId, RelationTypeGroup relationTypeGroup) { |
1276 | Map<String, String> params = new HashMap<>(); | 1238 | Map<String, String> params = new HashMap<>(); |
1277 | - params.put("toId", toId); | ||
1278 | - params.put("toType", toType); | ||
1279 | - params.put("relationTypeGroup", relationTypeGroup); | 1239 | + params.put("toId", toId.getId().toString()); |
1240 | + params.put("toType", toId.getEntityType().name()); | ||
1241 | + params.put("relationTypeGroup", relationTypeGroup.name()); | ||
1280 | 1242 | ||
1281 | return restTemplate.exchange( | 1243 | return restTemplate.exchange( |
1282 | baseURL + "/api/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}", | 1244 | baseURL + "/api/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}", |
@@ -1287,11 +1249,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1287,11 +1249,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1287 | params).getBody(); | 1249 | params).getBody(); |
1288 | } | 1250 | } |
1289 | 1251 | ||
1290 | - public List<EntityRelationInfo> findInfoByTo(String toId, String toType, String relationTypeGroup) { | 1252 | + public List<EntityRelationInfo> findInfoByTo(EntityId toId, RelationTypeGroup relationTypeGroup) { |
1291 | Map<String, String> params = new HashMap<>(); | 1253 | Map<String, String> params = new HashMap<>(); |
1292 | - params.put("toId", toId); | ||
1293 | - params.put("toType", toType); | ||
1294 | - params.put("relationTypeGroup", relationTypeGroup); | 1254 | + params.put("toId", toId.getId().toString()); |
1255 | + params.put("toType", toId.getEntityType().name()); | ||
1256 | + params.put("relationTypeGroup", relationTypeGroup.name()); | ||
1295 | 1257 | ||
1296 | return restTemplate.exchange( | 1258 | return restTemplate.exchange( |
1297 | baseURL + "/api/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}", | 1259 | baseURL + "/api/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}", |
@@ -1302,12 +1264,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1302,12 +1264,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1302 | params).getBody(); | 1264 | params).getBody(); |
1303 | } | 1265 | } |
1304 | 1266 | ||
1305 | - public List<EntityRelation> findByTo(String toId, String toType, String relationType, String relationTypeGroup) { | 1267 | + public List<EntityRelation> findByTo(EntityId toId, String relationType, RelationTypeGroup relationTypeGroup) { |
1306 | Map<String, String> params = new HashMap<>(); | 1268 | Map<String, String> params = new HashMap<>(); |
1307 | - params.put("toId", toId); | ||
1308 | - params.put("toType", toType); | 1269 | + params.put("toId", toId.getId().toString()); |
1270 | + params.put("toType", toId.getEntityType().name()); | ||
1309 | params.put("relationType", relationType); | 1271 | params.put("relationType", relationType); |
1310 | - params.put("relationTypeGroup", relationTypeGroup); | 1272 | + params.put("relationTypeGroup", relationTypeGroup.name()); |
1311 | 1273 | ||
1312 | return restTemplate.exchange( | 1274 | return restTemplate.exchange( |
1313 | baseURL + "/api/relations?toId={toId}&toType={toType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}", | 1275 | baseURL + "/api/relations?toId={toId}&toType={toType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}", |
@@ -1336,9 +1298,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1336,9 +1298,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1336 | }).getBody(); | 1298 | }).getBody(); |
1337 | } | 1299 | } |
1338 | 1300 | ||
1339 | - public Optional<EntityView> getEntityViewById(String entityViewId) { | 1301 | + public Optional<EntityView> getEntityViewById(EntityViewId entityViewId) { |
1340 | try { | 1302 | try { |
1341 | - ResponseEntity<EntityView> entityView = restTemplate.getForEntity(baseURL + "/api/entityView/{entityViewId}", EntityView.class, entityViewId); | 1303 | + ResponseEntity<EntityView> entityView = restTemplate.getForEntity(baseURL + "/api/entityView/{entityViewId}", EntityView.class, entityViewId.getId()); |
1342 | return Optional.ofNullable(entityView.getBody()); | 1304 | return Optional.ofNullable(entityView.getBody()); |
1343 | } catch (HttpClientErrorException exception) { | 1305 | } catch (HttpClientErrorException exception) { |
1344 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1306 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1370,9 +1332,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1370,9 +1332,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1370 | } | 1332 | } |
1371 | } | 1333 | } |
1372 | 1334 | ||
1373 | - public Optional<EntityView> assignEntityViewToCustomer(String customerId, String entityViewId) { | 1335 | + public Optional<EntityView> assignEntityViewToCustomer(CustomerId customerId, EntityViewId entityViewId) { |
1374 | try { | 1336 | try { |
1375 | - ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/entityView/{entityViewId}", null, EntityView.class, customerId, entityViewId); | 1337 | + ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/entityView/{entityViewId}", null, EntityView.class, customerId.getId(), entityViewId.getId()); |
1376 | return Optional.ofNullable(entityView.getBody()); | 1338 | return Optional.ofNullable(entityView.getBody()); |
1377 | } catch (HttpClientErrorException exception) { | 1339 | } catch (HttpClientErrorException exception) { |
1378 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1340 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1383,13 +1345,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1383,13 +1345,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1383 | } | 1345 | } |
1384 | } | 1346 | } |
1385 | 1347 | ||
1386 | - public Optional<EntityView> unassignEntityViewFromCustomer(String entityViewId) { | 1348 | + public Optional<EntityView> unassignEntityViewFromCustomer(EntityViewId entityViewId) { |
1387 | try { | 1349 | try { |
1388 | - ResponseEntity<EntityView> entityView = restTemplate.exchange( | ||
1389 | - baseURL + "/api/customer/entityView/{entityViewId}", | ||
1390 | - HttpMethod.DELETE, | ||
1391 | - HttpEntity.EMPTY, | ||
1392 | - EntityView.class, entityViewId); | 1350 | + ResponseEntity<EntityView> entityView = restTemplate.exchange(baseURL + "/api/customer/entityView/{entityViewId}", HttpMethod.DELETE, HttpEntity.EMPTY, EntityView.class, entityViewId.getId()); |
1393 | return Optional.ofNullable(entityView.getBody()); | 1351 | return Optional.ofNullable(entityView.getBody()); |
1394 | } catch (HttpClientErrorException exception) { | 1352 | } catch (HttpClientErrorException exception) { |
1395 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1353 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1400,31 +1358,29 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1400,31 +1358,29 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1400 | } | 1358 | } |
1401 | } | 1359 | } |
1402 | 1360 | ||
1403 | - public TextPageData<EntityView> getCustomerEntityViews(String customerId, String type, TextPageLink pageLink) { | 1361 | + public TextPageData<EntityView> getCustomerEntityViews(CustomerId customerId, String entityViewType, TextPageLink pageLink) { |
1404 | Map<String, String> params = new HashMap<>(); | 1362 | Map<String, String> params = new HashMap<>(); |
1405 | - params.put("customerId", customerId); | ||
1406 | - params.put("type", type); | 1363 | + params.put("customerId", customerId.getId().toString()); |
1364 | + params.put("type", entityViewType); | ||
1407 | addPageLinkToParam(params, pageLink); | 1365 | addPageLinkToParam(params, pageLink); |
1408 | return restTemplate.exchange( | 1366 | return restTemplate.exchange( |
1409 | baseURL + "/api/customer/{customerId}/entityViews?type={type}&" + getUrlParams(pageLink), | 1367 | baseURL + "/api/customer/{customerId}/entityViews?type={type}&" + getUrlParams(pageLink), |
1410 | HttpMethod.GET, | 1368 | HttpMethod.GET, |
1411 | HttpEntity.EMPTY, | 1369 | HttpEntity.EMPTY, |
1412 | new ParameterizedTypeReference<TextPageData<EntityView>>() { | 1370 | new ParameterizedTypeReference<TextPageData<EntityView>>() { |
1413 | - }, | ||
1414 | - params).getBody(); | 1371 | + }, params).getBody(); |
1415 | } | 1372 | } |
1416 | 1373 | ||
1417 | - public TextPageData<EntityView> getTenantEntityViews(String type, TextPageLink pageLink) { | 1374 | + public TextPageData<EntityView> getTenantEntityViews(String entityViewType, TextPageLink pageLink) { |
1418 | Map<String, String> params = new HashMap<>(); | 1375 | Map<String, String> params = new HashMap<>(); |
1419 | - params.put("type", type); | 1376 | + params.put("type", entityViewType); |
1420 | addPageLinkToParam(params, pageLink); | 1377 | addPageLinkToParam(params, pageLink); |
1421 | return restTemplate.exchange( | 1378 | return restTemplate.exchange( |
1422 | baseURL + "/api/tenant/entityViews?type={type}&" + getUrlParams(pageLink), | 1379 | baseURL + "/api/tenant/entityViews?type={type}&" + getUrlParams(pageLink), |
1423 | HttpMethod.GET, | 1380 | HttpMethod.GET, |
1424 | HttpEntity.EMPTY, | 1381 | HttpEntity.EMPTY, |
1425 | new ParameterizedTypeReference<TextPageData<EntityView>>() { | 1382 | new ParameterizedTypeReference<TextPageData<EntityView>>() { |
1426 | - }, | ||
1427 | - params).getBody(); | 1383 | + }, params).getBody(); |
1428 | } | 1384 | } |
1429 | 1385 | ||
1430 | public List<EntityView> findByQuery(EntityViewSearchQuery query) { | 1386 | public List<EntityView> findByQuery(EntityViewSearchQuery query) { |
@@ -1437,9 +1393,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1437,9 +1393,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1437 | }).getBody(); | 1393 | }).getBody(); |
1438 | } | 1394 | } |
1439 | 1395 | ||
1440 | - public Optional<EntityView> assignEntityViewToPublicCustomer(String entityViewId) { | 1396 | + public Optional<EntityView> assignEntityViewToPublicCustomer(EntityViewId entityViewId) { |
1441 | try { | 1397 | try { |
1442 | - ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/api/customer/public/entityView/{entityViewId}", null, EntityView.class, entityViewId); | 1398 | + ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/api/customer/public/entityView/{entityViewId}", null, EntityView.class, entityViewId.getId()); |
1443 | return Optional.ofNullable(entityView.getBody()); | 1399 | return Optional.ofNullable(entityView.getBody()); |
1444 | } catch (HttpClientErrorException exception) { | 1400 | } catch (HttpClientErrorException exception) { |
1445 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1401 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1450,12 +1406,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1450,12 +1406,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1450 | } | 1406 | } |
1451 | } | 1407 | } |
1452 | 1408 | ||
1453 | - public TimePageData<Event> getEvents(EntityId entityId, String eventType, String tenantId, TimePageLink pageLink) { | 1409 | + public TimePageData<Event> getEvents(EntityId entityId, String eventType, TenantId tenantId, TimePageLink pageLink) { |
1454 | Map<String, String> params = new HashMap<>(); | 1410 | Map<String, String> params = new HashMap<>(); |
1455 | params.put("entityType", entityId.getEntityType().name()); | 1411 | params.put("entityType", entityId.getEntityType().name()); |
1456 | params.put("entityId", entityId.getId().toString()); | 1412 | params.put("entityId", entityId.getId().toString()); |
1457 | params.put("eventType", eventType); | 1413 | params.put("eventType", eventType); |
1458 | - params.put("tenantId", tenantId); | 1414 | + params.put("tenantId", tenantId.getId().toString()); |
1459 | addPageLinkToParam(params, pageLink); | 1415 | addPageLinkToParam(params, pageLink); |
1460 | 1416 | ||
1461 | return restTemplate.exchange( | 1417 | return restTemplate.exchange( |
@@ -1467,11 +1423,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1467,11 +1423,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1467 | params).getBody(); | 1423 | params).getBody(); |
1468 | } | 1424 | } |
1469 | 1425 | ||
1470 | - public TimePageData<Event> getEvents(EntityId entityId, String tenantId, TimePageLink pageLink) { | 1426 | + public TimePageData<Event> getEvents(EntityId entityId, TenantId tenantId, TimePageLink pageLink) { |
1471 | Map<String, String> params = new HashMap<>(); | 1427 | Map<String, String> params = new HashMap<>(); |
1472 | params.put("entityType", entityId.getEntityType().name()); | 1428 | params.put("entityType", entityId.getEntityType().name()); |
1473 | params.put("entityId", entityId.getId().toString()); | 1429 | params.put("entityId", entityId.getId().toString()); |
1474 | - params.put("tenantId", tenantId); | 1430 | + params.put("tenantId", tenantId.getId().toString()); |
1475 | addPageLinkToParam(params, pageLink); | 1431 | addPageLinkToParam(params, pageLink); |
1476 | 1432 | ||
1477 | return restTemplate.exchange( | 1433 | return restTemplate.exchange( |
@@ -1483,8 +1439,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1483,8 +1439,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1483 | params).getBody(); | 1439 | params).getBody(); |
1484 | } | 1440 | } |
1485 | 1441 | ||
1486 | - public void handleOneWayDeviceRPCRequest(String deviceId, JsonNode requestBody) { | ||
1487 | - restTemplate.postForLocation(baseURL + "/api/plugins/rpc/oneway/{deviceId}", requestBody, deviceId); | 1442 | + public void handleOneWayDeviceRPCRequest(DeviceId deviceId, JsonNode requestBody) { |
1443 | + restTemplate.postForLocation(baseURL + "/api/plugins/rpc/oneway/{deviceId}", requestBody, deviceId.getId()); | ||
1488 | } | 1444 | } |
1489 | 1445 | ||
1490 | public JsonNode handleTwoWayDeviceRPCRequest(String deviceId, JsonNode requestBody) { | 1446 | public JsonNode handleTwoWayDeviceRPCRequest(String deviceId, JsonNode requestBody) { |
@@ -1497,9 +1453,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1497,9 +1453,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1497 | deviceId).getBody(); | 1453 | deviceId).getBody(); |
1498 | } | 1454 | } |
1499 | 1455 | ||
1500 | - public Optional<RuleChain> getRuleChainById(String ruleChainId) { | 1456 | + public Optional<RuleChain> getRuleChainById(RuleChainId ruleChainId) { |
1501 | try { | 1457 | try { |
1502 | - ResponseEntity<RuleChain> ruleChain = restTemplate.getForEntity(baseURL + "/api/ruleChain/{ruleChainId}", RuleChain.class, ruleChainId); | 1458 | + ResponseEntity<RuleChain> ruleChain = restTemplate.getForEntity(baseURL + "/api/ruleChain/{ruleChainId}", RuleChain.class, ruleChainId.getId()); |
1503 | return Optional.ofNullable(ruleChain.getBody()); | 1459 | return Optional.ofNullable(ruleChain.getBody()); |
1504 | } catch (HttpClientErrorException exception) { | 1460 | } catch (HttpClientErrorException exception) { |
1505 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1461 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1510,9 +1466,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1510,9 +1466,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1510 | } | 1466 | } |
1511 | } | 1467 | } |
1512 | 1468 | ||
1513 | - public Optional<RuleChainMetaData> getRuleChainMetaData(String ruleChainId) { | 1469 | + public Optional<RuleChainMetaData> getRuleChainMetaData(RuleChainId ruleChainId) { |
1514 | try { | 1470 | try { |
1515 | - ResponseEntity<RuleChainMetaData> ruleChainMetaData = restTemplate.getForEntity(baseURL + "/api/ruleChain/{ruleChainId}/metadata", RuleChainMetaData.class, ruleChainId); | 1471 | + ResponseEntity<RuleChainMetaData> ruleChainMetaData = restTemplate.getForEntity(baseURL + "/api/ruleChain/{ruleChainId}/metadata", RuleChainMetaData.class, ruleChainId.getId()); |
1516 | return Optional.ofNullable(ruleChainMetaData.getBody()); | 1472 | return Optional.ofNullable(ruleChainMetaData.getBody()); |
1517 | } catch (HttpClientErrorException exception) { | 1473 | } catch (HttpClientErrorException exception) { |
1518 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1474 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1527,9 +1483,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1527,9 +1483,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1527 | return restTemplate.postForEntity(baseURL + "/api/ruleChain", ruleChain, RuleChain.class).getBody(); | 1483 | return restTemplate.postForEntity(baseURL + "/api/ruleChain", ruleChain, RuleChain.class).getBody(); |
1528 | } | 1484 | } |
1529 | 1485 | ||
1530 | - public Optional<RuleChain> setRootRuleChain(String ruleChainId) { | 1486 | + public Optional<RuleChain> setRootRuleChain(RuleChainId ruleChainId) { |
1531 | try { | 1487 | try { |
1532 | - ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/ruleChain/{ruleChainId}/root", null, RuleChain.class, ruleChainId); | 1488 | + ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/ruleChain/{ruleChainId}/root", null, RuleChain.class, ruleChainId.getId()); |
1533 | return Optional.ofNullable(ruleChain.getBody()); | 1489 | return Optional.ofNullable(ruleChain.getBody()); |
1534 | } catch (HttpClientErrorException exception) { | 1490 | } catch (HttpClientErrorException exception) { |
1535 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1491 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1548,21 +1504,21 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1548,21 +1504,21 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1548 | Map<String, String> params = new HashMap<>(); | 1504 | Map<String, String> params = new HashMap<>(); |
1549 | addPageLinkToParam(params, pageLink); | 1505 | addPageLinkToParam(params, pageLink); |
1550 | return restTemplate.exchange( | 1506 | return restTemplate.exchange( |
1551 | - baseURL + "/api/ruleChains" + getUrlParams(pageLink), | 1507 | + baseURL + "/api/ruleChains?" + getUrlParams(pageLink), |
1552 | HttpMethod.GET, | 1508 | HttpMethod.GET, |
1553 | HttpEntity.EMPTY, | 1509 | HttpEntity.EMPTY, |
1554 | new ParameterizedTypeReference<TextPageData<RuleChain>>() { | 1510 | new ParameterizedTypeReference<TextPageData<RuleChain>>() { |
1555 | - } | ||
1556 | - ).getBody(); | 1511 | + }, |
1512 | + params).getBody(); | ||
1557 | } | 1513 | } |
1558 | 1514 | ||
1559 | - public void deleteRuleChain(String ruleChainId) { | ||
1560 | - restTemplate.delete(baseURL + "/api/ruleChain/{ruleChainId}", ruleChainId); | 1515 | + public void deleteRuleChain(RuleChainId ruleChainId) { |
1516 | + restTemplate.delete(baseURL + "/api/ruleChain/{ruleChainId}", ruleChainId.getId()); | ||
1561 | } | 1517 | } |
1562 | 1518 | ||
1563 | - public Optional<JsonNode> getLatestRuleNodeDebugInput(String ruleNodeId) { | 1519 | + public Optional<JsonNode> getLatestRuleNodeDebugInput(RuleNodeId ruleNodeId) { |
1564 | try { | 1520 | try { |
1565 | - ResponseEntity<JsonNode> jsonNode = restTemplate.getForEntity(baseURL + "/api/ruleNode/{ruleNodeId}/debugIn", JsonNode.class, ruleNodeId); | 1521 | + ResponseEntity<JsonNode> jsonNode = restTemplate.getForEntity(baseURL + "/api/ruleNode/{ruleNodeId}/debugIn", JsonNode.class, ruleNodeId.getId()); |
1566 | return Optional.ofNullable(jsonNode.getBody()); | 1522 | return Optional.ofNullable(jsonNode.getBody()); |
1567 | } catch (HttpClientErrorException exception) { | 1523 | } catch (HttpClientErrorException exception) { |
1568 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1524 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1668,19 +1624,17 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1668,19 +1624,17 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1668 | } | 1624 | } |
1669 | 1625 | ||
1670 | 1626 | ||
1671 | - public List<TsKvEntry> getTimeseries(EntityId entityId, List<String> keys, Long startTs, Long endTs, Long interval, Integer limit, String agg) { | 1627 | + public List<TsKvEntry> getTimeseries(EntityId entityId, List<String> keys, Long interval, Aggregation agg, TimePageLink pageLink) { |
1672 | Map<String, String> params = new HashMap<>(); | 1628 | Map<String, String> params = new HashMap<>(); |
1629 | + addPageLinkToParam(params, pageLink); | ||
1673 | params.put("entityType", entityId.getEntityType().name()); | 1630 | params.put("entityType", entityId.getEntityType().name()); |
1674 | params.put("entityId", entityId.getId().toString()); | 1631 | params.put("entityId", entityId.getId().toString()); |
1675 | params.put("keys", listToString(keys)); | 1632 | params.put("keys", listToString(keys)); |
1676 | - params.put("startTs", startTs.toString()); | ||
1677 | - params.put("endTs", endTs.toString()); | ||
1678 | params.put("interval", interval == null ? "0" : interval.toString()); | 1633 | params.put("interval", interval == null ? "0" : interval.toString()); |
1679 | - params.put("limit", limit == null ? "100" : limit.toString()); | ||
1680 | - params.put("agg", agg == null ? "NONE" : agg); | 1634 | + params.put("agg", agg == null ? "NONE" : agg.name()); |
1681 | 1635 | ||
1682 | Map<String, List<JsonNode>> timeseries = restTemplate.exchange( | 1636 | Map<String, List<JsonNode>> timeseries = restTemplate.exchange( |
1683 | - baseURL + "/api/plugins/telemetry/{entityType}/{entityId}/values/timeseries?keys={keys}&startTs={startTs}&endTs={endTs}&interval={interval}&limit={limit}&agg={agg}", | 1637 | + baseURL + "/api/plugins/telemetry/{entityType}/{entityId}/values/timeseries?keys={keys}&interval={interval}&agg={agg}&" + getUrlParams(pageLink), |
1684 | HttpMethod.GET, | 1638 | HttpMethod.GET, |
1685 | HttpEntity.EMPTY, | 1639 | HttpEntity.EMPTY, |
1686 | new ParameterizedTypeReference<Map<String, List<JsonNode>>>() { | 1640 | new ParameterizedTypeReference<Map<String, List<JsonNode>>>() { |
@@ -1807,9 +1761,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1807,9 +1761,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1807 | 1761 | ||
1808 | } | 1762 | } |
1809 | 1763 | ||
1810 | - public Optional<Tenant> getTenantById(String tenantId) { | 1764 | + public Optional<Tenant> getTenantById(TenantId tenantId) { |
1811 | try { | 1765 | try { |
1812 | - ResponseEntity<Tenant> tenant = restTemplate.getForEntity(baseURL + "/api/tenant/{tenantId}", Tenant.class, tenantId); | 1766 | + ResponseEntity<Tenant> tenant = restTemplate.getForEntity(baseURL + "/api/tenant/{tenantId}", Tenant.class, tenantId.getId()); |
1813 | return Optional.ofNullable(tenant.getBody()); | 1767 | return Optional.ofNullable(tenant.getBody()); |
1814 | } catch (HttpClientErrorException exception) { | 1768 | } catch (HttpClientErrorException exception) { |
1815 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1769 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1824,8 +1778,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1824,8 +1778,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1824 | return restTemplate.postForEntity(baseURL + "/api/tenant", tenant, Tenant.class).getBody(); | 1778 | return restTemplate.postForEntity(baseURL + "/api/tenant", tenant, Tenant.class).getBody(); |
1825 | } | 1779 | } |
1826 | 1780 | ||
1827 | - public void deleteTenant(String tenantId) { | ||
1828 | - restTemplate.delete(baseURL + "/api/tenant/{tenantId}", tenantId); | 1781 | + public void deleteTenant(TenantId tenantId) { |
1782 | + restTemplate.delete(baseURL + "/api/tenant/{tenantId}", tenantId.getId()); | ||
1829 | } | 1783 | } |
1830 | 1784 | ||
1831 | public TextPageData<Tenant> getTenants(TextPageLink pageLink) { | 1785 | public TextPageData<Tenant> getTenants(TextPageLink pageLink) { |
@@ -1836,13 +1790,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1836,13 +1790,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1836 | HttpMethod.GET, | 1790 | HttpMethod.GET, |
1837 | HttpEntity.EMPTY, | 1791 | HttpEntity.EMPTY, |
1838 | new ParameterizedTypeReference<TextPageData<Tenant>>() { | 1792 | new ParameterizedTypeReference<TextPageData<Tenant>>() { |
1839 | - }, | ||
1840 | - params).getBody(); | 1793 | + }, params).getBody(); |
1841 | } | 1794 | } |
1842 | 1795 | ||
1843 | - public Optional<User> getUserById(String userId) { | 1796 | + public Optional<User> getUserById(UserId userId) { |
1844 | try { | 1797 | try { |
1845 | - ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/api/user/{userId}", User.class, userId); | 1798 | + ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/api/user/{userId}", User.class, userId.getId()); |
1846 | return Optional.ofNullable(user.getBody()); | 1799 | return Optional.ofNullable(user.getBody()); |
1847 | } catch (HttpClientErrorException exception) { | 1800 | } catch (HttpClientErrorException exception) { |
1848 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1801 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1857,9 +1810,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1857,9 +1810,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1857 | return restTemplate.getForEntity(baseURL + "/api/user/tokenAccessEnabled", Boolean.class).getBody(); | 1810 | return restTemplate.getForEntity(baseURL + "/api/user/tokenAccessEnabled", Boolean.class).getBody(); |
1858 | } | 1811 | } |
1859 | 1812 | ||
1860 | - public Optional<JsonNode> getUserToken(String userId) { | 1813 | + public Optional<JsonNode> getUserToken(UserId userId) { |
1861 | try { | 1814 | try { |
1862 | - ResponseEntity<JsonNode> userToken = restTemplate.getForEntity(baseURL + "/api/user/{userId}/token", JsonNode.class, userId); | 1815 | + ResponseEntity<JsonNode> userToken = restTemplate.getForEntity(baseURL + "/api/user/{userId}/token", JsonNode.class, userId.getId()); |
1863 | return Optional.ofNullable(userToken.getBody()); | 1816 | return Optional.ofNullable(userToken.getBody()); |
1864 | } catch (HttpClientErrorException exception) { | 1817 | } catch (HttpClientErrorException exception) { |
1865 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1818 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1878,17 +1831,17 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1878,17 +1831,17 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1878 | restTemplate.postForLocation(baseURL + "/api/user/sendActivationMail?email={email}", null, email); | 1831 | restTemplate.postForLocation(baseURL + "/api/user/sendActivationMail?email={email}", null, email); |
1879 | } | 1832 | } |
1880 | 1833 | ||
1881 | - public String getActivationLink(String userId) { | ||
1882 | - return restTemplate.getForEntity(baseURL + "/api/user/{userId}/activationLink", String.class, userId).getBody(); | 1834 | + public String getActivationLink(UserId userId) { |
1835 | + return restTemplate.getForEntity(baseURL + "/api/user/{userId}/activationLink", String.class, userId.getId()).getBody(); | ||
1883 | } | 1836 | } |
1884 | 1837 | ||
1885 | - public void deleteUser(String userId) { | ||
1886 | - restTemplate.delete(baseURL + "/api/user/{userId}", userId); | 1838 | + public void deleteUser(UserId userId) { |
1839 | + restTemplate.delete(baseURL + "/api/user/{userId}", userId.getId()); | ||
1887 | } | 1840 | } |
1888 | 1841 | ||
1889 | - public TextPageData<User> getTenantAdmins(String tenantId, TextPageLink pageLink) { | 1842 | + public TextPageData<User> getTenantAdmins(TenantId tenantId, TextPageLink pageLink) { |
1890 | Map<String, String> params = new HashMap<>(); | 1843 | Map<String, String> params = new HashMap<>(); |
1891 | - params.put("tenantId", tenantId); | 1844 | + params.put("tenantId", tenantId.getId().toString()); |
1892 | addPageLinkToParam(params, pageLink); | 1845 | addPageLinkToParam(params, pageLink); |
1893 | 1846 | ||
1894 | return restTemplate.exchange( | 1847 | return restTemplate.exchange( |
@@ -1896,13 +1849,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1896,13 +1849,12 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1896 | HttpMethod.GET, | 1849 | HttpMethod.GET, |
1897 | HttpEntity.EMPTY, | 1850 | HttpEntity.EMPTY, |
1898 | new ParameterizedTypeReference<TextPageData<User>>() { | 1851 | new ParameterizedTypeReference<TextPageData<User>>() { |
1899 | - }, | ||
1900 | - params).getBody(); | 1852 | + }, params).getBody(); |
1901 | } | 1853 | } |
1902 | 1854 | ||
1903 | - public TextPageData<User> getCustomerUsers(String customerId, TextPageLink pageLink) { | 1855 | + public TextPageData<User> getCustomerUsers(CustomerId customerId, TextPageLink pageLink) { |
1904 | Map<String, String> params = new HashMap<>(); | 1856 | Map<String, String> params = new HashMap<>(); |
1905 | - params.put("customerId", customerId); | 1857 | + params.put("customerId", customerId.getId().toString()); |
1906 | addPageLinkToParam(params, pageLink); | 1858 | addPageLinkToParam(params, pageLink); |
1907 | 1859 | ||
1908 | return restTemplate.exchange( | 1860 | return restTemplate.exchange( |
@@ -1910,22 +1862,21 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1910,22 +1862,21 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1910 | HttpMethod.GET, | 1862 | HttpMethod.GET, |
1911 | HttpEntity.EMPTY, | 1863 | HttpEntity.EMPTY, |
1912 | new ParameterizedTypeReference<TextPageData<User>>() { | 1864 | new ParameterizedTypeReference<TextPageData<User>>() { |
1913 | - }, | ||
1914 | - params).getBody(); | 1865 | + }, params).getBody(); |
1915 | } | 1866 | } |
1916 | 1867 | ||
1917 | - public void setUserCredentialsEnabled(String userId, boolean userCredentialsEnabled) { | 1868 | + public void setUserCredentialsEnabled(UserId userId, boolean userCredentialsEnabled) { |
1918 | restTemplate.postForLocation( | 1869 | restTemplate.postForLocation( |
1919 | baseURL + "/api/user/{userId}/userCredentialsEnabled?serCredentialsEnabled={serCredentialsEnabled}", | 1870 | baseURL + "/api/user/{userId}/userCredentialsEnabled?serCredentialsEnabled={serCredentialsEnabled}", |
1920 | null, | 1871 | null, |
1921 | - userId, | 1872 | + userId.getId(), |
1922 | userCredentialsEnabled); | 1873 | userCredentialsEnabled); |
1923 | } | 1874 | } |
1924 | 1875 | ||
1925 | - public Optional<WidgetsBundle> getWidgetsBundleById(String widgetsBundleId) { | 1876 | + public Optional<WidgetsBundle> getWidgetsBundleById(WidgetsBundleId widgetsBundleId) { |
1926 | try { | 1877 | try { |
1927 | ResponseEntity<WidgetsBundle> widgetsBundle = | 1878 | ResponseEntity<WidgetsBundle> widgetsBundle = |
1928 | - restTemplate.getForEntity(baseURL + "/api/widgetsBundle/{widgetsBundleId}", WidgetsBundle.class, widgetsBundleId); | 1879 | + restTemplate.getForEntity(baseURL + "/api/widgetsBundle/{widgetsBundleId}", WidgetsBundle.class, widgetsBundleId.getId()); |
1929 | return Optional.ofNullable(widgetsBundle.getBody()); | 1880 | return Optional.ofNullable(widgetsBundle.getBody()); |
1930 | } catch (HttpClientErrorException exception) { | 1881 | } catch (HttpClientErrorException exception) { |
1931 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1882 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1940,8 +1891,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1940,8 +1891,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1940 | return restTemplate.postForEntity(baseURL + "/api/widgetsBundle", widgetsBundle, WidgetsBundle.class).getBody(); | 1891 | return restTemplate.postForEntity(baseURL + "/api/widgetsBundle", widgetsBundle, WidgetsBundle.class).getBody(); |
1941 | } | 1892 | } |
1942 | 1893 | ||
1943 | - public void deleteWidgetsBundle(String widgetsBundleId) { | ||
1944 | - restTemplate.delete(baseURL + "/api/widgetsBundle/{widgetsBundleId}", widgetsBundleId); | 1894 | + public void deleteWidgetsBundle(WidgetsBundleId widgetsBundleId) { |
1895 | + restTemplate.delete(baseURL + "/api/widgetsBundle/{widgetsBundleId}", widgetsBundleId.getId()); | ||
1945 | } | 1896 | } |
1946 | 1897 | ||
1947 | public TextPageData<WidgetsBundle> getWidgetsBundles(TextPageLink pageLink) { | 1898 | public TextPageData<WidgetsBundle> getWidgetsBundles(TextPageLink pageLink) { |
@@ -1952,7 +1903,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1952,7 +1903,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1952 | HttpMethod.GET, | 1903 | HttpMethod.GET, |
1953 | HttpEntity.EMPTY, | 1904 | HttpEntity.EMPTY, |
1954 | new ParameterizedTypeReference<TextPageData<WidgetsBundle>>() { | 1905 | new ParameterizedTypeReference<TextPageData<WidgetsBundle>>() { |
1955 | - }).getBody(); | 1906 | + }, params).getBody(); |
1956 | } | 1907 | } |
1957 | 1908 | ||
1958 | public List<WidgetsBundle> getWidgetsBundles() { | 1909 | public List<WidgetsBundle> getWidgetsBundles() { |
@@ -1964,10 +1915,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1964,10 +1915,10 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1964 | }).getBody(); | 1915 | }).getBody(); |
1965 | } | 1916 | } |
1966 | 1917 | ||
1967 | - public Optional<WidgetType> getWidgetTypeById(String widgetTypeId) { | 1918 | + public Optional<WidgetType> getWidgetTypeById(WidgetsBundleId widgetTypeId) { |
1968 | try { | 1919 | try { |
1969 | ResponseEntity<WidgetType> widgetType = | 1920 | ResponseEntity<WidgetType> widgetType = |
1970 | - restTemplate.getForEntity(baseURL + "/api/widgetType/{widgetTypeId}", WidgetType.class, widgetTypeId); | 1921 | + restTemplate.getForEntity(baseURL + "/api/widgetType/{widgetTypeId}", WidgetType.class, widgetTypeId.getId()); |
1971 | return Optional.ofNullable(widgetType.getBody()); | 1922 | return Optional.ofNullable(widgetType.getBody()); |
1972 | } catch (HttpClientErrorException exception) { | 1923 | } catch (HttpClientErrorException exception) { |
1973 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | 1924 | if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
@@ -1982,8 +1933,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -1982,8 +1933,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
1982 | return restTemplate.postForEntity(baseURL + "/api/widgetType", widgetType, WidgetType.class).getBody(); | 1933 | return restTemplate.postForEntity(baseURL + "/api/widgetType", widgetType, WidgetType.class).getBody(); |
1983 | } | 1934 | } |
1984 | 1935 | ||
1985 | - public void deleteWidgetType(String widgetTypeId) { | ||
1986 | - restTemplate.delete(baseURL + "/api/widgetType/{widgetTypeId}", widgetTypeId); | 1936 | + public void deleteWidgetType(WidgetTypeId widgetTypeId) { |
1937 | + restTemplate.delete(baseURL + "/api/widgetType/{widgetTypeId}", widgetTypeId.getId()); | ||
1987 | } | 1938 | } |
1988 | 1939 | ||
1989 | public List<WidgetType> getBundleWidgetTypes(boolean isSystem, String bundleAlias) { | 1940 | public List<WidgetType> getBundleWidgetTypes(boolean isSystem, String bundleAlias) { |
@@ -2016,6 +1967,34 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -2016,6 +1967,34 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
2016 | } | 1967 | } |
2017 | } | 1968 | } |
2018 | 1969 | ||
1970 | + private String getUrlParams(TimePageLink pageLink) { | ||
1971 | + String urlParams = "limit={limit}&ascOrder={ascOrder}"; | ||
1972 | + if (pageLink.getStartTime() != null) { | ||
1973 | + urlParams += "&startTime={startTime}"; | ||
1974 | + } | ||
1975 | + if (pageLink.getEndTime() != null) { | ||
1976 | + urlParams += "&endTime={endTime}"; | ||
1977 | + } | ||
1978 | + if (pageLink.getIdOffset() != null) { | ||
1979 | + urlParams += "&offset={offset}"; | ||
1980 | + } | ||
1981 | + return urlParams; | ||
1982 | + } | ||
1983 | + | ||
1984 | + private String getUrlParams(TextPageLink pageLink) { | ||
1985 | + String urlParams = "limit={limit}"; | ||
1986 | + if (!isEmpty(pageLink.getTextSearch())) { | ||
1987 | + urlParams += "&textSearch={textSearch}"; | ||
1988 | + } | ||
1989 | + if (!isEmpty(pageLink.getIdOffset())) { | ||
1990 | + urlParams += "&idOffset={idOffset}"; | ||
1991 | + } | ||
1992 | + if (!isEmpty(pageLink.getTextOffset())) { | ||
1993 | + urlParams += "&textOffset={textOffset}"; | ||
1994 | + } | ||
1995 | + return urlParams; | ||
1996 | + } | ||
1997 | + | ||
2019 | private void addPageLinkToParam(Map<String, String> params, TimePageLink pageLink) { | 1998 | private void addPageLinkToParam(Map<String, String> params, TimePageLink pageLink) { |
2020 | params.put("limit", String.valueOf(pageLink.getLimit())); | 1999 | params.put("limit", String.valueOf(pageLink.getLimit())); |
2021 | if (pageLink.getStartTime() != null) { | 2000 | if (pageLink.getStartTime() != null) { |
@@ -2049,6 +2028,14 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | @@ -2049,6 +2028,14 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { | ||
2049 | return String.join(",", list); | 2028 | return String.join(",", list); |
2050 | } | 2029 | } |
2051 | 2030 | ||
2031 | + private String listIdsToString(List<? extends EntityId> list) { | ||
2032 | + return listToString(list.stream().map(id -> id.getId().toString()).collect(Collectors.toList())); | ||
2033 | + } | ||
2034 | + | ||
2035 | + private String listEnumToString(List<? extends Enum> list) { | ||
2036 | + return listToString(list.stream().map(Enum::name).collect(Collectors.toList())); | ||
2037 | + } | ||
2038 | + | ||
2052 | @Override | 2039 | @Override |
2053 | public void close() { | 2040 | public void close() { |
2054 | if (service != null) { | 2041 | if (service != null) { |