|
@@ -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,26 @@ public class EntityRelationController extends BaseController { |
|
@@ -52,10 +55,26 @@ 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
|
+ private static final String SECURITY_CHECKS_ENTITIES_DESCRIPTION = "\n\nIf the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
59
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that 'from' and 'to' entities are owned by the same tenant. " +
|
|
|
60
|
+ "If the user has the authority of 'Customer User', the server checks that the 'from' and 'to' entities are assigned to the same customer.";
|
|
|
61
|
+
|
|
|
62
|
+ private static final String SECURITY_CHECKS_ENTITY_DESCRIPTION = "\n\nIf the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
63
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that the entity is owned by the same tenant. " +
|
|
|
64
|
+ "If the user has the authority of 'Customer User', the server checks that the entity is assigned to the same customer.";
|
|
|
65
|
+
|
|
|
66
|
+
|
|
|
67
|
+ @ApiOperation(value = "Create Relation (saveRelation)",
|
|
|
68
|
+ notes = "Creates or updates a relation between two entities in the platform. " +
|
|
|
69
|
+ "Relations unique key is a combination of from/to entity id and relation type group and relation type. " +
|
|
|
70
|
+ "\n\nIf the user has the authority of 'System Administrator', the server checks that 'from' and 'to' entities are owned by the sysadmin. " +
|
|
|
71
|
+ "If the user has the authority of 'Tenant Administrator', the server checks that 'from' and 'to' entities are owned by the same tenant. " +
|
|
|
72
|
+ "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')")
|
73
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
56
|
@RequestMapping(value = "/relation", method = RequestMethod.POST)
|
74
|
@RequestMapping(value = "/relation", method = RequestMethod.POST)
|
57
|
@ResponseStatus(value = HttpStatus.OK)
|
75
|
@ResponseStatus(value = HttpStatus.OK)
|
58
|
- public void saveRelation(@RequestBody EntityRelation relation) throws ThingsboardException {
|
76
|
+ public void saveRelation(@ApiParam(value = "A JSON value representing the relation.", required = true)
|
|
|
77
|
+ @RequestBody EntityRelation relation) throws ThingsboardException {
|
59
|
try {
|
78
|
try {
|
60
|
checkNotNull(relation);
|
79
|
checkNotNull(relation);
|
61
|
checkEntityId(relation.getFrom(), Operation.WRITE);
|
80
|
checkEntityId(relation.getFrom(), Operation.WRITE);
|
|
@@ -80,14 +99,17 @@ public class EntityRelationController extends BaseController { |
|
@@ -80,14 +99,17 @@ public class EntityRelationController extends BaseController { |
80
|
}
|
99
|
}
|
81
|
}
|
100
|
}
|
82
|
|
101
|
|
|
|
102
|
+ @ApiOperation(value = "Delete Relation (deleteRelation)",
|
|
|
103
|
+ notes = "Deletes a relation between two entities in the platform. " + SECURITY_CHECKS_ENTITIES_DESCRIPTION)
|
83
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
104
|
@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})
|
105
|
@RequestMapping(value = "/relation", method = RequestMethod.DELETE, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE})
|
85
|
@ResponseStatus(value = HttpStatus.OK)
|
106
|
@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 {
|
107
|
+ public void deleteRelation(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId,
|
|
|
108
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType,
|
|
|
109
|
+ @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType,
|
|
|
110
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup,
|
|
|
111
|
+ @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId,
|
|
|
112
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType) throws ThingsboardException {
|
91
|
checkParameter(FROM_ID, strFromId);
|
113
|
checkParameter(FROM_ID, strFromId);
|
92
|
checkParameter(FROM_TYPE, strFromType);
|
114
|
checkParameter(FROM_TYPE, strFromType);
|
93
|
checkParameter(RELATION_TYPE, strRelationType);
|
115
|
checkParameter(RELATION_TYPE, strRelationType);
|
|
@@ -119,11 +141,14 @@ public class EntityRelationController extends BaseController { |
|
@@ -119,11 +141,14 @@ public class EntityRelationController extends BaseController { |
119
|
}
|
141
|
}
|
120
|
}
|
142
|
}
|
121
|
|
143
|
|
|
|
144
|
+ @ApiOperation(value = "Delete Relations (deleteRelations)",
|
|
|
145
|
+ notes = "Deletes all the relation (both 'from' and 'to' direction) for the specified entity. " +
|
|
|
146
|
+ SECURITY_CHECKS_ENTITY_DESCRIPTION)
|
122
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN','TENANT_ADMIN', 'CUSTOMER_USER')")
|
147
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN','TENANT_ADMIN', 'CUSTOMER_USER')")
|
123
|
- @RequestMapping(value = "/relations", method = RequestMethod.DELETE, params = {"id", "type"})
|
148
|
+ @RequestMapping(value = "/relations", method = RequestMethod.DELETE, params = {"entityId", "entityType"})
|
124
|
@ResponseStatus(value = HttpStatus.OK)
|
149
|
@ResponseStatus(value = HttpStatus.OK)
|
125
|
- public void deleteRelations(@RequestParam("entityId") String strId,
|
|
|
126
|
- @RequestParam("entityType") String strType) throws ThingsboardException {
|
150
|
+ public void deleteRelations(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam("entityId") String strId,
|
|
|
151
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam("entityType") String strType) throws ThingsboardException {
|
127
|
checkParameter("entityId", strId);
|
152
|
checkParameter("entityId", strId);
|
128
|
checkParameter("entityType", strType);
|
153
|
checkParameter("entityType", strType);
|
129
|
EntityId entityId = EntityIdFactory.getByTypeAndId(strType, strId);
|
154
|
EntityId entityId = EntityIdFactory.getByTypeAndId(strType, strId);
|
|
@@ -137,14 +162,18 @@ public class EntityRelationController extends BaseController { |
|
@@ -137,14 +162,18 @@ public class EntityRelationController extends BaseController { |
137
|
}
|
162
|
}
|
138
|
}
|
163
|
}
|
139
|
|
164
|
|
|
|
165
|
+ @ApiOperation(value = "Get Relation (getRelation)",
|
|
|
166
|
+ notes = "Returns relation object between two specified entities if present. Otherwise throws exception." + SECURITY_CHECKS_ENTITIES_DESCRIPTION,
|
|
|
167
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
140
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
168
|
@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})
|
169
|
@RequestMapping(value = "/relation", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE})
|
142
|
@ResponseBody
|
170
|
@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 {
|
171
|
+ public EntityRelation getRelation(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId,
|
|
|
172
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType,
|
|
|
173
|
+ @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType,
|
|
|
174
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION) @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup,
|
|
|
175
|
+ @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId,
|
|
|
176
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType) throws ThingsboardException {
|
148
|
try {
|
177
|
try {
|
149
|
checkParameter(FROM_ID, strFromId);
|
178
|
checkParameter(FROM_ID, strFromId);
|
150
|
checkParameter(FROM_TYPE, strFromType);
|
179
|
checkParameter(FROM_TYPE, strFromType);
|
|
@@ -162,11 +191,16 @@ public class EntityRelationController extends BaseController { |
|
@@ -162,11 +191,16 @@ public class EntityRelationController extends BaseController { |
162
|
}
|
191
|
}
|
163
|
}
|
192
|
}
|
164
|
|
193
|
|
|
|
194
|
+ @ApiOperation(value = "Get List of Relations (findByFrom)",
|
|
|
195
|
+ notes = "Returns list of relation objects for the specified entity by the 'from' direction. " +
|
|
|
196
|
+ SECURITY_CHECKS_ENTITY_DESCRIPTION,
|
|
|
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, required = true) @RequestParam(FROM_ID) String strFromId,
|
|
|
202
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @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,16 @@ public class EntityRelationController extends BaseController { |
|
@@ -180,11 +214,16 @@ 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
|
+ SECURITY_CHECKS_ENTITY_DESCRIPTION +" " + RELATION_INFO_DESCRIPTION,
|
|
|
220
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
183
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
221
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
184
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE})
|
222
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE})
|
185
|
@ResponseBody
|
223
|
@ResponseBody
|
186
|
- public List<EntityRelationInfo> findInfoByFrom(@RequestParam(FROM_ID) String strFromId,
|
|
|
187
|
- @RequestParam(FROM_TYPE) String strFromType,
|
224
|
+ public List<EntityRelationInfo> findInfoByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId,
|
|
|
225
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType,
|
|
|
226
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
188
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
227
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
189
|
checkParameter(FROM_ID, strFromId);
|
228
|
checkParameter(FROM_ID, strFromId);
|
190
|
checkParameter(FROM_TYPE, strFromType);
|
229
|
checkParameter(FROM_TYPE, strFromType);
|
|
@@ -198,12 +237,17 @@ public class EntityRelationController extends BaseController { |
|
@@ -198,12 +237,17 @@ public class EntityRelationController extends BaseController { |
198
|
}
|
237
|
}
|
199
|
}
|
238
|
}
|
200
|
|
239
|
|
|
|
240
|
+ @ApiOperation(value = "Get List of Relations (findByFrom)",
|
|
|
241
|
+ notes = "Returns list of relation objects for the specified entity by the 'from' direction and relation type. " +
|
|
|
242
|
+ SECURITY_CHECKS_ENTITY_DESCRIPTION,
|
|
|
243
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
201
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
244
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
202
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE})
|
245
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE})
|
203
|
@ResponseBody
|
246
|
@ResponseBody
|
204
|
- public List<EntityRelation> findByFrom(@RequestParam(FROM_ID) String strFromId,
|
|
|
205
|
- @RequestParam(FROM_TYPE) String strFromType,
|
|
|
206
|
- @RequestParam(RELATION_TYPE) String strRelationType,
|
247
|
+ public List<EntityRelation> findByFrom(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(FROM_ID) String strFromId,
|
|
|
248
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(FROM_TYPE) String strFromType,
|
|
|
249
|
+ @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType,
|
|
|
250
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
207
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
251
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
208
|
checkParameter(FROM_ID, strFromId);
|
252
|
checkParameter(FROM_ID, strFromId);
|
209
|
checkParameter(FROM_TYPE, strFromType);
|
253
|
checkParameter(FROM_TYPE, strFromType);
|
|
@@ -218,11 +262,16 @@ public class EntityRelationController extends BaseController { |
|
@@ -218,11 +262,16 @@ public class EntityRelationController extends BaseController { |
218
|
}
|
262
|
}
|
219
|
}
|
263
|
}
|
220
|
|
264
|
|
|
|
265
|
+ @ApiOperation(value = "Get List of Relations (findByTo)",
|
|
|
266
|
+ notes = "Returns list of relation objects for the specified entity by the 'to' direction. " +
|
|
|
267
|
+ SECURITY_CHECKS_ENTITY_DESCRIPTION,
|
|
|
268
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
221
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
269
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
222
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE})
|
270
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE})
|
223
|
@ResponseBody
|
271
|
@ResponseBody
|
224
|
- public List<EntityRelation> findByTo(@RequestParam(TO_ID) String strToId,
|
|
|
225
|
- @RequestParam(TO_TYPE) String strToType,
|
272
|
+ public List<EntityRelation> findByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId,
|
|
|
273
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType,
|
|
|
274
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
226
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
275
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
227
|
checkParameter(TO_ID, strToId);
|
276
|
checkParameter(TO_ID, strToId);
|
228
|
checkParameter(TO_TYPE, strToType);
|
277
|
checkParameter(TO_TYPE, strToType);
|
|
@@ -236,11 +285,16 @@ public class EntityRelationController extends BaseController { |
|
@@ -236,11 +285,16 @@ public class EntityRelationController extends BaseController { |
236
|
}
|
285
|
}
|
237
|
}
|
286
|
}
|
238
|
|
287
|
|
|
|
288
|
+ @ApiOperation(value = "Get List of Relation Infos (findInfoByTo)",
|
|
|
289
|
+ notes = "Returns list of relation info objects for the specified entity by the 'to' direction. " +
|
|
|
290
|
+ SECURITY_CHECKS_ENTITY_DESCRIPTION + " " + RELATION_INFO_DESCRIPTION,
|
|
|
291
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
239
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
292
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
240
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {TO_ID, TO_TYPE})
|
293
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {TO_ID, TO_TYPE})
|
241
|
@ResponseBody
|
294
|
@ResponseBody
|
242
|
- public List<EntityRelationInfo> findInfoByTo(@RequestParam(TO_ID) String strToId,
|
|
|
243
|
- @RequestParam(TO_TYPE) String strToType,
|
295
|
+ public List<EntityRelationInfo> findInfoByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId,
|
|
|
296
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType,
|
|
|
297
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
244
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
298
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
245
|
checkParameter(TO_ID, strToId);
|
299
|
checkParameter(TO_ID, strToId);
|
246
|
checkParameter(TO_TYPE, strToType);
|
300
|
checkParameter(TO_TYPE, strToType);
|
|
@@ -254,12 +308,17 @@ public class EntityRelationController extends BaseController { |
|
@@ -254,12 +308,17 @@ public class EntityRelationController extends BaseController { |
254
|
}
|
308
|
}
|
255
|
}
|
309
|
}
|
256
|
|
310
|
|
|
|
311
|
+ @ApiOperation(value = "Get List of Relations (findByTo)",
|
|
|
312
|
+ notes = "Returns list of relation objects for the specified entity by the 'to' direction and relation type. " +
|
|
|
313
|
+ SECURITY_CHECKS_ENTITY_DESCRIPTION,
|
|
|
314
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
257
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
315
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
258
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE, RELATION_TYPE})
|
316
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE, RELATION_TYPE})
|
259
|
@ResponseBody
|
317
|
@ResponseBody
|
260
|
- public List<EntityRelation> findByTo(@RequestParam(TO_ID) String strToId,
|
|
|
261
|
- @RequestParam(TO_TYPE) String strToType,
|
|
|
262
|
- @RequestParam(RELATION_TYPE) String strRelationType,
|
318
|
+ public List<EntityRelation> findByTo(@ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @RequestParam(TO_ID) String strToId,
|
|
|
319
|
+ @ApiParam(value = ENTITY_TYPE_DESCRIPTION, required = true) @RequestParam(TO_TYPE) String strToType,
|
|
|
320
|
+ @ApiParam(value = RELATION_TYPE_PARAM_DESCRIPTION, required = true) @RequestParam(RELATION_TYPE) String strRelationType,
|
|
|
321
|
+ @ApiParam(value = RELATION_TYPE_GROUP_PARAM_DESCRIPTION)
|
263
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
322
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException {
|
264
|
checkParameter(TO_ID, strToId);
|
323
|
checkParameter(TO_ID, strToId);
|
265
|
checkParameter(TO_TYPE, strToType);
|
324
|
checkParameter(TO_TYPE, strToType);
|
|
@@ -274,10 +333,15 @@ public class EntityRelationController extends BaseController { |
|
@@ -274,10 +333,15 @@ public class EntityRelationController extends BaseController { |
274
|
}
|
333
|
}
|
275
|
}
|
334
|
}
|
276
|
|
335
|
|
|
|
336
|
+ @ApiOperation(value = "Find related entities (findByQuery)",
|
|
|
337
|
+ notes = "Returns all entities that are related to the specific entity. " +
|
|
|
338
|
+ "The entity id, relation type, entity types, depth of the search, and other query parameters defined using complex 'EntityRelationsQuery' object. " +
|
|
|
339
|
+ "See 'Model' tab of the Parameters for more info.", produces = MediaType.APPLICATION_JSON_VALUE)
|
277
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
340
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
278
|
@RequestMapping(value = "/relations", method = RequestMethod.POST)
|
341
|
@RequestMapping(value = "/relations", method = RequestMethod.POST)
|
279
|
@ResponseBody
|
342
|
@ResponseBody
|
280
|
- public List<EntityRelation> findByQuery(@RequestBody EntityRelationsQuery query) throws ThingsboardException {
|
343
|
+ public List<EntityRelation> findByQuery(@ApiParam(value = "A JSON value representing the entity relations query object.", required = true)
|
|
|
344
|
+ @RequestBody EntityRelationsQuery query) throws ThingsboardException {
|
281
|
checkNotNull(query);
|
345
|
checkNotNull(query);
|
282
|
checkNotNull(query.getParameters());
|
346
|
checkNotNull(query.getParameters());
|
283
|
checkNotNull(query.getFilters());
|
347
|
checkNotNull(query.getFilters());
|
|
@@ -289,10 +353,15 @@ public class EntityRelationController extends BaseController { |
|
@@ -289,10 +353,15 @@ public class EntityRelationController extends BaseController { |
289
|
}
|
353
|
}
|
290
|
}
|
354
|
}
|
291
|
|
355
|
|
|
|
356
|
+ @ApiOperation(value = "Find related entity infos (findInfoByQuery)",
|
|
|
357
|
+ notes = "Returns all entity infos that are related to the specific entity. " +
|
|
|
358
|
+ "The entity id, relation type, entity types, depth of the search, and other query parameters defined using complex 'EntityRelationsQuery' object. " +
|
|
|
359
|
+ "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')")
|
360
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
293
|
@RequestMapping(value = "/relations/info", method = RequestMethod.POST)
|
361
|
@RequestMapping(value = "/relations/info", method = RequestMethod.POST)
|
294
|
@ResponseBody
|
362
|
@ResponseBody
|
295
|
- public List<EntityRelationInfo> findInfoByQuery(@RequestBody EntityRelationsQuery query) throws ThingsboardException {
|
363
|
+ public List<EntityRelationInfo> findInfoByQuery(@ApiParam(value = "A JSON value representing the entity relations query object.", required = true)
|
|
|
364
|
+ @RequestBody EntityRelationsQuery query) throws ThingsboardException {
|
296
|
checkNotNull(query);
|
365
|
checkNotNull(query);
|
297
|
checkNotNull(query.getParameters());
|
366
|
checkNotNull(query.getParameters());
|
298
|
checkNotNull(query.getFilters());
|
367
|
checkNotNull(query.getFilters());
|