Commit 5aed684bdde67bf9739988efc1f2c6c687051a08

Authored by Andrii Shvaika
1 parent 07dca7ef

Entity View controller

... ... @@ -17,7 +17,6 @@ package org.thingsboard.server.controller;
17 17
18 18 public class ControllerConstants {
19 19
20   -
21 20 protected static final String NEW_LINE = "\n\n";
22 21 protected static final int DEFAULT_PAGE_SIZE = 1000;
23 22 protected static final String ENTITY_TYPE = "entityType";
... ... @@ -32,6 +31,7 @@ public class ControllerConstants {
32 31 protected static final String DASHBOARD_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
33 32 protected static final String RPC_ID_PARAM_DESCRIPTION = "A string value representing the rpc id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
34 33 protected static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
  34 + protected static final String ENTITY_VIEW_ID_PARAM_DESCRIPTION = "A string value representing the entity view id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
35 35 protected static final String DEVICE_PROFILE_ID_PARAM_DESCRIPTION = "A string value representing the device profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
36 36 protected static final String TENANT_PROFILE_ID_PARAM_DESCRIPTION = "A string value representing the tenant profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
37 37 protected static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
... ... @@ -56,6 +56,7 @@ public class ControllerConstants {
56 56 protected static final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page";
57 57 protected static final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0";
58 58 protected static final String DEVICE_TYPE_DESCRIPTION = "Device type as the name of the device profile";
  59 + protected static final String ENTITY_VIEW_TYPE_DESCRIPTION = "Entity View type";
59 60 protected static final String ASSET_TYPE_DESCRIPTION = "Asset type";
60 61 protected static final String EDGE_TYPE_DESCRIPTION = "A string value representing the edge type. For example, 'default'";
61 62 protected static final String RULE_CHAIN_TYPE_DESCRIPTION = "Rule chain type (CORE or EDGE)";
... ... @@ -64,6 +65,7 @@ public class ControllerConstants {
64 65 protected static final String WIDGET_BUNDLE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the widget bundle title.";
65 66 protected static final String RPC_TEXT_SEARCH_DESCRIPTION = "Not implemented. Leave empty.";
66 67 protected static final String DEVICE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device name.";
  68 + protected static final String ENTITY_VIEW_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the entity view name.";
67 69 protected static final String USER_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the user email.";
68 70 protected static final String TENANT_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the tenant name.";
69 71 protected static final String TENANT_PROFILE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the tenant profile name.";
... ... @@ -78,6 +80,8 @@ public class ControllerConstants {
78 80 protected static final String CUSTOMER_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title, email, country, city";
79 81 protected static final String RPC_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, expirationTime, request, response";
80 82 protected static final String DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, deviceProfileName, label, customerTitle";
  83 + protected static final String ENTITY_VIEW_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type";
  84 + protected static final String ENTITY_VIEW_INFO_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, type, customerTitle";
81 85 protected static final String USER_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, firstName, lastName, email";
82 86 protected static final String TENANT_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title, email, country, state, city, address, address2, zip, phone, email";
83 87 protected static final String TENANT_PROFILE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, description, isDefault";
... ... @@ -1359,4 +1363,11 @@ public class ControllerConstants {
1359 1363
1360 1364 protected static final String DEVICE_PROFILE_ID = "deviceProfileId";
1361 1365
  1366 + protected static final String MODEL_DESCRIPTION = "See the 'Model' tab for more details.";
  1367 + protected static final String ENTITY_VIEW_DESCRIPTION = "Entity Views limit the degree of exposure of the Device or Asset telemetry and attributes to the Customers. " +
  1368 + "Every Entity View references exactly one entity (device or asset) and defines telemetry and attribute keys that will be visible to the assigned Customer. " +
  1369 + "As a Tenant Administrator you are able to create multiple EVs per Device or Asset and assign them to different Customers. ";
  1370 + protected static final String ENTITY_VIEW_INFO_DESCRIPTION = "Entity Views Info extends the Entity View with customer title and 'is public' flag. " + ENTITY_VIEW_DESCRIPTION;
  1371 +
  1372 +
1362 1373 }
... ...
... ... @@ -87,6 +87,7 @@ import java.util.UUID;
87 87 import java.util.stream.Collectors;
88 88
89 89 import static org.thingsboard.server.controller.ControllerConstants.CUSTOMER_AUTHORITY_PARAGRAPH;
  90 +import static org.thingsboard.server.controller.ControllerConstants.CUSTOMER_ID;
90 91 import static org.thingsboard.server.controller.ControllerConstants.CUSTOMER_ID_PARAM_DESCRIPTION;
91 92 import static org.thingsboard.server.controller.ControllerConstants.DEVICE_ID_PARAM_DESCRIPTION;
92 93 import static org.thingsboard.server.controller.ControllerConstants.DEVICE_INFO_DESCRIPTION;
... ... @@ -492,7 +493,7 @@ public class DeviceController extends BaseController {
492 493 @ResponseBody
493 494 public PageData<Device> getCustomerDevices(
494 495 @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION, required = true)
495   - @PathVariable("customerId") String strCustomerId,
  496 + @PathVariable(CUSTOMER_ID) String strCustomerId,
496 497 @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
497 498 @RequestParam int pageSize,
498 499 @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
... ...
... ... @@ -21,6 +21,7 @@ import com.google.common.util.concurrent.ListenableFuture;
21 21 import com.google.common.util.concurrent.MoreExecutors;
22 22 import com.google.common.util.concurrent.SettableFuture;
23 23 import io.swagger.annotations.ApiOperation;
  24 +import io.swagger.annotations.ApiParam;
24 25 import lombok.extern.slf4j.Slf4j;
25 26 import org.springframework.beans.factory.annotation.Autowired;
26 27 import org.springframework.http.HttpStatus;
... ... @@ -74,7 +75,7 @@ import java.util.concurrent.ExecutionException;
74 75 import java.util.stream.Collectors;
75 76
76 77 import static org.apache.commons.lang3.StringUtils.isBlank;
77   -import static org.thingsboard.server.controller.ControllerConstants.CUSTOMER_ID;
  78 +import static org.thingsboard.server.controller.ControllerConstants.*;
78 79 import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION;
79 80 import static org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION;
80 81 import static org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION;
... ... @@ -95,10 +96,16 @@ public class EntityViewController extends BaseController {
95 96 @Autowired
96 97 private TimeseriesService tsService;
97 98
  99 + @ApiOperation(value = "Get entity view (getEntityViewById)",
  100 + notes = "Fetch the EntityView object based on the provided entity view id. "
  101 + + ENTITY_VIEW_DESCRIPTION + MODEL_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH,
  102 + produces = MediaType.APPLICATION_JSON_VALUE)
98 103 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
99 104 @RequestMapping(value = "/entityView/{entityViewId}", method = RequestMethod.GET)
100 105 @ResponseBody
101   - public EntityView getEntityViewById(@PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
  106 + public EntityView getEntityViewById(
  107 + @ApiParam(value = ENTITY_VIEW_ID_PARAM_DESCRIPTION)
  108 + @PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
102 109 checkParameter(ENTITY_VIEW_ID, strEntityViewId);
103 110 try {
104 111 return checkEntityViewId(new EntityViewId(toUUID(strEntityViewId)), Operation.READ);
... ... @@ -107,10 +114,16 @@ public class EntityViewController extends BaseController {
107 114 }
108 115 }
109 116
  117 + @ApiOperation(value = "Get Entity View info (getEntityViewInfoById)",
  118 + notes = "Fetch the Entity View info object based on the provided Entity View Id. "
  119 + + ENTITY_VIEW_INFO_DESCRIPTION + MODEL_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH,
  120 + produces = MediaType.APPLICATION_JSON_VALUE)
110 121 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
111 122 @RequestMapping(value = "/entityView/info/{entityViewId}", method = RequestMethod.GET)
112 123 @ResponseBody
113   - public EntityViewInfo getEntityViewInfoById(@PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
  124 + public EntityViewInfo getEntityViewInfoById(
  125 + @ApiParam(value = ENTITY_VIEW_ID_PARAM_DESCRIPTION)
  126 + @PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
114 127 checkParameter(ENTITY_VIEW_ID, strEntityViewId);
115 128 try {
116 129 EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId));
... ... @@ -120,10 +133,15 @@ public class EntityViewController extends BaseController {
120 133 }
121 134 }
122 135
  136 + @ApiOperation(value = "Save or update entity view (saveEntityView)",
  137 + notes = ENTITY_VIEW_DESCRIPTION + MODEL_DESCRIPTION,
  138 + produces = MediaType.APPLICATION_JSON_VALUE)
123 139 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
124 140 @RequestMapping(value = "/entityView", method = RequestMethod.POST)
125 141 @ResponseBody
126   - public EntityView saveEntityView(@RequestBody EntityView entityView) throws ThingsboardException {
  142 + public EntityView saveEntityView(
  143 + @ApiParam(value = "A JSON object representing the entity view.")
  144 + @RequestBody EntityView entityView) throws ThingsboardException {
127 145 try {
128 146 entityView.setTenantId(getCurrentUser().getTenantId());
129 147
... ... @@ -357,10 +375,15 @@ public class EntityViewController extends BaseController {
357 375 keys);
358 376 }
359 377
  378 + @ApiOperation(value = "Delete entity view (deleteEntityView)",
  379 + notes = "Delete the EntityView object based on the provided entity view id. "
  380 + + TENANT_AUTHORITY_PARAGRAPH)
360 381 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
361 382 @RequestMapping(value = "/entityView/{entityViewId}", method = RequestMethod.DELETE)
362 383 @ResponseStatus(value = HttpStatus.OK)
363   - public void deleteEntityView(@PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
  384 + public void deleteEntityView(
  385 + @ApiParam(value = ENTITY_VIEW_ID_PARAM_DESCRIPTION)
  386 + @PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
364 387 checkParameter(ENTITY_VIEW_ID, strEntityViewId);
365 388 try {
366 389 EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId));
... ... @@ -382,10 +405,14 @@ public class EntityViewController extends BaseController {
382 405 }
383 406 }
384 407
  408 + @ApiOperation(value = "Get Entity View by name (getTenantEntityView)",
  409 + notes = "Fetch the Entity View object based on the tenant id and entity view name. " + TENANT_AUTHORITY_PARAGRAPH,
  410 + produces = MediaType.APPLICATION_JSON_VALUE)
385 411 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
386 412 @RequestMapping(value = "/tenant/entityViews", params = {"entityViewName"}, method = RequestMethod.GET)
387 413 @ResponseBody
388 414 public EntityView getTenantEntityView(
  415 + @ApiParam(value = "Entity View name")
389 416 @RequestParam String entityViewName) throws ThingsboardException {
390 417 try {
391 418 TenantId tenantId = getCurrentUser().getTenantId();
... ... @@ -395,11 +422,16 @@ public class EntityViewController extends BaseController {
395 422 }
396 423 }
397 424
  425 + @ApiOperation(value = "Assign Entity View to customer (assignEntityViewToCustomer)",
  426 + notes = "Creates assignment of the Entity View to customer. Customer will be able to query Entity View afterwards." + TENANT_AUTHORITY_PARAGRAPH)
398 427 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
399 428 @RequestMapping(value = "/customer/{customerId}/entityView/{entityViewId}", method = RequestMethod.POST)
400 429 @ResponseBody
401   - public EntityView assignEntityViewToCustomer(@PathVariable(CUSTOMER_ID) String strCustomerId,
402   - @PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
  430 + public EntityView assignEntityViewToCustomer(
  431 + @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
  432 + @PathVariable(CUSTOMER_ID) String strCustomerId,
  433 + @ApiParam(value = ENTITY_VIEW_ID_PARAM_DESCRIPTION)
  434 + @PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
403 435 checkParameter(CUSTOMER_ID, strCustomerId);
404 436 checkParameter(ENTITY_VIEW_ID, strEntityViewId);
405 437 try {
... ... @@ -426,10 +458,14 @@ public class EntityViewController extends BaseController {
426 458 }
427 459 }
428 460
  461 + @ApiOperation(value = "Unassign Entity View from customer (unassignEntityViewFromCustomer)",
  462 + notes = "Clears assignment of the Entity View to customer. Customer will not be able to query Entity View afterwards." + TENANT_AUTHORITY_PARAGRAPH)
429 463 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
430 464 @RequestMapping(value = "/customer/entityView/{entityViewId}", method = RequestMethod.DELETE)
431 465 @ResponseBody
432   - public EntityView unassignEntityViewFromCustomer(@PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
  466 + public EntityView unassignEntityViewFromCustomer(
  467 + @ApiParam(value = ENTITY_VIEW_ID_PARAM_DESCRIPTION)
  468 + @PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
433 469 checkParameter(ENTITY_VIEW_ID, strEntityViewId);
434 470 try {
435 471 EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId));
... ... @@ -455,18 +491,28 @@ public class EntityViewController extends BaseController {
455 491 }
456 492 }
457 493
  494 + @ApiOperation(value = "Get Customer Entity Views (getCustomerEntityViews)",
  495 + notes = "Returns a page of Entity View objects assigned to customer. " +
  496 + PAGE_DATA_PARAMETERS + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
458 497 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
459 498 @RequestMapping(value = "/customer/{customerId}/entityViews", params = {"pageSize", "page"}, method = RequestMethod.GET)
460 499 @ResponseBody
461 500 public PageData<EntityView> getCustomerEntityViews(
462   - @PathVariable("customerId") String strCustomerId,
  501 + @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION, required = true)
  502 + @PathVariable(CUSTOMER_ID) String strCustomerId,
  503 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
463 504 @RequestParam int pageSize,
  505 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
464 506 @RequestParam int page,
  507 + @ApiParam(value = ENTITY_VIEW_TYPE)
465 508 @RequestParam(required = false) String type,
  509 + @ApiParam(value = ENTITY_VIEW_TEXT_SEARCH_DESCRIPTION)
466 510 @RequestParam(required = false) String textSearch,
  511 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = ENTITY_VIEW_SORT_PROPERTY_ALLOWABLE_VALUES)
467 512 @RequestParam(required = false) String sortProperty,
  513 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
468 514 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
469   - checkParameter("customerId", strCustomerId);
  515 + checkParameter(CUSTOMER_ID, strCustomerId);
470 516 try {
471 517 TenantId tenantId = getCurrentUser().getTenantId();
472 518 CustomerId customerId = new CustomerId(toUUID(strCustomerId));
... ... @@ -482,16 +528,26 @@ public class EntityViewController extends BaseController {
482 528 }
483 529 }
484 530
  531 + @ApiOperation(value = "Get Customer Entity View info (getCustomerEntityViewInfos)",
  532 + notes = "Returns a page of Entity View info objects assigned to customer. " + ENTITY_VIEW_DESCRIPTION +
  533 + PAGE_DATA_PARAMETERS + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
485 534 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
486 535 @RequestMapping(value = "/customer/{customerId}/entityViewInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
487 536 @ResponseBody
488 537 public PageData<EntityViewInfo> getCustomerEntityViewInfos(
489   - @PathVariable("customerId") String strCustomerId,
  538 + @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION, required = true)
  539 + @PathVariable(CUSTOMER_ID) String strCustomerId,
  540 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
490 541 @RequestParam int pageSize,
  542 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
491 543 @RequestParam int page,
  544 + @ApiParam(value = ENTITY_VIEW_TYPE)
492 545 @RequestParam(required = false) String type,
  546 + @ApiParam(value = ENTITY_VIEW_TEXT_SEARCH_DESCRIPTION)
493 547 @RequestParam(required = false) String textSearch,
  548 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = ENTITY_VIEW_INFO_SORT_PROPERTY_ALLOWABLE_VALUES)
494 549 @RequestParam(required = false) String sortProperty,
  550 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
495 551 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
496 552 checkParameter("customerId", strCustomerId);
497 553 try {
... ... @@ -509,15 +565,24 @@ public class EntityViewController extends BaseController {
509 565 }
510 566 }
511 567
  568 + @ApiOperation(value = "Get Tenant Entity Views (getTenantEntityViews)",
  569 + notes = "Returns a page of entity views owned by tenant. " + ENTITY_VIEW_DESCRIPTION +
  570 + PAGE_DATA_PARAMETERS + TENANT_AUTHORITY_PARAGRAPH)
512 571 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
513 572 @RequestMapping(value = "/tenant/entityViews", params = {"pageSize", "page"}, method = RequestMethod.GET)
514 573 @ResponseBody
515 574 public PageData<EntityView> getTenantEntityViews(
  575 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
516 576 @RequestParam int pageSize,
  577 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
517 578 @RequestParam int page,
  579 + @ApiParam(value = ENTITY_VIEW_TYPE)
518 580 @RequestParam(required = false) String type,
  581 + @ApiParam(value = ENTITY_VIEW_TEXT_SEARCH_DESCRIPTION)
519 582 @RequestParam(required = false) String textSearch,
  583 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = ENTITY_VIEW_SORT_PROPERTY_ALLOWABLE_VALUES)
520 584 @RequestParam(required = false) String sortProperty,
  585 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
521 586 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
522 587 try {
523 588 TenantId tenantId = getCurrentUser().getTenantId();
... ... @@ -533,15 +598,24 @@ public class EntityViewController extends BaseController {
533 598 }
534 599 }
535 600
  601 + @ApiOperation(value = "Get Tenant Entity Views (getTenantEntityViews)",
  602 + notes = "Returns a page of entity views info owned by tenant. " + ENTITY_VIEW_DESCRIPTION +
  603 + PAGE_DATA_PARAMETERS + TENANT_AUTHORITY_PARAGRAPH)
536 604 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
537 605 @RequestMapping(value = "/tenant/entityViewInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
538 606 @ResponseBody
539 607 public PageData<EntityViewInfo> getTenantEntityViewInfos(
  608 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
540 609 @RequestParam int pageSize,
  610 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
541 611 @RequestParam int page,
  612 + @ApiParam(value = ENTITY_VIEW_TYPE)
542 613 @RequestParam(required = false) String type,
  614 + @ApiParam(value = ENTITY_VIEW_TEXT_SEARCH_DESCRIPTION)
543 615 @RequestParam(required = false) String textSearch,
  616 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = ENTITY_VIEW_INFO_SORT_PROPERTY_ALLOWABLE_VALUES)
544 617 @RequestParam(required = false) String sortProperty,
  618 + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
545 619 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
546 620 try {
547 621 TenantId tenantId = getCurrentUser().getTenantId();
... ... @@ -556,10 +630,16 @@ public class EntityViewController extends BaseController {
556 630 }
557 631 }
558 632
  633 + @ApiOperation(value = "Find related entity views (findByQuery)",
  634 + notes = "Returns all entity views that are related to the specific entity. " +
  635 + "The entity id, relation type, entity view types, depth of the search, and other query parameters defined using complex 'EntityViewSearchQuery' object. " +
  636 + "See 'Model' tab of the Parameters for more info." + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
559 637 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
560 638 @RequestMapping(value = "/entityViews", method = RequestMethod.POST)
561 639 @ResponseBody
562   - public List<EntityView> findByQuery(@RequestBody EntityViewSearchQuery query) throws ThingsboardException {
  640 + public List<EntityView> findByQuery(
  641 + @ApiParam(value = "The entity view search query JSON")
  642 + @RequestBody EntityViewSearchQuery query) throws ThingsboardException {
563 643 checkNotNull(query);
564 644 checkNotNull(query.getParameters());
565 645 checkNotNull(query.getEntityViewTypes());
... ... @@ -580,6 +660,9 @@ public class EntityViewController extends BaseController {
580 660 }
581 661 }
582 662
  663 + @ApiOperation(value = "Get Entity View Types (getEntityViewTypes)",
  664 + notes = "Returns a set of unique entity view types based on entity views that are either owned by the tenant or assigned to the customer which user is performing the request."
  665 + + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
583 666 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
584 667 @RequestMapping(value = "/entityView/types", method = RequestMethod.GET)
585 668 @ResponseBody
... ... @@ -594,10 +677,16 @@ public class EntityViewController extends BaseController {
594 677 }
595 678 }
596 679
  680 + @ApiOperation(value = "Make entity view publicly available (assignEntityViewToPublicCustomer)",
  681 + notes = "Entity View will be available for non-authorized (not logged-in) users. " +
  682 + "This is useful to create dashboards that you plan to share/embed on a publicly available website. " +
  683 + "However, users that are logged-in and belong to different tenant will not be able to access the entity view." + TENANT_AUTHORITY_PARAGRAPH)
597 684 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
598 685 @RequestMapping(value = "/customer/public/entityView/{entityViewId}", method = RequestMethod.POST)
599 686 @ResponseBody
600   - public EntityView assignEntityViewToPublicCustomer(@PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
  687 + public EntityView assignEntityViewToPublicCustomer(
  688 + @ApiParam(value = ENTITY_VIEW_ID_PARAM_DESCRIPTION)
  689 + @PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
601 690 checkParameter(ENTITY_VIEW_ID, strEntityViewId);
602 691 try {
603 692 EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId));
... ...
... ... @@ -92,10 +92,10 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
92 92 return this;
93 93 }
94 94
95   - @ApiModelProperty(position = 1, value = "JSON object with the device Id. " +
96   - "Specify this field to update the device. " +
97   - "Referencing non-existing device Id will cause error. " +
98   - "Omit this field to create new device." )
  95 + @ApiModelProperty(position = 1, value = "JSON object with the Device Id. " +
  96 + "Specify this field to update the Device. " +
  97 + "Referencing non-existing Device Id will cause error. " +
  98 + "Omit this field to create new Device." )
99 99 @Override
100 100 public DeviceId getId() {
101 101 return super.getId();
... ...
... ... @@ -15,6 +15,8 @@
15 15 */
16 16 package org.thingsboard.server.common.data;
17 17
  18 +import com.fasterxml.jackson.databind.JsonNode;
  19 +import io.swagger.annotations.ApiModelProperty;
18 20 import lombok.AllArgsConstructor;
19 21 import lombok.Data;
20 22 import lombok.EqualsAndHashCode;
... ... @@ -37,15 +39,21 @@ public class EntityView extends SearchTextBasedWithAdditionalInfo<EntityViewId>
37 39
38 40 private static final long serialVersionUID = 5582010124562018986L;
39 41
  42 + @ApiModelProperty(position = 7, required = true, value = "JSON object with the referenced Entity Id (Device or Asset).")
40 43 private EntityId entityId;
41 44 private TenantId tenantId;
42 45 private CustomerId customerId;
43 46 @NoXss
  47 + @ApiModelProperty(position = 5, required = true, value = "Entity View name", example = "A4B72CCDFF33")
44 48 private String name;
45 49 @NoXss
  50 + @ApiModelProperty(position = 6, required = true, value = "Device Profile Name", example = "Temperature Sensor")
46 51 private String type;
  52 + @ApiModelProperty(position = 8, required = true, value = "Set of telemetry and attribute keys to expose via Entity View.")
47 53 private TelemetryEntityView keys;
  54 + @ApiModelProperty(position = 9, value = "Represents the start time of the interval that is used to limit access to target device telemetry. Customer will not be able to see entity telemetry that is outside the specified interval;")
48 55 private long startTimeMs;
  56 + @ApiModelProperty(position = 10, value = "Represents the end time of the interval that is used to limit access to target device telemetry. Customer will not be able to see entity telemetry that is outside the specified interval;")
49 57 private long endTimeMs;
50 58
51 59 public EntityView() {
... ... @@ -73,6 +81,7 @@ public class EntityView extends SearchTextBasedWithAdditionalInfo<EntityViewId>
73 81 return getName() /*What the ...*/;
74 82 }
75 83
  84 + @ApiModelProperty(position = 4, value = "JSON object with Customer Id. Use 'assignEntityViewToCustomer' to change the Customer Id.", readOnly = true)
76 85 @Override
77 86 public CustomerId getCustomerId() {
78 87 return customerId;
... ... @@ -83,8 +92,31 @@ public class EntityView extends SearchTextBasedWithAdditionalInfo<EntityViewId>
83 92 return name;
84 93 }
85 94
  95 + @ApiModelProperty(position = 3, value = "JSON object with Tenant Id.", readOnly = true)
86 96 @Override
87 97 public TenantId getTenantId() {
88 98 return tenantId;
89 99 }
  100 +
  101 + @ApiModelProperty(position = 1, value = "JSON object with the Entity View Id. " +
  102 + "Specify this field to update the Entity View. " +
  103 + "Referencing non-existing Entity View Id will cause error. " +
  104 + "Omit this field to create new Entity View." )
  105 + @Override
  106 + public EntityViewId getId() {
  107 + return super.getId();
  108 + }
  109 +
  110 + @ApiModelProperty(position = 2, value = "Timestamp of the Entity View creation, in milliseconds", example = "1609459200000", readOnly = true)
  111 + @Override
  112 + public long getCreatedTime() {
  113 + return super.getCreatedTime();
  114 + }
  115 +
  116 + @ApiModelProperty(position = 11, value = "Additional parameters of the device", dataType = "com.fasterxml.jackson.databind.JsonNode")
  117 + @Override
  118 + public JsonNode getAdditionalInfo() {
  119 + return super.getAdditionalInfo();
  120 + }
  121 +
90 122 }
... ...
... ... @@ -15,13 +15,16 @@
15 15 */
16 16 package org.thingsboard.server.common.data;
17 17
  18 +import io.swagger.annotations.ApiModelProperty;
18 19 import lombok.Data;
19 20 import org.thingsboard.server.common.data.id.EntityViewId;
20 21
21 22 @Data
22 23 public class EntityViewInfo extends EntityView {
23 24
  25 + @ApiModelProperty(position = 12, value = "Title of the Customer that owns the entity view.", readOnly = true)
24 26 private String customerTitle;
  27 + @ApiModelProperty(position = 13, value = "Indicates special 'Public' Customer that is auto-generated to use the entity view on public dashboards.", readOnly = true)
25 28 private boolean customerIsPublic;
26 29
27 30 public EntityViewInfo() {
... ...
... ... @@ -15,6 +15,8 @@
15 15 */
16 16 package org.thingsboard.server.common.data.entityview;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 20 import lombok.Data;
19 21 import org.thingsboard.server.common.data.EntityType;
20 22 import org.thingsboard.server.common.data.relation.EntityRelation;
... ... @@ -25,11 +27,15 @@ import org.thingsboard.server.common.data.relation.RelationsSearchParameters;
25 27 import java.util.Collections;
26 28 import java.util.List;
27 29
  30 +@ApiModel
28 31 @Data
29 32 public class EntityViewSearchQuery {
30 33
  34 + @ApiModelProperty(position = 3, value = "Main search parameters.")
31 35 private RelationsSearchParameters parameters;
  36 + @ApiModelProperty(position = 1, value = "Type of the relation between root entity and device (e.g. 'Contains' or 'Manages').")
32 37 private String relationType;
  38 + @ApiModelProperty(position = 2, value = "Array of entity view types to filter the related entities (e.g. 'Temperature Sensor', 'Smoke Sensor').")
33 39 private List<String> entityViewTypes;
34 40
35 41 public EntityRelationsQuery toEntitySearchQuery() {
... ...
... ... @@ -15,6 +15,8 @@
15 15 */
16 16 package org.thingsboard.server.common.data.objects;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 20 import lombok.Data;
19 21 import lombok.NoArgsConstructor;
20 22
... ... @@ -26,11 +28,15 @@ import java.util.List;
26 28 * Created by Victor Basanets on 9/05/2017.
27 29 */
28 30 @Data
  31 +@ApiModel
29 32 @NoArgsConstructor
30 33 public class AttributesEntityView implements Serializable {
31 34
  35 + @ApiModelProperty(position = 1, required = true, value = "List of client-side attribute keys to expose", example = "currentConfiguration")
32 36 private List<String> cs = new ArrayList<>();
  37 + @ApiModelProperty(position = 3, required = true, value = "List of server-side attribute keys to expose", example = "model")
33 38 private List<String> ss = new ArrayList<>();
  39 + @ApiModelProperty(position = 2, required = true, value = "List of shared attribute keys to expose", example = "targetConfiguration")
34 40 private List<String> sh = new ArrayList<>();
35 41
36 42 public AttributesEntityView(List<String> cs,
... ...
... ... @@ -15,6 +15,8 @@
15 15 */
16 16 package org.thingsboard.server.common.data.objects;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 20 import lombok.Data;
19 21 import lombok.NoArgsConstructor;
20 22
... ... @@ -25,11 +27,14 @@ import java.util.List;
25 27 /**
26 28 * Created by Victor Basanets on 9/05/2017.
27 29 */
  30 +@ApiModel
28 31 @Data
29 32 @NoArgsConstructor
30 33 public class TelemetryEntityView implements Serializable {
31 34
  35 + @ApiModelProperty(position = 1, required = true, value = "List of time-series data keys to expose", example = "temperature, humidity")
32 36 private List<String> timeseries;
  37 + @ApiModelProperty(position = 2, required = true, value = "JSON object with attributes to expose")
33 38 private AttributesEntityView attributes;
34 39
35 40 public TelemetryEntityView(List<String> timeseries, AttributesEntityView attributes) {
... ...