|
@@ -15,7 +15,10 @@ |
|
@@ -15,7 +15,10 @@ |
15
|
*/
|
15
|
*/
|
16
|
package org.thingsboard.server.controller;
|
16
|
package org.thingsboard.server.controller;
|
17
|
|
17
|
|
|
|
18
|
+import io.swagger.annotations.ApiOperation;
|
|
|
19
|
+import io.swagger.annotations.ApiParam;
|
18
|
import org.springframework.http.HttpStatus;
|
20
|
import org.springframework.http.HttpStatus;
|
|
|
21
|
+import org.springframework.http.MediaType;
|
19
|
import org.springframework.security.access.prepost.PreAuthorize;
|
22
|
import org.springframework.security.access.prepost.PreAuthorize;
|
20
|
import org.springframework.web.bind.annotation.RequestBody;
|
23
|
import org.springframework.web.bind.annotation.RequestBody;
|
21
|
import org.springframework.web.bind.annotation.RequestMapping;
|
24
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -52,10 +55,16 @@ public class EntityRelationController extends BaseController { |
|
@@ -52,10 +55,16 @@ public class EntityRelationController extends BaseController { |
52
|
public static final String RELATION_TYPE = "relationType";
|
55
|
public static final String RELATION_TYPE = "relationType";
|
53
|
public static final String TO_ID = "toId";
|
56
|
public static final String TO_ID = "toId";
|
54
|
|
57
|
|
|
|
58
|
+ @ApiOperation(value = "Create Relation (saveRelation)",
|
|
|
59
|
+ notes = "Creates a relation between two entities in the platform. " +
|
|
|
60
|
+ "If the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
61
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that 'from' and 'to' entities are owned by the same tenant. " +
|
|
|
62
|
+ "If the user has the authority of 'Customer User', the server checks that the 'from' and 'to' entities are assigned to the same customer.")
|
55
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
63
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
56
|
@RequestMapping(value = "/relation", method = RequestMethod.POST)
|
64
|
@RequestMapping(value = "/relation", method = RequestMethod.POST)
|
57
|
@ResponseStatus(value = HttpStatus.OK)
|
65
|
@ResponseStatus(value = HttpStatus.OK)
|
58
|
- public void saveRelation(@RequestBody EntityRelation relation) throws ThingsboardException {
|
66
|
+ public void saveRelation(@ApiParam(value = "A JSON value representing the relation.")
|
|
|
67
|
+ @RequestBody EntityRelation relation) throws ThingsboardException {
|
59
|
try {
|
68
|
try {
|
60
|
checkNotNull(relation);
|
69
|
checkNotNull(relation);
|
61
|
checkEntityId(relation.getFrom(), Operation.WRITE);
|
70
|
checkEntityId(relation.getFrom(), Operation.WRITE);
|
|
@@ -80,14 +89,20 @@ public class EntityRelationController extends BaseController { |
|
@@ -80,14 +89,20 @@ public class EntityRelationController extends BaseController { |
80
|
}
|
89
|
}
|
81
|
}
|
90
|
}
|
82
|
|
91
|
|
|
|
92
|
+ @ApiOperation(value = "Delete Relation (deleteRelation)",
|
|
|
93
|
+ notes = "Deletes a relation between two entities in the platform. " +
|
|
|
94
|
+ "If the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
95
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that 'from' and 'to' entities are owned by the same tenant. " +
|
|
|
96
|
+ "If the user has the authority of 'Customer User', the server checks that the 'from' and 'to' entities are assigned to the same customer.")
|
83
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
97
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
84
|
@RequestMapping(value = "/relation", method = RequestMethod.DELETE, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE})
|
98
|
@RequestMapping(value = "/relation", method = RequestMethod.DELETE, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE})
|
85
|
@ResponseStatus(value = HttpStatus.OK)
|
99
|
@ResponseStatus(value = HttpStatus.OK)
|
86
|
- public void deleteRelation(@RequestParam(FROM_ID) String strFromId,
|
|
|
87
|
- @RequestParam(FROM_TYPE) String strFromType,
|
|
|
88
|
- @RequestParam(RELATION_TYPE) String strRelationType,
|
|
|
89
|
- @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup,
|
|
|
90
|
- @RequestParam(TO_ID) String strToId, @RequestParam(TO_TYPE) String strToType) throws ThingsboardException {
|
100
|
+ public void deleteRelation(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam(FROM_ID) String strFromId,
|
|
|
101
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam(FROM_TYPE) String strFromType,
|
|
|
102
|
+ @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION) @RequestParam(RELATION_TYPE) String strRelationType,
|
|
|
103
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup,
|
|
|
104
|
+ @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam(TO_ID) String strToId,
|
|
|
105
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam(TO_TYPE) String strToType) throws ThingsboardException {
|
91
|
checkParameter(FROM_ID, strFromId);
|
106
|
checkParameter(FROM_ID, strFromId);
|
92
|
checkParameter(FROM_TYPE, strFromType);
|
107
|
checkParameter(FROM_TYPE, strFromType);
|
93
|
checkParameter(RELATION_TYPE, strRelationType);
|
108
|
checkParameter(RELATION_TYPE, strRelationType);
|
|
@@ -119,11 +134,16 @@ public class EntityRelationController extends BaseController { |
|
@@ -119,11 +134,16 @@ public class EntityRelationController extends BaseController { |
119
|
}
|
134
|
}
|
120
|
}
|
135
|
}
|
121
|
|
136
|
|
|
|
137
|
+ @ApiOperation(value = "Delete Relations (deleteRelations)",
|
|
|
138
|
+ notes = "Deletes all the relation (both 'from' and 'to' direction) for the specified entity. " +
|
|
|
139
|
+ "If the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
140
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that entity is owned by the same tenant. " +
|
|
|
141
|
+ "If the user has the authority of 'Customer User', the server checks that the entity is assigned to the same customer.")
|
122
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN','TENANT_ADMIN', 'CUSTOMER_USER')")
|
142
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN','TENANT_ADMIN', 'CUSTOMER_USER')")
|
123
|
- @RequestMapping(value = "/relations", method = RequestMethod.DELETE, params = {"id", "type"})
|
143
|
+ @RequestMapping(value = "/relations", method = RequestMethod.DELETE, params = {"entityId", "entityType"})
|
124
|
@ResponseStatus(value = HttpStatus.OK)
|
144
|
@ResponseStatus(value = HttpStatus.OK)
|
125
|
- public void deleteRelations(@RequestParam("entityId") String strId,
|
|
|
126
|
- @RequestParam("entityType") String strType) throws ThingsboardException {
|
145
|
+ public void deleteRelations(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam("entityId") String strId,
|
|
|
146
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam("entityType") String strType) throws ThingsboardException {
|
127
|
checkParameter("entityId", strId);
|
147
|
checkParameter("entityId", strId);
|
128
|
checkParameter("entityType", strType);
|
148
|
checkParameter("entityType", strType);
|
129
|
EntityId entityId = EntityIdFactory.getByTypeAndId(strType, strId);
|
149
|
EntityId entityId = EntityIdFactory.getByTypeAndId(strType, strId);
|
|
@@ -137,14 +157,21 @@ public class EntityRelationController extends BaseController { |
|
@@ -137,14 +157,21 @@ public class EntityRelationController extends BaseController { |
137
|
}
|
157
|
}
|
138
|
}
|
158
|
}
|
139
|
|
159
|
|
|
|
160
|
+ @ApiOperation(value = "Get Relation (getRelation)",
|
|
|
161
|
+ notes = "Returns relation object between two specified entities if present. Otherwise throws exception." +
|
|
|
162
|
+ "If the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
163
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that 'from' and 'to' entities are owned by the same tenant. " +
|
|
|
164
|
+ "If the user has the authority of 'Customer User', the server checks that the 'from' and 'to' entities are assigned to the same customer.",
|
|
|
165
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
140
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
166
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
141
|
@RequestMapping(value = "/relation", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE})
|
167
|
@RequestMapping(value = "/relation", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE})
|
142
|
@ResponseBody
|
168
|
@ResponseBody
|
143
|
- public EntityRelation getRelation(@RequestParam(FROM_ID) String strFromId,
|
|
|
144
|
- @RequestParam(FROM_TYPE) String strFromType,
|
|
|
145
|
- @RequestParam(RELATION_TYPE) String strRelationType,
|
|
|
146
|
- @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup,
|
|
|
147
|
- @RequestParam(TO_ID) String strToId, @RequestParam(TO_TYPE) String strToType) throws ThingsboardException {
|
169
|
+ public EntityRelation getRelation(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam(FROM_ID) String strFromId,
|
|
|
170
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam(FROM_TYPE) String strFromType,
|
|
|
171
|
+ @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION) @RequestParam(RELATION_TYPE) String strRelationType,
|
|
|
172
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup,
|
|
|
173
|
+ @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam(TO_ID) String strToId,
|
|
|
174
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam(TO_TYPE) String strToType) throws ThingsboardException {
|
148
|
try {
|
175
|
try {
|
149
|
checkParameter(FROM_ID, strFromId);
|
176
|
checkParameter(FROM_ID, strFromId);
|
150
|
checkParameter(FROM_TYPE, strFromType);
|
177
|
checkParameter(FROM_TYPE, strFromType);
|
|
@@ -162,11 +189,18 @@ public class EntityRelationController extends BaseController { |
|
@@ -162,11 +189,18 @@ public class EntityRelationController extends BaseController { |
162
|
}
|
189
|
}
|
163
|
}
|
190
|
}
|
164
|
|
191
|
|
|
|
192
|
+ @ApiOperation(value = "Get List of Relations (findByFrom)",
|
|
|
193
|
+ notes = "Returns list of relation objects for the specified entity by the 'from' direction. " +
|
|
|
194
|
+ "If the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
195
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that the entity is owned by the same tenant. " +
|
|
|
196
|
+ "If the user has the authority of 'Customer User', the server checks that the entity is assigned to the same customer.",
|
|
|
197
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
165
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
198
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
166
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE})
|
199
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE})
|
167
|
@ResponseBody
|
200
|
@ResponseBody
|
168
|
- public List<EntityRelation> findByFrom(@RequestParam(FROM_ID) String strFromId,
|
|
|
169
|
- @RequestParam(FROM_TYPE) String strFromType,
|
201
|
+ public List<EntityRelation> findByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam(FROM_ID) String strFromId,
|
|
|
202
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam(FROM_TYPE) String strFromType,
|
|
|
203
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
170
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
204
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
171
|
checkParameter(FROM_ID, strFromId);
|
205
|
checkParameter(FROM_ID, strFromId);
|
172
|
checkParameter(FROM_TYPE, strFromType);
|
206
|
checkParameter(FROM_TYPE, strFromType);
|
|
@@ -180,11 +214,18 @@ public class EntityRelationController extends BaseController { |
|
@@ -180,11 +214,18 @@ public class EntityRelationController extends BaseController { |
180
|
}
|
214
|
}
|
181
|
}
|
215
|
}
|
182
|
|
216
|
|
|
|
217
|
+ @ApiOperation(value = "Get List of Relation Infos (findInfoByFrom)",
|
|
|
218
|
+ notes = "Returns list of relation info objects for the specified entity by the 'from' direction. " +
|
|
|
219
|
+ "If the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
220
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that the entity is owned by the same tenant. " +
|
|
|
221
|
+ "If the user has the authority of 'Customer User', the server checks that the entity is assigned to the same customer. " + RELATION_INFO_DESCRIPTION,
|
|
|
222
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
183
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
223
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
184
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE})
|
224
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE})
|
185
|
@ResponseBody
|
225
|
@ResponseBody
|
186
|
- public List<EntityRelationInfo> findInfoByFrom(@RequestParam(FROM_ID) String strFromId,
|
|
|
187
|
- @RequestParam(FROM_TYPE) String strFromType,
|
226
|
+ public List<EntityRelationInfo> findInfoByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam(FROM_ID) String strFromId,
|
|
|
227
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam(FROM_TYPE) String strFromType,
|
|
|
228
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
188
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
229
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
189
|
checkParameter(FROM_ID, strFromId);
|
230
|
checkParameter(FROM_ID, strFromId);
|
190
|
checkParameter(FROM_TYPE, strFromType);
|
231
|
checkParameter(FROM_TYPE, strFromType);
|
|
@@ -198,12 +239,19 @@ public class EntityRelationController extends BaseController { |
|
@@ -198,12 +239,19 @@ public class EntityRelationController extends BaseController { |
198
|
}
|
239
|
}
|
199
|
}
|
240
|
}
|
200
|
|
241
|
|
|
|
242
|
+ @ApiOperation(value = "Get List of Relations (findByFrom)",
|
|
|
243
|
+ notes = "Returns list of relation objects for the specified entity by the 'from' direction and relation type. " +
|
|
|
244
|
+ "If the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
245
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that the entity is owned by the same tenant. " +
|
|
|
246
|
+ "If the user has the authority of 'Customer User', the server checks that the entity is assigned to the same customer.",
|
|
|
247
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
201
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
248
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
202
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE})
|
249
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE})
|
203
|
@ResponseBody
|
250
|
@ResponseBody
|
204
|
- public List<EntityRelation> findByFrom(@RequestParam(FROM_ID) String strFromId,
|
|
|
205
|
- @RequestParam(FROM_TYPE) String strFromType,
|
|
|
206
|
- @RequestParam(RELATION_TYPE) String strRelationType,
|
251
|
+ public List<EntityRelation> findByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam(FROM_ID) String strFromId,
|
|
|
252
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam(FROM_TYPE) String strFromType,
|
|
|
253
|
+ @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION) @RequestParam(RELATION_TYPE) String strRelationType,
|
|
|
254
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
207
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
255
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
208
|
checkParameter(FROM_ID, strFromId);
|
256
|
checkParameter(FROM_ID, strFromId);
|
209
|
checkParameter(FROM_TYPE, strFromType);
|
257
|
checkParameter(FROM_TYPE, strFromType);
|
|
@@ -218,11 +266,18 @@ public class EntityRelationController extends BaseController { |
|
@@ -218,11 +266,18 @@ public class EntityRelationController extends BaseController { |
218
|
}
|
266
|
}
|
219
|
}
|
267
|
}
|
220
|
|
268
|
|
|
|
269
|
+ @ApiOperation(value = "Get List of Relations (findByTo)",
|
|
|
270
|
+ notes = "Returns list of relation objects for the specified entity by the 'to' direction. " +
|
|
|
271
|
+ "If the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
272
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that the entity is owned by the same tenant. " +
|
|
|
273
|
+ "If the user has the authority of 'Customer User', the server checks that the entity is assigned to the same customer.",
|
|
|
274
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
221
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
275
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
222
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE})
|
276
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE})
|
223
|
@ResponseBody
|
277
|
@ResponseBody
|
224
|
- public List<EntityRelation> findByTo(@RequestParam(TO_ID) String strToId,
|
|
|
225
|
- @RequestParam(TO_TYPE) String strToType,
|
278
|
+ public List<EntityRelation> findByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam(TO_ID) String strToId,
|
|
|
279
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam(TO_TYPE) String strToType,
|
|
|
280
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
226
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
281
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
227
|
checkParameter(TO_ID, strToId);
|
282
|
checkParameter(TO_ID, strToId);
|
228
|
checkParameter(TO_TYPE, strToType);
|
283
|
checkParameter(TO_TYPE, strToType);
|
|
@@ -236,11 +291,18 @@ public class EntityRelationController extends BaseController { |
|
@@ -236,11 +291,18 @@ public class EntityRelationController extends BaseController { |
236
|
}
|
291
|
}
|
237
|
}
|
292
|
}
|
238
|
|
293
|
|
|
|
294
|
+ @ApiOperation(value = "Get List of Relation Infos (findInfoByTo)",
|
|
|
295
|
+ notes = "Returns list of relation info objects for the specified entity by the 'to' direction. " +
|
|
|
296
|
+ "If the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
297
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that the entity is owned by the same tenant. " +
|
|
|
298
|
+ "If the user has the authority of 'Customer User', the server checks that the entity is assigned to the same customer. " + RELATION_INFO_DESCRIPTION,
|
|
|
299
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
239
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
300
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
240
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {TO_ID, TO_TYPE})
|
301
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {TO_ID, TO_TYPE})
|
241
|
@ResponseBody
|
302
|
@ResponseBody
|
242
|
- public List<EntityRelationInfo> findInfoByTo(@RequestParam(TO_ID) String strToId,
|
|
|
243
|
- @RequestParam(TO_TYPE) String strToType,
|
303
|
+ public List<EntityRelationInfo> findInfoByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam(TO_ID) String strToId,
|
|
|
304
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam(TO_TYPE) String strToType,
|
|
|
305
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
244
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
306
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
245
|
checkParameter(TO_ID, strToId);
|
307
|
checkParameter(TO_ID, strToId);
|
246
|
checkParameter(TO_TYPE, strToType);
|
308
|
checkParameter(TO_TYPE, strToType);
|
|
@@ -254,12 +316,19 @@ public class EntityRelationController extends BaseController { |
|
@@ -254,12 +316,19 @@ public class EntityRelationController extends BaseController { |
254
|
}
|
316
|
}
|
255
|
}
|
317
|
}
|
256
|
|
318
|
|
|
|
319
|
+ @ApiOperation(value = "Get List of Relations (findByTo)",
|
|
|
320
|
+ notes = "Returns list of relation objects for the specified entity by the 'to' direction and relation type. " +
|
|
|
321
|
+ "If the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
322
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that the entity is owned by the same tenant. " +
|
|
|
323
|
+ "If the user has the authority of 'Customer User', the server checks that the entity is assigned to the same customer.",
|
|
|
324
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
257
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
325
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
258
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE, RELATION_TYPE})
|
326
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE, RELATION_TYPE})
|
259
|
@ResponseBody
|
327
|
@ResponseBody
|
260
|
- public List<EntityRelation> findByTo(@RequestParam(TO_ID) String strToId,
|
|
|
261
|
- @RequestParam(TO_TYPE) String strToType,
|
|
|
262
|
- @RequestParam(RELATION_TYPE) String strRelationType,
|
328
|
+ public List<EntityRelation> findByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION) @RequestParam(TO_ID) String strToId,
|
|
|
329
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION) @RequestParam(TO_TYPE) String strToType,
|
|
|
330
|
+ @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION) @RequestParam(RELATION_TYPE) String strRelationType,
|
|
|
331
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
263
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
332
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
264
|
checkParameter(TO_ID, strToId);
|
333
|
checkParameter(TO_ID, strToId);
|
265
|
checkParameter(TO_TYPE, strToType);
|
334
|
checkParameter(TO_TYPE, strToType);
|
|
@@ -274,10 +343,15 @@ public class EntityRelationController extends BaseController { |
|
@@ -274,10 +343,15 @@ public class EntityRelationController extends BaseController { |
274
|
}
|
343
|
}
|
275
|
}
|
344
|
}
|
276
|
|
345
|
|
|
|
346
|
+ @ApiOperation(value = "Find related entities (findByQuery)",
|
|
|
347
|
+ notes = "Returns all entities that are related to the specific entity. " +
|
|
|
348
|
+ "The entity id, relation type, entity types, depth of the search, and other query parameters defined using complex 'EntityRelationsQuery' object. " +
|
|
|
349
|
+ "See 'Model' tab of the Parameters for more info.", produces = MediaType.APPLICATION_JSON_VALUE)
|
277
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
350
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
278
|
@RequestMapping(value = "/relations", method = RequestMethod.POST)
|
351
|
@RequestMapping(value = "/relations", method = RequestMethod.POST)
|
279
|
@ResponseBody
|
352
|
@ResponseBody
|
280
|
- public List<EntityRelation> findByQuery(@RequestBody EntityRelationsQuery query) throws ThingsboardException {
|
353
|
+ public List<EntityRelation> findByQuery(@ApiParam(value = "A JSON value representing the entity relations query object.")
|
|
|
354
|
+ @RequestBody EntityRelationsQuery query) throws ThingsboardException {
|
281
|
checkNotNull(query);
|
355
|
checkNotNull(query);
|
282
|
checkNotNull(query.getParameters());
|
356
|
checkNotNull(query.getParameters());
|
283
|
checkNotNull(query.getFilters());
|
357
|
checkNotNull(query.getFilters());
|
|
@@ -289,10 +363,15 @@ public class EntityRelationController extends BaseController { |
|
@@ -289,10 +363,15 @@ public class EntityRelationController extends BaseController { |
289
|
}
|
363
|
}
|
290
|
}
|
364
|
}
|
291
|
|
365
|
|
|
|
366
|
+ @ApiOperation(value = "Find related entity infos (findInfoByQuery)",
|
|
|
367
|
+ notes = "Returns all entity infos that are related to the specific entity. " +
|
|
|
368
|
+ "The entity id, relation type, entity types, depth of the search, and other query parameters defined using complex 'EntityRelationsQuery' object. " +
|
|
|
369
|
+ "See 'Model' tab of the Parameters for more info. " + RELATION_INFO_DESCRIPTION, produces = MediaType.APPLICATION_JSON_VALUE)
|
292
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
370
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
293
|
@RequestMapping(value = "/relations/info", method = RequestMethod.POST)
|
371
|
@RequestMapping(value = "/relations/info", method = RequestMethod.POST)
|
294
|
@ResponseBody
|
372
|
@ResponseBody
|
295
|
- public List<EntityRelationInfo> findInfoByQuery(@RequestBody EntityRelationsQuery query) throws ThingsboardException {
|
373
|
+ public List<EntityRelationInfo> findInfoByQuery(@ApiParam(value = "A JSON value representing the entity relations query object.")
|
|
|
374
|
+ @RequestBody EntityRelationsQuery query) throws ThingsboardException {
|
296
|
checkNotNull(query);
|
375
|
checkNotNull(query);
|
297
|
checkNotNull(query.getParameters());
|
376
|
checkNotNull(query.getParameters());
|
298
|
checkNotNull(query.getFilters());
|
377
|
checkNotNull(query.getFilters());
|