Commit 4bb56df51a747b78015a83dd1b21b9ee6ddef933
1 parent
85fcfef8
Added cassandra edge dao. Tests fixed
Showing
91 changed files
with
705 additions
and
427 deletions
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | "ruleChain": { | 2 | "ruleChain": { |
3 | "additionalInfo": null, | 3 | "additionalInfo": null, |
4 | "name": "Root Rule Chain", | 4 | "name": "Root Rule Chain", |
5 | + "type": "CORE", | ||
5 | "firstRuleNodeId": null, | 6 | "firstRuleNodeId": null, |
6 | "root": true, | 7 | "root": true, |
7 | "debugMode": false, | 8 | "debugMode": false, |
@@ -18,11 +18,16 @@ CREATE TABLE IF NOT EXISTS thingsboard.edge ( | @@ -18,11 +18,16 @@ CREATE TABLE IF NOT EXISTS thingsboard.edge ( | ||
18 | id timeuuid, | 18 | id timeuuid, |
19 | tenant_id timeuuid, | 19 | tenant_id timeuuid, |
20 | customer_id timeuuid, | 20 | customer_id timeuuid, |
21 | + root_rule_chain_id timeuuid, | ||
22 | + type text, | ||
21 | name text, | 23 | name text, |
24 | + label text, | ||
22 | search_text text, | 25 | search_text text, |
26 | + routing_key text, | ||
27 | + secret text, | ||
23 | configuration text, | 28 | configuration text, |
24 | additional_info text, | 29 | additional_info text, |
25 | - PRIMARY KEY (id, tenant_id) | 30 | + PRIMARY KEY (id, tenant_id, customer_id, type) |
26 | ); | 31 | ); |
27 | 32 | ||
28 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_name AS | 33 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_name AS |
@@ -32,6 +37,13 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_name AS | @@ -32,6 +37,13 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_name AS | ||
32 | PRIMARY KEY ( tenant_id, name, id, customer_id, type) | 37 | PRIMARY KEY ( tenant_id, name, id, customer_id, type) |
33 | WITH CLUSTERING ORDER BY ( name ASC, id DESC, customer_id DESC); | 38 | WITH CLUSTERING ORDER BY ( name ASC, id DESC, customer_id DESC); |
34 | 39 | ||
40 | +CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_routing_key AS | ||
41 | + SELECT * | ||
42 | + from thingsboard.edge | ||
43 | + WHERE tenant_id IS NOT NULL AND customer_id IS NOT NULL AND type IS NOT NULL AND routing_key IS NOT NULL AND id IS NOT NULL | ||
44 | + PRIMARY KEY ( tenant_id, routing_key, id, customer_id, type) | ||
45 | + WITH CLUSTERING ORDER BY ( routing_key ASC, id DESC, customer_id DESC); | ||
46 | + | ||
35 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_search_text AS | 47 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_search_text AS |
36 | SELECT * | 48 | SELECT * |
37 | from thingsboard.edge | 49 | from thingsboard.edge |
@@ -60,4 +72,22 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_customer_by_type_and_ | @@ -60,4 +72,22 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_customer_by_type_and_ | ||
60 | PRIMARY KEY ( customer_id, tenant_id, type, search_text, id ) | 72 | PRIMARY KEY ( customer_id, tenant_id, type, search_text, id ) |
61 | WITH CLUSTERING ORDER BY ( tenant_id DESC, type ASC, search_text ASC, id DESC ); | 73 | WITH CLUSTERING ORDER BY ( tenant_id DESC, type ASC, search_text ASC, id DESC ); |
62 | 74 | ||
63 | --- VOBA ADD changes for the MATERIALIZED view for DEVICE ASSET ENTITY_VIEW RULE_CHAIN | ||
75 | +CREATE TABLE IF NOT EXISTS thingsboard.edge_event ( | ||
76 | + id timeuuid, | ||
77 | + tenant_id timeuuid, | ||
78 | + edge_id timeuuid, | ||
79 | + edge_event_type text, | ||
80 | + edge_event_action text, | ||
81 | + edge_event_uid text, | ||
82 | + entity_id timeuuid, | ||
83 | + body text, | ||
84 | + PRIMARY KEY ((tenant_id, edge_id), edge_event_type, edge_event_uid) | ||
85 | +); | ||
86 | + | ||
87 | +CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_event_by_id AS | ||
88 | + SELECT * | ||
89 | + FROM thingsboard.edge_event | ||
90 | + WHERE tenant_id IS NOT NULL AND edge_id IS NOT NULL AND edge_event_type IS NOT NULL | ||
91 | + AND id IS NOT NULL AND edge_event_uid IS NOT NULL | ||
92 | + PRIMARY KEY ((tenant_id, edge_id), id, edge_event_type, edge_event_uid) | ||
93 | + WITH CLUSTERING ORDER BY (id ASC); |
@@ -26,5 +26,19 @@ CREATE TABLE IF NOT EXISTS edge ( | @@ -26,5 +26,19 @@ CREATE TABLE IF NOT EXISTS edge ( | ||
26 | routing_key varchar(255), | 26 | routing_key varchar(255), |
27 | secret varchar(255), | 27 | secret varchar(255), |
28 | search_text varchar(255), | 28 | search_text varchar(255), |
29 | - tenant_id varchar(31) | 29 | + tenant_id varchar(31), |
30 | + CONSTRAINT edge_name_unq_key UNIQUE (tenant_id, name), | ||
31 | + CONSTRAINT edge_routing_key_unq_key UNIQUE (routing_key) | ||
32 | +); | ||
33 | + | ||
34 | +CREATE TABLE IF NOT EXISTS edge_event ( | ||
35 | + id varchar(31) NOT NULL CONSTRAINT edge_event_pkey PRIMARY KEY, | ||
36 | + edge_id varchar(31), | ||
37 | + edge_event_type varchar(255), | ||
38 | + edge_event_uid varchar(255), | ||
39 | + entity_id varchar(31), | ||
40 | + edge_event_action varchar(255), | ||
41 | + body varchar(10000000), | ||
42 | + tenant_id varchar(31), | ||
43 | + ts bigint NOT NULL | ||
30 | ); | 44 | ); |
@@ -212,6 +212,9 @@ public abstract class BaseController { | @@ -212,6 +212,9 @@ public abstract class BaseController { | ||
212 | @Getter | 212 | @Getter |
213 | private boolean logControllerErrorStackTrace; | 213 | private boolean logControllerErrorStackTrace; |
214 | 214 | ||
215 | + @Value("${edges.rpc.enabled}") | ||
216 | + @Getter | ||
217 | + private boolean edgesSupportEnabled; | ||
215 | 218 | ||
216 | @ExceptionHandler(ThingsboardException.class) | 219 | @ExceptionHandler(ThingsboardException.class) |
217 | public void handleThingsboardException(ThingsboardException ex, HttpServletResponse response) { | 220 | public void handleThingsboardException(ThingsboardException ex, HttpServletResponse response) { |
@@ -745,6 +748,9 @@ public abstract class BaseController { | @@ -745,6 +748,9 @@ public abstract class BaseController { | ||
745 | } | 748 | } |
746 | 749 | ||
747 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, CustomerId customerId, ActionType edgeEventAction) { | 750 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, CustomerId customerId, ActionType edgeEventAction) { |
751 | + if (!edgesSupportEnabled) { | ||
752 | + return; | ||
753 | + } | ||
748 | try { | 754 | try { |
749 | sendNotificationMsgToEdgeService(tenantId, edgeId, null, json.writeValueAsString(customerId), EdgeEventType.EDGE, edgeEventAction); | 755 | sendNotificationMsgToEdgeService(tenantId, edgeId, null, json.writeValueAsString(customerId), EdgeEventType.EDGE, edgeEventAction); |
750 | } catch (Exception e) { | 756 | } catch (Exception e) { |
@@ -753,6 +759,9 @@ public abstract class BaseController { | @@ -753,6 +759,9 @@ public abstract class BaseController { | ||
753 | } | 759 | } |
754 | 760 | ||
755 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, CustomerId customerId, ActionType edgeEventAction) { | 761 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, CustomerId customerId, ActionType edgeEventAction) { |
762 | + if (!edgesSupportEnabled) { | ||
763 | + return; | ||
764 | + } | ||
756 | EdgeEventType edgeEventType = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); | 765 | EdgeEventType edgeEventType = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); |
757 | try { | 766 | try { |
758 | if (edgeEventType != null) { | 767 | if (edgeEventType != null) { |
@@ -764,6 +773,9 @@ public abstract class BaseController { | @@ -764,6 +773,9 @@ public abstract class BaseController { | ||
764 | } | 773 | } |
765 | 774 | ||
766 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityRelation relation, ActionType edgeEventAction) { | 775 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityRelation relation, ActionType edgeEventAction) { |
776 | + if (!edgesSupportEnabled) { | ||
777 | + return; | ||
778 | + } | ||
767 | try { | 779 | try { |
768 | if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && | 780 | if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && |
769 | !relation.getTo().getEntityType().equals(EntityType.EDGE)) { | 781 | !relation.getTo().getEntityType().equals(EntityType.EDGE)) { |
@@ -779,6 +791,9 @@ public abstract class BaseController { | @@ -779,6 +791,9 @@ public abstract class BaseController { | ||
779 | } | 791 | } |
780 | 792 | ||
781 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, ActionType edgeEventAction) { | 793 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, ActionType edgeEventAction) { |
794 | + if (!edgesSupportEnabled) { | ||
795 | + return; | ||
796 | + } | ||
782 | EdgeEventType edgeEventType = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); | 797 | EdgeEventType edgeEventType = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); |
783 | if (edgeEventType != null) { | 798 | if (edgeEventType != null) { |
784 | sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, edgeEventType, edgeEventAction); | 799 | sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, edgeEventType, edgeEventAction); |
@@ -31,10 +31,8 @@ import org.thingsboard.server.common.data.Dashboard; | @@ -31,10 +31,8 @@ import org.thingsboard.server.common.data.Dashboard; | ||
31 | import org.thingsboard.server.common.data.DashboardInfo; | 31 | import org.thingsboard.server.common.data.DashboardInfo; |
32 | import org.thingsboard.server.common.data.EntityType; | 32 | import org.thingsboard.server.common.data.EntityType; |
33 | import org.thingsboard.server.common.data.ShortCustomerInfo; | 33 | import org.thingsboard.server.common.data.ShortCustomerInfo; |
34 | -import org.thingsboard.server.common.data.ShortEdgeInfo; | ||
35 | import org.thingsboard.server.common.data.audit.ActionType; | 34 | import org.thingsboard.server.common.data.audit.ActionType; |
36 | import org.thingsboard.server.common.data.edge.Edge; | 35 | import org.thingsboard.server.common.data.edge.Edge; |
37 | -import org.thingsboard.server.common.data.edge.EdgeEventType; | ||
38 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 36 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
39 | import org.thingsboard.server.common.data.id.CustomerId; | 37 | import org.thingsboard.server.common.data.id.CustomerId; |
40 | import org.thingsboard.server.common.data.id.DashboardId; | 38 | import org.thingsboard.server.common.data.id.DashboardId; |
@@ -88,9 +88,6 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -88,9 +88,6 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
88 | private RuleChainService ruleChainService; | 88 | private RuleChainService ruleChainService; |
89 | 89 | ||
90 | @Autowired | 90 | @Autowired |
91 | - private RelationService relationService; | ||
92 | - | ||
93 | - @Autowired | ||
94 | private EdgeEventService edgeEventService; | 91 | private EdgeEventService edgeEventService; |
95 | 92 | ||
96 | @Autowired | 93 | @Autowired |
@@ -135,12 +132,12 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -135,12 +132,12 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
135 | EdgeEvent edgeEvent = new EdgeEvent(); | 132 | EdgeEvent edgeEvent = new EdgeEvent(); |
136 | edgeEvent.setEdgeId(edgeId); | 133 | edgeEvent.setEdgeId(edgeId); |
137 | edgeEvent.setTenantId(tenantId); | 134 | edgeEvent.setTenantId(tenantId); |
138 | - edgeEvent.setEdgeEventType(edgeEventType); | ||
139 | - edgeEvent.setEdgeEventAction(edgeEventAction.name()); | 135 | + edgeEvent.setType(edgeEventType); |
136 | + edgeEvent.setAction(edgeEventAction.name()); | ||
140 | if (entityId != null) { | 137 | if (entityId != null) { |
141 | edgeEvent.setEntityId(entityId.getId()); | 138 | edgeEvent.setEntityId(entityId.getId()); |
142 | } | 139 | } |
143 | - edgeEvent.setEntityBody(entityBody); | 140 | + edgeEvent.setBody(entityBody); |
144 | edgeEventService.saveAsync(edgeEvent); | 141 | edgeEventService.saveAsync(edgeEvent); |
145 | } | 142 | } |
146 | 143 |
@@ -307,7 +307,7 @@ public final class EdgeGrpcSession implements Closeable { | @@ -307,7 +307,7 @@ public final class EdgeGrpcSession implements Closeable { | ||
307 | log.trace("Processing edge event [{}]", edgeEvent); | 307 | log.trace("Processing edge event [{}]", edgeEvent); |
308 | try { | 308 | try { |
309 | DownlinkMsg downlinkMsg = null; | 309 | DownlinkMsg downlinkMsg = null; |
310 | - ActionType edgeEventAction = ActionType.valueOf(edgeEvent.getEdgeEventAction()); | 310 | + ActionType edgeEventAction = ActionType.valueOf(edgeEvent.getAction()); |
311 | switch (edgeEventAction) { | 311 | switch (edgeEventAction) { |
312 | case UPDATED: | 312 | case UPDATED: |
313 | case ADDED: | 313 | case ADDED: |
@@ -350,7 +350,7 @@ public final class EdgeGrpcSession implements Closeable { | @@ -350,7 +350,7 @@ public final class EdgeGrpcSession implements Closeable { | ||
350 | 350 | ||
351 | private DownlinkMsg processEntityExistsRequestMessage(EdgeEvent edgeEvent) { | 351 | private DownlinkMsg processEntityExistsRequestMessage(EdgeEvent edgeEvent) { |
352 | DownlinkMsg downlinkMsg = null; | 352 | DownlinkMsg downlinkMsg = null; |
353 | - if (EdgeEventType.DEVICE.equals(edgeEvent.getEdgeEventType())) { | 353 | + if (EdgeEventType.DEVICE.equals(edgeEvent.getType())) { |
354 | DeviceId deviceId = new DeviceId(edgeEvent.getEntityId()); | 354 | DeviceId deviceId = new DeviceId(edgeEvent.getEntityId()); |
355 | Device device = ctx.getDeviceService().findDeviceById(edge.getTenantId(), deviceId); | 355 | Device device = ctx.getDeviceService().findDeviceById(edge.getTenantId(), deviceId); |
356 | CustomerId customerId = getCustomerIdIfEdgeAssignedToCustomer(device); | 356 | CustomerId customerId = getCustomerIdIfEdgeAssignedToCustomer(device); |
@@ -365,7 +365,7 @@ public final class EdgeGrpcSession implements Closeable { | @@ -365,7 +365,7 @@ public final class EdgeGrpcSession implements Closeable { | ||
365 | private DownlinkMsg processRpcCallMsg(EdgeEvent edgeEvent) { | 365 | private DownlinkMsg processRpcCallMsg(EdgeEvent edgeEvent) { |
366 | log.trace("Executing processRpcCall, edgeEvent [{}]", edgeEvent); | 366 | log.trace("Executing processRpcCall, edgeEvent [{}]", edgeEvent); |
367 | DeviceRpcCallMsg deviceRpcCallMsg = | 367 | DeviceRpcCallMsg deviceRpcCallMsg = |
368 | - ctx.getDeviceMsgConstructor().constructDeviceRpcCallMsg(edgeEvent.getEntityBody()); | 368 | + ctx.getDeviceMsgConstructor().constructDeviceRpcCallMsg(edgeEvent.getBody()); |
369 | return DownlinkMsg.newBuilder() | 369 | return DownlinkMsg.newBuilder() |
370 | .addAllDeviceRpcCallMsg(Collections.singletonList(deviceRpcCallMsg)) | 370 | .addAllDeviceRpcCallMsg(Collections.singletonList(deviceRpcCallMsg)) |
371 | .build(); | 371 | .build(); |
@@ -373,7 +373,7 @@ public final class EdgeGrpcSession implements Closeable { | @@ -373,7 +373,7 @@ public final class EdgeGrpcSession implements Closeable { | ||
373 | 373 | ||
374 | private DownlinkMsg processCredentialsRequestMessage(EdgeEvent edgeEvent) { | 374 | private DownlinkMsg processCredentialsRequestMessage(EdgeEvent edgeEvent) { |
375 | DownlinkMsg downlinkMsg = null; | 375 | DownlinkMsg downlinkMsg = null; |
376 | - if (EdgeEventType.DEVICE.equals(edgeEvent.getEdgeEventType())) { | 376 | + if (EdgeEventType.DEVICE.equals(edgeEvent.getType())) { |
377 | DeviceId deviceId = new DeviceId(edgeEvent.getEntityId()); | 377 | DeviceId deviceId = new DeviceId(edgeEvent.getEntityId()); |
378 | DeviceCredentialsRequestMsg deviceCredentialsRequestMsg = DeviceCredentialsRequestMsg.newBuilder() | 378 | DeviceCredentialsRequestMsg deviceCredentialsRequestMsg = DeviceCredentialsRequestMsg.newBuilder() |
379 | .setDeviceIdMSB(deviceId.getId().getMostSignificantBits()) | 379 | .setDeviceIdMSB(deviceId.getId().getMostSignificantBits()) |
@@ -409,7 +409,7 @@ public final class EdgeGrpcSession implements Closeable { | @@ -409,7 +409,7 @@ public final class EdgeGrpcSession implements Closeable { | ||
409 | private DownlinkMsg processTelemetryMessage(EdgeEvent edgeEvent) { | 409 | private DownlinkMsg processTelemetryMessage(EdgeEvent edgeEvent) { |
410 | log.trace("Executing processTelemetryMessage, edgeEvent [{}]", edgeEvent); | 410 | log.trace("Executing processTelemetryMessage, edgeEvent [{}]", edgeEvent); |
411 | EntityId entityId = null; | 411 | EntityId entityId = null; |
412 | - switch (edgeEvent.getEdgeEventType()) { | 412 | + switch (edgeEvent.getType()) { |
413 | case DEVICE: | 413 | case DEVICE: |
414 | entityId = new DeviceId(edgeEvent.getEntityId()); | 414 | entityId = new DeviceId(edgeEvent.getEntityId()); |
415 | break; | 415 | break; |
@@ -431,21 +431,21 @@ public final class EdgeGrpcSession implements Closeable { | @@ -431,21 +431,21 @@ public final class EdgeGrpcSession implements Closeable { | ||
431 | } | 431 | } |
432 | DownlinkMsg downlinkMsg = null; | 432 | DownlinkMsg downlinkMsg = null; |
433 | if (entityId != null) { | 433 | if (entityId != null) { |
434 | - log.debug("Sending telemetry data msg, entityId [{}], body [{}]", edgeEvent.getEntityId(), edgeEvent.getEntityBody()); | 434 | + log.debug("Sending telemetry data msg, entityId [{}], body [{}]", edgeEvent.getEntityId(), edgeEvent.getBody()); |
435 | try { | 435 | try { |
436 | - ActionType actionType = ActionType.valueOf(edgeEvent.getEdgeEventAction()); | ||
437 | - downlinkMsg = constructEntityDataProtoMsg(entityId, actionType, JsonUtils.parse(mapper.writeValueAsString(edgeEvent.getEntityBody()))); | 436 | + ActionType actionType = ActionType.valueOf(edgeEvent.getAction()); |
437 | + downlinkMsg = constructEntityDataProtoMsg(entityId, actionType, JsonUtils.parse(mapper.writeValueAsString(edgeEvent.getBody()))); | ||
438 | } catch (Exception e) { | 438 | } catch (Exception e) { |
439 | - log.warn("Can't send telemetry data msg, entityId [{}], body [{}]", edgeEvent.getEntityId(), edgeEvent.getEntityBody(), e); | 439 | + log.warn("Can't send telemetry data msg, entityId [{}], body [{}]", edgeEvent.getEntityId(), edgeEvent.getBody(), e); |
440 | } | 440 | } |
441 | } | 441 | } |
442 | return downlinkMsg; | 442 | return downlinkMsg; |
443 | } | 443 | } |
444 | 444 | ||
445 | private DownlinkMsg processEntityMessage(EdgeEvent edgeEvent, ActionType edgeEventAction) { | 445 | private DownlinkMsg processEntityMessage(EdgeEvent edgeEvent, ActionType edgeEventAction) { |
446 | - UpdateMsgType msgType = getResponseMsgType(ActionType.valueOf(edgeEvent.getEdgeEventAction())); | 446 | + UpdateMsgType msgType = getResponseMsgType(ActionType.valueOf(edgeEvent.getAction())); |
447 | log.trace("Executing processEntityMessage, edgeEvent [{}], edgeEventAction [{}], msgType [{}]", edgeEvent, edgeEventAction, msgType); | 447 | log.trace("Executing processEntityMessage, edgeEvent [{}], edgeEventAction [{}], msgType [{}]", edgeEvent, edgeEventAction, msgType); |
448 | - switch (edgeEvent.getEdgeEventType()) { | 448 | + switch (edgeEvent.getType()) { |
449 | case EDGE: | 449 | case EDGE: |
450 | // TODO: voba - add edge update logic | 450 | // TODO: voba - add edge update logic |
451 | return null; | 451 | return null; |
@@ -728,7 +728,7 @@ public final class EdgeGrpcSession implements Closeable { | @@ -728,7 +728,7 @@ public final class EdgeGrpcSession implements Closeable { | ||
728 | } | 728 | } |
729 | 729 | ||
730 | private DownlinkMsg processRelation(EdgeEvent edgeEvent, UpdateMsgType msgType) { | 730 | private DownlinkMsg processRelation(EdgeEvent edgeEvent, UpdateMsgType msgType) { |
731 | - EntityRelation entityRelation = mapper.convertValue(edgeEvent.getEntityBody(), EntityRelation.class); | 731 | + EntityRelation entityRelation = mapper.convertValue(edgeEvent.getBody(), EntityRelation.class); |
732 | RelationUpdateMsg r = ctx.getRelationMsgConstructor().constructRelationUpdatedMsg(msgType, entityRelation); | 732 | RelationUpdateMsg r = ctx.getRelationMsgConstructor().constructRelationUpdatedMsg(msgType, entityRelation); |
733 | return DownlinkMsg.newBuilder() | 733 | return DownlinkMsg.newBuilder() |
734 | .addAllRelationUpdateMsg(Collections.singletonList(r)) | 734 | .addAllRelationUpdateMsg(Collections.singletonList(r)) |
@@ -804,7 +804,7 @@ public final class EdgeGrpcSession implements Closeable { | @@ -804,7 +804,7 @@ public final class EdgeGrpcSession implements Closeable { | ||
804 | } | 804 | } |
805 | 805 | ||
806 | private DownlinkMsg processAdminSettings(EdgeEvent edgeEvent) { | 806 | private DownlinkMsg processAdminSettings(EdgeEvent edgeEvent) { |
807 | - AdminSettings adminSettings = mapper.convertValue(edgeEvent.getEntityBody(), AdminSettings.class); | 807 | + AdminSettings adminSettings = mapper.convertValue(edgeEvent.getBody(), AdminSettings.class); |
808 | AdminSettingsUpdateMsg t = ctx.getAdminSettingsMsgConstructor().constructAdminSettingsUpdateMsg(adminSettings); | 808 | AdminSettingsUpdateMsg t = ctx.getAdminSettingsMsgConstructor().constructAdminSettingsUpdateMsg(adminSettings); |
809 | return DownlinkMsg.newBuilder() | 809 | return DownlinkMsg.newBuilder() |
810 | .addAllAdminSettingsUpdateMsg(Collections.singletonList(t)) | 810 | .addAllAdminSettingsUpdateMsg(Collections.singletonList(t)) |
@@ -534,12 +534,12 @@ public class DefaultSyncEdgeService implements SyncEdgeService { | @@ -534,12 +534,12 @@ public class DefaultSyncEdgeService implements SyncEdgeService { | ||
534 | EdgeEvent edgeEvent = new EdgeEvent(); | 534 | EdgeEvent edgeEvent = new EdgeEvent(); |
535 | edgeEvent.setTenantId(tenantId); | 535 | edgeEvent.setTenantId(tenantId); |
536 | edgeEvent.setEdgeId(edgeId); | 536 | edgeEvent.setEdgeId(edgeId); |
537 | - edgeEvent.setEdgeEventType(edgeEventType); | ||
538 | - edgeEvent.setEdgeEventAction(edgeEventAction.name()); | 537 | + edgeEvent.setType(edgeEventType); |
538 | + edgeEvent.setAction(edgeEventAction.name()); | ||
539 | if (entityId != null) { | 539 | if (entityId != null) { |
540 | edgeEvent.setEntityId(entityId.getId()); | 540 | edgeEvent.setEntityId(entityId.getId()); |
541 | } | 541 | } |
542 | - edgeEvent.setEntityBody(entityBody); | 542 | + edgeEvent.setBody(entityBody); |
543 | return edgeEventService.saveAsync(edgeEvent); | 543 | return edgeEventService.saveAsync(edgeEvent); |
544 | } | 544 | } |
545 | } | 545 | } |
@@ -105,12 +105,12 @@ public abstract class BaseProcessor { | @@ -105,12 +105,12 @@ public abstract class BaseProcessor { | ||
105 | EdgeEvent edgeEvent = new EdgeEvent(); | 105 | EdgeEvent edgeEvent = new EdgeEvent(); |
106 | edgeEvent.setTenantId(tenantId); | 106 | edgeEvent.setTenantId(tenantId); |
107 | edgeEvent.setEdgeId(edgeId); | 107 | edgeEvent.setEdgeId(edgeId); |
108 | - edgeEvent.setEdgeEventType(edgeEventType); | ||
109 | - edgeEvent.setEdgeEventAction(edgeEventAction.name()); | 108 | + edgeEvent.setType(edgeEventType); |
109 | + edgeEvent.setAction(edgeEventAction.name()); | ||
110 | if (entityId != null) { | 110 | if (entityId != null) { |
111 | edgeEvent.setEntityId(entityId.getId()); | 111 | edgeEvent.setEntityId(entityId.getId()); |
112 | } | 112 | } |
113 | - edgeEvent.setEntityBody(entityBody); | 113 | + edgeEvent.setBody(entityBody); |
114 | return edgeEventService.saveAsync(edgeEvent); | 114 | return edgeEventService.saveAsync(edgeEvent); |
115 | } | 115 | } |
116 | } | 116 | } |
@@ -30,6 +30,12 @@ public interface TbRuleEngineDeviceRpcService extends RuleEngineRpcService { | @@ -30,6 +30,12 @@ public interface TbRuleEngineDeviceRpcService extends RuleEngineRpcService { | ||
30 | void processRpcResponseFromDevice(FromDeviceRpcResponse response); | 30 | void processRpcResponseFromDevice(FromDeviceRpcResponse response); |
31 | 31 | ||
32 | 32 | ||
33 | + /** | ||
34 | + * Sends Rpc response from the Device to TB Core. | ||
35 | + * | ||
36 | + * @param originServiceId Service ID of the origin component | ||
37 | + * @param response the RPC response | ||
38 | + */ | ||
33 | void sendRpcResponseToTbCore(String originServiceId, FromDeviceRpcResponse response); | 39 | void sendRpcResponseToTbCore(String originServiceId, FromDeviceRpcResponse response); |
34 | 40 | ||
35 | } | 41 | } |
@@ -26,7 +26,6 @@ | @@ -26,7 +26,6 @@ | ||
26 | </appender> | 26 | </appender> |
27 | 27 | ||
28 | <logger name="org.thingsboard.server" level="INFO" /> | 28 | <logger name="org.thingsboard.server" level="INFO" /> |
29 | - <logger name="org.thingsboard.server.service.edge" level="TRACE" /> | ||
30 | 29 | ||
31 | <!-- <logger name="org.thingsboard.server.service.queue" level="TRACE" />--> | 30 | <!-- <logger name="org.thingsboard.server.service.queue" level="TRACE" />--> |
32 | <!-- <logger name="org.thingsboard.server.service.transport" level="TRACE" />--> | 31 | <!-- <logger name="org.thingsboard.server.service.transport" level="TRACE" />--> |
@@ -599,6 +599,7 @@ edges: | @@ -599,6 +599,7 @@ edges: | ||
599 | max_read_records_count: "${EDGES_RPC_STORAGE_MAX_READ_RECORDS_COUNT:50}" | 599 | max_read_records_count: "${EDGES_RPC_STORAGE_MAX_READ_RECORDS_COUNT:50}" |
600 | no_read_records_sleep: "${EDGES_RPC_NO_READ_RECORDS_SLEEP:1000}" | 600 | no_read_records_sleep: "${EDGES_RPC_NO_READ_RECORDS_SLEEP:1000}" |
601 | sleep_between_batches: "${EDGES_RPC_SLEEP_BETWEEN_BATCHES:1000}" | 601 | sleep_between_batches: "${EDGES_RPC_SLEEP_BETWEEN_BATCHES:1000}" |
602 | + edge_events_ttl: "${EDGES_EDGE_EVENTS_TTL:0}" | ||
602 | state: | 603 | state: |
603 | persistToTelemetry: "${EDGES_PERSIST_STATE_TO_TELEMETRY:false}" | 604 | persistToTelemetry: "${EDGES_PERSIST_STATE_TO_TELEMETRY:false}" |
604 | 605 |
@@ -23,6 +23,7 @@ import io.jsonwebtoken.Header; | @@ -23,6 +23,7 @@ import io.jsonwebtoken.Header; | ||
23 | import io.jsonwebtoken.Jwt; | 23 | import io.jsonwebtoken.Jwt; |
24 | import io.jsonwebtoken.Jwts; | 24 | import io.jsonwebtoken.Jwts; |
25 | import lombok.extern.slf4j.Slf4j; | 25 | import lombok.extern.slf4j.Slf4j; |
26 | +import org.apache.commons.lang3.RandomStringUtils; | ||
26 | import org.apache.commons.lang3.StringUtils; | 27 | import org.apache.commons.lang3.StringUtils; |
27 | import org.hamcrest.Matcher; | 28 | import org.hamcrest.Matcher; |
28 | import org.junit.After; | 29 | import org.junit.After; |
@@ -62,6 +63,7 @@ import org.thingsboard.server.common.data.BaseData; | @@ -62,6 +63,7 @@ import org.thingsboard.server.common.data.BaseData; | ||
62 | import org.thingsboard.server.common.data.Customer; | 63 | import org.thingsboard.server.common.data.Customer; |
63 | import org.thingsboard.server.common.data.Tenant; | 64 | import org.thingsboard.server.common.data.Tenant; |
64 | import org.thingsboard.server.common.data.User; | 65 | import org.thingsboard.server.common.data.User; |
66 | +import org.thingsboard.server.common.data.edge.Edge; | ||
65 | import org.thingsboard.server.common.data.id.TenantId; | 67 | import org.thingsboard.server.common.data.id.TenantId; |
66 | import org.thingsboard.server.common.data.id.UUIDBased; | 68 | import org.thingsboard.server.common.data.id.UUIDBased; |
67 | import org.thingsboard.server.common.data.page.TextPageLink; | 69 | import org.thingsboard.server.common.data.page.TextPageLink; |
@@ -498,4 +500,16 @@ public abstract class AbstractControllerTest { | @@ -498,4 +500,16 @@ public abstract class AbstractControllerTest { | ||
498 | return jsonPath("$.message", matcher); | 500 | return jsonPath("$.message", matcher); |
499 | } | 501 | } |
500 | 502 | ||
503 | + protected Edge constructEdge(String name, String type) { | ||
504 | + return constructEdge(tenantId, name, type); | ||
505 | + } | ||
506 | + protected Edge constructEdge(TenantId tenantId, String name, String type) { | ||
507 | + Edge edge = new Edge(); | ||
508 | + edge.setTenantId(tenantId); | ||
509 | + edge.setName(name); | ||
510 | + edge.setType(type); | ||
511 | + edge.setSecret(RandomStringUtils.randomAlphanumeric(20)); | ||
512 | + edge.setRoutingKey(RandomStringUtils.randomAlphanumeric(20)); | ||
513 | + return edge; | ||
514 | + } | ||
501 | } | 515 | } |
@@ -27,9 +27,11 @@ import org.thingsboard.server.common.data.EntitySubtype; | @@ -27,9 +27,11 @@ import org.thingsboard.server.common.data.EntitySubtype; | ||
27 | import org.thingsboard.server.common.data.Tenant; | 27 | import org.thingsboard.server.common.data.Tenant; |
28 | import org.thingsboard.server.common.data.User; | 28 | import org.thingsboard.server.common.data.User; |
29 | import org.thingsboard.server.common.data.asset.Asset; | 29 | import org.thingsboard.server.common.data.asset.Asset; |
30 | +import org.thingsboard.server.common.data.edge.Edge; | ||
30 | import org.thingsboard.server.common.data.id.CustomerId; | 31 | import org.thingsboard.server.common.data.id.CustomerId; |
31 | import org.thingsboard.server.common.data.page.TextPageData; | 32 | import org.thingsboard.server.common.data.page.TextPageData; |
32 | import org.thingsboard.server.common.data.page.TextPageLink; | 33 | import org.thingsboard.server.common.data.page.TextPageLink; |
34 | +import org.thingsboard.server.common.data.page.TimePageData; | ||
33 | import org.thingsboard.server.common.data.security.Authority; | 35 | import org.thingsboard.server.common.data.security.Authority; |
34 | import org.thingsboard.server.dao.model.ModelConstants; | 36 | import org.thingsboard.server.dao.model.ModelConstants; |
35 | import org.thingsboard.server.service.stats.DefaultRuleEngineStatisticsService; | 37 | import org.thingsboard.server.service.stats.DefaultRuleEngineStatisticsService; |
@@ -690,4 +692,30 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { | @@ -690,4 +692,30 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { | ||
690 | Assert.assertEquals(0, pageData.getData().size()); | 692 | Assert.assertEquals(0, pageData.getData().size()); |
691 | } | 693 | } |
692 | 694 | ||
695 | + @Test | ||
696 | + public void testAssignAssetToEdge() throws Exception { | ||
697 | + Edge edge = constructEdge("My edge", "default"); | ||
698 | + Edge savedEdge = doPost("/api/edge", edge, Edge.class); | ||
699 | + | ||
700 | + Asset asset = new Asset(); | ||
701 | + asset.setName("My asset"); | ||
702 | + asset.setType("default"); | ||
703 | + Asset savedAsset = doPost("/api/asset", asset, Asset.class); | ||
704 | + | ||
705 | + doPost("/api/edge/" + savedEdge.getId().getId().toString() | ||
706 | + + "/asset/" + savedAsset.getId().getId().toString(), Asset.class); | ||
707 | + | ||
708 | + TimePageData<Asset> pageData = doGetTypedWithPageLink("/api/edge/" + savedEdge.getId().getId().toString() + "/assets?", | ||
709 | + new TypeReference<TimePageData<Asset>>() {}, new TextPageLink(100)); | ||
710 | + | ||
711 | + Assert.assertEquals(1, pageData.getData().size()); | ||
712 | + | ||
713 | + doDelete("/api/edge/" + savedEdge.getId().getId().toString() | ||
714 | + + "/asset/" + savedAsset.getId().getId().toString(), Asset.class); | ||
715 | + | ||
716 | + pageData = doGetTypedWithPageLink("/api/edge/" + savedEdge.getId().getId().toString() + "/assets?", | ||
717 | + new TypeReference<TimePageData<Asset>>() {}, new TextPageLink(100)); | ||
718 | + | ||
719 | + Assert.assertEquals(0, pageData.getData().size()); | ||
720 | + } | ||
693 | } | 721 | } |
@@ -15,28 +15,32 @@ | @@ -15,28 +15,32 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.controller; | 16 | package org.thingsboard.server.controller; |
17 | 17 | ||
18 | -import static org.hamcrest.Matchers.containsString; | ||
19 | -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
20 | - | ||
21 | -import java.util.ArrayList; | ||
22 | -import java.util.Collections; | ||
23 | -import java.util.List; | ||
24 | - | ||
25 | import com.datastax.driver.core.utils.UUIDs; | 18 | import com.datastax.driver.core.utils.UUIDs; |
19 | +import com.fasterxml.jackson.core.type.TypeReference; | ||
26 | import org.apache.commons.lang3.RandomStringUtils; | 20 | import org.apache.commons.lang3.RandomStringUtils; |
27 | -import org.thingsboard.server.common.data.*; | 21 | +import org.junit.After; |
22 | +import org.junit.Assert; | ||
23 | +import org.junit.Before; | ||
24 | +import org.junit.Test; | ||
25 | +import org.thingsboard.server.common.data.Customer; | ||
26 | +import org.thingsboard.server.common.data.Dashboard; | ||
27 | +import org.thingsboard.server.common.data.DashboardInfo; | ||
28 | +import org.thingsboard.server.common.data.Tenant; | ||
29 | +import org.thingsboard.server.common.data.User; | ||
30 | +import org.thingsboard.server.common.data.edge.Edge; | ||
28 | import org.thingsboard.server.common.data.id.CustomerId; | 31 | import org.thingsboard.server.common.data.id.CustomerId; |
29 | import org.thingsboard.server.common.data.page.TextPageData; | 32 | import org.thingsboard.server.common.data.page.TextPageData; |
30 | import org.thingsboard.server.common.data.page.TextPageLink; | 33 | import org.thingsboard.server.common.data.page.TextPageLink; |
31 | import org.thingsboard.server.common.data.page.TimePageData; | 34 | import org.thingsboard.server.common.data.page.TimePageData; |
32 | import org.thingsboard.server.common.data.page.TimePageLink; | 35 | import org.thingsboard.server.common.data.page.TimePageLink; |
33 | import org.thingsboard.server.common.data.security.Authority; | 36 | import org.thingsboard.server.common.data.security.Authority; |
34 | -import org.junit.After; | ||
35 | -import org.junit.Assert; | ||
36 | -import org.junit.Before; | ||
37 | -import org.junit.Test; | ||
38 | 37 | ||
39 | -import com.fasterxml.jackson.core.type.TypeReference; | 38 | +import java.util.ArrayList; |
39 | +import java.util.Collections; | ||
40 | +import java.util.List; | ||
41 | + | ||
42 | +import static org.hamcrest.Matchers.containsString; | ||
43 | +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
40 | 44 | ||
41 | public abstract class BaseDashboardControllerTest extends AbstractControllerTest { | 45 | public abstract class BaseDashboardControllerTest extends AbstractControllerTest { |
42 | 46 | ||
@@ -349,4 +353,30 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest | @@ -349,4 +353,30 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest | ||
349 | Assert.assertEquals(dashboards, loadedDashboards); | 353 | Assert.assertEquals(dashboards, loadedDashboards); |
350 | } | 354 | } |
351 | 355 | ||
356 | + @Test | ||
357 | + public void testAssignDashboardToEdge() throws Exception { | ||
358 | + Edge edge = constructEdge("My edge", "default"); | ||
359 | + Edge savedEdge = doPost("/api/edge", edge, Edge.class); | ||
360 | + | ||
361 | + Dashboard dashboard = new Dashboard(); | ||
362 | + dashboard.setTitle("My dashboard"); | ||
363 | + Dashboard savedDashboard = doPost("/api/dashboard", dashboard, Dashboard.class); | ||
364 | + | ||
365 | + doPost("/api/edge/" + savedEdge.getId().getId().toString() | ||
366 | + + "/dashboard/" + savedDashboard.getId().getId().toString(), Dashboard.class); | ||
367 | + | ||
368 | + TimePageData<Dashboard> pageData = doGetTypedWithPageLink("/api/edge/" + savedEdge.getId().getId().toString() + "/dashboards?", | ||
369 | + new TypeReference<TimePageData<Dashboard>>() {}, new TextPageLink(100)); | ||
370 | + | ||
371 | + Assert.assertEquals(1, pageData.getData().size()); | ||
372 | + | ||
373 | + doDelete("/api/edge/" + savedEdge.getId().getId().toString() | ||
374 | + + "/dashboard/" + savedDashboard.getId().getId().toString(), Dashboard.class); | ||
375 | + | ||
376 | + pageData = doGetTypedWithPageLink("/api/edge/" + savedEdge.getId().getId().toString() + "/dashboards?", | ||
377 | + new TypeReference<TimePageData<Dashboard>>() {}, new TextPageLink(100)); | ||
378 | + | ||
379 | + Assert.assertEquals(0, pageData.getData().size()); | ||
380 | + } | ||
381 | + | ||
352 | } | 382 | } |
@@ -27,11 +27,13 @@ import org.thingsboard.server.common.data.Device; | @@ -27,11 +27,13 @@ import org.thingsboard.server.common.data.Device; | ||
27 | import org.thingsboard.server.common.data.EntitySubtype; | 27 | import org.thingsboard.server.common.data.EntitySubtype; |
28 | import org.thingsboard.server.common.data.Tenant; | 28 | import org.thingsboard.server.common.data.Tenant; |
29 | import org.thingsboard.server.common.data.User; | 29 | import org.thingsboard.server.common.data.User; |
30 | +import org.thingsboard.server.common.data.edge.Edge; | ||
30 | import org.thingsboard.server.common.data.id.CustomerId; | 31 | import org.thingsboard.server.common.data.id.CustomerId; |
31 | import org.thingsboard.server.common.data.id.DeviceCredentialsId; | 32 | import org.thingsboard.server.common.data.id.DeviceCredentialsId; |
32 | import org.thingsboard.server.common.data.id.DeviceId; | 33 | import org.thingsboard.server.common.data.id.DeviceId; |
33 | import org.thingsboard.server.common.data.page.TextPageData; | 34 | import org.thingsboard.server.common.data.page.TextPageData; |
34 | import org.thingsboard.server.common.data.page.TextPageLink; | 35 | import org.thingsboard.server.common.data.page.TextPageLink; |
36 | +import org.thingsboard.server.common.data.page.TimePageData; | ||
35 | import org.thingsboard.server.common.data.relation.EntityRelation; | 37 | import org.thingsboard.server.common.data.relation.EntityRelation; |
36 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; | 38 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
37 | import org.thingsboard.server.common.data.security.Authority; | 39 | import org.thingsboard.server.common.data.security.Authority; |
@@ -849,4 +851,31 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { | @@ -849,4 +851,31 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { | ||
849 | doDelete("/api/tenant/" + savedDifferentTenant.getId().getId().toString()) | 851 | doDelete("/api/tenant/" + savedDifferentTenant.getId().getId().toString()) |
850 | .andExpect(status().isOk()); | 852 | .andExpect(status().isOk()); |
851 | } | 853 | } |
854 | + | ||
855 | + @Test | ||
856 | + public void testAssignDeviceToEdge() throws Exception { | ||
857 | + Edge edge = constructEdge("My edge", "default"); | ||
858 | + Edge savedEdge = doPost("/api/edge", edge, Edge.class); | ||
859 | + | ||
860 | + Device device = new Device(); | ||
861 | + device.setName("My device"); | ||
862 | + device.setType("default"); | ||
863 | + Device savedDevice = doPost("/api/device", device, Device.class); | ||
864 | + | ||
865 | + doPost("/api/edge/" + savedEdge.getId().getId().toString() | ||
866 | + + "/device/" + savedDevice.getId().getId().toString(), Device.class); | ||
867 | + | ||
868 | + TimePageData<Device> pageData = doGetTypedWithPageLink("/api/edge/" + savedEdge.getId().getId().toString() + "/devices?", | ||
869 | + new TypeReference<TimePageData<Device>>() {}, new TextPageLink(100)); | ||
870 | + | ||
871 | + Assert.assertEquals(1, pageData.getData().size()); | ||
872 | + | ||
873 | + doDelete("/api/edge/" + savedEdge.getId().getId().toString() | ||
874 | + + "/device/" + savedDevice.getId().getId().toString(), Device.class); | ||
875 | + | ||
876 | + pageData = doGetTypedWithPageLink("/api/edge/" + savedEdge.getId().getId().toString() + "/devices?", | ||
877 | + new TypeReference<TimePageData<Device>>() {}, new TextPageLink(100)); | ||
878 | + | ||
879 | + Assert.assertEquals(0, pageData.getData().size()); | ||
880 | + } | ||
852 | } | 881 | } |
@@ -638,17 +638,4 @@ public abstract class BaseEdgeControllerTest extends AbstractControllerTest { | @@ -638,17 +638,4 @@ public abstract class BaseEdgeControllerTest extends AbstractControllerTest { | ||
638 | Assert.assertEquals(0, pageData.getData().size()); | 638 | Assert.assertEquals(0, pageData.getData().size()); |
639 | } | 639 | } |
640 | 640 | ||
641 | - private Edge constructEdge(String name, String type) { | ||
642 | - return constructEdge(tenantId, name, type); | ||
643 | - } | ||
644 | - | ||
645 | - private Edge constructEdge(TenantId tenantId, String name, String type) { | ||
646 | - Edge edge = new Edge(); | ||
647 | - edge.setTenantId(tenantId); | ||
648 | - edge.setName(name); | ||
649 | - edge.setType(type); | ||
650 | - edge.setSecret(RandomStringUtils.randomAlphanumeric(20)); | ||
651 | - edge.setRoutingKey(RandomStringUtils.randomAlphanumeric(20)); | ||
652 | - return edge; | ||
653 | - } | ||
654 | } | 641 | } |
@@ -83,38 +83,29 @@ public class BaseEdgeEventControllerTest extends AbstractControllerTest { | @@ -83,38 +83,29 @@ public class BaseEdgeEventControllerTest extends AbstractControllerTest { | ||
83 | Device savedDevice = doPost("/api/device", device, Device.class); | 83 | Device savedDevice = doPost("/api/device", device, Device.class); |
84 | 84 | ||
85 | doPost("/api/edge/" + edge.getId().toString() + "/device/" + savedDevice.getId().toString(), Device.class); | 85 | doPost("/api/edge/" + edge.getId().toString() + "/device/" + savedDevice.getId().toString(), Device.class); |
86 | + Thread.sleep(1000); | ||
86 | 87 | ||
87 | Asset asset = constructAsset("TestAsset", "default"); | 88 | Asset asset = constructAsset("TestAsset", "default"); |
88 | Asset savedAsset = doPost("/api/asset", asset, Asset.class); | 89 | Asset savedAsset = doPost("/api/asset", asset, Asset.class); |
89 | 90 | ||
90 | doPost("/api/edge/" + edge.getId().toString() + "/asset/" + savedAsset.getId().toString(), Asset.class); | 91 | doPost("/api/edge/" + edge.getId().toString() + "/asset/" + savedAsset.getId().toString(), Asset.class); |
92 | + Thread.sleep(1000); | ||
91 | 93 | ||
92 | EntityRelation relation = new EntityRelation(savedAsset.getId(), savedDevice.getId(), EntityRelation.CONTAINS_TYPE); | 94 | EntityRelation relation = new EntityRelation(savedAsset.getId(), savedDevice.getId(), EntityRelation.CONTAINS_TYPE); |
93 | 95 | ||
94 | doPost("/api/relation", relation); | 96 | doPost("/api/relation", relation); |
95 | - | ||
96 | - Thread.sleep(2000); | 97 | + Thread.sleep(1000); |
97 | 98 | ||
98 | List<EdgeEvent> edgeEvents = doGetTypedWithTimePageLink("/api/edge/" + edge.getId().toString() + "/events?", | 99 | List<EdgeEvent> edgeEvents = doGetTypedWithTimePageLink("/api/edge/" + edge.getId().toString() + "/events?", |
99 | new TypeReference<TimePageData<EdgeEvent>>() { | 100 | new TypeReference<TimePageData<EdgeEvent>>() { |
100 | - }, new TimePageLink(5)).getData(); | 101 | + }, new TimePageLink(4)).getData(); |
101 | 102 | ||
102 | Assert.assertFalse(edgeEvents.isEmpty()); | 103 | Assert.assertFalse(edgeEvents.isEmpty()); |
103 | Assert.assertEquals(4, edgeEvents.size()); | 104 | Assert.assertEquals(4, edgeEvents.size()); |
104 | - Assert.assertEquals(edgeEvents.get(0).getEdgeEventType(), EdgeEventType.RELATION); | ||
105 | - Assert.assertEquals(edgeEvents.get(1).getEdgeEventType(), EdgeEventType.ASSET); | ||
106 | - Assert.assertEquals(edgeEvents.get(2).getEdgeEventType(), EdgeEventType.DEVICE); | ||
107 | - Assert.assertEquals(edgeEvents.get(3).getEdgeEventType(), EdgeEventType.RULE_CHAIN); | ||
108 | - } | ||
109 | - | ||
110 | - private Edge constructEdge(String name, String type) { | ||
111 | - Edge edge = new Edge(); | ||
112 | - edge.setTenantId(tenantId); | ||
113 | - edge.setName(name); | ||
114 | - edge.setType(type); | ||
115 | - edge.setSecret(RandomStringUtils.randomAlphanumeric(20)); | ||
116 | - edge.setRoutingKey(RandomStringUtils.randomAlphanumeric(20)); | ||
117 | - return edge; | 105 | + Assert.assertEquals(EdgeEventType.RELATION, edgeEvents.get(0).getType()); |
106 | + Assert.assertEquals(EdgeEventType.ASSET, edgeEvents.get(1).getType()); | ||
107 | + Assert.assertEquals(EdgeEventType.DEVICE, edgeEvents.get(2).getType()); | ||
108 | + Assert.assertEquals(EdgeEventType.RULE_CHAIN, edgeEvents.get(3).getType()); | ||
118 | } | 109 | } |
119 | 110 | ||
120 | private Device constructDevice(String name, String type) { | 111 | private Device constructDevice(String name, String type) { |
@@ -31,11 +31,13 @@ import org.thingsboard.server.common.data.Device; | @@ -31,11 +31,13 @@ import org.thingsboard.server.common.data.Device; | ||
31 | import org.thingsboard.server.common.data.EntityView; | 31 | import org.thingsboard.server.common.data.EntityView; |
32 | import org.thingsboard.server.common.data.Tenant; | 32 | import org.thingsboard.server.common.data.Tenant; |
33 | import org.thingsboard.server.common.data.User; | 33 | import org.thingsboard.server.common.data.User; |
34 | +import org.thingsboard.server.common.data.edge.Edge; | ||
34 | import org.thingsboard.server.common.data.id.CustomerId; | 35 | import org.thingsboard.server.common.data.id.CustomerId; |
35 | import org.thingsboard.server.common.data.objects.AttributesEntityView; | 36 | import org.thingsboard.server.common.data.objects.AttributesEntityView; |
36 | import org.thingsboard.server.common.data.objects.TelemetryEntityView; | 37 | import org.thingsboard.server.common.data.objects.TelemetryEntityView; |
37 | import org.thingsboard.server.common.data.page.TextPageData; | 38 | import org.thingsboard.server.common.data.page.TextPageData; |
38 | import org.thingsboard.server.common.data.page.TextPageLink; | 39 | import org.thingsboard.server.common.data.page.TextPageLink; |
40 | +import org.thingsboard.server.common.data.page.TimePageData; | ||
39 | import org.thingsboard.server.common.data.security.Authority; | 41 | import org.thingsboard.server.common.data.security.Authority; |
40 | import org.thingsboard.server.common.data.security.DeviceCredentials; | 42 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
41 | import org.thingsboard.server.dao.model.ModelConstants; | 43 | import org.thingsboard.server.dao.model.ModelConstants; |
@@ -52,7 +54,6 @@ import java.util.concurrent.TimeUnit; | @@ -52,7 +54,6 @@ import java.util.concurrent.TimeUnit; | ||
52 | import static org.hamcrest.Matchers.containsString; | 54 | import static org.hamcrest.Matchers.containsString; |
53 | import static org.junit.Assert.assertEquals; | 55 | import static org.junit.Assert.assertEquals; |
54 | import static org.junit.Assert.assertNotNull; | 56 | import static org.junit.Assert.assertNotNull; |
55 | -import static org.junit.Assert.assertNull; | ||
56 | import static org.junit.Assert.assertTrue; | 57 | import static org.junit.Assert.assertTrue; |
57 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | 58 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
58 | import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; | 59 | import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; |
@@ -552,4 +553,31 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes | @@ -552,4 +553,31 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes | ||
552 | 553 | ||
553 | return loadedItems; | 554 | return loadedItems; |
554 | } | 555 | } |
556 | + | ||
557 | + @Test | ||
558 | + public void testAssignEntityViewToEdge() throws Exception { | ||
559 | + Edge edge = constructEdge("My edge", "default"); | ||
560 | + Edge savedEdge = doPost("/api/edge", edge, Edge.class); | ||
561 | + | ||
562 | + EntityView savedEntityView = getNewSavedEntityView("My entityView"); | ||
563 | + | ||
564 | + doPost("/api/edge/" + savedEdge.getId().getId().toString() | ||
565 | + + "/device/" + testDevice.getId().getId().toString(), Device.class); | ||
566 | + | ||
567 | + doPost("/api/edge/" + savedEdge.getId().getId().toString() | ||
568 | + + "/entityView/" + savedEntityView.getId().getId().toString(), EntityView.class); | ||
569 | + | ||
570 | + TimePageData<EntityView> pageData = doGetTypedWithPageLink("/api/edge/" + savedEdge.getId().getId().toString() + "/entityViews?", | ||
571 | + new TypeReference<TimePageData<EntityView>>() {}, new TextPageLink(100)); | ||
572 | + | ||
573 | + Assert.assertEquals(1, pageData.getData().size()); | ||
574 | + | ||
575 | + doDelete("/api/edge/" + savedEdge.getId().getId().toString() | ||
576 | + + "/entityView/" + savedEntityView.getId().getId().toString(), EntityView.class); | ||
577 | + | ||
578 | + pageData = doGetTypedWithPageLink("/api/edge/" + savedEdge.getId().getId().toString() + "/entityViews?", | ||
579 | + new TypeReference<TimePageData<EntityView>>() {}, new TextPageLink(100)); | ||
580 | + | ||
581 | + Assert.assertEquals(0, pageData.getData().size()); | ||
582 | + } | ||
555 | } | 583 | } |
@@ -27,8 +27,7 @@ import java.util.Arrays; | @@ -27,8 +27,7 @@ import java.util.Arrays; | ||
27 | 27 | ||
28 | @RunWith(ClasspathSuite.class) | 28 | @RunWith(ClasspathSuite.class) |
29 | @ClasspathSuite.ClassnameFilters({ | 29 | @ClasspathSuite.ClassnameFilters({ |
30 | - // TODO: voba - fix before final test on cassandra | ||
31 | - "org.thingsboard.server.controller.nosql.*VOBA_FIX_BEFORE_FINAL_TESTTest"}) | 30 | + "org.thingsboard.server.controller.nosql.*Test"}) |
32 | public class ControllerNoSqlTestSuite { | 31 | public class ControllerNoSqlTestSuite { |
33 | 32 | ||
34 | @ClassRule | 33 | @ClassRule |
@@ -27,8 +27,7 @@ import java.util.Arrays; | @@ -27,8 +27,7 @@ import java.util.Arrays; | ||
27 | 27 | ||
28 | @RunWith(ClasspathSuite.class) | 28 | @RunWith(ClasspathSuite.class) |
29 | @ClasspathSuite.ClassnameFilters({ | 29 | @ClasspathSuite.ClassnameFilters({ |
30 | - // TODO: voba - fix before final test on cassandra | ||
31 | - "org.thingsboard.server.mqtt.*.nosql.*VOBA_FIX_BEFORE_FINAL_TESTTest"}) | 30 | + "org.thingsboard.server.mqtt.*.nosql.*Test"}) |
32 | public class MqttNoSqlTestSuite { | 31 | public class MqttNoSqlTestSuite { |
33 | 32 | ||
34 | @ClassRule | 33 | @ClassRule |
@@ -30,8 +30,7 @@ import java.util.Arrays; | @@ -30,8 +30,7 @@ import java.util.Arrays; | ||
30 | */ | 30 | */ |
31 | @RunWith(ClasspathSuite.class) | 31 | @RunWith(ClasspathSuite.class) |
32 | @ClasspathSuite.ClassnameFilters({ | 32 | @ClasspathSuite.ClassnameFilters({ |
33 | - // TODO: voba - fix before final test on cassandra | ||
34 | - "org.thingsboard.server.system.*VOBA_FIX_BEFORE_FINAL_TESTNoSqlTest"}) | 33 | + "org.thingsboard.server.system.*NoSqlTest"}) |
35 | public class SystemNoSqlTestSuite { | 34 | public class SystemNoSqlTestSuite { |
36 | 35 | ||
37 | @ClassRule | 36 | @ClassRule |
@@ -77,14 +77,3 @@ public interface EdgeService { | @@ -77,14 +77,3 @@ public interface EdgeService { | ||
77 | 77 | ||
78 | ListenableFuture<List<EdgeId>> findRelatedEdgeIdsByEntityId(TenantId tenantId, EntityId entityId); | 78 | ListenableFuture<List<EdgeId>> findRelatedEdgeIdsByEntityId(TenantId tenantId, EntityId entityId); |
79 | } | 79 | } |
80 | - | ||
81 | - | ||
82 | - | ||
83 | - | ||
84 | - | ||
85 | - | ||
86 | - | ||
87 | - | ||
88 | - | ||
89 | - | ||
90 | - |
@@ -16,15 +16,12 @@ | @@ -16,15 +16,12 @@ | ||
16 | package org.thingsboard.server.common.data; | 16 | package org.thingsboard.server.common.data; |
17 | 17 | ||
18 | import com.fasterxml.jackson.annotation.JsonProperty; | 18 | import com.fasterxml.jackson.annotation.JsonProperty; |
19 | -import lombok.Getter; | ||
20 | -import lombok.Setter; | ||
21 | -import org.thingsboard.server.common.data.edge.Edge; | ||
22 | import org.thingsboard.server.common.data.id.CustomerId; | 19 | import org.thingsboard.server.common.data.id.CustomerId; |
23 | import org.thingsboard.server.common.data.id.DashboardId; | 20 | import org.thingsboard.server.common.data.id.DashboardId; |
24 | -import org.thingsboard.server.common.data.id.EdgeId; | ||
25 | import org.thingsboard.server.common.data.id.TenantId; | 21 | import org.thingsboard.server.common.data.id.TenantId; |
26 | 22 | ||
27 | -import java.util.*; | 23 | +import java.util.HashSet; |
24 | +import java.util.Set; | ||
28 | 25 | ||
29 | public class DashboardInfo extends SearchTextBased<DashboardId> implements HasName, HasTenantId { | 26 | public class DashboardInfo extends SearchTextBased<DashboardId> implements HasName, HasTenantId { |
30 | 27 |
1 | -/** | ||
2 | - * Copyright © 2016-2020 The Thingsboard Authors | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | -package org.thingsboard.server.common.data; | ||
17 | - | ||
18 | -import lombok.AllArgsConstructor; | ||
19 | -import lombok.Getter; | ||
20 | -import lombok.Setter; | ||
21 | -import org.thingsboard.server.common.data.id.EdgeId; | ||
22 | -import org.thingsboard.server.common.data.id.RuleChainId; | ||
23 | - | ||
24 | -@AllArgsConstructor | ||
25 | -public class ShortEdgeInfo { | ||
26 | - | ||
27 | - @Getter @Setter | ||
28 | - private EdgeId edgeId; | ||
29 | - | ||
30 | - @Getter @Setter | ||
31 | - private String title; | ||
32 | - | ||
33 | - @Getter @Setter | ||
34 | - private RuleChainId rootRuleChainId; | ||
35 | - | ||
36 | - @Override | ||
37 | - public boolean equals(Object o) { | ||
38 | - if (this == o) return true; | ||
39 | - if (o == null || getClass() != o.getClass()) return false; | ||
40 | - | ||
41 | - ShortEdgeInfo that = (ShortEdgeInfo) o; | ||
42 | - | ||
43 | - return edgeId.equals(that.edgeId); | ||
44 | - } | ||
45 | - | ||
46 | - @Override | ||
47 | - public int hashCode() { | ||
48 | - return edgeId.hashCode(); | ||
49 | - } | ||
50 | -} |
@@ -15,7 +15,6 @@ | @@ -15,7 +15,6 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.common.data.edge; | 16 | package org.thingsboard.server.common.data.edge; |
17 | 17 | ||
18 | -import com.fasterxml.jackson.annotation.JsonIgnore; | ||
19 | import com.fasterxml.jackson.databind.JsonNode; | 18 | import com.fasterxml.jackson.databind.JsonNode; |
20 | import lombok.EqualsAndHashCode; | 19 | import lombok.EqualsAndHashCode; |
21 | import lombok.Getter; | 20 | import lombok.Getter; |
@@ -25,8 +24,6 @@ import org.thingsboard.server.common.data.HasCustomerId; | @@ -25,8 +24,6 @@ import org.thingsboard.server.common.data.HasCustomerId; | ||
25 | import org.thingsboard.server.common.data.HasName; | 24 | import org.thingsboard.server.common.data.HasName; |
26 | import org.thingsboard.server.common.data.HasTenantId; | 25 | import org.thingsboard.server.common.data.HasTenantId; |
27 | import org.thingsboard.server.common.data.SearchTextBasedWithAdditionalInfo; | 26 | import org.thingsboard.server.common.data.SearchTextBasedWithAdditionalInfo; |
28 | -import org.thingsboard.server.common.data.ShortCustomerInfo; | ||
29 | -import org.thingsboard.server.common.data.ShortEdgeInfo; | ||
30 | import org.thingsboard.server.common.data.id.CustomerId; | 27 | import org.thingsboard.server.common.data.id.CustomerId; |
31 | import org.thingsboard.server.common.data.id.EdgeId; | 28 | import org.thingsboard.server.common.data.id.EdgeId; |
32 | import org.thingsboard.server.common.data.id.RuleChainId; | 29 | import org.thingsboard.server.common.data.id.RuleChainId; |
@@ -70,11 +67,6 @@ public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements H | @@ -70,11 +67,6 @@ public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements H | ||
70 | this.configuration = edge.getConfiguration(); | 67 | this.configuration = edge.getConfiguration(); |
71 | } | 68 | } |
72 | 69 | ||
73 | - @JsonIgnore | ||
74 | - public ShortEdgeInfo toShortEdgeInfo() { | ||
75 | - return new ShortEdgeInfo(id, name, rootRuleChainId); | ||
76 | - } | ||
77 | - | ||
78 | @Override | 70 | @Override |
79 | public String getSearchText() { | 71 | public String getSearchText() { |
80 | return getName(); | 72 | return getName(); |
@@ -29,10 +29,11 @@ public class EdgeEvent extends BaseData<EdgeEventId> { | @@ -29,10 +29,11 @@ public class EdgeEvent extends BaseData<EdgeEventId> { | ||
29 | 29 | ||
30 | private TenantId tenantId; | 30 | private TenantId tenantId; |
31 | private EdgeId edgeId; | 31 | private EdgeId edgeId; |
32 | - private String edgeEventAction; | 32 | + private String action; |
33 | private UUID entityId; | 33 | private UUID entityId; |
34 | - private EdgeEventType edgeEventType; | ||
35 | - private transient JsonNode entityBody; | 34 | + private String uid; |
35 | + private EdgeEventType type; | ||
36 | + private transient JsonNode body; | ||
36 | 37 | ||
37 | public EdgeEvent() { | 38 | public EdgeEvent() { |
38 | super(); | 39 | super(); |
@@ -20,20 +20,13 @@ import com.fasterxml.jackson.databind.JsonNode; | @@ -20,20 +20,13 @@ import com.fasterxml.jackson.databind.JsonNode; | ||
20 | import lombok.Data; | 20 | import lombok.Data; |
21 | import lombok.EqualsAndHashCode; | 21 | import lombok.EqualsAndHashCode; |
22 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
23 | -import org.thingsboard.server.common.data.EdgeUtils; | ||
24 | import org.thingsboard.server.common.data.HasName; | 23 | import org.thingsboard.server.common.data.HasName; |
25 | import org.thingsboard.server.common.data.HasTenantId; | 24 | import org.thingsboard.server.common.data.HasTenantId; |
26 | import org.thingsboard.server.common.data.SearchTextBasedWithAdditionalInfo; | 25 | import org.thingsboard.server.common.data.SearchTextBasedWithAdditionalInfo; |
27 | -import org.thingsboard.server.common.data.ShortEdgeInfo; | ||
28 | -import org.thingsboard.server.common.data.edge.Edge; | ||
29 | -import org.thingsboard.server.common.data.id.EdgeId; | ||
30 | import org.thingsboard.server.common.data.id.RuleChainId; | 26 | import org.thingsboard.server.common.data.id.RuleChainId; |
31 | import org.thingsboard.server.common.data.id.RuleNodeId; | 27 | import org.thingsboard.server.common.data.id.RuleNodeId; |
32 | import org.thingsboard.server.common.data.id.TenantId; | 28 | import org.thingsboard.server.common.data.id.TenantId; |
33 | 29 | ||
34 | -import java.util.HashSet; | ||
35 | -import java.util.Set; | ||
36 | - | ||
37 | @Data | 30 | @Data |
38 | @EqualsAndHashCode(callSuper = true) | 31 | @EqualsAndHashCode(callSuper = true) |
39 | @Slf4j | 32 | @Slf4j |
@@ -56,7 +56,7 @@ public class BaseEdgeEventService implements EdgeEventService { | @@ -56,7 +56,7 @@ public class BaseEdgeEventService implements EdgeEventService { | ||
56 | if (edgeEvent.getEdgeId() == null) { | 56 | if (edgeEvent.getEdgeId() == null) { |
57 | throw new DataValidationException("Edge id should be specified!"); | 57 | throw new DataValidationException("Edge id should be specified!"); |
58 | } | 58 | } |
59 | - if (StringUtils.isEmpty(edgeEvent.getEdgeEventAction())) { | 59 | + if (StringUtils.isEmpty(edgeEvent.getAction())) { |
60 | throw new DataValidationException("Edge Event action should be specified!"); | 60 | throw new DataValidationException("Edge Event action should be specified!"); |
61 | } | 61 | } |
62 | } | 62 | } |
@@ -15,13 +15,21 @@ | @@ -15,13 +15,21 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.edge; | 16 | package org.thingsboard.server.dao.edge; |
17 | 17 | ||
18 | +import com.datastax.driver.core.ResultSet; | ||
19 | +import com.datastax.driver.core.ResultSetFuture; | ||
20 | +import com.datastax.driver.core.Statement; | ||
21 | +import com.datastax.driver.core.querybuilder.Select; | ||
22 | +import com.datastax.driver.mapping.Result; | ||
23 | +import com.google.common.base.Function; | ||
18 | import com.google.common.util.concurrent.Futures; | 24 | import com.google.common.util.concurrent.Futures; |
19 | import com.google.common.util.concurrent.ListenableFuture; | 25 | import com.google.common.util.concurrent.ListenableFuture; |
20 | import com.google.common.util.concurrent.MoreExecutors; | 26 | import com.google.common.util.concurrent.MoreExecutors; |
21 | import lombok.extern.slf4j.Slf4j; | 27 | import lombok.extern.slf4j.Slf4j; |
22 | import org.springframework.beans.factory.annotation.Autowired; | 28 | import org.springframework.beans.factory.annotation.Autowired; |
23 | import org.springframework.stereotype.Component; | 29 | import org.springframework.stereotype.Component; |
30 | +import org.thingsboard.server.common.data.Device; | ||
24 | import org.thingsboard.server.common.data.EntitySubtype; | 31 | import org.thingsboard.server.common.data.EntitySubtype; |
32 | +import org.thingsboard.server.common.data.EntityType; | ||
25 | import org.thingsboard.server.common.data.edge.Edge; | 33 | import org.thingsboard.server.common.data.edge.Edge; |
26 | import org.thingsboard.server.common.data.id.DashboardId; | 34 | import org.thingsboard.server.common.data.id.DashboardId; |
27 | import org.thingsboard.server.common.data.id.RuleChainId; | 35 | import org.thingsboard.server.common.data.id.RuleChainId; |
@@ -29,17 +37,40 @@ import org.thingsboard.server.common.data.id.TenantId; | @@ -29,17 +37,40 @@ import org.thingsboard.server.common.data.id.TenantId; | ||
29 | import org.thingsboard.server.common.data.page.TextPageLink; | 37 | import org.thingsboard.server.common.data.page.TextPageLink; |
30 | import org.thingsboard.server.common.data.relation.EntityRelation; | 38 | import org.thingsboard.server.common.data.relation.EntityRelation; |
31 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; | 39 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
40 | +import org.thingsboard.server.dao.DaoUtil; | ||
41 | +import org.thingsboard.server.dao.model.EntitySubtypeEntity; | ||
32 | import org.thingsboard.server.dao.model.nosql.EdgeEntity; | 42 | import org.thingsboard.server.dao.model.nosql.EdgeEntity; |
33 | import org.thingsboard.server.dao.nosql.CassandraAbstractSearchTextDao; | 43 | import org.thingsboard.server.dao.nosql.CassandraAbstractSearchTextDao; |
34 | import org.thingsboard.server.dao.relation.RelationDao; | 44 | import org.thingsboard.server.dao.relation.RelationDao; |
35 | import org.thingsboard.server.dao.util.NoSqlDao; | 45 | import org.thingsboard.server.dao.util.NoSqlDao; |
36 | 46 | ||
47 | +import javax.annotation.Nullable; | ||
37 | import java.util.ArrayList; | 48 | import java.util.ArrayList; |
49 | +import java.util.Arrays; | ||
50 | +import java.util.Collections; | ||
38 | import java.util.List; | 51 | import java.util.List; |
39 | import java.util.Optional; | 52 | import java.util.Optional; |
40 | import java.util.UUID; | 53 | import java.util.UUID; |
41 | 54 | ||
55 | +import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; | ||
56 | +import static com.datastax.driver.core.querybuilder.QueryBuilder.in; | ||
57 | +import static com.datastax.driver.core.querybuilder.QueryBuilder.select; | ||
58 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_BY_CUSTOMER_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME; | ||
59 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_BY_CUSTOMER_BY_TYPE_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME; | ||
60 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_BY_TENANT_AND_NAME_VIEW_NAME; | ||
61 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_BY_TENANT_AND_ROUTING_KEY_VIEW_NAME; | ||
62 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME; | ||
63 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_BY_TENANT_BY_TYPE_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME; | ||
42 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_COLUMN_FAMILY_NAME; | 64 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_COLUMN_FAMILY_NAME; |
65 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_CUSTOMER_ID_PROPERTY; | ||
66 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_NAME_PROPERTY; | ||
67 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_ROUTING_KEY_PROPERTY; | ||
68 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_TENANT_ID_PROPERTY; | ||
69 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_TYPE_PROPERTY; | ||
70 | +import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_SUBTYPE_COLUMN_FAMILY_NAME; | ||
71 | +import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_SUBTYPE_ENTITY_TYPE_PROPERTY; | ||
72 | +import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_SUBTYPE_TENANT_ID_PROPERTY; | ||
73 | +import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY; | ||
43 | 74 | ||
44 | @Component | 75 | @Component |
45 | @Slf4j | 76 | @Slf4j |
@@ -59,50 +90,124 @@ public class CassandraEdgeDao extends CassandraAbstractSearchTextDao<EdgeEntity, | @@ -59,50 +90,124 @@ public class CassandraEdgeDao extends CassandraAbstractSearchTextDao<EdgeEntity, | ||
59 | return EDGE_COLUMN_FAMILY_NAME; | 90 | return EDGE_COLUMN_FAMILY_NAME; |
60 | } | 91 | } |
61 | 92 | ||
93 | + @Override | ||
94 | + public Edge save(TenantId tenantId, Edge domain) { | ||
95 | + Edge savedEdge = super.save(tenantId, domain); | ||
96 | + EntitySubtype entitySubtype = new EntitySubtype(savedEdge.getTenantId(), EntityType.EDGE, savedEdge.getType()); | ||
97 | + EntitySubtypeEntity entitySubtypeEntity = new EntitySubtypeEntity(entitySubtype); | ||
98 | + Statement saveStatement = cluster.getMapper(EntitySubtypeEntity.class).saveQuery(entitySubtypeEntity); | ||
99 | + executeWrite(tenantId, saveStatement); | ||
100 | + return savedEdge; | ||
101 | + } | ||
62 | 102 | ||
63 | @Override | 103 | @Override |
64 | public List<Edge> findEdgesByTenantId(UUID tenantId, TextPageLink pageLink) { | 104 | public List<Edge> findEdgesByTenantId(UUID tenantId, TextPageLink pageLink) { |
65 | - return null; | 105 | + log.debug("Try to find edge by tenantId [{}] and pageLink [{}]", tenantId, pageLink); |
106 | + List<EdgeEntity> edgeEntities = findPageWithTextSearch(new TenantId(tenantId), EDGE_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME, | ||
107 | + Collections.singletonList(eq(EDGE_TENANT_ID_PROPERTY, tenantId)), pageLink); | ||
108 | + | ||
109 | + log.trace("Found edges [{}] by tenantId [{}] and pageLink [{}]", edgeEntities, tenantId, pageLink); | ||
110 | + return DaoUtil.convertDataList(edgeEntities); | ||
66 | } | 111 | } |
67 | 112 | ||
68 | @Override | 113 | @Override |
69 | public List<Edge> findEdgesByTenantIdAndType(UUID tenantId, String type, TextPageLink pageLink) { | 114 | public List<Edge> findEdgesByTenantIdAndType(UUID tenantId, String type, TextPageLink pageLink) { |
70 | - return null; | 115 | + log.debug("Try to find edges by tenantId [{}], type [{}] and pageLink [{}]", tenantId, type, pageLink); |
116 | + List<EdgeEntity> edgeEntities = findPageWithTextSearch(new TenantId(tenantId), EDGE_BY_TENANT_BY_TYPE_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME, | ||
117 | + Arrays.asList(eq(EDGE_TYPE_PROPERTY, type), | ||
118 | + eq(EDGE_TENANT_ID_PROPERTY, tenantId)), pageLink); | ||
119 | + log.trace("Found edges [{}] by tenantId [{}], type [{}] and pageLink [{}]", edgeEntities, tenantId, type, pageLink); | ||
120 | + return DaoUtil.convertDataList(edgeEntities); | ||
71 | } | 121 | } |
72 | 122 | ||
73 | @Override | 123 | @Override |
74 | public ListenableFuture<List<Edge>> findEdgesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> edgeIds) { | 124 | public ListenableFuture<List<Edge>> findEdgesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> edgeIds) { |
75 | - return null; | 125 | + log.debug("Try to find edges by tenantId [{}] and edge Ids [{}]", tenantId, edgeIds); |
126 | + Select select = select().from(getColumnFamilyName()); | ||
127 | + Select.Where query = select.where(); | ||
128 | + query.and(eq(EDGE_TENANT_ID_PROPERTY, tenantId)); | ||
129 | + query.and(in(ID_PROPERTY, edgeIds)); | ||
130 | + return findListByStatementAsync(new TenantId(tenantId), query); | ||
76 | } | 131 | } |
77 | 132 | ||
78 | @Override | 133 | @Override |
79 | public List<Edge> findEdgesByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink) { | 134 | public List<Edge> findEdgesByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink) { |
80 | - return null; | 135 | + log.debug("Try to find edges by tenantId [{}], customerId[{}] and pageLink [{}]", tenantId, customerId, pageLink); |
136 | + List<EdgeEntity> edgeEntities = findPageWithTextSearch(new TenantId(tenantId), EDGE_BY_CUSTOMER_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME, | ||
137 | + Arrays.asList(eq(EDGE_CUSTOMER_ID_PROPERTY, customerId), | ||
138 | + eq(EDGE_TENANT_ID_PROPERTY, tenantId)), | ||
139 | + pageLink); | ||
140 | + | ||
141 | + log.trace("Found edges [{}] by tenantId [{}], customerId [{}] and pageLink [{}]", edgeEntities, tenantId, customerId, pageLink); | ||
142 | + return DaoUtil.convertDataList(edgeEntities); | ||
81 | } | 143 | } |
82 | 144 | ||
83 | @Override | 145 | @Override |
84 | public List<Edge> findEdgesByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, TextPageLink pageLink) { | 146 | public List<Edge> findEdgesByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, TextPageLink pageLink) { |
85 | - return null; | 147 | + log.debug("Try to find edges by tenantId [{}], customerId [{}], type [{}] and pageLink [{}]", tenantId, customerId, type, pageLink); |
148 | + List<EdgeEntity> edgeEntities = findPageWithTextSearch(new TenantId(tenantId), EDGE_BY_CUSTOMER_BY_TYPE_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME, | ||
149 | + Arrays.asList(eq(EDGE_TYPE_PROPERTY, type), | ||
150 | + eq(EDGE_CUSTOMER_ID_PROPERTY, customerId), | ||
151 | + eq(EDGE_TENANT_ID_PROPERTY, tenantId)), | ||
152 | + pageLink); | ||
153 | + | ||
154 | + log.trace("Found edges [{}] by tenantId [{}], customerId [{}], type [{}] and pageLink [{}]", edgeEntities, tenantId, customerId, type, pageLink); | ||
155 | + return DaoUtil.convertDataList(edgeEntities); | ||
86 | } | 156 | } |
87 | 157 | ||
88 | @Override | 158 | @Override |
89 | public ListenableFuture<List<Edge>> findEdgesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> edgeIds) { | 159 | public ListenableFuture<List<Edge>> findEdgesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> edgeIds) { |
90 | - return null; | 160 | + log.debug("Try to find edges by tenantId [{}], customerId [{}] and edges Ids [{}]", tenantId, customerId, edgeIds); |
161 | + Select select = select().from(getColumnFamilyName()); | ||
162 | + Select.Where query = select.where(); | ||
163 | + query.and(eq(EDGE_TENANT_ID_PROPERTY, tenantId)); | ||
164 | + query.and(eq(EDGE_CUSTOMER_ID_PROPERTY, customerId)); | ||
165 | + query.and(in(ID_PROPERTY, edgeIds)); | ||
166 | + return findListByStatementAsync(new TenantId(tenantId), query); | ||
91 | } | 167 | } |
92 | 168 | ||
93 | @Override | 169 | @Override |
94 | - public Optional<Edge> findEdgeByTenantIdAndName(UUID tenantId, String name) { | ||
95 | - return Optional.empty(); | 170 | + public Optional<Edge> findEdgeByTenantIdAndName(UUID tenantId, String edgeName) { |
171 | + Select select = select().from(EDGE_BY_TENANT_AND_NAME_VIEW_NAME); | ||
172 | + Select.Where query = select.where(); | ||
173 | + query.and(eq(EDGE_TENANT_ID_PROPERTY, tenantId)); | ||
174 | + query.and(eq(EDGE_NAME_PROPERTY, edgeName)); | ||
175 | + return Optional.ofNullable(DaoUtil.getData(findOneByStatement(new TenantId(tenantId), query))); | ||
96 | } | 176 | } |
97 | 177 | ||
98 | @Override | 178 | @Override |
99 | public ListenableFuture<List<EntitySubtype>> findTenantEdgeTypesAsync(UUID tenantId) { | 179 | public ListenableFuture<List<EntitySubtype>> findTenantEdgeTypesAsync(UUID tenantId) { |
100 | - return null; | 180 | + Select select = select().from(ENTITY_SUBTYPE_COLUMN_FAMILY_NAME); |
181 | + Select.Where query = select.where(); | ||
182 | + query.and(eq(ENTITY_SUBTYPE_TENANT_ID_PROPERTY, tenantId)); | ||
183 | + query.and(eq(ENTITY_SUBTYPE_ENTITY_TYPE_PROPERTY, EntityType.EDGE)); | ||
184 | + query.setConsistencyLevel(cluster.getDefaultReadConsistencyLevel()); | ||
185 | + ResultSetFuture resultSetFuture = executeAsyncRead(new TenantId(tenantId), query); | ||
186 | + return Futures.transform(resultSetFuture, new Function<ResultSet, List<EntitySubtype>>() { | ||
187 | + @Nullable | ||
188 | + @Override | ||
189 | + public List<EntitySubtype> apply(@Nullable ResultSet resultSet) { | ||
190 | + Result<EntitySubtypeEntity> result = cluster.getMapper(EntitySubtypeEntity.class).map(resultSet); | ||
191 | + if (result != null) { | ||
192 | + List<EntitySubtype> entitySubtypes = new ArrayList<>(); | ||
193 | + result.all().forEach((entitySubtypeEntity) -> | ||
194 | + entitySubtypes.add(entitySubtypeEntity.toEntitySubtype()) | ||
195 | + ); | ||
196 | + return entitySubtypes; | ||
197 | + } else { | ||
198 | + return Collections.emptyList(); | ||
199 | + } | ||
200 | + } | ||
201 | + }, MoreExecutors.directExecutor()); | ||
101 | } | 202 | } |
102 | 203 | ||
103 | @Override | 204 | @Override |
104 | public Optional<Edge> findByRoutingKey(UUID tenantId, String routingKey) { | 205 | public Optional<Edge> findByRoutingKey(UUID tenantId, String routingKey) { |
105 | - return Optional.empty(); | 206 | + Select select = select().from(EDGE_BY_TENANT_AND_ROUTING_KEY_VIEW_NAME); |
207 | + Select.Where query = select.where(); | ||
208 | + query.and(eq(EDGE_TENANT_ID_PROPERTY, tenantId)); | ||
209 | + query.and(eq(EDGE_ROUTING_KEY_PROPERTY, routingKey)); | ||
210 | + return Optional.ofNullable(DaoUtil.getData(findOneByStatement(new TenantId(tenantId), query))); | ||
106 | } | 211 | } |
107 | 212 | ||
108 | @Override | 213 | @Override |
@@ -15,19 +15,38 @@ | @@ -15,19 +15,38 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.edge; | 16 | package org.thingsboard.server.dao.edge; |
17 | 17 | ||
18 | +import com.datastax.driver.core.ResultSetFuture; | ||
19 | +import com.datastax.driver.core.querybuilder.Insert; | ||
20 | +import com.datastax.driver.core.querybuilder.QueryBuilder; | ||
21 | +import com.datastax.driver.core.utils.UUIDs; | ||
22 | +import com.google.common.util.concurrent.Futures; | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 23 | import com.google.common.util.concurrent.ListenableFuture; |
24 | +import com.google.common.util.concurrent.MoreExecutors; | ||
19 | import lombok.extern.slf4j.Slf4j; | 25 | import lombok.extern.slf4j.Slf4j; |
26 | +import org.apache.commons.lang3.StringUtils; | ||
27 | +import org.springframework.beans.factory.annotation.Value; | ||
20 | import org.springframework.stereotype.Component; | 28 | import org.springframework.stereotype.Component; |
29 | +import org.thingsboard.server.common.data.audit.ActionType; | ||
21 | import org.thingsboard.server.common.data.edge.EdgeEvent; | 30 | import org.thingsboard.server.common.data.edge.EdgeEvent; |
31 | +import org.thingsboard.server.common.data.id.EdgeEventId; | ||
22 | import org.thingsboard.server.common.data.id.EdgeId; | 32 | import org.thingsboard.server.common.data.id.EdgeId; |
33 | +import org.thingsboard.server.common.data.id.TenantId; | ||
23 | import org.thingsboard.server.common.data.page.TimePageLink; | 34 | import org.thingsboard.server.common.data.page.TimePageLink; |
35 | +import org.thingsboard.server.dao.DaoUtil; | ||
36 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
24 | import org.thingsboard.server.dao.model.nosql.EdgeEventEntity; | 37 | import org.thingsboard.server.dao.model.nosql.EdgeEventEntity; |
25 | import org.thingsboard.server.dao.nosql.CassandraAbstractSearchTimeDao; | 38 | import org.thingsboard.server.dao.nosql.CassandraAbstractSearchTimeDao; |
26 | import org.thingsboard.server.dao.util.NoSqlDao; | 39 | import org.thingsboard.server.dao.util.NoSqlDao; |
27 | 40 | ||
41 | +import java.util.Arrays; | ||
28 | import java.util.List; | 42 | import java.util.List; |
43 | +import java.util.Optional; | ||
29 | import java.util.UUID; | 44 | import java.util.UUID; |
45 | +import java.util.stream.Collectors; | ||
30 | 46 | ||
47 | +import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; | ||
48 | +import static com.datastax.driver.core.querybuilder.QueryBuilder.ttl; | ||
49 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_BY_ID_VIEW_NAME; | ||
31 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_FAMILY_NAME; | 50 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_FAMILY_NAME; |
32 | 51 | ||
33 | @Component | 52 | @Component |
@@ -35,6 +54,8 @@ import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_ | @@ -35,6 +54,8 @@ import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_ | ||
35 | @NoSqlDao | 54 | @NoSqlDao |
36 | public class CassandraEdgeEventDao extends CassandraAbstractSearchTimeDao<EdgeEventEntity, EdgeEvent> implements EdgeEventDao { | 55 | public class CassandraEdgeEventDao extends CassandraAbstractSearchTimeDao<EdgeEventEntity, EdgeEvent> implements EdgeEventDao { |
37 | 56 | ||
57 | + @Value("${edges.edge_events_ttl:0}") | ||
58 | + private int edgeEventsTtl; | ||
38 | 59 | ||
39 | @Override | 60 | @Override |
40 | protected Class<EdgeEventEntity> getColumnFamilyClass() { | 61 | protected Class<EdgeEventEntity> getColumnFamilyClass() { |
@@ -46,14 +67,61 @@ public class CassandraEdgeEventDao extends CassandraAbstractSearchTimeDao<EdgeEv | @@ -46,14 +67,61 @@ public class CassandraEdgeEventDao extends CassandraAbstractSearchTimeDao<EdgeEv | ||
46 | return EDGE_EVENT_COLUMN_FAMILY_NAME; | 67 | return EDGE_EVENT_COLUMN_FAMILY_NAME; |
47 | } | 68 | } |
48 | 69 | ||
49 | - | ||
50 | @Override | 70 | @Override |
51 | public ListenableFuture<EdgeEvent> saveAsync(EdgeEvent edgeEvent) { | 71 | public ListenableFuture<EdgeEvent> saveAsync(EdgeEvent edgeEvent) { |
52 | - return null; | 72 | + log.debug("Save edge event [{}] ", edgeEvent); |
73 | + if (edgeEvent.getId() == null) { | ||
74 | + edgeEvent.setId(new EdgeEventId(UUIDs.timeBased())); | ||
75 | + } | ||
76 | + if (StringUtils.isEmpty(edgeEvent.getUid())) { | ||
77 | + edgeEvent.setUid(edgeEvent.getId().toString()); | ||
78 | + } | ||
79 | + ListenableFuture<Optional<EdgeEvent>> optionalSave = saveAsync(edgeEvent.getTenantId(), new EdgeEventEntity(edgeEvent), edgeEventsTtl); | ||
80 | + return Futures.transform(optionalSave, opt -> opt.orElse(null), MoreExecutors.directExecutor()); | ||
81 | + } | ||
82 | + | ||
83 | + private ListenableFuture<Optional<EdgeEvent>> saveAsync(TenantId tenantId, EdgeEventEntity entity, int ttl) { | ||
84 | + if (entity.getUuid() == null) { | ||
85 | + entity.setUuid(UUIDs.timeBased()); | ||
86 | + } | ||
87 | + Insert insert = QueryBuilder.insertInto(getColumnFamilyName()) | ||
88 | + .value(ModelConstants.ID_PROPERTY, entity.getUuid()) | ||
89 | + .value(ModelConstants.EDGE_EVENT_TENANT_ID_PROPERTY, entity.getTenantId()) | ||
90 | + .value(ModelConstants.EDGE_EVENT_EDGE_ID_PROPERTY, entity.getEdgeId()) | ||
91 | + .value(ModelConstants.EDGE_EVENT_TYPE_PROPERTY, entity.getEdgeEventType()) | ||
92 | + .value(ModelConstants.EDGE_EVENT_UID_PROPERTY, entity.getEdgeEventUid()) | ||
93 | + .value(ModelConstants.EDGE_EVENT_ENTITY_ID_PROPERTY, entity.getEntityId()) | ||
94 | + .value(ModelConstants.EDGE_EVENT_ACTION_PROPERTY, entity.getEdgeEventAction()) | ||
95 | + .value(ModelConstants.EDGE_EVENT_BODY_PROPERTY, entity.getBody()); | ||
96 | + | ||
97 | + if (ttl > 0) { | ||
98 | + insert.using(ttl(ttl)); | ||
99 | + } | ||
100 | + ResultSetFuture resultSetFuture = executeAsyncWrite(tenantId, insert); | ||
101 | + return Futures.transform(resultSetFuture, rs -> { | ||
102 | + if (rs.wasApplied()) { | ||
103 | + return Optional.of(DaoUtil.getData(entity)); | ||
104 | + } else { | ||
105 | + return Optional.empty(); | ||
106 | + } | ||
107 | + }, MoreExecutors.directExecutor()); | ||
53 | } | 108 | } |
54 | 109 | ||
55 | @Override | 110 | @Override |
56 | public List<EdgeEvent> findEdgeEvents(UUID tenantId, EdgeId edgeId, TimePageLink pageLink, boolean withTsUpdate) { | 111 | public List<EdgeEvent> findEdgeEvents(UUID tenantId, EdgeId edgeId, TimePageLink pageLink, boolean withTsUpdate) { |
57 | - return null; | 112 | + log.trace("Try to find edge events by tenant [{}], edgeId [{}] and pageLink [{}]", tenantId, edgeId, pageLink); |
113 | + List<EdgeEventEntity> entities = findPageWithTimeSearch(new TenantId(tenantId), EDGE_EVENT_BY_ID_VIEW_NAME, | ||
114 | + Arrays.asList(eq(ModelConstants.EDGE_EVENT_TENANT_ID_PROPERTY, tenantId), | ||
115 | + eq(ModelConstants.EDGE_EVENT_EDGE_ID_PROPERTY, edgeId.getId())), | ||
116 | + pageLink); | ||
117 | + log.trace("Found events by tenant [{}], edgeId [{}] and pageLink [{}]", tenantId, edgeId, pageLink); | ||
118 | + List<EdgeEvent> edgeEvents = DaoUtil.convertDataList(entities); | ||
119 | + if (!withTsUpdate) { | ||
120 | + return edgeEvents.stream() | ||
121 | + .filter(edgeEvent -> !edgeEvent.getAction().equals(ActionType.TIMESERIES_UPDATED.name())) | ||
122 | + .collect(Collectors.toList()); | ||
123 | + } else { | ||
124 | + return edgeEvents; | ||
125 | + } | ||
58 | } | 126 | } |
59 | } | 127 | } |
@@ -368,6 +368,12 @@ public class ModelConstants { | @@ -368,6 +368,12 @@ public class ModelConstants { | ||
368 | public static final String EDGE_TYPE_PROPERTY = "type"; | 368 | public static final String EDGE_TYPE_PROPERTY = "type"; |
369 | public static final String EDGE_CONFIGURATION_PROPERTY = "configuration"; | 369 | public static final String EDGE_CONFIGURATION_PROPERTY = "configuration"; |
370 | public static final String EDGE_ADDITIONAL_INFO_PROPERTY = ADDITIONAL_INFO_PROPERTY; | 370 | public static final String EDGE_ADDITIONAL_INFO_PROPERTY = ADDITIONAL_INFO_PROPERTY; |
371 | + public static final String EDGE_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "edge_by_tenant_and_search_text"; | ||
372 | + public static final String EDGE_BY_TENANT_BY_TYPE_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "edge_by_tenant_by_type_and_search_text"; | ||
373 | + public static final String EDGE_BY_CUSTOMER_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "edge_by_customer_and_search_text"; | ||
374 | + public static final String EDGE_BY_CUSTOMER_BY_TYPE_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "edge_by_customer_by_type_and_search_text"; | ||
375 | + public static final String EDGE_BY_TENANT_AND_NAME_VIEW_NAME = "edge_by_tenant_and_name"; | ||
376 | + public static final String EDGE_BY_TENANT_AND_ROUTING_KEY_VIEW_NAME = "edge_by_tenant_and_routing_key"; | ||
371 | 377 | ||
372 | public static final String EDGE_ROUTING_KEY_PROPERTY = "routing_key"; | 378 | public static final String EDGE_ROUTING_KEY_PROPERTY = "routing_key"; |
373 | public static final String EDGE_SECRET_PROPERTY = "secret"; | 379 | public static final String EDGE_SECRET_PROPERTY = "secret"; |
@@ -380,8 +386,11 @@ public class ModelConstants { | @@ -380,8 +386,11 @@ public class ModelConstants { | ||
380 | public static final String EDGE_EVENT_EDGE_ID_PROPERTY = "edge_id"; | 386 | public static final String EDGE_EVENT_EDGE_ID_PROPERTY = "edge_id"; |
381 | public static final String EDGE_EVENT_TYPE_PROPERTY = "edge_event_type"; | 387 | public static final String EDGE_EVENT_TYPE_PROPERTY = "edge_event_type"; |
382 | public static final String EDGE_EVENT_ACTION_PROPERTY = "edge_event_action"; | 388 | public static final String EDGE_EVENT_ACTION_PROPERTY = "edge_event_action"; |
389 | + public static final String EDGE_EVENT_UID_PROPERTY = "edge_event_uid"; | ||
383 | public static final String EDGE_EVENT_ENTITY_ID_PROPERTY = "entity_id"; | 390 | public static final String EDGE_EVENT_ENTITY_ID_PROPERTY = "entity_id"; |
384 | - public static final String EDGE_EVENT_ENTITY_BODY_PROPERTY = "entity_body"; | 391 | + public static final String EDGE_EVENT_BODY_PROPERTY = "body"; |
392 | + | ||
393 | + public static final String EDGE_EVENT_BY_ID_VIEW_NAME = "edge_event_by_id"; | ||
385 | 394 | ||
386 | /** | 395 | /** |
387 | * Cassandra attributes and timeseries constants. | 396 | * Cassandra attributes and timeseries constants. |
@@ -32,6 +32,9 @@ import org.thingsboard.server.dao.model.type.JsonCodec; | @@ -32,6 +32,9 @@ import org.thingsboard.server.dao.model.type.JsonCodec; | ||
32 | 32 | ||
33 | import java.util.UUID; | 33 | import java.util.UUID; |
34 | 34 | ||
35 | +import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_CUSTOMER_ID_PROPERTY; | ||
36 | +import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_TENANT_ID_PROPERTY; | ||
37 | +import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_TYPE_PROPERTY; | ||
35 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_ADDITIONAL_INFO_PROPERTY; | 38 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_ADDITIONAL_INFO_PROPERTY; |
36 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_COLUMN_FAMILY_NAME; | 39 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_COLUMN_FAMILY_NAME; |
37 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_CONFIGURATION_PROPERTY; | 40 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_CONFIGURATION_PROPERTY; |
@@ -50,21 +53,22 @@ import static org.thingsboard.server.dao.model.ModelConstants.SEARCH_TEXT_PROPER | @@ -50,21 +53,22 @@ import static org.thingsboard.server.dao.model.ModelConstants.SEARCH_TEXT_PROPER | ||
50 | @Table(name = EDGE_COLUMN_FAMILY_NAME) | 53 | @Table(name = EDGE_COLUMN_FAMILY_NAME) |
51 | public class EdgeEntity implements SearchTextEntity<Edge> { | 54 | public class EdgeEntity implements SearchTextEntity<Edge> { |
52 | 55 | ||
53 | - @PartitionKey | 56 | + @PartitionKey(value = 0) |
54 | @Column(name = ID_PROPERTY) | 57 | @Column(name = ID_PROPERTY) |
55 | private UUID id; | 58 | private UUID id; |
56 | 59 | ||
57 | - @ClusteringColumn | 60 | + @PartitionKey(value = 1) |
58 | @Column(name = EDGE_TENANT_ID_PROPERTY) | 61 | @Column(name = EDGE_TENANT_ID_PROPERTY) |
59 | private UUID tenantId; | 62 | private UUID tenantId; |
60 | 63 | ||
61 | - @ClusteringColumn | 64 | + @PartitionKey(value = 2) |
62 | @Column(name = EDGE_CUSTOMER_ID_PROPERTY) | 65 | @Column(name = EDGE_CUSTOMER_ID_PROPERTY) |
63 | private UUID customerId; | 66 | private UUID customerId; |
64 | 67 | ||
65 | @Column(name = EDGE_ROOT_RULE_CHAIN_ID_PROPERTY) | 68 | @Column(name = EDGE_ROOT_RULE_CHAIN_ID_PROPERTY) |
66 | private UUID rootRuleChainId; | 69 | private UUID rootRuleChainId; |
67 | 70 | ||
71 | + @PartitionKey(value = 3) | ||
68 | @Column(name = EDGE_TYPE_PROPERTY) | 72 | @Column(name = EDGE_TYPE_PROPERTY) |
69 | private String type; | 73 | private String type; |
70 | 74 |
@@ -23,18 +23,13 @@ import com.datastax.driver.mapping.annotations.Table; | @@ -23,18 +23,13 @@ import com.datastax.driver.mapping.annotations.Table; | ||
23 | import com.fasterxml.jackson.databind.JsonNode; | 23 | import com.fasterxml.jackson.databind.JsonNode; |
24 | import lombok.Data; | 24 | import lombok.Data; |
25 | import lombok.NoArgsConstructor; | 25 | import lombok.NoArgsConstructor; |
26 | -import org.thingsboard.server.common.data.EntityType; | ||
27 | -import org.thingsboard.server.common.data.Event; | ||
28 | import org.thingsboard.server.common.data.edge.EdgeEvent; | 26 | import org.thingsboard.server.common.data.edge.EdgeEvent; |
29 | import org.thingsboard.server.common.data.edge.EdgeEventType; | 27 | import org.thingsboard.server.common.data.edge.EdgeEventType; |
30 | import org.thingsboard.server.common.data.id.EdgeEventId; | 28 | import org.thingsboard.server.common.data.id.EdgeEventId; |
31 | import org.thingsboard.server.common.data.id.EdgeId; | 29 | import org.thingsboard.server.common.data.id.EdgeId; |
32 | -import org.thingsboard.server.common.data.id.EntityIdFactory; | ||
33 | -import org.thingsboard.server.common.data.id.EventId; | ||
34 | import org.thingsboard.server.common.data.id.TenantId; | 30 | import org.thingsboard.server.common.data.id.TenantId; |
35 | import org.thingsboard.server.dao.model.BaseEntity; | 31 | import org.thingsboard.server.dao.model.BaseEntity; |
36 | import org.thingsboard.server.dao.model.type.EdgeEventTypeCodec; | 32 | import org.thingsboard.server.dao.model.type.EdgeEventTypeCodec; |
37 | -import org.thingsboard.server.dao.model.type.EntityTypeCodec; | ||
38 | import org.thingsboard.server.dao.model.type.JsonCodec; | 33 | import org.thingsboard.server.dao.model.type.JsonCodec; |
39 | 34 | ||
40 | import java.util.UUID; | 35 | import java.util.UUID; |
@@ -42,17 +37,11 @@ import java.util.UUID; | @@ -42,17 +37,11 @@ import java.util.UUID; | ||
42 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ACTION_PROPERTY; | 37 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ACTION_PROPERTY; |
43 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_FAMILY_NAME; | 38 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_FAMILY_NAME; |
44 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_EDGE_ID_PROPERTY; | 39 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_EDGE_ID_PROPERTY; |
45 | -import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ENTITY_BODY_PROPERTY; | 40 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_BODY_PROPERTY; |
46 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ENTITY_ID_PROPERTY; | 41 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ENTITY_ID_PROPERTY; |
47 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_TENANT_ID_PROPERTY; | 42 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_TENANT_ID_PROPERTY; |
48 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_TYPE_PROPERTY; | 43 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_TYPE_PROPERTY; |
49 | -import static org.thingsboard.server.dao.model.ModelConstants.EVENT_BODY_PROPERTY; | ||
50 | -import static org.thingsboard.server.dao.model.ModelConstants.EVENT_COLUMN_FAMILY_NAME; | ||
51 | -import static org.thingsboard.server.dao.model.ModelConstants.EVENT_ENTITY_ID_PROPERTY; | ||
52 | -import static org.thingsboard.server.dao.model.ModelConstants.EVENT_ENTITY_TYPE_PROPERTY; | ||
53 | -import static org.thingsboard.server.dao.model.ModelConstants.EVENT_TENANT_ID_PROPERTY; | ||
54 | -import static org.thingsboard.server.dao.model.ModelConstants.EVENT_TYPE_PROPERTY; | ||
55 | -import static org.thingsboard.server.dao.model.ModelConstants.EVENT_UID_PROPERTY; | 44 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_UID_PROPERTY; |
56 | import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY; | 45 | import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY; |
57 | 46 | ||
58 | @Data | 47 | @Data |
@@ -71,25 +60,23 @@ public class EdgeEventEntity implements BaseEntity<EdgeEvent> { | @@ -71,25 +60,23 @@ public class EdgeEventEntity implements BaseEntity<EdgeEvent> { | ||
71 | @Column(name = EDGE_EVENT_EDGE_ID_PROPERTY) | 60 | @Column(name = EDGE_EVENT_EDGE_ID_PROPERTY) |
72 | private UUID edgeId; | 61 | private UUID edgeId; |
73 | 62 | ||
74 | - @PartitionKey(value = 2) | 63 | + @ClusteringColumn() |
75 | @Column(name = EDGE_EVENT_TYPE_PROPERTY, codec = EdgeEventTypeCodec.class) | 64 | @Column(name = EDGE_EVENT_TYPE_PROPERTY, codec = EdgeEventTypeCodec.class) |
76 | private EdgeEventType edgeEventType; | 65 | private EdgeEventType edgeEventType; |
77 | 66 | ||
78 | - @PartitionKey(value = 3) | ||
79 | - @Column(name = EDGE_EVENT_ENTITY_ID_PROPERTY) | ||
80 | - private UUID entityId; | ||
81 | - | ||
82 | - @ClusteringColumn() | 67 | + @ClusteringColumn(value = 1) |
83 | @Column(name = EDGE_EVENT_ACTION_PROPERTY) | 68 | @Column(name = EDGE_EVENT_ACTION_PROPERTY) |
84 | private String edgeEventAction; | 69 | private String edgeEventAction; |
85 | 70 | ||
86 | - // TODO | ||
87 | - @ClusteringColumn(value = 1) | ||
88 | - @Column(name = EVENT_UID_PROPERTY) | ||
89 | - private String eventUid; | 71 | + @ClusteringColumn(value = 2) |
72 | + @Column(name = EDGE_EVENT_UID_PROPERTY) | ||
73 | + private String edgeEventUid; | ||
74 | + | ||
75 | + @Column(name = EDGE_EVENT_ENTITY_ID_PROPERTY) | ||
76 | + private UUID entityId; | ||
90 | 77 | ||
91 | - @Column(name = EDGE_EVENT_ENTITY_BODY_PROPERTY, codec = JsonCodec.class) | ||
92 | - private JsonNode entityBody; | 78 | + @Column(name = EDGE_EVENT_BODY_PROPERTY, codec = JsonCodec.class) |
79 | + private JsonNode body; | ||
93 | 80 | ||
94 | public EdgeEventEntity(EdgeEvent edgeEvent) { | 81 | public EdgeEventEntity(EdgeEvent edgeEvent) { |
95 | if (edgeEvent.getId() != null) { | 82 | if (edgeEvent.getId() != null) { |
@@ -101,13 +88,11 @@ public class EdgeEventEntity implements BaseEntity<EdgeEvent> { | @@ -101,13 +88,11 @@ public class EdgeEventEntity implements BaseEntity<EdgeEvent> { | ||
101 | if (edgeEvent.getEdgeId() != null) { | 88 | if (edgeEvent.getEdgeId() != null) { |
102 | this.edgeId = edgeEvent.getEdgeId().getId(); | 89 | this.edgeId = edgeEvent.getEdgeId().getId(); |
103 | } | 90 | } |
104 | -// if (event.getEntityId() != null) { | ||
105 | -// this.entityType = event.getEntityId().getEntityType(); | ||
106 | -// this.entityId = event.getEntityId().getId(); | ||
107 | -// } | ||
108 | -// this.edgeEventType = edgeEvent.getEdgeEventType(); | ||
109 | -// this.edgeEventAction = edgeEvent.getEdgeEventAction(); | ||
110 | -// this.entityBody = edgeEvent.getEntityBody(); | 91 | + this.entityId = edgeEvent.getEntityId(); |
92 | + this.edgeEventType = edgeEvent.getType(); | ||
93 | + this.edgeEventAction = edgeEvent.getAction(); | ||
94 | + this.edgeEventUid = edgeEvent.getUid(); | ||
95 | + this.body = edgeEvent.getBody(); | ||
111 | } | 96 | } |
112 | 97 | ||
113 | @Override | 98 | @Override |
@@ -123,13 +108,14 @@ public class EdgeEventEntity implements BaseEntity<EdgeEvent> { | @@ -123,13 +108,14 @@ public class EdgeEventEntity implements BaseEntity<EdgeEvent> { | ||
123 | @Override | 108 | @Override |
124 | public EdgeEvent toData() { | 109 | public EdgeEvent toData() { |
125 | EdgeEvent edgeEvent = new EdgeEvent(new EdgeEventId(id)); | 110 | EdgeEvent edgeEvent = new EdgeEvent(new EdgeEventId(id)); |
126 | -// edgeEvent.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
127 | -// edgeEvent.setTenantId(new TenantId(tenantId)); | ||
128 | -// edgeEvent.setEdgeId(new EdgeId(edgeId)); | ||
129 | -// edgeEvent.setEntityId(entityId); | ||
130 | -// event.setBody(body); | ||
131 | -// event.setType(eventType); | ||
132 | -// event.setUid(eventUid); | 111 | + edgeEvent.setCreatedTime(UUIDs.unixTimestamp(id)); |
112 | + edgeEvent.setTenantId(new TenantId(tenantId)); | ||
113 | + edgeEvent.setEdgeId(new EdgeId(edgeId)); | ||
114 | + edgeEvent.setEntityId(entityId); | ||
115 | + edgeEvent.setType(edgeEventType); | ||
116 | + edgeEvent.setAction(edgeEventAction); | ||
117 | + edgeEvent.setBody(body); | ||
118 | + edgeEvent.setUid(edgeEventUid); | ||
133 | return edgeEvent; | 119 | return edgeEvent; |
134 | } | 120 | } |
135 | } | 121 | } |
@@ -41,11 +41,13 @@ import java.util.UUID; | @@ -41,11 +41,13 @@ import java.util.UUID; | ||
41 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ACTION_PROPERTY; | 41 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ACTION_PROPERTY; |
42 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_FAMILY_NAME; | 42 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_FAMILY_NAME; |
43 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_EDGE_ID_PROPERTY; | 43 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_EDGE_ID_PROPERTY; |
44 | -import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ENTITY_BODY_PROPERTY; | 44 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_BODY_PROPERTY; |
45 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ENTITY_ID_PROPERTY; | 45 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ENTITY_ID_PROPERTY; |
46 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_TENANT_ID_PROPERTY; | 46 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_TENANT_ID_PROPERTY; |
47 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_TYPE_PROPERTY; | 47 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_TYPE_PROPERTY; |
48 | +import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_UID_PROPERTY; | ||
48 | import static org.thingsboard.server.dao.model.ModelConstants.EPOCH_DIFF; | 49 | import static org.thingsboard.server.dao.model.ModelConstants.EPOCH_DIFF; |
50 | +import static org.thingsboard.server.dao.model.ModelConstants.EVENT_UID_PROPERTY; | ||
49 | import static org.thingsboard.server.dao.model.ModelConstants.TS_COLUMN; | 51 | import static org.thingsboard.server.dao.model.ModelConstants.TS_COLUMN; |
50 | 52 | ||
51 | @Data | 53 | @Data |
@@ -73,9 +75,12 @@ public class EdgeEventEntity extends BaseSqlEntity<EdgeEvent> implements BaseEnt | @@ -73,9 +75,12 @@ public class EdgeEventEntity extends BaseSqlEntity<EdgeEvent> implements BaseEnt | ||
73 | private String edgeEventAction; | 75 | private String edgeEventAction; |
74 | 76 | ||
75 | @Type(type = "json") | 77 | @Type(type = "json") |
76 | - @Column(name = EDGE_EVENT_ENTITY_BODY_PROPERTY) | 78 | + @Column(name = EDGE_EVENT_BODY_PROPERTY) |
77 | private JsonNode entityBody; | 79 | private JsonNode entityBody; |
78 | 80 | ||
81 | + @Column(name = EDGE_EVENT_UID_PROPERTY) | ||
82 | + private String edgeEventUid; | ||
83 | + | ||
79 | @Column(name = TS_COLUMN) | 84 | @Column(name = TS_COLUMN) |
80 | private long ts; | 85 | private long ts; |
81 | 86 | ||
@@ -95,9 +100,10 @@ public class EdgeEventEntity extends BaseSqlEntity<EdgeEvent> implements BaseEnt | @@ -95,9 +100,10 @@ public class EdgeEventEntity extends BaseSqlEntity<EdgeEvent> implements BaseEnt | ||
95 | if (edgeEvent.getEntityId() != null) { | 100 | if (edgeEvent.getEntityId() != null) { |
96 | this.entityId = toString(edgeEvent.getEntityId()); | 101 | this.entityId = toString(edgeEvent.getEntityId()); |
97 | } | 102 | } |
98 | - this.edgeEventType = edgeEvent.getEdgeEventType(); | ||
99 | - this.edgeEventAction = edgeEvent.getEdgeEventAction(); | ||
100 | - this.entityBody = edgeEvent.getEntityBody(); | 103 | + this.edgeEventType = edgeEvent.getType(); |
104 | + this.edgeEventAction = edgeEvent.getAction(); | ||
105 | + this.entityBody = edgeEvent.getBody(); | ||
106 | + this.edgeEventUid = edgeEvent.getUid(); | ||
101 | } | 107 | } |
102 | 108 | ||
103 | @Override | 109 | @Override |
@@ -109,9 +115,10 @@ public class EdgeEventEntity extends BaseSqlEntity<EdgeEvent> implements BaseEnt | @@ -109,9 +115,10 @@ public class EdgeEventEntity extends BaseSqlEntity<EdgeEvent> implements BaseEnt | ||
109 | if (entityId != null) { | 115 | if (entityId != null) { |
110 | edgeEvent.setEntityId(toUUID(entityId)); | 116 | edgeEvent.setEntityId(toUUID(entityId)); |
111 | } | 117 | } |
112 | - edgeEvent.setEdgeEventType(edgeEventType); | ||
113 | - edgeEvent.setEdgeEventAction(edgeEventAction); | ||
114 | - edgeEvent.setEntityBody(entityBody); | 118 | + edgeEvent.setType(edgeEventType); |
119 | + edgeEvent.setAction(edgeEventAction); | ||
120 | + edgeEvent.setBody(entityBody); | ||
121 | + edgeEvent.setUid(edgeEventUid); | ||
115 | return edgeEvent; | 122 | return edgeEvent; |
116 | } | 123 | } |
117 | 124 |
@@ -35,8 +35,10 @@ import org.thingsboard.server.dao.model.type.ComponentLifecycleStateCodec; | @@ -35,8 +35,10 @@ import org.thingsboard.server.dao.model.type.ComponentLifecycleStateCodec; | ||
35 | import org.thingsboard.server.dao.model.type.ComponentScopeCodec; | 35 | import org.thingsboard.server.dao.model.type.ComponentScopeCodec; |
36 | import org.thingsboard.server.dao.model.type.ComponentTypeCodec; | 36 | import org.thingsboard.server.dao.model.type.ComponentTypeCodec; |
37 | import org.thingsboard.server.dao.model.type.DeviceCredentialsTypeCodec; | 37 | import org.thingsboard.server.dao.model.type.DeviceCredentialsTypeCodec; |
38 | +import org.thingsboard.server.dao.model.type.EdgeEventTypeCodec; | ||
38 | import org.thingsboard.server.dao.model.type.EntityTypeCodec; | 39 | import org.thingsboard.server.dao.model.type.EntityTypeCodec; |
39 | import org.thingsboard.server.dao.model.type.JsonCodec; | 40 | import org.thingsboard.server.dao.model.type.JsonCodec; |
41 | +import org.thingsboard.server.dao.model.type.RuleChainTypeCodec; | ||
40 | 42 | ||
41 | import java.util.concurrent.ConcurrentHashMap; | 43 | import java.util.concurrent.ConcurrentHashMap; |
42 | import java.util.concurrent.ConcurrentMap; | 44 | import java.util.concurrent.ConcurrentMap; |
@@ -71,6 +73,8 @@ public abstract class CassandraAbstractDao { | @@ -71,6 +73,8 @@ public abstract class CassandraAbstractDao { | ||
71 | registerCodecIfNotFound(registry, new ComponentTypeCodec()); | 73 | registerCodecIfNotFound(registry, new ComponentTypeCodec()); |
72 | registerCodecIfNotFound(registry, new ComponentScopeCodec()); | 74 | registerCodecIfNotFound(registry, new ComponentScopeCodec()); |
73 | registerCodecIfNotFound(registry, new EntityTypeCodec()); | 75 | registerCodecIfNotFound(registry, new EntityTypeCodec()); |
76 | + registerCodecIfNotFound(registry, new EdgeEventTypeCodec()); | ||
77 | + registerCodecIfNotFound(registry, new RuleChainTypeCodec()); | ||
74 | } | 78 | } |
75 | return session; | 79 | return session; |
76 | } | 80 | } |
@@ -19,14 +19,12 @@ import com.google.common.base.Function; | @@ -19,14 +19,12 @@ import com.google.common.base.Function; | ||
19 | import com.google.common.util.concurrent.Futures; | 19 | import com.google.common.util.concurrent.Futures; |
20 | import com.google.common.util.concurrent.ListenableFuture; | 20 | import com.google.common.util.concurrent.ListenableFuture; |
21 | import com.google.common.util.concurrent.MoreExecutors; | 21 | import com.google.common.util.concurrent.MoreExecutors; |
22 | -import jnr.ffi.annotations.In; | ||
23 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
24 | import org.apache.commons.lang3.StringUtils; | 23 | import org.apache.commons.lang3.StringUtils; |
25 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
26 | import org.springframework.stereotype.Service; | 25 | import org.springframework.stereotype.Service; |
27 | import org.thingsboard.server.common.data.BaseData; | 26 | import org.thingsboard.server.common.data.BaseData; |
28 | import org.thingsboard.server.common.data.EntityType; | 27 | import org.thingsboard.server.common.data.EntityType; |
29 | -import org.thingsboard.server.common.data.ShortEdgeInfo; | ||
30 | import org.thingsboard.server.common.data.Tenant; | 28 | import org.thingsboard.server.common.data.Tenant; |
31 | import org.thingsboard.server.common.data.edge.Edge; | 29 | import org.thingsboard.server.common.data.edge.Edge; |
32 | import org.thingsboard.server.common.data.id.EdgeId; | 30 | import org.thingsboard.server.common.data.id.EdgeId; |
@@ -46,14 +44,11 @@ import org.thingsboard.server.common.data.rule.RuleChainConnectionInfo; | @@ -46,14 +44,11 @@ import org.thingsboard.server.common.data.rule.RuleChainConnectionInfo; | ||
46 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; | 44 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; |
47 | import org.thingsboard.server.common.data.rule.RuleChainType; | 45 | import org.thingsboard.server.common.data.rule.RuleChainType; |
48 | import org.thingsboard.server.common.data.rule.RuleNode; | 46 | import org.thingsboard.server.common.data.rule.RuleNode; |
49 | -import org.thingsboard.server.dao.edge.EdgeDao; | ||
50 | import org.thingsboard.server.dao.edge.EdgeService; | 47 | import org.thingsboard.server.dao.edge.EdgeService; |
51 | import org.thingsboard.server.dao.entity.AbstractEntityService; | 48 | import org.thingsboard.server.dao.entity.AbstractEntityService; |
52 | import org.thingsboard.server.dao.exception.DataValidationException; | 49 | import org.thingsboard.server.dao.exception.DataValidationException; |
53 | -import org.thingsboard.server.dao.relation.RelationDao; | ||
54 | import org.thingsboard.server.dao.service.DataValidator; | 50 | import org.thingsboard.server.dao.service.DataValidator; |
55 | import org.thingsboard.server.dao.service.PaginatedRemover; | 51 | import org.thingsboard.server.dao.service.PaginatedRemover; |
56 | -import org.thingsboard.server.dao.service.TimePaginatedRemover; | ||
57 | import org.thingsboard.server.dao.service.Validator; | 52 | import org.thingsboard.server.dao.service.Validator; |
58 | import org.thingsboard.server.dao.tenant.TenantDao; | 53 | import org.thingsboard.server.dao.tenant.TenantDao; |
59 | 54 | ||
@@ -65,7 +60,6 @@ import java.util.Map; | @@ -65,7 +60,6 @@ import java.util.Map; | ||
65 | import java.util.concurrent.ExecutionException; | 60 | import java.util.concurrent.ExecutionException; |
66 | 61 | ||
67 | import static org.thingsboard.server.dao.service.Validator.validateId; | 62 | import static org.thingsboard.server.dao.service.Validator.validateId; |
68 | -import static org.thingsboard.server.dao.service.Validator.validateString; | ||
69 | 63 | ||
70 | /** | 64 | /** |
71 | * Created by igor on 3/12/18. | 65 | * Created by igor on 3/12/18. |
@@ -730,9 +730,13 @@ CREATE TABLE IF NOT EXISTS thingsboard.edge ( | @@ -730,9 +730,13 @@ CREATE TABLE IF NOT EXISTS thingsboard.edge ( | ||
730 | id timeuuid, | 730 | id timeuuid, |
731 | tenant_id timeuuid, | 731 | tenant_id timeuuid, |
732 | customer_id timeuuid, | 732 | customer_id timeuuid, |
733 | - name text, | 733 | + root_rule_chain_id timeuuid, |
734 | type text, | 734 | type text, |
735 | + name text, | ||
736 | + label text, | ||
735 | search_text text, | 737 | search_text text, |
738 | + routing_key text, | ||
739 | + secret text, | ||
736 | configuration text, | 740 | configuration text, |
737 | additional_info text, | 741 | additional_info text, |
738 | PRIMARY KEY (id, tenant_id, customer_id, type) | 742 | PRIMARY KEY (id, tenant_id, customer_id, type) |
@@ -745,6 +749,13 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_name AS | @@ -745,6 +749,13 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_name AS | ||
745 | PRIMARY KEY ( tenant_id, name, id, customer_id, type) | 749 | PRIMARY KEY ( tenant_id, name, id, customer_id, type) |
746 | WITH CLUSTERING ORDER BY ( name ASC, id DESC, customer_id DESC); | 750 | WITH CLUSTERING ORDER BY ( name ASC, id DESC, customer_id DESC); |
747 | 751 | ||
752 | +CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_routing_key AS | ||
753 | + SELECT * | ||
754 | + from thingsboard.edge | ||
755 | + WHERE tenant_id IS NOT NULL AND customer_id IS NOT NULL AND type IS NOT NULL AND routing_key IS NOT NULL AND id IS NOT NULL | ||
756 | + PRIMARY KEY ( tenant_id, routing_key, id, customer_id, type) | ||
757 | + WITH CLUSTERING ORDER BY ( routing_key ASC, id DESC, customer_id DESC); | ||
758 | + | ||
748 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_search_text AS | 759 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_search_text AS |
749 | SELECT * | 760 | SELECT * |
750 | from thingsboard.edge | 761 | from thingsboard.edge |
@@ -772,3 +783,23 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_customer_by_type_and_ | @@ -772,3 +783,23 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_customer_by_type_and_ | ||
772 | WHERE tenant_id IS NOT NULL AND customer_id IS NOT NULL AND type IS NOT NULL AND search_text IS NOT NULL AND id IS NOT NULL | 783 | WHERE tenant_id IS NOT NULL AND customer_id IS NOT NULL AND type IS NOT NULL AND search_text IS NOT NULL AND id IS NOT NULL |
773 | PRIMARY KEY ( customer_id, tenant_id, type, search_text, id ) | 784 | PRIMARY KEY ( customer_id, tenant_id, type, search_text, id ) |
774 | WITH CLUSTERING ORDER BY ( tenant_id DESC, type ASC, search_text ASC, id DESC ); | 785 | WITH CLUSTERING ORDER BY ( tenant_id DESC, type ASC, search_text ASC, id DESC ); |
786 | + | ||
787 | +CREATE TABLE IF NOT EXISTS thingsboard.edge_event ( | ||
788 | + id timeuuid, | ||
789 | + tenant_id timeuuid, | ||
790 | + edge_id timeuuid, | ||
791 | + edge_event_type text, | ||
792 | + edge_event_action text, | ||
793 | + edge_event_uid text, | ||
794 | + entity_id timeuuid, | ||
795 | + body text, | ||
796 | + PRIMARY KEY ((tenant_id, edge_id), edge_event_type, edge_event_uid) | ||
797 | +); | ||
798 | + | ||
799 | +CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_event_by_id AS | ||
800 | + SELECT * | ||
801 | + FROM thingsboard.edge_event | ||
802 | + WHERE tenant_id IS NOT NULL AND edge_id IS NOT NULL AND edge_event_type IS NOT NULL | ||
803 | + AND id IS NOT NULL AND edge_event_uid IS NOT NULL | ||
804 | + PRIMARY KEY ((tenant_id, edge_id), id, edge_event_type, edge_event_uid) | ||
805 | + WITH CLUSTERING ORDER BY (id ASC); |
@@ -275,9 +275,10 @@ CREATE TABLE IF NOT EXISTS edge_event ( | @@ -275,9 +275,10 @@ CREATE TABLE IF NOT EXISTS edge_event ( | ||
275 | id varchar(31) NOT NULL CONSTRAINT edge_event_pkey PRIMARY KEY, | 275 | id varchar(31) NOT NULL CONSTRAINT edge_event_pkey PRIMARY KEY, |
276 | edge_id varchar(31), | 276 | edge_id varchar(31), |
277 | edge_event_type varchar(255), | 277 | edge_event_type varchar(255), |
278 | + edge_event_uid varchar(255), | ||
278 | entity_id varchar(31), | 279 | entity_id varchar(31), |
279 | edge_event_action varchar(255), | 280 | edge_event_action varchar(255), |
280 | - entity_body varchar(10000000), | 281 | + body varchar(10000000), |
281 | tenant_id varchar(31), | 282 | tenant_id varchar(31), |
282 | ts bigint NOT NULL | 283 | ts bigint NOT NULL |
283 | -); | ||
284 | +); |
@@ -275,14 +275,16 @@ CREATE TABLE IF NOT EXISTS edge_event ( | @@ -275,14 +275,16 @@ CREATE TABLE IF NOT EXISTS edge_event ( | ||
275 | id varchar(31) NOT NULL CONSTRAINT edge_event_pkey PRIMARY KEY, | 275 | id varchar(31) NOT NULL CONSTRAINT edge_event_pkey PRIMARY KEY, |
276 | edge_id varchar(31), | 276 | edge_id varchar(31), |
277 | edge_event_type varchar(255), | 277 | edge_event_type varchar(255), |
278 | + edge_event_uid varchar(255), | ||
278 | entity_id varchar(31), | 279 | entity_id varchar(31), |
279 | edge_event_action varchar(255), | 280 | edge_event_action varchar(255), |
280 | - entity_body varchar(10000000), | 281 | + body varchar(10000000), |
281 | tenant_id varchar(31), | 282 | tenant_id varchar(31), |
282 | ts bigint NOT NULL | 283 | ts bigint NOT NULL |
283 | ); | 284 | ); |
284 | 285 | ||
285 | 286 | ||
287 | + | ||
286 | CREATE OR REPLACE PROCEDURE cleanup_events_by_ttl(IN ttl bigint, IN debug_ttl bigint, INOUT deleted bigint) | 288 | CREATE OR REPLACE PROCEDURE cleanup_events_by_ttl(IN ttl bigint, IN debug_ttl bigint, INOUT deleted bigint) |
287 | LANGUAGE plpgsql AS | 289 | LANGUAGE plpgsql AS |
288 | $$ | 290 | $$ |
@@ -25,8 +25,7 @@ import java.util.Arrays; | @@ -25,8 +25,7 @@ import java.util.Arrays; | ||
25 | 25 | ||
26 | @RunWith(ClasspathSuite.class) | 26 | @RunWith(ClasspathSuite.class) |
27 | @ClassnameFilters({ | 27 | @ClassnameFilters({ |
28 | - // TODO: voba - fix before final test on cassandra | ||
29 | - "org.thingsboard.server.dao.service.*VOBA_FIX_BEFORE_FINAL_TESTServiceNoSqlTest" | 28 | + "org.thingsboard.server.dao.service.nosql.*ServiceNoSqlTest" |
30 | }) | 29 | }) |
31 | public class NoSqlDaoServiceTestSuite { | 30 | public class NoSqlDaoServiceTestSuite { |
32 | 31 |
@@ -46,9 +46,9 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest { | @@ -46,9 +46,9 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest { | ||
46 | Assert.assertEquals(saved.getTenantId(), edgeEvent.getTenantId()); | 46 | Assert.assertEquals(saved.getTenantId(), edgeEvent.getTenantId()); |
47 | Assert.assertEquals(saved.getEdgeId(), edgeEvent.getEdgeId()); | 47 | Assert.assertEquals(saved.getEdgeId(), edgeEvent.getEdgeId()); |
48 | Assert.assertEquals(saved.getEntityId(), edgeEvent.getEntityId()); | 48 | Assert.assertEquals(saved.getEntityId(), edgeEvent.getEntityId()); |
49 | - Assert.assertEquals(saved.getEdgeEventType(), edgeEvent.getEdgeEventType()); | ||
50 | - Assert.assertEquals(saved.getEdgeEventAction(), edgeEvent.getEdgeEventAction()); | ||
51 | - Assert.assertEquals(saved.getEntityBody(), edgeEvent.getEntityBody()); | 49 | + Assert.assertEquals(saved.getType(), edgeEvent.getType()); |
50 | + Assert.assertEquals(saved.getAction(), edgeEvent.getAction()); | ||
51 | + Assert.assertEquals(saved.getBody(), edgeEvent.getBody()); | ||
52 | } | 52 | } |
53 | 53 | ||
54 | protected EdgeEvent generateEdgeEvent(TenantId tenantId, EdgeId edgeId, EntityId entityId, String edgeEventAction) throws IOException { | 54 | protected EdgeEvent generateEdgeEvent(TenantId tenantId, EdgeId edgeId, EntityId entityId, String edgeEventAction) throws IOException { |
@@ -59,9 +59,9 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest { | @@ -59,9 +59,9 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest { | ||
59 | edgeEvent.setTenantId(tenantId); | 59 | edgeEvent.setTenantId(tenantId); |
60 | edgeEvent.setEdgeId(edgeId); | 60 | edgeEvent.setEdgeId(edgeId); |
61 | edgeEvent.setEntityId(entityId.getId()); | 61 | edgeEvent.setEntityId(entityId.getId()); |
62 | - edgeEvent.setEdgeEventType(EdgeEventType.DEVICE); | ||
63 | - edgeEvent.setEdgeEventAction(edgeEventAction); | ||
64 | - edgeEvent.setEntityBody(readFromResource("TestJsonData.json")); | 62 | + edgeEvent.setType(EdgeEventType.DEVICE); |
63 | + edgeEvent.setAction(edgeEventAction); | ||
64 | + edgeEvent.setBody(readFromResource("TestJsonData.json")); | ||
65 | return edgeEvent; | 65 | return edgeEvent; |
66 | } | 66 | } |
67 | 67 | ||
@@ -109,7 +109,7 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest { | @@ -109,7 +109,7 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest { | ||
109 | TimePageLink pageLink = new TimePageLink(1); | 109 | TimePageLink pageLink = new TimePageLink(1); |
110 | 110 | ||
111 | EdgeEvent edgeEventWithTsUpdate = generateEdgeEvent(tenantId, edgeId, deviceId, ActionType.TIMESERIES_UPDATED.name()); | 111 | EdgeEvent edgeEventWithTsUpdate = generateEdgeEvent(tenantId, edgeId, deviceId, ActionType.TIMESERIES_UPDATED.name()); |
112 | - edgeEventService.saveAsync(edgeEventWithTsUpdate); | 112 | + edgeEventService.saveAsync(edgeEventWithTsUpdate).get(); |
113 | 113 | ||
114 | TimePageData<EdgeEvent> allEdgeEvents = edgeEventService.findEdgeEvents(tenantId, edgeId, pageLink, true); | 114 | TimePageData<EdgeEvent> allEdgeEvents = edgeEventService.findEdgeEvents(tenantId, edgeId, pageLink, true); |
115 | TimePageData<EdgeEvent> edgeEventsWithoutTsUpdate = edgeEventService.findEdgeEvents(tenantId, edgeId, pageLink, false); | 115 | TimePageData<EdgeEvent> edgeEventsWithoutTsUpdate = edgeEventService.findEdgeEvents(tenantId, edgeId, pageLink, false); |
@@ -22,9 +22,13 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; | @@ -22,9 +22,13 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
22 | import org.thingsboard.rule.engine.api.TbNodeException; | 22 | import org.thingsboard.rule.engine.api.TbNodeException; |
23 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 23 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
24 | import org.thingsboard.server.common.data.EntityType; | 24 | import org.thingsboard.server.common.data.EntityType; |
25 | -import org.thingsboard.server.common.data.id.*; | 25 | +import org.thingsboard.server.common.data.id.AssetId; |
26 | +import org.thingsboard.server.common.data.id.CustomerId; | ||
27 | +import org.thingsboard.server.common.data.id.DashboardId; | ||
28 | +import org.thingsboard.server.common.data.id.DeviceId; | ||
29 | +import org.thingsboard.server.common.data.id.EdgeId; | ||
30 | +import org.thingsboard.server.common.data.id.EntityViewId; | ||
26 | import org.thingsboard.server.common.data.plugin.ComponentType; | 31 | import org.thingsboard.server.common.data.plugin.ComponentType; |
27 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
28 | import org.thingsboard.server.common.msg.TbMsg; | 32 | import org.thingsboard.server.common.msg.TbMsg; |
29 | 33 | ||
30 | @Slf4j | 34 | @Slf4j |
@@ -37,7 +41,8 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -37,7 +41,8 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
37 | "Will create new Customer if it doesn't exists and 'Create new Customer if not exists' is set to true.", | 41 | "Will create new Customer if it doesn't exists and 'Create new Customer if not exists' is set to true.", |
38 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 42 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
39 | configDirective = "tbActionNodeAssignToCustomerConfig", | 43 | configDirective = "tbActionNodeAssignToCustomerConfig", |
40 | - icon = "add_circle") | 44 | + icon = "add_circle" |
45 | +) | ||
41 | public class TbAssignToCustomerNode extends TbAbstractCustomerActionNode<TbAssignToCustomerNodeConfiguration> { | 46 | public class TbAssignToCustomerNode extends TbAbstractCustomerActionNode<TbAssignToCustomerNodeConfiguration> { |
42 | 47 | ||
43 | @Override | 48 | @Override |
@@ -29,7 +29,6 @@ import org.thingsboard.server.common.data.alarm.Alarm; | @@ -29,7 +29,6 @@ import org.thingsboard.server.common.data.alarm.Alarm; | ||
29 | import org.thingsboard.server.common.data.alarm.AlarmStatus; | 29 | import org.thingsboard.server.common.data.alarm.AlarmStatus; |
30 | import org.thingsboard.server.common.data.id.AlarmId; | 30 | import org.thingsboard.server.common.data.id.AlarmId; |
31 | import org.thingsboard.server.common.data.plugin.ComponentType; | 31 | import org.thingsboard.server.common.data.plugin.ComponentType; |
32 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
33 | import org.thingsboard.server.common.msg.TbMsg; | 32 | import org.thingsboard.server.common.msg.TbMsg; |
34 | 33 | ||
35 | @Slf4j | 34 | @Slf4j |
@@ -46,7 +45,8 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -46,7 +45,8 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
46 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>'name = ' + metadata.customerName;</code>.", | 45 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>'name = ' + metadata.customerName;</code>.", |
47 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 46 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
48 | configDirective = "tbActionNodeClearAlarmConfig", | 47 | configDirective = "tbActionNodeClearAlarmConfig", |
49 | - icon = "notifications_off") | 48 | + icon = "notifications_off" |
49 | +) | ||
50 | public class TbClearAlarmNode extends TbAbstractAlarmNode<TbClearAlarmNodeConfiguration> { | 50 | public class TbClearAlarmNode extends TbAbstractAlarmNode<TbClearAlarmNodeConfiguration> { |
51 | 51 | ||
52 | @Override | 52 | @Override |
@@ -21,19 +21,18 @@ import com.google.gson.JsonElement; | @@ -21,19 +21,18 @@ import com.google.gson.JsonElement; | ||
21 | import com.google.gson.JsonParser; | 21 | import com.google.gson.JsonParser; |
22 | import com.google.gson.JsonPrimitive; | 22 | import com.google.gson.JsonPrimitive; |
23 | import lombok.extern.slf4j.Slf4j; | 23 | import lombok.extern.slf4j.Slf4j; |
24 | +import org.thingsboard.common.util.DonAsynchron; | ||
24 | import org.thingsboard.rule.engine.api.EmptyNodeConfiguration; | 25 | import org.thingsboard.rule.engine.api.EmptyNodeConfiguration; |
25 | import org.thingsboard.rule.engine.api.RuleNode; | 26 | import org.thingsboard.rule.engine.api.RuleNode; |
26 | import org.thingsboard.rule.engine.api.TbContext; | 27 | import org.thingsboard.rule.engine.api.TbContext; |
27 | import org.thingsboard.rule.engine.api.TbNode; | 28 | import org.thingsboard.rule.engine.api.TbNode; |
28 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; | 29 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
29 | import org.thingsboard.rule.engine.api.TbNodeException; | 30 | import org.thingsboard.rule.engine.api.TbNodeException; |
30 | -import org.thingsboard.common.util.DonAsynchron; | ||
31 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 31 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
32 | import org.thingsboard.server.common.data.DataConstants; | 32 | import org.thingsboard.server.common.data.DataConstants; |
33 | import org.thingsboard.server.common.data.EntityView; | 33 | import org.thingsboard.server.common.data.EntityView; |
34 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; | 34 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
35 | import org.thingsboard.server.common.data.plugin.ComponentType; | 35 | import org.thingsboard.server.common.data.plugin.ComponentType; |
36 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
37 | import org.thingsboard.server.common.msg.TbMsg; | 36 | import org.thingsboard.server.common.msg.TbMsg; |
38 | import org.thingsboard.server.common.msg.session.SessionMsgType; | 37 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
39 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; | 38 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; |
@@ -57,7 +56,8 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | @@ -57,7 +56,8 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
57 | "Changes message originator to related entity view and produces new messages according to count of updated entity views", | 56 | "Changes message originator to related entity view and produces new messages according to count of updated entity views", |
58 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 57 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
59 | configDirective = "tbNodeEmptyConfig", | 58 | configDirective = "tbNodeEmptyConfig", |
60 | - icon = "content_copy") | 59 | + icon = "content_copy" |
60 | +) | ||
61 | public class TbCopyAttributesToEntityViewNode implements TbNode { | 61 | public class TbCopyAttributesToEntityViewNode implements TbNode { |
62 | 62 | ||
63 | EmptyNodeConfiguration config; | 63 | EmptyNodeConfiguration config; |
@@ -31,7 +31,6 @@ import org.thingsboard.server.common.data.alarm.Alarm; | @@ -31,7 +31,6 @@ import org.thingsboard.server.common.data.alarm.Alarm; | ||
31 | import org.thingsboard.server.common.data.alarm.AlarmStatus; | 31 | import org.thingsboard.server.common.data.alarm.AlarmStatus; |
32 | import org.thingsboard.server.common.data.id.TenantId; | 32 | import org.thingsboard.server.common.data.id.TenantId; |
33 | import org.thingsboard.server.common.data.plugin.ComponentType; | 33 | import org.thingsboard.server.common.data.plugin.ComponentType; |
34 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
35 | import org.thingsboard.server.common.msg.TbMsg; | 34 | import org.thingsboard.server.common.msg.TbMsg; |
36 | 35 | ||
37 | import java.io.IOException; | 36 | import java.io.IOException; |
@@ -51,7 +50,8 @@ import java.util.List; | @@ -51,7 +50,8 @@ import java.util.List; | ||
51 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>'name = ' + metadata.customerName;</code>.", | 50 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>'name = ' + metadata.customerName;</code>.", |
52 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 51 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
53 | configDirective = "tbActionNodeCreateAlarmConfig", | 52 | configDirective = "tbActionNodeCreateAlarmConfig", |
54 | - icon = "notifications_active") | 53 | + icon = "notifications_active" |
54 | +) | ||
55 | public class TbCreateAlarmNode extends TbAbstractAlarmNode<TbCreateAlarmNodeConfiguration> { | 55 | public class TbCreateAlarmNode extends TbAbstractAlarmNode<TbCreateAlarmNodeConfiguration> { |
56 | 56 | ||
57 | private static ObjectMapper mapper = new ObjectMapper(); | 57 | private static ObjectMapper mapper = new ObjectMapper(); |
@@ -34,7 +34,6 @@ import org.thingsboard.server.common.data.id.TenantId; | @@ -34,7 +34,6 @@ import org.thingsboard.server.common.data.id.TenantId; | ||
34 | import org.thingsboard.server.common.data.plugin.ComponentType; | 34 | import org.thingsboard.server.common.data.plugin.ComponentType; |
35 | import org.thingsboard.server.common.data.relation.EntityRelation; | 35 | import org.thingsboard.server.common.data.relation.EntityRelation; |
36 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; | 36 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
37 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
38 | import org.thingsboard.server.common.msg.TbMsg; | 37 | import org.thingsboard.server.common.msg.TbMsg; |
39 | 38 | ||
40 | import java.util.ArrayList; | 39 | import java.util.ArrayList; |
@@ -54,7 +53,8 @@ import java.util.List; | @@ -54,7 +53,8 @@ import java.util.List; | ||
54 | nodeDetails = "If the relation already exists or successfully created - Message send via <b>Success</b> chain, otherwise <b>Failure</b> chain will be used.", | 53 | nodeDetails = "If the relation already exists or successfully created - Message send via <b>Success</b> chain, otherwise <b>Failure</b> chain will be used.", |
55 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 54 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
56 | configDirective = "tbActionNodeCreateRelationConfig", | 55 | configDirective = "tbActionNodeCreateRelationConfig", |
57 | - icon = "add_circle") | 56 | + icon = "add_circle" |
57 | +) | ||
58 | public class TbCreateRelationNode extends TbAbstractRelationActionNode<TbCreateRelationNodeConfiguration> { | 58 | public class TbCreateRelationNode extends TbAbstractRelationActionNode<TbCreateRelationNodeConfiguration> { |
59 | 59 | ||
60 | @Override | 60 | @Override |
@@ -27,7 +27,6 @@ import org.thingsboard.rule.engine.util.EntityContainer; | @@ -27,7 +27,6 @@ import org.thingsboard.rule.engine.util.EntityContainer; | ||
27 | import org.thingsboard.server.common.data.plugin.ComponentType; | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
28 | import org.thingsboard.server.common.data.relation.EntityRelation; | 28 | import org.thingsboard.server.common.data.relation.EntityRelation; |
29 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; | 29 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
30 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
31 | import org.thingsboard.server.common.msg.TbMsg; | 30 | import org.thingsboard.server.common.msg.TbMsg; |
32 | 31 | ||
33 | import java.util.ArrayList; | 32 | import java.util.ArrayList; |
@@ -44,7 +43,8 @@ import java.util.List; | @@ -44,7 +43,8 @@ import java.util.List; | ||
44 | nodeDetails = "If the relation(s) successfully deleted - Message send via <b>Success</b> chain, otherwise <b>Failure</b> chain will be used.", | 43 | nodeDetails = "If the relation(s) successfully deleted - Message send via <b>Success</b> chain, otherwise <b>Failure</b> chain will be used.", |
45 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 44 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
46 | configDirective = "tbActionNodeDeleteRelationConfig", | 45 | configDirective = "tbActionNodeDeleteRelationConfig", |
47 | - icon = "remove_circle") | 46 | + icon = "remove_circle" |
47 | +) | ||
48 | public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteRelationNodeConfiguration> { | 48 | public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteRelationNodeConfiguration> { |
49 | 49 | ||
50 | @Override | 50 | @Override |
@@ -17,14 +17,17 @@ package org.thingsboard.rule.engine.action; | @@ -17,14 +17,17 @@ package org.thingsboard.rule.engine.action; | ||
17 | 17 | ||
18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
19 | import org.thingsboard.common.util.ListeningExecutor; | 19 | import org.thingsboard.common.util.ListeningExecutor; |
20 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
21 | +import org.thingsboard.rule.engine.api.ScriptEngine; | ||
22 | +import org.thingsboard.rule.engine.api.TbContext; | ||
23 | +import org.thingsboard.rule.engine.api.TbNode; | ||
24 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
25 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
20 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
21 | -import org.thingsboard.rule.engine.api.*; | ||
22 | import org.thingsboard.server.common.data.plugin.ComponentType; | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
23 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
24 | import org.thingsboard.server.common.msg.TbMsg; | 28 | import org.thingsboard.server.common.msg.TbMsg; |
25 | 29 | ||
26 | import static org.thingsboard.common.util.DonAsynchron.withCallback; | 30 | import static org.thingsboard.common.util.DonAsynchron.withCallback; |
27 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
28 | 31 | ||
29 | @Slf4j | 32 | @Slf4j |
30 | @RuleNode( | 33 | @RuleNode( |
@@ -37,7 +40,8 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | @@ -37,7 +40,8 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
37 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>'name = ' + metadata.customerName;</code>.", | 40 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>'name = ' + metadata.customerName;</code>.", |
38 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 41 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
39 | configDirective = "tbActionNodeLogConfig", | 42 | configDirective = "tbActionNodeLogConfig", |
40 | - icon = "menu") | 43 | + icon = "menu" |
44 | +) | ||
41 | public class TbLogNode implements TbNode { | 45 | public class TbLogNode implements TbNode { |
42 | 46 | ||
43 | private TbLogNodeConfiguration config; | 47 | private TbLogNodeConfiguration config; |
@@ -15,16 +15,17 @@ | @@ -15,16 +15,17 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.rule.engine.action; | 16 | package org.thingsboard.rule.engine.action; |
17 | 17 | ||
18 | -import com.datastax.driver.core.utils.UUIDs; | ||
19 | import com.google.gson.Gson; | 18 | import com.google.gson.Gson; |
20 | import com.google.gson.JsonObject; | 19 | import com.google.gson.JsonObject; |
21 | import lombok.extern.slf4j.Slf4j; | 20 | import lombok.extern.slf4j.Slf4j; |
22 | -import org.thingsboard.rule.engine.api.*; | 21 | +import org.thingsboard.rule.engine.api.RuleNode; |
22 | +import org.thingsboard.rule.engine.api.TbContext; | ||
23 | +import org.thingsboard.rule.engine.api.TbNode; | ||
24 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
25 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
23 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
24 | import org.thingsboard.server.common.data.plugin.ComponentType; | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
25 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
26 | import org.thingsboard.server.common.msg.TbMsg; | 28 | import org.thingsboard.server.common.msg.TbMsg; |
27 | -import org.thingsboard.server.common.msg.TbMsgDataType; | ||
28 | import org.thingsboard.server.common.msg.TbMsgMetaData; | 29 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
29 | import org.thingsboard.server.common.msg.queue.ServiceQueue; | 30 | import org.thingsboard.server.common.msg.queue.ServiceQueue; |
30 | import org.thingsboard.server.common.msg.session.SessionMsgType; | 31 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
@@ -44,7 +45,8 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | @@ -44,7 +45,8 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
44 | nodeDetails = "Count incoming messages for specified interval and produces POST_TELEMETRY_REQUEST msg with messages count", | 45 | nodeDetails = "Count incoming messages for specified interval and produces POST_TELEMETRY_REQUEST msg with messages count", |
45 | icon = "functions", | 46 | icon = "functions", |
46 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 47 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
47 | - configDirective = "tbActionNodeMsgCountConfig") | 48 | + configDirective = "tbActionNodeMsgCountConfig" |
49 | +) | ||
48 | public class TbMsgCountNode implements TbNode { | 50 | public class TbMsgCountNode implements TbNode { |
49 | 51 | ||
50 | private static final String TB_MSG_COUNT_NODE_MSG = "TbMsgCountNodeMsg"; | 52 | private static final String TB_MSG_COUNT_NODE_MSG = "TbMsgCountNodeMsg"; |
@@ -48,8 +48,10 @@ import org.thingsboard.server.dao.model.type.ComponentLifecycleStateCodec; | @@ -48,8 +48,10 @@ import org.thingsboard.server.dao.model.type.ComponentLifecycleStateCodec; | ||
48 | import org.thingsboard.server.dao.model.type.ComponentScopeCodec; | 48 | import org.thingsboard.server.dao.model.type.ComponentScopeCodec; |
49 | import org.thingsboard.server.dao.model.type.ComponentTypeCodec; | 49 | import org.thingsboard.server.dao.model.type.ComponentTypeCodec; |
50 | import org.thingsboard.server.dao.model.type.DeviceCredentialsTypeCodec; | 50 | import org.thingsboard.server.dao.model.type.DeviceCredentialsTypeCodec; |
51 | +import org.thingsboard.server.dao.model.type.EdgeEventTypeCodec; | ||
51 | import org.thingsboard.server.dao.model.type.EntityTypeCodec; | 52 | import org.thingsboard.server.dao.model.type.EntityTypeCodec; |
52 | import org.thingsboard.server.dao.model.type.JsonCodec; | 53 | import org.thingsboard.server.dao.model.type.JsonCodec; |
54 | +import org.thingsboard.server.dao.model.type.RuleChainTypeCodec; | ||
53 | import org.thingsboard.server.dao.nosql.CassandraStatementTask; | 55 | import org.thingsboard.server.dao.nosql.CassandraStatementTask; |
54 | 56 | ||
55 | import javax.annotation.Nullable; | 57 | import javax.annotation.Nullable; |
@@ -144,6 +146,8 @@ public class TbSaveToCustomCassandraTableNode implements TbNode { | @@ -144,6 +146,8 @@ public class TbSaveToCustomCassandraTableNode implements TbNode { | ||
144 | registerCodecIfNotFound(registry, new ComponentTypeCodec()); | 146 | registerCodecIfNotFound(registry, new ComponentTypeCodec()); |
145 | registerCodecIfNotFound(registry, new ComponentScopeCodec()); | 147 | registerCodecIfNotFound(registry, new ComponentScopeCodec()); |
146 | registerCodecIfNotFound(registry, new EntityTypeCodec()); | 148 | registerCodecIfNotFound(registry, new EntityTypeCodec()); |
149 | + registerCodecIfNotFound(registry, new EdgeEventTypeCodec()); | ||
150 | + registerCodecIfNotFound(registry, new RuleChainTypeCodec()); | ||
147 | } | 151 | } |
148 | return session; | 152 | return session; |
149 | } | 153 | } |
@@ -24,10 +24,13 @@ import com.amazonaws.services.sns.model.PublishRequest; | @@ -24,10 +24,13 @@ import com.amazonaws.services.sns.model.PublishRequest; | ||
24 | import com.amazonaws.services.sns.model.PublishResult; | 24 | import com.amazonaws.services.sns.model.PublishResult; |
25 | import com.google.common.util.concurrent.ListenableFuture; | 25 | import com.google.common.util.concurrent.ListenableFuture; |
26 | import lombok.extern.slf4j.Slf4j; | 26 | import lombok.extern.slf4j.Slf4j; |
27 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
28 | +import org.thingsboard.rule.engine.api.TbContext; | ||
29 | +import org.thingsboard.rule.engine.api.TbNode; | ||
30 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
31 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
27 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 32 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
28 | -import org.thingsboard.rule.engine.api.*; | ||
29 | import org.thingsboard.server.common.data.plugin.ComponentType; | 33 | import org.thingsboard.server.common.data.plugin.ComponentType; |
30 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
31 | import org.thingsboard.server.common.msg.TbMsg; | 34 | import org.thingsboard.server.common.msg.TbMsg; |
32 | import org.thingsboard.server.common.msg.TbMsgMetaData; | 35 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
33 | 36 |
@@ -26,16 +26,18 @@ import com.amazonaws.services.sqs.model.SendMessageResult; | @@ -26,16 +26,18 @@ import com.amazonaws.services.sqs.model.SendMessageResult; | ||
26 | import com.google.common.util.concurrent.ListenableFuture; | 26 | import com.google.common.util.concurrent.ListenableFuture; |
27 | import lombok.extern.slf4j.Slf4j; | 27 | import lombok.extern.slf4j.Slf4j; |
28 | import org.apache.commons.lang3.StringUtils; | 28 | import org.apache.commons.lang3.StringUtils; |
29 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
30 | +import org.thingsboard.rule.engine.api.TbContext; | ||
31 | +import org.thingsboard.rule.engine.api.TbNode; | ||
32 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
33 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
29 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 34 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
30 | -import org.thingsboard.rule.engine.api.*; | ||
31 | import org.thingsboard.server.common.data.plugin.ComponentType; | 35 | import org.thingsboard.server.common.data.plugin.ComponentType; |
32 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
33 | import org.thingsboard.server.common.msg.TbMsg; | 36 | import org.thingsboard.server.common.msg.TbMsg; |
34 | import org.thingsboard.server.common.msg.TbMsgMetaData; | 37 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
35 | 38 | ||
36 | import java.util.HashMap; | 39 | import java.util.HashMap; |
37 | import java.util.Map; | 40 | import java.util.Map; |
38 | -import java.util.concurrent.ExecutionException; | ||
39 | 41 | ||
40 | import static org.thingsboard.common.util.DonAsynchron.withCallback; | 42 | import static org.thingsboard.common.util.DonAsynchron.withCallback; |
41 | 43 |
@@ -18,12 +18,16 @@ package org.thingsboard.rule.engine.debug; | @@ -18,12 +18,16 @@ package org.thingsboard.rule.engine.debug; | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
20 | import org.springframework.util.StringUtils; | 20 | import org.springframework.util.StringUtils; |
21 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
22 | +import org.thingsboard.rule.engine.api.ScriptEngine; | ||
23 | +import org.thingsboard.rule.engine.api.TbContext; | ||
24 | +import org.thingsboard.rule.engine.api.TbNode; | ||
25 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
26 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
21 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 27 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
22 | -import org.thingsboard.rule.engine.api.*; | ||
23 | import org.thingsboard.server.common.data.id.EntityId; | 28 | import org.thingsboard.server.common.data.id.EntityId; |
24 | import org.thingsboard.server.common.data.id.EntityIdFactory; | 29 | import org.thingsboard.server.common.data.id.EntityIdFactory; |
25 | import org.thingsboard.server.common.data.plugin.ComponentType; | 30 | import org.thingsboard.server.common.data.plugin.ComponentType; |
26 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
27 | import org.thingsboard.server.common.msg.TbMsg; | 31 | import org.thingsboard.server.common.msg.TbMsg; |
28 | import org.thingsboard.server.common.msg.TbMsgMetaData; | 32 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
29 | import org.thingsboard.server.common.msg.queue.PartitionChangeMsg; | 33 | import org.thingsboard.server.common.msg.queue.PartitionChangeMsg; |
@@ -24,7 +24,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; | @@ -24,7 +24,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
24 | import org.thingsboard.rule.engine.api.TbNodeException; | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
26 | import org.thingsboard.server.common.data.plugin.ComponentType; | 26 | import org.thingsboard.server.common.data.plugin.ComponentType; |
27 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
28 | import org.thingsboard.server.common.msg.TbMsg; | 27 | import org.thingsboard.server.common.msg.TbMsg; |
29 | import org.thingsboard.server.common.msg.TbMsgMetaData; | 28 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
30 | import org.thingsboard.server.common.msg.queue.ServiceQueue; | 29 | import org.thingsboard.server.common.msg.queue.ServiceQueue; |
@@ -34,7 +33,6 @@ import java.util.Map; | @@ -34,7 +33,6 @@ import java.util.Map; | ||
34 | import java.util.UUID; | 33 | import java.util.UUID; |
35 | import java.util.concurrent.TimeUnit; | 34 | import java.util.concurrent.TimeUnit; |
36 | 35 | ||
37 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.FAILURE; | ||
38 | import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | 36 | import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; |
39 | 37 | ||
40 | @Slf4j | 38 | @Slf4j |
@@ -154,10 +154,10 @@ public class TbMsgPushToEdgeNode implements TbNode { | @@ -154,10 +154,10 @@ public class TbMsgPushToEdgeNode implements TbNode { | ||
154 | private EdgeEvent buildEdgeEvent(TenantId tenantId, ActionType edgeEventAction, UUID entityId, EdgeEventType edgeEventType, JsonNode entityBody) { | 154 | private EdgeEvent buildEdgeEvent(TenantId tenantId, ActionType edgeEventAction, UUID entityId, EdgeEventType edgeEventType, JsonNode entityBody) { |
155 | EdgeEvent edgeEvent = new EdgeEvent(); | 155 | EdgeEvent edgeEvent = new EdgeEvent(); |
156 | edgeEvent.setTenantId(tenantId); | 156 | edgeEvent.setTenantId(tenantId); |
157 | - edgeEvent.setEdgeEventAction(edgeEventAction.name()); | 157 | + edgeEvent.setAction(edgeEventAction.name()); |
158 | edgeEvent.setEntityId(entityId); | 158 | edgeEvent.setEntityId(entityId); |
159 | - edgeEvent.setEdgeEventType(edgeEventType); | ||
160 | - edgeEvent.setEntityBody(entityBody); | 159 | + edgeEvent.setType(edgeEventType); |
160 | + edgeEvent.setBody(entityBody); | ||
161 | return edgeEvent; | 161 | return edgeEvent; |
162 | } | 162 | } |
163 | 163 |
@@ -24,7 +24,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; | @@ -24,7 +24,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
24 | import org.thingsboard.rule.engine.api.TbNodeException; | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
26 | import org.thingsboard.server.common.data.plugin.ComponentType; | 26 | import org.thingsboard.server.common.data.plugin.ComponentType; |
27 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
28 | import org.thingsboard.server.common.msg.TbMsg; | 27 | import org.thingsboard.server.common.msg.TbMsg; |
29 | 28 | ||
30 | import java.util.List; | 29 | import java.util.List; |
@@ -40,8 +39,7 @@ import java.util.Map; | @@ -40,8 +39,7 @@ import java.util.Map; | ||
40 | nodeDetails = "If selected checkbox 'Check that all selected keys are present'\" and all keys in message data and metadata are exist - send Message via <b>True</b> chain, otherwise <b>False</b> chain is used.\n" + | 39 | nodeDetails = "If selected checkbox 'Check that all selected keys are present'\" and all keys in message data and metadata are exist - send Message via <b>True</b> chain, otherwise <b>False</b> chain is used.\n" + |
41 | "Else if the checkbox is not selected, and at least one of the keys from data or metadata of the message exists - send Message via <b>True</b> chain, otherwise, <b>False</b> chain is used. ", | 40 | "Else if the checkbox is not selected, and at least one of the keys from data or metadata of the message exists - send Message via <b>True</b> chain, otherwise, <b>False</b> chain is used. ", |
42 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 41 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
43 | - configDirective = "tbFilterNodeCheckMessageConfig" | ||
44 | -) | 42 | + configDirective = "tbFilterNodeCheckMessageConfig") |
45 | public class TbCheckMessageNode implements TbNode { | 43 | public class TbCheckMessageNode implements TbNode { |
46 | 44 | ||
47 | private static final Gson gson = new Gson(); | 45 | private static final Gson gson = new Gson(); |
@@ -31,7 +31,6 @@ import org.thingsboard.server.common.data.plugin.ComponentType; | @@ -31,7 +31,6 @@ import org.thingsboard.server.common.data.plugin.ComponentType; | ||
31 | import org.thingsboard.server.common.data.relation.EntityRelation; | 31 | import org.thingsboard.server.common.data.relation.EntityRelation; |
32 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; | 32 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
33 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; | 33 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
34 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
35 | import org.thingsboard.server.common.msg.TbMsg; | 34 | import org.thingsboard.server.common.msg.TbMsg; |
36 | 35 | ||
37 | import java.util.List; | 36 | import java.util.List; |
@@ -52,8 +51,7 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback; | @@ -52,8 +51,7 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback; | ||
52 | " any relation to the originator of the message by type and direction.", | 51 | " any relation to the originator of the message by type and direction.", |
53 | nodeDetails = "If at least one relation exists - send Message via <b>True</b> chain, otherwise <b>False</b> chain is used.", | 52 | nodeDetails = "If at least one relation exists - send Message via <b>True</b> chain, otherwise <b>False</b> chain is used.", |
54 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 53 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
55 | - configDirective = "tbFilterNodeCheckRelationConfig" | ||
56 | -) | 54 | + configDirective = "tbFilterNodeCheckRelationConfig") |
57 | public class TbCheckRelationNode implements TbNode { | 55 | public class TbCheckRelationNode implements TbNode { |
58 | 56 | ||
59 | private TbCheckRelationNodeConfiguration config; | 57 | private TbCheckRelationNodeConfiguration config; |
@@ -16,11 +16,14 @@ | @@ -16,11 +16,14 @@ | ||
16 | package org.thingsboard.rule.engine.filter; | 16 | package org.thingsboard.rule.engine.filter; |
17 | 17 | ||
18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
19 | -import org.thingsboard.common.util.ListeningExecutor; | 19 | +import org.thingsboard.rule.engine.api.RuleNode; |
20 | +import org.thingsboard.rule.engine.api.ScriptEngine; | ||
21 | +import org.thingsboard.rule.engine.api.TbContext; | ||
22 | +import org.thingsboard.rule.engine.api.TbNode; | ||
23 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
24 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
20 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
21 | -import org.thingsboard.rule.engine.api.*; | ||
22 | import org.thingsboard.server.common.data.plugin.ComponentType; | 26 | import org.thingsboard.server.common.data.plugin.ComponentType; |
23 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
24 | import org.thingsboard.server.common.msg.TbMsg; | 27 | import org.thingsboard.server.common.msg.TbMsg; |
25 | 28 | ||
26 | import static org.thingsboard.common.util.DonAsynchron.withCallback; | 29 | import static org.thingsboard.common.util.DonAsynchron.withCallback; |
@@ -37,8 +40,7 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback; | @@ -37,8 +40,7 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback; | ||
37 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>metadata.customerName === 'John';</code><br/>" + | 40 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>metadata.customerName === 'John';</code><br/>" + |
38 | "Message type can be accessed via <code>msgType</code> property.", | 41 | "Message type can be accessed via <code>msgType</code> property.", |
39 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 42 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
40 | - configDirective = "tbFilterNodeScriptConfig" | ||
41 | -) | 43 | + configDirective = "tbFilterNodeScriptConfig") |
42 | 44 | ||
43 | public class TbJsFilterNode implements TbNode { | 45 | public class TbJsFilterNode implements TbNode { |
44 | 46 |
@@ -17,10 +17,14 @@ package org.thingsboard.rule.engine.filter; | @@ -17,10 +17,14 @@ package org.thingsboard.rule.engine.filter; | ||
17 | 17 | ||
18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
19 | import org.thingsboard.common.util.ListeningExecutor; | 19 | import org.thingsboard.common.util.ListeningExecutor; |
20 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
21 | +import org.thingsboard.rule.engine.api.ScriptEngine; | ||
22 | +import org.thingsboard.rule.engine.api.TbContext; | ||
23 | +import org.thingsboard.rule.engine.api.TbNode; | ||
24 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
25 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
20 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
21 | -import org.thingsboard.rule.engine.api.*; | ||
22 | import org.thingsboard.server.common.data.plugin.ComponentType; | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
23 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
24 | import org.thingsboard.server.common.msg.TbMsg; | 28 | import org.thingsboard.server.common.msg.TbMsg; |
25 | 29 | ||
26 | import java.util.Set; | 30 | import java.util.Set; |
@@ -40,8 +44,7 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback; | @@ -40,8 +44,7 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback; | ||
40 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>metadata.customerName === 'John';</code><br/>" + | 44 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>metadata.customerName === 'John';</code><br/>" + |
41 | "Message type can be accessed via <code>msgType</code> property.", | 45 | "Message type can be accessed via <code>msgType</code> property.", |
42 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 46 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
43 | - configDirective = "tbFilterNodeSwitchConfig" | ||
44 | -) | 47 | + configDirective = "tbFilterNodeSwitchConfig") |
45 | public class TbJsSwitchNode implements TbNode { | 48 | public class TbJsSwitchNode implements TbNode { |
46 | 49 | ||
47 | private TbJsSwitchNodeConfiguration config; | 50 | private TbJsSwitchNodeConfiguration config; |
@@ -16,10 +16,13 @@ | @@ -16,10 +16,13 @@ | ||
16 | package org.thingsboard.rule.engine.filter; | 16 | package org.thingsboard.rule.engine.filter; |
17 | 17 | ||
18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
19 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
20 | +import org.thingsboard.rule.engine.api.TbContext; | ||
21 | +import org.thingsboard.rule.engine.api.TbNode; | ||
22 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
23 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
19 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 24 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
20 | -import org.thingsboard.rule.engine.api.*; | ||
21 | import org.thingsboard.server.common.data.plugin.ComponentType; | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
22 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
23 | import org.thingsboard.server.common.msg.TbMsg; | 26 | import org.thingsboard.server.common.msg.TbMsg; |
24 | 27 | ||
25 | /** | 28 | /** |
@@ -34,8 +37,7 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -34,8 +37,7 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
34 | nodeDescription = "Filter incoming messages by Message Type", | 37 | nodeDescription = "Filter incoming messages by Message Type", |
35 | nodeDetails = "If incoming MessageType is expected - send Message via <b>True</b> chain, otherwise <b>False</b> chain is used.", | 38 | nodeDetails = "If incoming MessageType is expected - send Message via <b>True</b> chain, otherwise <b>False</b> chain is used.", |
36 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, | 39 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
37 | - configDirective = "tbFilterNodeMessageTypeConfig" | ||
38 | -) | 40 | + configDirective = "tbFilterNodeMessageTypeConfig") |
39 | public class TbMsgTypeFilterNode implements TbNode { | 41 | public class TbMsgTypeFilterNode implements TbNode { |
40 | 42 | ||
41 | TbMsgTypeFilterNodeConfiguration config; | 43 | TbMsgTypeFilterNodeConfiguration config; |
@@ -25,7 +25,6 @@ import org.thingsboard.rule.engine.api.TbNodeException; | @@ -25,7 +25,6 @@ import org.thingsboard.rule.engine.api.TbNodeException; | ||
25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
26 | import org.thingsboard.server.common.data.DataConstants; | 26 | import org.thingsboard.server.common.data.DataConstants; |
27 | import org.thingsboard.server.common.data.plugin.ComponentType; | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
28 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
29 | import org.thingsboard.server.common.msg.TbMsg; | 28 | import org.thingsboard.server.common.msg.TbMsg; |
30 | import org.thingsboard.server.common.msg.session.SessionMsgType; | 29 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
31 | 30 | ||
@@ -40,8 +39,7 @@ import org.thingsboard.server.common.msg.session.SessionMsgType; | @@ -40,8 +39,7 @@ import org.thingsboard.server.common.msg.session.SessionMsgType; | ||
40 | nodeDescription = "Route incoming messages by Message Type", | 39 | nodeDescription = "Route incoming messages by Message Type", |
41 | nodeDetails = "Sends messages with message types <b>\"Post attributes\", \"Post telemetry\", \"RPC Request\"</b> etc. via corresponding chain, otherwise <b>Other</b> chain is used.", | 40 | nodeDetails = "Sends messages with message types <b>\"Post attributes\", \"Post telemetry\", \"RPC Request\"</b> etc. via corresponding chain, otherwise <b>Other</b> chain is used.", |
42 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 41 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
43 | - configDirective = "tbNodeEmptyConfig" | ||
44 | -) | 42 | + configDirective = "tbNodeEmptyConfig") |
45 | public class TbMsgTypeSwitchNode implements TbNode { | 43 | public class TbMsgTypeSwitchNode implements TbNode { |
46 | 44 | ||
47 | EmptyNodeConfiguration config; | 45 | EmptyNodeConfiguration config; |
@@ -16,11 +16,14 @@ | @@ -16,11 +16,14 @@ | ||
16 | package org.thingsboard.rule.engine.filter; | 16 | package org.thingsboard.rule.engine.filter; |
17 | 17 | ||
18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
19 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
20 | +import org.thingsboard.rule.engine.api.TbContext; | ||
21 | +import org.thingsboard.rule.engine.api.TbNode; | ||
22 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
23 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
19 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 24 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
20 | -import org.thingsboard.rule.engine.api.*; | ||
21 | import org.thingsboard.server.common.data.EntityType; | 25 | import org.thingsboard.server.common.data.EntityType; |
22 | import org.thingsboard.server.common.data.plugin.ComponentType; | 26 | import org.thingsboard.server.common.data.plugin.ComponentType; |
23 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
24 | import org.thingsboard.server.common.msg.TbMsg; | 27 | import org.thingsboard.server.common.msg.TbMsg; |
25 | 28 | ||
26 | @Slf4j | 29 | @Slf4j |
@@ -32,8 +35,7 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -32,8 +35,7 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
32 | nodeDescription = "Filter incoming messages by message Originator Type", | 35 | nodeDescription = "Filter incoming messages by message Originator Type", |
33 | nodeDetails = "If Originator Type of incoming message is expected - send Message via <b>True</b> chain, otherwise <b>False</b> chain is used.", | 36 | nodeDetails = "If Originator Type of incoming message is expected - send Message via <b>True</b> chain, otherwise <b>False</b> chain is used.", |
34 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, | 37 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
35 | - configDirective = "tbFilterNodeOriginatorTypeConfig" | ||
36 | -) | 38 | + configDirective = "tbFilterNodeOriginatorTypeConfig") |
37 | public class TbOriginatorTypeFilterNode implements TbNode { | 39 | public class TbOriginatorTypeFilterNode implements TbNode { |
38 | 40 | ||
39 | TbOriginatorTypeFilterNodeConfiguration config; | 41 | TbOriginatorTypeFilterNodeConfiguration config; |
@@ -16,11 +16,15 @@ | @@ -16,11 +16,15 @@ | ||
16 | package org.thingsboard.rule.engine.filter; | 16 | package org.thingsboard.rule.engine.filter; |
17 | 17 | ||
18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
19 | +import org.thingsboard.rule.engine.api.EmptyNodeConfiguration; | ||
20 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
21 | +import org.thingsboard.rule.engine.api.TbContext; | ||
22 | +import org.thingsboard.rule.engine.api.TbNode; | ||
23 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
24 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
19 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
20 | -import org.thingsboard.rule.engine.api.*; | ||
21 | import org.thingsboard.server.common.data.EntityType; | 26 | import org.thingsboard.server.common.data.EntityType; |
22 | import org.thingsboard.server.common.data.plugin.ComponentType; | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
23 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
24 | import org.thingsboard.server.common.msg.TbMsg; | 28 | import org.thingsboard.server.common.msg.TbMsg; |
25 | 29 | ||
26 | @Slf4j | 30 | @Slf4j |
@@ -32,8 +36,7 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -32,8 +36,7 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
32 | nodeDescription = "Route incoming messages by Message Originator Type", | 36 | nodeDescription = "Route incoming messages by Message Originator Type", |
33 | nodeDetails = "Routes messages to chain according to the originator type ('Device', 'Asset', etc.).", | 37 | nodeDetails = "Routes messages to chain according to the originator type ('Device', 'Asset', etc.).", |
34 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 38 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
35 | - configDirective = "tbNodeEmptyConfig" | ||
36 | -) | 39 | + configDirective = "tbNodeEmptyConfig") |
37 | public class TbOriginatorTypeSwitchNode implements TbNode { | 40 | public class TbOriginatorTypeSwitchNode implements TbNode { |
38 | 41 | ||
39 | EmptyNodeConfiguration config; | 42 | EmptyNodeConfiguration config; |
@@ -26,10 +26,13 @@ import com.google.protobuf.ByteString; | @@ -26,10 +26,13 @@ import com.google.protobuf.ByteString; | ||
26 | import com.google.pubsub.v1.ProjectTopicName; | 26 | import com.google.pubsub.v1.ProjectTopicName; |
27 | import com.google.pubsub.v1.PubsubMessage; | 27 | import com.google.pubsub.v1.PubsubMessage; |
28 | import lombok.extern.slf4j.Slf4j; | 28 | import lombok.extern.slf4j.Slf4j; |
29 | -import org.thingsboard.rule.engine.api.*; | 29 | +import org.thingsboard.rule.engine.api.RuleNode; |
30 | +import org.thingsboard.rule.engine.api.TbContext; | ||
31 | +import org.thingsboard.rule.engine.api.TbNode; | ||
32 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
33 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
30 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 34 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
31 | import org.thingsboard.server.common.data.plugin.ComponentType; | 35 | import org.thingsboard.server.common.data.plugin.ComponentType; |
32 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
33 | import org.thingsboard.server.common.msg.TbMsg; | 36 | import org.thingsboard.server.common.msg.TbMsg; |
34 | import org.thingsboard.server.common.msg.TbMsgMetaData; | 37 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
35 | 38 | ||
@@ -37,8 +40,6 @@ import java.io.ByteArrayInputStream; | @@ -37,8 +40,6 @@ import java.io.ByteArrayInputStream; | ||
37 | import java.io.IOException; | 40 | import java.io.IOException; |
38 | import java.util.concurrent.TimeUnit; | 41 | import java.util.concurrent.TimeUnit; |
39 | 42 | ||
40 | -import static org.thingsboard.common.util.DonAsynchron.withCallback; | ||
41 | - | ||
42 | @Slf4j | 43 | @Slf4j |
43 | @RuleNode( | 44 | @RuleNode( |
44 | type = ComponentType.EXTERNAL, | 45 | type = ComponentType.EXTERNAL, |
@@ -28,7 +28,6 @@ import org.thingsboard.server.common.data.kv.AttributeKvEntry; | @@ -28,7 +28,6 @@ import org.thingsboard.server.common.data.kv.AttributeKvEntry; | ||
28 | import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; | 28 | import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; |
29 | import org.thingsboard.server.common.data.kv.StringDataEntry; | 29 | import org.thingsboard.server.common.data.kv.StringDataEntry; |
30 | import org.thingsboard.server.common.data.plugin.ComponentType; | 30 | import org.thingsboard.server.common.data.plugin.ComponentType; |
31 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
32 | import org.thingsboard.server.common.msg.TbMsg; | 31 | import org.thingsboard.server.common.msg.TbMsg; |
33 | 32 | ||
34 | import java.util.Collections; | 33 | import java.util.Collections; |
@@ -15,32 +15,13 @@ | @@ -15,32 +15,13 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.rule.engine.geo; | 16 | package org.thingsboard.rule.engine.geo; |
17 | 17 | ||
18 | -import com.google.gson.JsonArray; | ||
19 | -import com.google.gson.JsonElement; | ||
20 | -import com.google.gson.JsonObject; | ||
21 | -import com.google.gson.JsonParser; | ||
22 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
23 | -import org.locationtech.spatial4j.context.jts.JtsSpatialContext; | ||
24 | -import org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory; | ||
25 | -import org.locationtech.spatial4j.shape.Point; | ||
26 | -import org.locationtech.spatial4j.shape.Shape; | ||
27 | -import org.locationtech.spatial4j.shape.ShapeFactory; | ||
28 | -import org.locationtech.spatial4j.shape.SpatialRelation; | ||
29 | -import org.springframework.util.StringUtils; | ||
30 | import org.thingsboard.rule.engine.api.RuleNode; | 19 | import org.thingsboard.rule.engine.api.RuleNode; |
31 | import org.thingsboard.rule.engine.api.TbContext; | 20 | import org.thingsboard.rule.engine.api.TbContext; |
32 | -import org.thingsboard.rule.engine.api.TbNode; | ||
33 | -import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
34 | import org.thingsboard.rule.engine.api.TbNodeException; | 21 | import org.thingsboard.rule.engine.api.TbNodeException; |
35 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
36 | -import org.thingsboard.rule.engine.filter.TbMsgTypeFilterNodeConfiguration; | ||
37 | import org.thingsboard.server.common.data.plugin.ComponentType; | 22 | import org.thingsboard.server.common.data.plugin.ComponentType; |
38 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
39 | import org.thingsboard.server.common.msg.TbMsg; | 23 | import org.thingsboard.server.common.msg.TbMsg; |
40 | 24 | ||
41 | -import java.util.Collections; | ||
42 | -import java.util.List; | ||
43 | - | ||
44 | /** | 25 | /** |
45 | * Created by ashvayka on 19.01.18. | 26 | * Created by ashvayka on 19.01.18. |
46 | */ | 27 | */ |
@@ -53,8 +34,7 @@ import java.util.List; | @@ -53,8 +34,7 @@ import java.util.List; | ||
53 | nodeDescription = "Filter incoming messages by GPS based geofencing", | 34 | nodeDescription = "Filter incoming messages by GPS based geofencing", |
54 | nodeDetails = "Extracts latitude and longitude parameters from incoming message and returns 'True' if they are inside configured perimeters, 'False' otherwise.", | 35 | nodeDetails = "Extracts latitude and longitude parameters from incoming message and returns 'True' if they are inside configured perimeters, 'False' otherwise.", |
55 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 36 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
56 | - configDirective = "tbFilterNodeGpsGeofencingConfig" | ||
57 | -) | 37 | + configDirective = "tbFilterNodeGpsGeofencingConfig") |
58 | public class TbGpsGeofencingFilterNode extends AbstractGeofencingNode<TbGpsGeofencingFilterNodeConfiguration> { | 38 | public class TbGpsGeofencingFilterNode extends AbstractGeofencingNode<TbGpsGeofencingFilterNodeConfiguration> { |
59 | 39 | ||
60 | @Override | 40 | @Override |
@@ -33,7 +33,6 @@ import org.thingsboard.rule.engine.api.TbNodeException; | @@ -33,7 +33,6 @@ import org.thingsboard.rule.engine.api.TbNodeException; | ||
33 | import org.thingsboard.rule.engine.api.TbRelationTypes; | 33 | import org.thingsboard.rule.engine.api.TbRelationTypes; |
34 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 34 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
35 | import org.thingsboard.server.common.data.plugin.ComponentType; | 35 | import org.thingsboard.server.common.data.plugin.ComponentType; |
36 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
37 | import org.thingsboard.server.common.msg.TbMsg; | 36 | import org.thingsboard.server.common.msg.TbMsg; |
38 | import org.thingsboard.server.common.msg.TbMsgMetaData; | 37 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
39 | 38 |
@@ -19,10 +19,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; | @@ -19,10 +19,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; | ||
19 | import com.fasterxml.jackson.databind.ObjectMapper; | 19 | import com.fasterxml.jackson.databind.ObjectMapper; |
20 | import lombok.extern.slf4j.Slf4j; | 20 | import lombok.extern.slf4j.Slf4j; |
21 | import org.springframework.util.StringUtils; | 21 | import org.springframework.util.StringUtils; |
22 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
23 | +import org.thingsboard.rule.engine.api.TbContext; | ||
24 | +import org.thingsboard.rule.engine.api.TbNode; | ||
25 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
26 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
22 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 27 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
23 | -import org.thingsboard.rule.engine.api.*; | ||
24 | import org.thingsboard.server.common.data.plugin.ComponentType; | 28 | import org.thingsboard.server.common.data.plugin.ComponentType; |
25 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
26 | import org.thingsboard.server.common.msg.TbMsg; | 29 | import org.thingsboard.server.common.msg.TbMsg; |
27 | import org.thingsboard.server.common.msg.TbMsgMetaData; | 30 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
28 | 31 |
@@ -27,7 +27,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; | @@ -27,7 +27,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
27 | import org.thingsboard.rule.engine.api.TbNodeException; | 27 | import org.thingsboard.rule.engine.api.TbNodeException; |
28 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 28 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
29 | import org.thingsboard.server.common.data.plugin.ComponentType; | 29 | import org.thingsboard.server.common.data.plugin.ComponentType; |
30 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
31 | import org.thingsboard.server.common.msg.TbMsg; | 30 | import org.thingsboard.server.common.msg.TbMsg; |
32 | 31 | ||
33 | import javax.mail.internet.MimeMessage; | 32 | import javax.mail.internet.MimeMessage; |
@@ -18,14 +18,13 @@ package org.thingsboard.rule.engine.metadata; | @@ -18,14 +18,13 @@ package org.thingsboard.rule.engine.metadata; | ||
18 | import com.google.common.util.concurrent.Futures; | 18 | import com.google.common.util.concurrent.Futures; |
19 | import com.google.common.util.concurrent.ListenableFuture; | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | import lombok.extern.slf4j.Slf4j; | 20 | import lombok.extern.slf4j.Slf4j; |
21 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
22 | import org.thingsboard.rule.engine.api.RuleNode; | 21 | import org.thingsboard.rule.engine.api.RuleNode; |
23 | import org.thingsboard.rule.engine.api.TbContext; | 22 | import org.thingsboard.rule.engine.api.TbContext; |
24 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; | 23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
25 | import org.thingsboard.rule.engine.api.TbNodeException; | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | +import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
26 | import org.thingsboard.server.common.data.id.EntityId; | 26 | import org.thingsboard.server.common.data.id.EntityId; |
27 | import org.thingsboard.server.common.data.plugin.ComponentType; | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
28 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
29 | import org.thingsboard.server.common.msg.TbMsg; | 28 | import org.thingsboard.server.common.msg.TbMsg; |
30 | 29 | ||
31 | /** | 30 | /** |
@@ -41,8 +40,7 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -41,8 +40,7 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
41 | "To access those attributes in other nodes this template can be used " + | 40 | "To access those attributes in other nodes this template can be used " + |
42 | "<code>metadata.cs_temperature</code> or <code>metadata.shared_limit</code> ", | 41 | "<code>metadata.cs_temperature</code> or <code>metadata.shared_limit</code> ", |
43 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 42 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
44 | - configDirective = "tbEnrichmentNodeOriginatorAttributesConfig" | ||
45 | -) | 43 | + configDirective = "tbEnrichmentNodeOriginatorAttributesConfig") |
46 | public class TbGetAttributesNode extends TbAbstractGetAttributesNode<TbGetAttributesNodeConfiguration, EntityId> { | 44 | public class TbGetAttributesNode extends TbAbstractGetAttributesNode<TbGetAttributesNodeConfiguration, EntityId> { |
47 | 45 | ||
48 | @Override | 46 | @Override |
@@ -22,7 +22,6 @@ import org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader; | @@ -22,7 +22,6 @@ import org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader; | ||
22 | import org.thingsboard.server.common.data.id.CustomerId; | 22 | import org.thingsboard.server.common.data.id.CustomerId; |
23 | import org.thingsboard.server.common.data.id.EntityId; | 23 | import org.thingsboard.server.common.data.id.EntityId; |
24 | import org.thingsboard.server.common.data.plugin.ComponentType; | 24 | import org.thingsboard.server.common.data.plugin.ComponentType; |
25 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
26 | 25 | ||
27 | @RuleNode( | 26 | @RuleNode( |
28 | type = ComponentType.ENRICHMENT, | 27 | type = ComponentType.ENRICHMENT, |
@@ -34,8 +33,7 @@ import org.thingsboard.server.common.data.rule.RuleChainType; | @@ -34,8 +33,7 @@ import org.thingsboard.server.common.data.rule.RuleChainType; | ||
34 | "To access those attributes in other nodes this template can be used " + | 33 | "To access those attributes in other nodes this template can be used " + |
35 | "<code>metadata.temperature</code>.", | 34 | "<code>metadata.temperature</code>.", |
36 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, | 35 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
37 | - configDirective = "tbEnrichmentNodeCustomerAttributesConfig" | ||
38 | -) | 36 | + configDirective = "tbEnrichmentNodeCustomerAttributesConfig") |
39 | public class TbGetCustomerAttributeNode extends TbEntityGetAttrNode<CustomerId> { | 37 | public class TbGetCustomerAttributeNode extends TbEntityGetAttrNode<CustomerId> { |
40 | 38 | ||
41 | @Override | 39 | @Override |
@@ -31,7 +31,6 @@ import org.thingsboard.server.common.data.id.DeviceId; | @@ -31,7 +31,6 @@ import org.thingsboard.server.common.data.id.DeviceId; | ||
31 | import org.thingsboard.server.common.data.id.EdgeId; | 31 | import org.thingsboard.server.common.data.id.EdgeId; |
32 | import org.thingsboard.server.common.data.id.EntityViewId; | 32 | import org.thingsboard.server.common.data.id.EntityViewId; |
33 | import org.thingsboard.server.common.data.plugin.ComponentType; | 33 | import org.thingsboard.server.common.data.plugin.ComponentType; |
34 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
35 | import org.thingsboard.server.common.msg.TbMsg; | 34 | import org.thingsboard.server.common.msg.TbMsg; |
36 | 35 | ||
37 | @Slf4j | 36 | @Slf4j |
@@ -43,8 +42,7 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -43,8 +42,7 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
43 | "<b>Note:</b> only Device, Asset, and Entity View type are allowed.<br><br>" + | 42 | "<b>Note:</b> only Device, Asset, and Entity View type are allowed.<br><br>" + |
44 | "If the originator of the message is not assigned to Customer, or originator type is not supported - Message will be forwarded to <b>Failure</b> chain, otherwise, <b>Success</b> chain will be used.", | 43 | "If the originator of the message is not assigned to Customer, or originator type is not supported - Message will be forwarded to <b>Failure</b> chain, otherwise, <b>Success</b> chain will be used.", |
45 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 44 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
46 | - configDirective = "tbEnrichmentNodeEntityDetailsConfig" | ||
47 | -) | 45 | + configDirective = "tbEnrichmentNodeEntityDetailsConfig") |
48 | public class TbGetCustomerDetailsNode extends TbAbstractGetEntityDetailsNode<TbGetCustomerDetailsNodeConfiguration> { | 46 | public class TbGetCustomerDetailsNode extends TbAbstractGetEntityDetailsNode<TbGetCustomerDetailsNodeConfiguration> { |
49 | 47 | ||
50 | private static final String CUSTOMER_PREFIX = "customer_"; | 48 | private static final String CUSTOMER_PREFIX = "customer_"; |
@@ -17,16 +17,14 @@ package org.thingsboard.rule.engine.metadata; | @@ -17,16 +17,14 @@ package org.thingsboard.rule.engine.metadata; | ||
17 | 17 | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
20 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
21 | import org.thingsboard.rule.engine.api.RuleNode; | 20 | import org.thingsboard.rule.engine.api.RuleNode; |
22 | import org.thingsboard.rule.engine.api.TbContext; | 21 | import org.thingsboard.rule.engine.api.TbContext; |
23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; | 22 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
24 | import org.thingsboard.rule.engine.api.TbNodeException; | 23 | import org.thingsboard.rule.engine.api.TbNodeException; |
24 | +import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
25 | import org.thingsboard.rule.engine.util.EntitiesRelatedDeviceIdAsyncLoader; | 25 | import org.thingsboard.rule.engine.util.EntitiesRelatedDeviceIdAsyncLoader; |
26 | import org.thingsboard.server.common.data.id.DeviceId; | 26 | import org.thingsboard.server.common.data.id.DeviceId; |
27 | -import org.thingsboard.server.common.data.id.EntityId; | ||
28 | import org.thingsboard.server.common.data.plugin.ComponentType; | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
29 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
30 | import org.thingsboard.server.common.msg.TbMsg; | 28 | import org.thingsboard.server.common.msg.TbMsg; |
31 | 29 | ||
32 | @Slf4j | 30 | @Slf4j |
@@ -39,8 +37,7 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -39,8 +37,7 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
39 | "To access those attributes in other nodes this template can be used " + | 37 | "To access those attributes in other nodes this template can be used " + |
40 | "<code>metadata.cs_temperature</code> or <code>metadata.shared_limit</code> ", | 38 | "<code>metadata.cs_temperature</code> or <code>metadata.shared_limit</code> ", |
41 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 39 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
42 | - configDirective = "tbEnrichmentNodeDeviceAttributesConfig" | ||
43 | -) | 40 | + configDirective = "tbEnrichmentNodeDeviceAttributesConfig") |
44 | public class TbGetDeviceAttrNode extends TbAbstractGetAttributesNode<TbGetDeviceAttrNodeConfiguration, DeviceId> { | 41 | public class TbGetDeviceAttrNode extends TbAbstractGetAttributesNode<TbGetDeviceAttrNodeConfiguration, DeviceId> { |
45 | 42 | ||
46 | @Override | 43 | @Override |
@@ -28,11 +28,9 @@ import org.thingsboard.rule.engine.api.util.TbNodeUtils; | @@ -28,11 +28,9 @@ import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
28 | import org.thingsboard.rule.engine.util.EntitiesFieldsAsyncLoader; | 28 | import org.thingsboard.rule.engine.util.EntitiesFieldsAsyncLoader; |
29 | import org.thingsboard.server.common.data.id.EntityId; | 29 | import org.thingsboard.server.common.data.id.EntityId; |
30 | import org.thingsboard.server.common.data.plugin.ComponentType; | 30 | import org.thingsboard.server.common.data.plugin.ComponentType; |
31 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
32 | import org.thingsboard.server.common.msg.TbMsg; | 31 | import org.thingsboard.server.common.msg.TbMsg; |
33 | 32 | ||
34 | import static org.thingsboard.common.util.DonAsynchron.withCallback; | 33 | import static org.thingsboard.common.util.DonAsynchron.withCallback; |
35 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
36 | 34 | ||
37 | /** | 35 | /** |
38 | * Created by ashvayka on 19.01.18. | 36 | * Created by ashvayka on 19.01.18. |
@@ -44,8 +42,7 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | @@ -44,8 +42,7 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
44 | nodeDescription = "Add Message Originator fields values into Message Metadata", | 42 | nodeDescription = "Add Message Originator fields values into Message Metadata", |
45 | nodeDetails = "Will fetch fields values specified in mapping. If specified field is not part of originator fields it will be ignored.", | 43 | nodeDetails = "Will fetch fields values specified in mapping. If specified field is not part of originator fields it will be ignored.", |
46 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 44 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
47 | - configDirective = "tbEnrichmentNodeOriginatorFieldsConfig" | ||
48 | -) | 45 | + configDirective = "tbEnrichmentNodeOriginatorFieldsConfig") |
49 | public class TbGetOriginatorFieldsNode implements TbNode { | 46 | public class TbGetOriginatorFieldsNode implements TbNode { |
50 | 47 | ||
51 | private TbGetOriginatorFieldsConfiguration config; | 48 | private TbGetOriginatorFieldsConfiguration config; |
@@ -16,13 +16,14 @@ | @@ -16,13 +16,14 @@ | ||
16 | package org.thingsboard.rule.engine.metadata; | 16 | package org.thingsboard.rule.engine.metadata; |
17 | 17 | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
20 | +import org.thingsboard.rule.engine.api.TbContext; | ||
21 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
22 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
19 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 23 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
20 | -import org.thingsboard.rule.engine.api.*; | ||
21 | import org.thingsboard.rule.engine.util.EntitiesRelatedEntityIdAsyncLoader; | 24 | import org.thingsboard.rule.engine.util.EntitiesRelatedEntityIdAsyncLoader; |
22 | - | ||
23 | import org.thingsboard.server.common.data.id.EntityId; | 25 | import org.thingsboard.server.common.data.id.EntityId; |
24 | import org.thingsboard.server.common.data.plugin.ComponentType; | 26 | import org.thingsboard.server.common.data.plugin.ComponentType; |
25 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
26 | 27 | ||
27 | @RuleNode( | 28 | @RuleNode( |
28 | type = ComponentType.ENRICHMENT, | 29 | type = ComponentType.ENRICHMENT, |
@@ -36,8 +37,7 @@ import org.thingsboard.server.common.data.rule.RuleChainType; | @@ -36,8 +37,7 @@ import org.thingsboard.server.common.data.rule.RuleChainType; | ||
36 | "To access those attributes in other nodes this template can be used " + | 37 | "To access those attributes in other nodes this template can be used " + |
37 | "<code>metadata.temperature</code>.", | 38 | "<code>metadata.temperature</code>.", |
38 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, | 39 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
39 | - configDirective = "tbEnrichmentNodeRelatedAttributesConfig" | ||
40 | -) | 40 | + configDirective = "tbEnrichmentNodeRelatedAttributesConfig") |
41 | 41 | ||
42 | public class TbGetRelatedAttributeNode extends TbEntityGetAttrNode<EntityId> { | 42 | public class TbGetRelatedAttributeNode extends TbEntityGetAttrNode<EntityId> { |
43 | 43 |
@@ -38,7 +38,6 @@ import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery; | @@ -38,7 +38,6 @@ import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery; | ||
38 | import org.thingsboard.server.common.data.kv.ReadTsKvQuery; | 38 | import org.thingsboard.server.common.data.kv.ReadTsKvQuery; |
39 | import org.thingsboard.server.common.data.kv.TsKvEntry; | 39 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
40 | import org.thingsboard.server.common.data.plugin.ComponentType; | 40 | import org.thingsboard.server.common.data.plugin.ComponentType; |
41 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
42 | import org.thingsboard.server.common.msg.TbMsg; | 41 | import org.thingsboard.server.common.msg.TbMsg; |
43 | 42 | ||
44 | import java.io.IOException; | 43 | import java.io.IOException; |
@@ -47,7 +46,6 @@ import java.util.concurrent.ExecutionException; | @@ -47,7 +46,6 @@ import java.util.concurrent.ExecutionException; | ||
47 | import java.util.concurrent.TimeUnit; | 46 | import java.util.concurrent.TimeUnit; |
48 | import java.util.stream.Collectors; | 47 | import java.util.stream.Collectors; |
49 | 48 | ||
50 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
51 | import static org.thingsboard.rule.engine.metadata.TbGetTelemetryNodeConfiguration.FETCH_MODE_ALL; | 49 | import static org.thingsboard.rule.engine.metadata.TbGetTelemetryNodeConfiguration.FETCH_MODE_ALL; |
52 | import static org.thingsboard.rule.engine.metadata.TbGetTelemetryNodeConfiguration.FETCH_MODE_FIRST; | 50 | import static org.thingsboard.rule.engine.metadata.TbGetTelemetryNodeConfiguration.FETCH_MODE_FIRST; |
53 | import static org.thingsboard.rule.engine.metadata.TbGetTelemetryNodeConfiguration.MAX_FETCH_SIZE; | 51 | import static org.thingsboard.rule.engine.metadata.TbGetTelemetryNodeConfiguration.MAX_FETCH_SIZE; |
@@ -67,8 +65,7 @@ import static org.thingsboard.server.common.data.kv.Aggregation.NONE; | @@ -67,8 +65,7 @@ import static org.thingsboard.server.common.data.kv.Aggregation.NONE; | ||
67 | "Also, the rule node allows you to select telemetry sampling order: <b>ASC</b> or <b>DESC</b>. </br>" + | 65 | "Also, the rule node allows you to select telemetry sampling order: <b>ASC</b> or <b>DESC</b>. </br>" + |
68 | "<b>Note</b>: The maximum size of the fetched array is 1000 records.\n ", | 66 | "<b>Note</b>: The maximum size of the fetched array is 1000 records.\n ", |
69 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 67 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
70 | - configDirective = "tbEnrichmentNodeGetTelemetryFromDatabase" | ||
71 | -) | 68 | + configDirective = "tbEnrichmentNodeGetTelemetryFromDatabase") |
72 | public class TbGetTelemetryNode implements TbNode { | 69 | public class TbGetTelemetryNode implements TbNode { |
73 | 70 | ||
74 | private static final String DESC_ORDER = "DESC"; | 71 | private static final String DESC_ORDER = "DESC"; |
@@ -23,7 +23,6 @@ import org.thingsboard.rule.engine.util.EntitiesTenantIdAsyncLoader; | @@ -23,7 +23,6 @@ import org.thingsboard.rule.engine.util.EntitiesTenantIdAsyncLoader; | ||
23 | import org.thingsboard.server.common.data.id.EntityId; | 23 | import org.thingsboard.server.common.data.id.EntityId; |
24 | import org.thingsboard.server.common.data.id.TenantId; | 24 | import org.thingsboard.server.common.data.id.TenantId; |
25 | import org.thingsboard.server.common.data.plugin.ComponentType; | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
26 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
27 | 26 | ||
28 | @Slf4j | 27 | @Slf4j |
29 | @RuleNode( | 28 | @RuleNode( |
@@ -36,8 +35,7 @@ import org.thingsboard.server.common.data.rule.RuleChainType; | @@ -36,8 +35,7 @@ import org.thingsboard.server.common.data.rule.RuleChainType; | ||
36 | "To access those attributes in other nodes this template can be used " + | 35 | "To access those attributes in other nodes this template can be used " + |
37 | "<code>metadata.temperature</code>.", | 36 | "<code>metadata.temperature</code>.", |
38 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, | 37 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
39 | - configDirective = "tbEnrichmentNodeTenantAttributesConfig" | ||
40 | -) | 38 | + configDirective = "tbEnrichmentNodeTenantAttributesConfig") |
41 | public class TbGetTenantAttributeNode extends TbEntityGetAttrNode<TenantId> { | 39 | public class TbGetTenantAttributeNode extends TbEntityGetAttrNode<TenantId> { |
42 | 40 | ||
43 | @Override | 41 | @Override |
@@ -26,7 +26,6 @@ import org.thingsboard.rule.engine.api.TbNodeException; | @@ -26,7 +26,6 @@ import org.thingsboard.rule.engine.api.TbNodeException; | ||
26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
27 | import org.thingsboard.server.common.data.ContactBased; | 27 | import org.thingsboard.server.common.data.ContactBased; |
28 | import org.thingsboard.server.common.data.plugin.ComponentType; | 28 | import org.thingsboard.server.common.data.plugin.ComponentType; |
29 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
30 | import org.thingsboard.server.common.msg.TbMsg; | 29 | import org.thingsboard.server.common.msg.TbMsg; |
31 | 30 | ||
32 | @Slf4j | 31 | @Slf4j |
@@ -38,8 +37,7 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -38,8 +37,7 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
38 | "<b>Note:</b> only Device, Asset, and Entity View type are allowed.<br><br>" + | 37 | "<b>Note:</b> only Device, Asset, and Entity View type are allowed.<br><br>" + |
39 | "If the originator of the message is not assigned to Tenant, or originator type is not supported - Message will be forwarded to <b>Failure</b> chain, otherwise, <b>Success</b> chain will be used.", | 38 | "If the originator of the message is not assigned to Tenant, or originator type is not supported - Message will be forwarded to <b>Failure</b> chain, otherwise, <b>Success</b> chain will be used.", |
40 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 39 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
41 | - configDirective = "tbEnrichmentNodeEntityDetailsConfig" | ||
42 | -) | 40 | + configDirective = "tbEnrichmentNodeEntityDetailsConfig") |
43 | public class TbGetTenantDetailsNode extends TbAbstractGetEntityDetailsNode<TbGetTenantDetailsNodeConfiguration> { | 41 | public class TbGetTenantDetailsNode extends TbAbstractGetEntityDetailsNode<TbGetTenantDetailsNodeConfiguration> { |
44 | 42 | ||
45 | private static final String TENANT_PREFIX = "tenant_"; | 43 | private static final String TENANT_PREFIX = "tenant_"; |
@@ -21,14 +21,17 @@ import io.netty.handler.ssl.SslContext; | @@ -21,14 +21,17 @@ import io.netty.handler.ssl.SslContext; | ||
21 | import io.netty.handler.ssl.SslContextBuilder; | 21 | import io.netty.handler.ssl.SslContextBuilder; |
22 | import io.netty.util.concurrent.Future; | 22 | import io.netty.util.concurrent.Future; |
23 | import lombok.extern.slf4j.Slf4j; | 23 | import lombok.extern.slf4j.Slf4j; |
24 | +import org.springframework.util.StringUtils; | ||
24 | import org.thingsboard.mqtt.MqttClient; | 25 | import org.thingsboard.mqtt.MqttClient; |
25 | import org.thingsboard.mqtt.MqttClientConfig; | 26 | import org.thingsboard.mqtt.MqttClientConfig; |
26 | import org.thingsboard.mqtt.MqttConnectResult; | 27 | import org.thingsboard.mqtt.MqttConnectResult; |
27 | -import org.springframework.util.StringUtils; | 28 | +import org.thingsboard.rule.engine.api.RuleNode; |
29 | +import org.thingsboard.rule.engine.api.TbContext; | ||
30 | +import org.thingsboard.rule.engine.api.TbNode; | ||
31 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
32 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
28 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 33 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
29 | -import org.thingsboard.rule.engine.api.*; | ||
30 | import org.thingsboard.server.common.data.plugin.ComponentType; | 34 | import org.thingsboard.server.common.data.plugin.ComponentType; |
31 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
32 | import org.thingsboard.server.common.msg.TbMsg; | 35 | import org.thingsboard.server.common.msg.TbMsg; |
33 | import org.thingsboard.server.common.msg.TbMsgMetaData; | 36 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
34 | 37 |
@@ -16,18 +16,24 @@ | @@ -16,18 +16,24 @@ | ||
16 | package org.thingsboard.rule.engine.rabbitmq; | 16 | package org.thingsboard.rule.engine.rabbitmq; |
17 | 17 | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | -import com.rabbitmq.client.*; | 19 | +import com.rabbitmq.client.AMQP; |
20 | +import com.rabbitmq.client.Channel; | ||
21 | +import com.rabbitmq.client.Connection; | ||
22 | +import com.rabbitmq.client.ConnectionFactory; | ||
23 | +import com.rabbitmq.client.MessageProperties; | ||
20 | import lombok.extern.slf4j.Slf4j; | 24 | import lombok.extern.slf4j.Slf4j; |
21 | import org.apache.commons.lang3.StringUtils; | 25 | import org.apache.commons.lang3.StringUtils; |
26 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
27 | +import org.thingsboard.rule.engine.api.TbContext; | ||
28 | +import org.thingsboard.rule.engine.api.TbNode; | ||
29 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
30 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
22 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 31 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
23 | -import org.thingsboard.rule.engine.api.*; | ||
24 | import org.thingsboard.server.common.data.plugin.ComponentType; | 32 | import org.thingsboard.server.common.data.plugin.ComponentType; |
25 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
26 | import org.thingsboard.server.common.msg.TbMsg; | 33 | import org.thingsboard.server.common.msg.TbMsg; |
27 | import org.thingsboard.server.common.msg.TbMsgMetaData; | 34 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
28 | 35 | ||
29 | import java.nio.charset.Charset; | 36 | import java.nio.charset.Charset; |
30 | -import java.util.concurrent.ExecutionException; | ||
31 | 37 | ||
32 | import static org.thingsboard.common.util.DonAsynchron.withCallback; | 38 | import static org.thingsboard.common.util.DonAsynchron.withCallback; |
33 | 39 |
@@ -23,7 +23,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; | @@ -23,7 +23,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
23 | import org.thingsboard.rule.engine.api.TbNodeException; | 23 | import org.thingsboard.rule.engine.api.TbNodeException; |
24 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 24 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
25 | import org.thingsboard.server.common.data.plugin.ComponentType; | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
26 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
27 | import org.thingsboard.server.common.msg.TbMsg; | 26 | import org.thingsboard.server.common.msg.TbMsg; |
28 | 27 | ||
29 | @Slf4j | 28 | @Slf4j |
@@ -17,16 +17,14 @@ package org.thingsboard.rule.engine.rpc; | @@ -17,16 +17,14 @@ package org.thingsboard.rule.engine.rpc; | ||
17 | 17 | ||
18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
19 | import org.springframework.util.StringUtils; | 19 | import org.springframework.util.StringUtils; |
20 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
21 | import org.thingsboard.rule.engine.api.RuleNode; | 20 | import org.thingsboard.rule.engine.api.RuleNode; |
22 | import org.thingsboard.rule.engine.api.TbContext; | 21 | import org.thingsboard.rule.engine.api.TbContext; |
23 | import org.thingsboard.rule.engine.api.TbNode; | 22 | import org.thingsboard.rule.engine.api.TbNode; |
24 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; | 23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
25 | import org.thingsboard.rule.engine.api.TbNodeException; | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | +import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
26 | import org.thingsboard.server.common.data.EntityType; | 26 | import org.thingsboard.server.common.data.EntityType; |
27 | -import org.thingsboard.server.common.data.id.DeviceId; | ||
28 | import org.thingsboard.server.common.data.plugin.ComponentType; | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
29 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
30 | import org.thingsboard.server.common.msg.TbMsg; | 28 | import org.thingsboard.server.common.msg.TbMsg; |
31 | 29 | ||
32 | import java.util.UUID; | 30 | import java.util.UUID; |
@@ -145,19 +145,21 @@ public class TbSendRPCRequestNode implements TbNode { | @@ -145,19 +145,21 @@ public class TbSendRPCRequestNode implements TbNode { | ||
145 | List<EntityRelation> result = | 145 | List<EntityRelation> result = |
146 | ctx.getRelationService().findByToAndType(ctx.getTenantId(), msg.getOriginator(), EntityRelation.EDGE_TYPE, RelationTypeGroup.COMMON); | 146 | ctx.getRelationService().findByToAndType(ctx.getTenantId(), msg.getOriginator(), EntityRelation.EDGE_TYPE, RelationTypeGroup.COMMON); |
147 | if (result != null && result.size() > 0) { | 147 | if (result != null && result.size() > 0) { |
148 | - return new EdgeId(result.get(0).getFrom().getId()); | ||
149 | - } else { | ||
150 | - return null; | 148 | + EntityRelation relationToEdge = result.get(0); |
149 | + if (relationToEdge.getFrom() != null && relationToEdge.getFrom().getId() != null) { | ||
150 | + return new EdgeId(relationToEdge.getFrom().getId()); | ||
151 | + } | ||
151 | } | 152 | } |
153 | + return null; | ||
152 | } | 154 | } |
153 | 155 | ||
154 | private void sendRpcRequestToEdgeDevice(TbContext ctx, TbMsg msg, EdgeId edgeId, RuleEngineDeviceRpcRequest request) { | 156 | private void sendRpcRequestToEdgeDevice(TbContext ctx, TbMsg msg, EdgeId edgeId, RuleEngineDeviceRpcRequest request) { |
155 | EdgeEvent edgeEvent = new EdgeEvent(); | 157 | EdgeEvent edgeEvent = new EdgeEvent(); |
156 | edgeEvent.setTenantId(ctx.getTenantId()); | 158 | edgeEvent.setTenantId(ctx.getTenantId()); |
157 | - edgeEvent.setEdgeEventAction(ActionType.RPC_CALL.name()); | 159 | + edgeEvent.setAction(ActionType.RPC_CALL.name()); |
158 | edgeEvent.setEntityId(request.getDeviceId().getId()); | 160 | edgeEvent.setEntityId(request.getDeviceId().getId()); |
159 | - edgeEvent.setEdgeEventType(EdgeEventType.DEVICE); | ||
160 | - edgeEvent.setEntityBody(json.valueToTree(request)); | 161 | + edgeEvent.setType(EdgeEventType.DEVICE); |
162 | + edgeEvent.setBody(json.valueToTree(request)); | ||
161 | edgeEvent.setEdgeId(edgeId); | 163 | edgeEvent.setEdgeId(edgeId); |
162 | ListenableFuture<EdgeEvent> saveFuture = ctx.getEdgeEventService().saveAsync(edgeEvent); | 164 | ListenableFuture<EdgeEvent> saveFuture = ctx.getEdgeEventService().saveAsync(edgeEvent); |
163 | Futures.addCallback(saveFuture, new FutureCallback<EdgeEvent>() { | 165 | Futures.addCallback(saveFuture, new FutureCallback<EdgeEvent>() { |
@@ -24,12 +24,8 @@ import org.thingsboard.rule.engine.api.TbNode; | @@ -24,12 +24,8 @@ import org.thingsboard.rule.engine.api.TbNode; | ||
24 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; | 24 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
25 | import org.thingsboard.rule.engine.api.TbNodeException; | 25 | import org.thingsboard.rule.engine.api.TbNodeException; |
26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
27 | -import org.thingsboard.server.common.data.DataConstants; | ||
28 | -import org.thingsboard.server.common.data.EntityType; | ||
29 | -import org.thingsboard.server.common.data.id.DeviceId; | ||
30 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; | 27 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
31 | import org.thingsboard.server.common.data.plugin.ComponentType; | 28 | import org.thingsboard.server.common.data.plugin.ComponentType; |
32 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
33 | import org.thingsboard.server.common.msg.TbMsg; | 29 | import org.thingsboard.server.common.msg.TbMsg; |
34 | import org.thingsboard.server.common.msg.session.SessionMsgType; | 30 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
35 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; | 31 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; |
@@ -67,12 +63,11 @@ public class TbMsgAttributesNode implements TbNode { | @@ -67,12 +63,11 @@ public class TbMsgAttributesNode implements TbNode { | ||
67 | } | 63 | } |
68 | String src = msg.getData(); | 64 | String src = msg.getData(); |
69 | Set<AttributeKvEntry> attributes = JsonConverter.convertToAttributes(new JsonParser().parse(src)); | 65 | Set<AttributeKvEntry> attributes = JsonConverter.convertToAttributes(new JsonParser().parse(src)); |
70 | - String scope = msg.getMetaData().getValue(SCOPE); | ||
71 | - if (StringUtils.isEmpty(scope)) { | ||
72 | - scope = config.getScope(); | ||
73 | - msg.getMetaData().putValue("scope", scope); | 66 | + if (StringUtils.isEmpty(msg.getMetaData().getValue(SCOPE))) { |
67 | + msg.getMetaData().putValue(SCOPE, config.getScope()); | ||
74 | } | 68 | } |
75 | - ctx.getTelemetryService().saveAndNotify(ctx.getTenantId(), msg.getOriginator(), scope, new ArrayList<>(attributes), new TelemetryNodeCallback(ctx, msg)); | 69 | + ctx.getTelemetryService().saveAndNotify(ctx.getTenantId(), msg.getOriginator(), config.getScope(), |
70 | + new ArrayList<>(attributes), new TelemetryNodeCallback(ctx, msg)); | ||
76 | } | 71 | } |
77 | 72 | ||
78 | @Override | 73 | @Override |
@@ -18,17 +18,16 @@ package org.thingsboard.rule.engine.telemetry; | @@ -18,17 +18,16 @@ package org.thingsboard.rule.engine.telemetry; | ||
18 | import com.google.gson.JsonParser; | 18 | import com.google.gson.JsonParser; |
19 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
20 | import org.springframework.util.StringUtils; | 20 | import org.springframework.util.StringUtils; |
21 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
22 | import org.thingsboard.rule.engine.api.RuleNode; | 21 | import org.thingsboard.rule.engine.api.RuleNode; |
23 | import org.thingsboard.rule.engine.api.TbContext; | 22 | import org.thingsboard.rule.engine.api.TbContext; |
24 | import org.thingsboard.rule.engine.api.TbNode; | 23 | import org.thingsboard.rule.engine.api.TbNode; |
25 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; | 24 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
26 | import org.thingsboard.rule.engine.api.TbNodeException; | 25 | import org.thingsboard.rule.engine.api.TbNodeException; |
26 | +import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
27 | import org.thingsboard.server.common.data.kv.BasicTsKvEntry; | 27 | import org.thingsboard.server.common.data.kv.BasicTsKvEntry; |
28 | import org.thingsboard.server.common.data.kv.KvEntry; | 28 | import org.thingsboard.server.common.data.kv.KvEntry; |
29 | import org.thingsboard.server.common.data.kv.TsKvEntry; | 29 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
30 | import org.thingsboard.server.common.data.plugin.ComponentType; | 30 | import org.thingsboard.server.common.data.plugin.ComponentType; |
31 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
32 | import org.thingsboard.server.common.msg.TbMsg; | 31 | import org.thingsboard.server.common.msg.TbMsg; |
33 | import org.thingsboard.server.common.msg.session.SessionMsgType; | 32 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
34 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; | 33 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; |
@@ -22,13 +22,9 @@ import org.thingsboard.rule.engine.api.TbContext; | @@ -22,13 +22,9 @@ import org.thingsboard.rule.engine.api.TbContext; | ||
22 | import org.thingsboard.rule.engine.api.TbNode; | 22 | import org.thingsboard.rule.engine.api.TbNode; |
23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; | 23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
24 | import org.thingsboard.rule.engine.api.TbNodeException; | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
26 | import org.thingsboard.server.common.data.plugin.ComponentType; | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
27 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
28 | import org.thingsboard.server.common.msg.TbMsg; | 26 | import org.thingsboard.server.common.msg.TbMsg; |
29 | 27 | ||
30 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
31 | - | ||
32 | @Slf4j | 28 | @Slf4j |
33 | @RuleNode( | 29 | @RuleNode( |
34 | type = ComponentType.ACTION, | 30 | type = ComponentType.ACTION, |
@@ -39,8 +35,7 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | @@ -39,8 +35,7 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
39 | "Subsequent messages will not be processed until the previous message processing is completed or timeout event occurs.\n" + | 35 | "Subsequent messages will not be processed until the previous message processing is completed or timeout event occurs.\n" + |
40 | "Size of the queue per originator and timeout values are configurable on a system level", | 36 | "Size of the queue per originator and timeout values are configurable on a system level", |
41 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 37 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
42 | - configDirective = "tbNodeEmptyConfig" | ||
43 | -) | 38 | + configDirective = "tbNodeEmptyConfig") |
44 | @Deprecated | 39 | @Deprecated |
45 | public class TbSynchronizationBeginNode implements TbNode { | 40 | public class TbSynchronizationBeginNode implements TbNode { |
46 | 41 |
@@ -22,15 +22,9 @@ import org.thingsboard.rule.engine.api.TbContext; | @@ -22,15 +22,9 @@ import org.thingsboard.rule.engine.api.TbContext; | ||
22 | import org.thingsboard.rule.engine.api.TbNode; | 22 | import org.thingsboard.rule.engine.api.TbNode; |
23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; | 23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
24 | import org.thingsboard.rule.engine.api.TbNodeException; | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
26 | import org.thingsboard.server.common.data.plugin.ComponentType; | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
27 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
28 | import org.thingsboard.server.common.msg.TbMsg; | 26 | import org.thingsboard.server.common.msg.TbMsg; |
29 | 27 | ||
30 | -import java.util.concurrent.ExecutionException; | ||
31 | - | ||
32 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
33 | - | ||
34 | @Slf4j | 28 | @Slf4j |
35 | @RuleNode( | 29 | @RuleNode( |
36 | type = ComponentType.ACTION, | 30 | type = ComponentType.ACTION, |
@@ -20,18 +20,17 @@ import com.google.common.collect.Sets; | @@ -20,18 +20,17 @@ import com.google.common.collect.Sets; | ||
20 | import com.google.common.util.concurrent.Futures; | 20 | import com.google.common.util.concurrent.Futures; |
21 | import com.google.common.util.concurrent.ListenableFuture; | 21 | import com.google.common.util.concurrent.ListenableFuture; |
22 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
23 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
24 | import org.thingsboard.rule.engine.api.RuleNode; | 23 | import org.thingsboard.rule.engine.api.RuleNode; |
25 | import org.thingsboard.rule.engine.api.TbContext; | 24 | import org.thingsboard.rule.engine.api.TbContext; |
26 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; | 25 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
27 | import org.thingsboard.rule.engine.api.TbNodeException; | 26 | import org.thingsboard.rule.engine.api.TbNodeException; |
27 | +import org.thingsboard.rule.engine.api.util.TbNodeUtils; | ||
28 | import org.thingsboard.rule.engine.util.EntitiesAlarmOriginatorIdAsyncLoader; | 28 | import org.thingsboard.rule.engine.util.EntitiesAlarmOriginatorIdAsyncLoader; |
29 | import org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader; | 29 | import org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader; |
30 | import org.thingsboard.rule.engine.util.EntitiesRelatedEntityIdAsyncLoader; | 30 | import org.thingsboard.rule.engine.util.EntitiesRelatedEntityIdAsyncLoader; |
31 | import org.thingsboard.rule.engine.util.EntitiesTenantIdAsyncLoader; | 31 | import org.thingsboard.rule.engine.util.EntitiesTenantIdAsyncLoader; |
32 | import org.thingsboard.server.common.data.id.EntityId; | 32 | import org.thingsboard.server.common.data.id.EntityId; |
33 | import org.thingsboard.server.common.data.plugin.ComponentType; | 33 | import org.thingsboard.server.common.data.plugin.ComponentType; |
34 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
35 | import org.thingsboard.server.common.msg.TbMsg; | 34 | import org.thingsboard.server.common.msg.TbMsg; |
36 | 35 | ||
37 | import java.util.HashSet; | 36 | import java.util.HashSet; |
@@ -16,15 +16,15 @@ | @@ -16,15 +16,15 @@ | ||
16 | package org.thingsboard.rule.engine.transform; | 16 | package org.thingsboard.rule.engine.transform; |
17 | 17 | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | +import org.thingsboard.rule.engine.api.RuleNode; | ||
20 | +import org.thingsboard.rule.engine.api.ScriptEngine; | ||
21 | +import org.thingsboard.rule.engine.api.TbContext; | ||
22 | +import org.thingsboard.rule.engine.api.TbNodeConfiguration; | ||
23 | +import org.thingsboard.rule.engine.api.TbNodeException; | ||
19 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; | 24 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
20 | -import org.thingsboard.rule.engine.api.*; | ||
21 | import org.thingsboard.server.common.data.plugin.ComponentType; | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
22 | -import org.thingsboard.server.common.data.rule.RuleChainType; | ||
23 | import org.thingsboard.server.common.msg.TbMsg; | 26 | import org.thingsboard.server.common.msg.TbMsg; |
24 | 27 | ||
25 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.FAILURE; | ||
26 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
27 | - | ||
28 | @RuleNode( | 28 | @RuleNode( |
29 | type = ComponentType.TRANSFORMATION, | 29 | type = ComponentType.TRANSFORMATION, |
30 | name = "script", | 30 | name = "script", |
@@ -38,8 +38,7 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | @@ -38,8 +38,7 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | ||
38 | "<code>{ msg: <i style=\"color: #666;\">new payload</i>,<br/>   metadata: <i style=\"color: #666;\">new metadata</i>,<br/>   msgType: <i style=\"color: #666;\">new msgType</i> }</code><br/>" + | 38 | "<code>{ msg: <i style=\"color: #666;\">new payload</i>,<br/>   metadata: <i style=\"color: #666;\">new metadata</i>,<br/>   msgType: <i style=\"color: #666;\">new msgType</i> }</code><br/>" + |
39 | "All fields in resulting object are optional and will be taken from original message if not specified.", | 39 | "All fields in resulting object are optional and will be taken from original message if not specified.", |
40 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, | 40 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
41 | - configDirective = "tbTransformationNodeScriptConfig" | ||
42 | -) | 41 | + configDirective = "tbTransformationNodeScriptConfig") |
43 | public class TbTransformMsgNode extends TbAbstractTransformNode { | 42 | public class TbTransformMsgNode extends TbAbstractTransformNode { |
44 | 43 | ||
45 | private TbTransformMsgNodeConfiguration config; | 44 | private TbTransformMsgNodeConfiguration config; |