Commit 4bb56df51a747b78015a83dd1b21b9ee6ddef933
1 parent
85fcfef8
Added cassandra edge dao. Tests fixed
Showing
91 changed files
with
705 additions
and
427 deletions
... | ... | @@ -18,11 +18,16 @@ CREATE TABLE IF NOT EXISTS thingsboard.edge ( |
18 | 18 | id timeuuid, |
19 | 19 | tenant_id timeuuid, |
20 | 20 | customer_id timeuuid, |
21 | + root_rule_chain_id timeuuid, | |
22 | + type text, | |
21 | 23 | name text, |
24 | + label text, | |
22 | 25 | search_text text, |
26 | + routing_key text, | |
27 | + secret text, | |
23 | 28 | configuration text, |
24 | 29 | additional_info text, |
25 | - PRIMARY KEY (id, tenant_id) | |
30 | + PRIMARY KEY (id, tenant_id, customer_id, type) | |
26 | 31 | ); |
27 | 32 | |
28 | 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 | 37 | PRIMARY KEY ( tenant_id, name, id, customer_id, type) |
33 | 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 | 47 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_search_text AS |
36 | 48 | SELECT * |
37 | 49 | from thingsboard.edge |
... | ... | @@ -60,4 +72,22 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_customer_by_type_and_ |
60 | 72 | PRIMARY KEY ( customer_id, tenant_id, type, search_text, id ) |
61 | 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 | |
\ No newline at end of file | ||
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); | |
\ No newline at end of file | ... | ... |
... | ... | @@ -26,5 +26,19 @@ CREATE TABLE IF NOT EXISTS edge ( |
26 | 26 | routing_key varchar(255), |
27 | 27 | secret varchar(255), |
28 | 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 | 212 | @Getter |
213 | 213 | private boolean logControllerErrorStackTrace; |
214 | 214 | |
215 | + @Value("${edges.rpc.enabled}") | |
216 | + @Getter | |
217 | + private boolean edgesSupportEnabled; | |
215 | 218 | |
216 | 219 | @ExceptionHandler(ThingsboardException.class) |
217 | 220 | public void handleThingsboardException(ThingsboardException ex, HttpServletResponse response) { |
... | ... | @@ -745,6 +748,9 @@ public abstract class BaseController { |
745 | 748 | } |
746 | 749 | |
747 | 750 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, CustomerId customerId, ActionType edgeEventAction) { |
751 | + if (!edgesSupportEnabled) { | |
752 | + return; | |
753 | + } | |
748 | 754 | try { |
749 | 755 | sendNotificationMsgToEdgeService(tenantId, edgeId, null, json.writeValueAsString(customerId), EdgeEventType.EDGE, edgeEventAction); |
750 | 756 | } catch (Exception e) { |
... | ... | @@ -753,6 +759,9 @@ public abstract class BaseController { |
753 | 759 | } |
754 | 760 | |
755 | 761 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, CustomerId customerId, ActionType edgeEventAction) { |
762 | + if (!edgesSupportEnabled) { | |
763 | + return; | |
764 | + } | |
756 | 765 | EdgeEventType edgeEventType = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); |
757 | 766 | try { |
758 | 767 | if (edgeEventType != null) { |
... | ... | @@ -764,6 +773,9 @@ public abstract class BaseController { |
764 | 773 | } |
765 | 774 | |
766 | 775 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityRelation relation, ActionType edgeEventAction) { |
776 | + if (!edgesSupportEnabled) { | |
777 | + return; | |
778 | + } | |
767 | 779 | try { |
768 | 780 | if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && |
769 | 781 | !relation.getTo().getEntityType().equals(EntityType.EDGE)) { |
... | ... | @@ -779,6 +791,9 @@ public abstract class BaseController { |
779 | 791 | } |
780 | 792 | |
781 | 793 | protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, ActionType edgeEventAction) { |
794 | + if (!edgesSupportEnabled) { | |
795 | + return; | |
796 | + } | |
782 | 797 | EdgeEventType edgeEventType = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType()); |
783 | 798 | if (edgeEventType != null) { |
784 | 799 | sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, edgeEventType, edgeEventAction); | ... | ... |
... | ... | @@ -31,10 +31,8 @@ import org.thingsboard.server.common.data.Dashboard; |
31 | 31 | import org.thingsboard.server.common.data.DashboardInfo; |
32 | 32 | import org.thingsboard.server.common.data.EntityType; |
33 | 33 | import org.thingsboard.server.common.data.ShortCustomerInfo; |
34 | -import org.thingsboard.server.common.data.ShortEdgeInfo; | |
35 | 34 | import org.thingsboard.server.common.data.audit.ActionType; |
36 | 35 | import org.thingsboard.server.common.data.edge.Edge; |
37 | -import org.thingsboard.server.common.data.edge.EdgeEventType; | |
38 | 36 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
39 | 37 | import org.thingsboard.server.common.data.id.CustomerId; |
40 | 38 | import org.thingsboard.server.common.data.id.DashboardId; | ... | ... |
... | ... | @@ -88,9 +88,6 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { |
88 | 88 | private RuleChainService ruleChainService; |
89 | 89 | |
90 | 90 | @Autowired |
91 | - private RelationService relationService; | |
92 | - | |
93 | - @Autowired | |
94 | 91 | private EdgeEventService edgeEventService; |
95 | 92 | |
96 | 93 | @Autowired |
... | ... | @@ -135,12 +132,12 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { |
135 | 132 | EdgeEvent edgeEvent = new EdgeEvent(); |
136 | 133 | edgeEvent.setEdgeId(edgeId); |
137 | 134 | edgeEvent.setTenantId(tenantId); |
138 | - edgeEvent.setEdgeEventType(edgeEventType); | |
139 | - edgeEvent.setEdgeEventAction(edgeEventAction.name()); | |
135 | + edgeEvent.setType(edgeEventType); | |
136 | + edgeEvent.setAction(edgeEventAction.name()); | |
140 | 137 | if (entityId != null) { |
141 | 138 | edgeEvent.setEntityId(entityId.getId()); |
142 | 139 | } |
143 | - edgeEvent.setEntityBody(entityBody); | |
140 | + edgeEvent.setBody(entityBody); | |
144 | 141 | edgeEventService.saveAsync(edgeEvent); |
145 | 142 | } |
146 | 143 | ... | ... |
... | ... | @@ -307,7 +307,7 @@ public final class EdgeGrpcSession implements Closeable { |
307 | 307 | log.trace("Processing edge event [{}]", edgeEvent); |
308 | 308 | try { |
309 | 309 | DownlinkMsg downlinkMsg = null; |
310 | - ActionType edgeEventAction = ActionType.valueOf(edgeEvent.getEdgeEventAction()); | |
310 | + ActionType edgeEventAction = ActionType.valueOf(edgeEvent.getAction()); | |
311 | 311 | switch (edgeEventAction) { |
312 | 312 | case UPDATED: |
313 | 313 | case ADDED: |
... | ... | @@ -350,7 +350,7 @@ public final class EdgeGrpcSession implements Closeable { |
350 | 350 | |
351 | 351 | private DownlinkMsg processEntityExistsRequestMessage(EdgeEvent edgeEvent) { |
352 | 352 | DownlinkMsg downlinkMsg = null; |
353 | - if (EdgeEventType.DEVICE.equals(edgeEvent.getEdgeEventType())) { | |
353 | + if (EdgeEventType.DEVICE.equals(edgeEvent.getType())) { | |
354 | 354 | DeviceId deviceId = new DeviceId(edgeEvent.getEntityId()); |
355 | 355 | Device device = ctx.getDeviceService().findDeviceById(edge.getTenantId(), deviceId); |
356 | 356 | CustomerId customerId = getCustomerIdIfEdgeAssignedToCustomer(device); |
... | ... | @@ -365,7 +365,7 @@ public final class EdgeGrpcSession implements Closeable { |
365 | 365 | private DownlinkMsg processRpcCallMsg(EdgeEvent edgeEvent) { |
366 | 366 | log.trace("Executing processRpcCall, edgeEvent [{}]", edgeEvent); |
367 | 367 | DeviceRpcCallMsg deviceRpcCallMsg = |
368 | - ctx.getDeviceMsgConstructor().constructDeviceRpcCallMsg(edgeEvent.getEntityBody()); | |
368 | + ctx.getDeviceMsgConstructor().constructDeviceRpcCallMsg(edgeEvent.getBody()); | |
369 | 369 | return DownlinkMsg.newBuilder() |
370 | 370 | .addAllDeviceRpcCallMsg(Collections.singletonList(deviceRpcCallMsg)) |
371 | 371 | .build(); |
... | ... | @@ -373,7 +373,7 @@ public final class EdgeGrpcSession implements Closeable { |
373 | 373 | |
374 | 374 | private DownlinkMsg processCredentialsRequestMessage(EdgeEvent edgeEvent) { |
375 | 375 | DownlinkMsg downlinkMsg = null; |
376 | - if (EdgeEventType.DEVICE.equals(edgeEvent.getEdgeEventType())) { | |
376 | + if (EdgeEventType.DEVICE.equals(edgeEvent.getType())) { | |
377 | 377 | DeviceId deviceId = new DeviceId(edgeEvent.getEntityId()); |
378 | 378 | DeviceCredentialsRequestMsg deviceCredentialsRequestMsg = DeviceCredentialsRequestMsg.newBuilder() |
379 | 379 | .setDeviceIdMSB(deviceId.getId().getMostSignificantBits()) |
... | ... | @@ -409,7 +409,7 @@ public final class EdgeGrpcSession implements Closeable { |
409 | 409 | private DownlinkMsg processTelemetryMessage(EdgeEvent edgeEvent) { |
410 | 410 | log.trace("Executing processTelemetryMessage, edgeEvent [{}]", edgeEvent); |
411 | 411 | EntityId entityId = null; |
412 | - switch (edgeEvent.getEdgeEventType()) { | |
412 | + switch (edgeEvent.getType()) { | |
413 | 413 | case DEVICE: |
414 | 414 | entityId = new DeviceId(edgeEvent.getEntityId()); |
415 | 415 | break; |
... | ... | @@ -431,21 +431,21 @@ public final class EdgeGrpcSession implements Closeable { |
431 | 431 | } |
432 | 432 | DownlinkMsg downlinkMsg = null; |
433 | 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 | 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 | 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 | 442 | return downlinkMsg; |
443 | 443 | } |
444 | 444 | |
445 | 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 | 447 | log.trace("Executing processEntityMessage, edgeEvent [{}], edgeEventAction [{}], msgType [{}]", edgeEvent, edgeEventAction, msgType); |
448 | - switch (edgeEvent.getEdgeEventType()) { | |
448 | + switch (edgeEvent.getType()) { | |
449 | 449 | case EDGE: |
450 | 450 | // TODO: voba - add edge update logic |
451 | 451 | return null; |
... | ... | @@ -728,7 +728,7 @@ public final class EdgeGrpcSession implements Closeable { |
728 | 728 | } |
729 | 729 | |
730 | 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 | 732 | RelationUpdateMsg r = ctx.getRelationMsgConstructor().constructRelationUpdatedMsg(msgType, entityRelation); |
733 | 733 | return DownlinkMsg.newBuilder() |
734 | 734 | .addAllRelationUpdateMsg(Collections.singletonList(r)) |
... | ... | @@ -804,7 +804,7 @@ public final class EdgeGrpcSession implements Closeable { |
804 | 804 | } |
805 | 805 | |
806 | 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 | 808 | AdminSettingsUpdateMsg t = ctx.getAdminSettingsMsgConstructor().constructAdminSettingsUpdateMsg(adminSettings); |
809 | 809 | return DownlinkMsg.newBuilder() |
810 | 810 | .addAllAdminSettingsUpdateMsg(Collections.singletonList(t)) | ... | ... |
... | ... | @@ -534,12 +534,12 @@ public class DefaultSyncEdgeService implements SyncEdgeService { |
534 | 534 | EdgeEvent edgeEvent = new EdgeEvent(); |
535 | 535 | edgeEvent.setTenantId(tenantId); |
536 | 536 | edgeEvent.setEdgeId(edgeId); |
537 | - edgeEvent.setEdgeEventType(edgeEventType); | |
538 | - edgeEvent.setEdgeEventAction(edgeEventAction.name()); | |
537 | + edgeEvent.setType(edgeEventType); | |
538 | + edgeEvent.setAction(edgeEventAction.name()); | |
539 | 539 | if (entityId != null) { |
540 | 540 | edgeEvent.setEntityId(entityId.getId()); |
541 | 541 | } |
542 | - edgeEvent.setEntityBody(entityBody); | |
542 | + edgeEvent.setBody(entityBody); | |
543 | 543 | return edgeEventService.saveAsync(edgeEvent); |
544 | 544 | } |
545 | 545 | } | ... | ... |
... | ... | @@ -105,12 +105,12 @@ public abstract class BaseProcessor { |
105 | 105 | EdgeEvent edgeEvent = new EdgeEvent(); |
106 | 106 | edgeEvent.setTenantId(tenantId); |
107 | 107 | edgeEvent.setEdgeId(edgeId); |
108 | - edgeEvent.setEdgeEventType(edgeEventType); | |
109 | - edgeEvent.setEdgeEventAction(edgeEventAction.name()); | |
108 | + edgeEvent.setType(edgeEventType); | |
109 | + edgeEvent.setAction(edgeEventAction.name()); | |
110 | 110 | if (entityId != null) { |
111 | 111 | edgeEvent.setEntityId(entityId.getId()); |
112 | 112 | } |
113 | - edgeEvent.setEntityBody(entityBody); | |
113 | + edgeEvent.setBody(entityBody); | |
114 | 114 | return edgeEventService.saveAsync(edgeEvent); |
115 | 115 | } |
116 | 116 | } | ... | ... |
... | ... | @@ -30,6 +30,12 @@ public interface TbRuleEngineDeviceRpcService extends RuleEngineRpcService { |
30 | 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 | 39 | void sendRpcResponseToTbCore(String originServiceId, FromDeviceRpcResponse response); |
34 | 40 | |
35 | 41 | } | ... | ... |
... | ... | @@ -26,7 +26,6 @@ |
26 | 26 | </appender> |
27 | 27 | |
28 | 28 | <logger name="org.thingsboard.server" level="INFO" /> |
29 | - <logger name="org.thingsboard.server.service.edge" level="TRACE" /> | |
30 | 29 | |
31 | 30 | <!-- <logger name="org.thingsboard.server.service.queue" level="TRACE" />--> |
32 | 31 | <!-- <logger name="org.thingsboard.server.service.transport" level="TRACE" />--> | ... | ... |
... | ... | @@ -599,6 +599,7 @@ edges: |
599 | 599 | max_read_records_count: "${EDGES_RPC_STORAGE_MAX_READ_RECORDS_COUNT:50}" |
600 | 600 | no_read_records_sleep: "${EDGES_RPC_NO_READ_RECORDS_SLEEP:1000}" |
601 | 601 | sleep_between_batches: "${EDGES_RPC_SLEEP_BETWEEN_BATCHES:1000}" |
602 | + edge_events_ttl: "${EDGES_EDGE_EVENTS_TTL:0}" | |
602 | 603 | state: |
603 | 604 | persistToTelemetry: "${EDGES_PERSIST_STATE_TO_TELEMETRY:false}" |
604 | 605 | ... | ... |
... | ... | @@ -23,6 +23,7 @@ import io.jsonwebtoken.Header; |
23 | 23 | import io.jsonwebtoken.Jwt; |
24 | 24 | import io.jsonwebtoken.Jwts; |
25 | 25 | import lombok.extern.slf4j.Slf4j; |
26 | +import org.apache.commons.lang3.RandomStringUtils; | |
26 | 27 | import org.apache.commons.lang3.StringUtils; |
27 | 28 | import org.hamcrest.Matcher; |
28 | 29 | import org.junit.After; |
... | ... | @@ -62,6 +63,7 @@ import org.thingsboard.server.common.data.BaseData; |
62 | 63 | import org.thingsboard.server.common.data.Customer; |
63 | 64 | import org.thingsboard.server.common.data.Tenant; |
64 | 65 | import org.thingsboard.server.common.data.User; |
66 | +import org.thingsboard.server.common.data.edge.Edge; | |
65 | 67 | import org.thingsboard.server.common.data.id.TenantId; |
66 | 68 | import org.thingsboard.server.common.data.id.UUIDBased; |
67 | 69 | import org.thingsboard.server.common.data.page.TextPageLink; |
... | ... | @@ -498,4 +500,16 @@ public abstract class AbstractControllerTest { |
498 | 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 | 27 | import org.thingsboard.server.common.data.Tenant; |
28 | 28 | import org.thingsboard.server.common.data.User; |
29 | 29 | import org.thingsboard.server.common.data.asset.Asset; |
30 | +import org.thingsboard.server.common.data.edge.Edge; | |
30 | 31 | import org.thingsboard.server.common.data.id.CustomerId; |
31 | 32 | import org.thingsboard.server.common.data.page.TextPageData; |
32 | 33 | import org.thingsboard.server.common.data.page.TextPageLink; |
34 | +import org.thingsboard.server.common.data.page.TimePageData; | |
33 | 35 | import org.thingsboard.server.common.data.security.Authority; |
34 | 36 | import org.thingsboard.server.dao.model.ModelConstants; |
35 | 37 | import org.thingsboard.server.service.stats.DefaultRuleEngineStatisticsService; |
... | ... | @@ -690,4 +692,30 @@ public abstract class BaseAssetControllerTest extends AbstractControllerTest { |
690 | 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 | 15 | */ |
16 | 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 | 18 | import com.datastax.driver.core.utils.UUIDs; |
19 | +import com.fasterxml.jackson.core.type.TypeReference; | |
26 | 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 | 31 | import org.thingsboard.server.common.data.id.CustomerId; |
29 | 32 | import org.thingsboard.server.common.data.page.TextPageData; |
30 | 33 | import org.thingsboard.server.common.data.page.TextPageLink; |
31 | 34 | import org.thingsboard.server.common.data.page.TimePageData; |
32 | 35 | import org.thingsboard.server.common.data.page.TimePageLink; |
33 | 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 | 45 | public abstract class BaseDashboardControllerTest extends AbstractControllerTest { |
42 | 46 | |
... | ... | @@ -349,4 +353,30 @@ public abstract class BaseDashboardControllerTest extends AbstractControllerTest |
349 | 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 | 27 | import org.thingsboard.server.common.data.EntitySubtype; |
28 | 28 | import org.thingsboard.server.common.data.Tenant; |
29 | 29 | import org.thingsboard.server.common.data.User; |
30 | +import org.thingsboard.server.common.data.edge.Edge; | |
30 | 31 | import org.thingsboard.server.common.data.id.CustomerId; |
31 | 32 | import org.thingsboard.server.common.data.id.DeviceCredentialsId; |
32 | 33 | import org.thingsboard.server.common.data.id.DeviceId; |
33 | 34 | import org.thingsboard.server.common.data.page.TextPageData; |
34 | 35 | import org.thingsboard.server.common.data.page.TextPageLink; |
36 | +import org.thingsboard.server.common.data.page.TimePageData; | |
35 | 37 | import org.thingsboard.server.common.data.relation.EntityRelation; |
36 | 38 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
37 | 39 | import org.thingsboard.server.common.data.security.Authority; |
... | ... | @@ -849,4 +851,31 @@ public abstract class BaseDeviceControllerTest extends AbstractControllerTest { |
849 | 851 | doDelete("/api/tenant/" + savedDifferentTenant.getId().getId().toString()) |
850 | 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 | 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 | 83 | Device savedDevice = doPost("/api/device", device, Device.class); |
84 | 84 | |
85 | 85 | doPost("/api/edge/" + edge.getId().toString() + "/device/" + savedDevice.getId().toString(), Device.class); |
86 | + Thread.sleep(1000); | |
86 | 87 | |
87 | 88 | Asset asset = constructAsset("TestAsset", "default"); |
88 | 89 | Asset savedAsset = doPost("/api/asset", asset, Asset.class); |
89 | 90 | |
90 | 91 | doPost("/api/edge/" + edge.getId().toString() + "/asset/" + savedAsset.getId().toString(), Asset.class); |
92 | + Thread.sleep(1000); | |
91 | 93 | |
92 | 94 | EntityRelation relation = new EntityRelation(savedAsset.getId(), savedDevice.getId(), EntityRelation.CONTAINS_TYPE); |
93 | 95 | |
94 | 96 | doPost("/api/relation", relation); |
95 | - | |
96 | - Thread.sleep(2000); | |
97 | + Thread.sleep(1000); | |
97 | 98 | |
98 | 99 | List<EdgeEvent> edgeEvents = doGetTypedWithTimePageLink("/api/edge/" + edge.getId().toString() + "/events?", |
99 | 100 | new TypeReference<TimePageData<EdgeEvent>>() { |
100 | - }, new TimePageLink(5)).getData(); | |
101 | + }, new TimePageLink(4)).getData(); | |
101 | 102 | |
102 | 103 | Assert.assertFalse(edgeEvents.isEmpty()); |
103 | 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 | 111 | private Device constructDevice(String name, String type) { | ... | ... |
... | ... | @@ -31,11 +31,13 @@ import org.thingsboard.server.common.data.Device; |
31 | 31 | import org.thingsboard.server.common.data.EntityView; |
32 | 32 | import org.thingsboard.server.common.data.Tenant; |
33 | 33 | import org.thingsboard.server.common.data.User; |
34 | +import org.thingsboard.server.common.data.edge.Edge; | |
34 | 35 | import org.thingsboard.server.common.data.id.CustomerId; |
35 | 36 | import org.thingsboard.server.common.data.objects.AttributesEntityView; |
36 | 37 | import org.thingsboard.server.common.data.objects.TelemetryEntityView; |
37 | 38 | import org.thingsboard.server.common.data.page.TextPageData; |
38 | 39 | import org.thingsboard.server.common.data.page.TextPageLink; |
40 | +import org.thingsboard.server.common.data.page.TimePageData; | |
39 | 41 | import org.thingsboard.server.common.data.security.Authority; |
40 | 42 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
41 | 43 | import org.thingsboard.server.dao.model.ModelConstants; |
... | ... | @@ -52,7 +54,6 @@ import java.util.concurrent.TimeUnit; |
52 | 54 | import static org.hamcrest.Matchers.containsString; |
53 | 55 | import static org.junit.Assert.assertEquals; |
54 | 56 | import static org.junit.Assert.assertNotNull; |
55 | -import static org.junit.Assert.assertNull; | |
56 | 57 | import static org.junit.Assert.assertTrue; |
57 | 58 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
58 | 59 | import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; |
... | ... | @@ -552,4 +553,31 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
552 | 553 | |
553 | 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 | 27 | |
28 | 28 | @RunWith(ClasspathSuite.class) |
29 | 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 | 31 | public class ControllerNoSqlTestSuite { |
33 | 32 | |
34 | 33 | @ClassRule | ... | ... |
... | ... | @@ -27,8 +27,7 @@ import java.util.Arrays; |
27 | 27 | |
28 | 28 | @RunWith(ClasspathSuite.class) |
29 | 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 | 31 | public class MqttNoSqlTestSuite { |
33 | 32 | |
34 | 33 | @ClassRule | ... | ... |
... | ... | @@ -30,8 +30,7 @@ import java.util.Arrays; |
30 | 30 | */ |
31 | 31 | @RunWith(ClasspathSuite.class) |
32 | 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 | 34 | public class SystemNoSqlTestSuite { |
36 | 35 | |
37 | 36 | @ClassRule | ... | ... |
... | ... | @@ -16,15 +16,12 @@ |
16 | 16 | package org.thingsboard.server.common.data; |
17 | 17 | |
18 | 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 | 19 | import org.thingsboard.server.common.data.id.CustomerId; |
23 | 20 | import org.thingsboard.server.common.data.id.DashboardId; |
24 | -import org.thingsboard.server.common.data.id.EdgeId; | |
25 | 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 | 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 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.data.edge; |
17 | 17 | |
18 | -import com.fasterxml.jackson.annotation.JsonIgnore; | |
19 | 18 | import com.fasterxml.jackson.databind.JsonNode; |
20 | 19 | import lombok.EqualsAndHashCode; |
21 | 20 | import lombok.Getter; |
... | ... | @@ -25,8 +24,6 @@ import org.thingsboard.server.common.data.HasCustomerId; |
25 | 24 | import org.thingsboard.server.common.data.HasName; |
26 | 25 | import org.thingsboard.server.common.data.HasTenantId; |
27 | 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 | 27 | import org.thingsboard.server.common.data.id.CustomerId; |
31 | 28 | import org.thingsboard.server.common.data.id.EdgeId; |
32 | 29 | import org.thingsboard.server.common.data.id.RuleChainId; |
... | ... | @@ -70,11 +67,6 @@ public class Edge extends SearchTextBasedWithAdditionalInfo<EdgeId> implements H |
70 | 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 | 70 | @Override |
79 | 71 | public String getSearchText() { |
80 | 72 | return getName(); | ... | ... |
... | ... | @@ -29,10 +29,11 @@ public class EdgeEvent extends BaseData<EdgeEventId> { |
29 | 29 | |
30 | 30 | private TenantId tenantId; |
31 | 31 | private EdgeId edgeId; |
32 | - private String edgeEventAction; | |
32 | + private String action; | |
33 | 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 | 38 | public EdgeEvent() { |
38 | 39 | super(); | ... | ... |
... | ... | @@ -20,20 +20,13 @@ import com.fasterxml.jackson.databind.JsonNode; |
20 | 20 | import lombok.Data; |
21 | 21 | import lombok.EqualsAndHashCode; |
22 | 22 | import lombok.extern.slf4j.Slf4j; |
23 | -import org.thingsboard.server.common.data.EdgeUtils; | |
24 | 23 | import org.thingsboard.server.common.data.HasName; |
25 | 24 | import org.thingsboard.server.common.data.HasTenantId; |
26 | 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 | 26 | import org.thingsboard.server.common.data.id.RuleChainId; |
31 | 27 | import org.thingsboard.server.common.data.id.RuleNodeId; |
32 | 28 | import org.thingsboard.server.common.data.id.TenantId; |
33 | 29 | |
34 | -import java.util.HashSet; | |
35 | -import java.util.Set; | |
36 | - | |
37 | 30 | @Data |
38 | 31 | @EqualsAndHashCode(callSuper = true) |
39 | 32 | @Slf4j | ... | ... |
... | ... | @@ -56,7 +56,7 @@ public class BaseEdgeEventService implements EdgeEventService { |
56 | 56 | if (edgeEvent.getEdgeId() == null) { |
57 | 57 | throw new DataValidationException("Edge id should be specified!"); |
58 | 58 | } |
59 | - if (StringUtils.isEmpty(edgeEvent.getEdgeEventAction())) { | |
59 | + if (StringUtils.isEmpty(edgeEvent.getAction())) { | |
60 | 60 | throw new DataValidationException("Edge Event action should be specified!"); |
61 | 61 | } |
62 | 62 | } | ... | ... |
... | ... | @@ -15,13 +15,21 @@ |
15 | 15 | */ |
16 | 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 | 24 | import com.google.common.util.concurrent.Futures; |
19 | 25 | import com.google.common.util.concurrent.ListenableFuture; |
20 | 26 | import com.google.common.util.concurrent.MoreExecutors; |
21 | 27 | import lombok.extern.slf4j.Slf4j; |
22 | 28 | import org.springframework.beans.factory.annotation.Autowired; |
23 | 29 | import org.springframework.stereotype.Component; |
30 | +import org.thingsboard.server.common.data.Device; | |
24 | 31 | import org.thingsboard.server.common.data.EntitySubtype; |
32 | +import org.thingsboard.server.common.data.EntityType; | |
25 | 33 | import org.thingsboard.server.common.data.edge.Edge; |
26 | 34 | import org.thingsboard.server.common.data.id.DashboardId; |
27 | 35 | import org.thingsboard.server.common.data.id.RuleChainId; |
... | ... | @@ -29,17 +37,40 @@ import org.thingsboard.server.common.data.id.TenantId; |
29 | 37 | import org.thingsboard.server.common.data.page.TextPageLink; |
30 | 38 | import org.thingsboard.server.common.data.relation.EntityRelation; |
31 | 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 | 42 | import org.thingsboard.server.dao.model.nosql.EdgeEntity; |
33 | 43 | import org.thingsboard.server.dao.nosql.CassandraAbstractSearchTextDao; |
34 | 44 | import org.thingsboard.server.dao.relation.RelationDao; |
35 | 45 | import org.thingsboard.server.dao.util.NoSqlDao; |
36 | 46 | |
47 | +import javax.annotation.Nullable; | |
37 | 48 | import java.util.ArrayList; |
49 | +import java.util.Arrays; | |
50 | +import java.util.Collections; | |
38 | 51 | import java.util.List; |
39 | 52 | import java.util.Optional; |
40 | 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 | 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 | 75 | @Component |
45 | 76 | @Slf4j |
... | ... | @@ -59,50 +90,124 @@ public class CassandraEdgeDao extends CassandraAbstractSearchTextDao<EdgeEntity, |
59 | 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 | 103 | @Override |
64 | 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 | 113 | @Override |
69 | 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 | 123 | @Override |
74 | 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 | 133 | @Override |
79 | 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 | 145 | @Override |
84 | 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 | 158 | @Override |
89 | 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 | 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 | 178 | @Override |
99 | 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 | 204 | @Override |
104 | 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 | 213 | @Override | ... | ... |
... | ... | @@ -15,19 +15,38 @@ |
15 | 15 | */ |
16 | 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 | 23 | import com.google.common.util.concurrent.ListenableFuture; |
24 | +import com.google.common.util.concurrent.MoreExecutors; | |
19 | 25 | import lombok.extern.slf4j.Slf4j; |
26 | +import org.apache.commons.lang3.StringUtils; | |
27 | +import org.springframework.beans.factory.annotation.Value; | |
20 | 28 | import org.springframework.stereotype.Component; |
29 | +import org.thingsboard.server.common.data.audit.ActionType; | |
21 | 30 | import org.thingsboard.server.common.data.edge.EdgeEvent; |
31 | +import org.thingsboard.server.common.data.id.EdgeEventId; | |
22 | 32 | import org.thingsboard.server.common.data.id.EdgeId; |
33 | +import org.thingsboard.server.common.data.id.TenantId; | |
23 | 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 | 37 | import org.thingsboard.server.dao.model.nosql.EdgeEventEntity; |
25 | 38 | import org.thingsboard.server.dao.nosql.CassandraAbstractSearchTimeDao; |
26 | 39 | import org.thingsboard.server.dao.util.NoSqlDao; |
27 | 40 | |
41 | +import java.util.Arrays; | |
28 | 42 | import java.util.List; |
43 | +import java.util.Optional; | |
29 | 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 | 50 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_FAMILY_NAME; |
32 | 51 | |
33 | 52 | @Component |
... | ... | @@ -35,6 +54,8 @@ import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_ |
35 | 54 | @NoSqlDao |
36 | 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 | 60 | @Override |
40 | 61 | protected Class<EdgeEventEntity> getColumnFamilyClass() { |
... | ... | @@ -46,14 +67,61 @@ public class CassandraEdgeEventDao extends CassandraAbstractSearchTimeDao<EdgeEv |
46 | 67 | return EDGE_EVENT_COLUMN_FAMILY_NAME; |
47 | 68 | } |
48 | 69 | |
49 | - | |
50 | 70 | @Override |
51 | 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 | 110 | @Override |
56 | 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 | 368 | public static final String EDGE_TYPE_PROPERTY = "type"; |
369 | 369 | public static final String EDGE_CONFIGURATION_PROPERTY = "configuration"; |
370 | 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 | 378 | public static final String EDGE_ROUTING_KEY_PROPERTY = "routing_key"; |
373 | 379 | public static final String EDGE_SECRET_PROPERTY = "secret"; |
... | ... | @@ -380,8 +386,11 @@ public class ModelConstants { |
380 | 386 | public static final String EDGE_EVENT_EDGE_ID_PROPERTY = "edge_id"; |
381 | 387 | public static final String EDGE_EVENT_TYPE_PROPERTY = "edge_event_type"; |
382 | 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 | 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 | 396 | * Cassandra attributes and timeseries constants. | ... | ... |
... | ... | @@ -32,6 +32,9 @@ import org.thingsboard.server.dao.model.type.JsonCodec; |
32 | 32 | |
33 | 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 | 38 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_ADDITIONAL_INFO_PROPERTY; |
36 | 39 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_COLUMN_FAMILY_NAME; |
37 | 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 | 53 | @Table(name = EDGE_COLUMN_FAMILY_NAME) |
51 | 54 | public class EdgeEntity implements SearchTextEntity<Edge> { |
52 | 55 | |
53 | - @PartitionKey | |
56 | + @PartitionKey(value = 0) | |
54 | 57 | @Column(name = ID_PROPERTY) |
55 | 58 | private UUID id; |
56 | 59 | |
57 | - @ClusteringColumn | |
60 | + @PartitionKey(value = 1) | |
58 | 61 | @Column(name = EDGE_TENANT_ID_PROPERTY) |
59 | 62 | private UUID tenantId; |
60 | 63 | |
61 | - @ClusteringColumn | |
64 | + @PartitionKey(value = 2) | |
62 | 65 | @Column(name = EDGE_CUSTOMER_ID_PROPERTY) |
63 | 66 | private UUID customerId; |
64 | 67 | |
65 | 68 | @Column(name = EDGE_ROOT_RULE_CHAIN_ID_PROPERTY) |
66 | 69 | private UUID rootRuleChainId; |
67 | 70 | |
71 | + @PartitionKey(value = 3) | |
68 | 72 | @Column(name = EDGE_TYPE_PROPERTY) |
69 | 73 | private String type; |
70 | 74 | ... | ... |
... | ... | @@ -23,18 +23,13 @@ import com.datastax.driver.mapping.annotations.Table; |
23 | 23 | import com.fasterxml.jackson.databind.JsonNode; |
24 | 24 | import lombok.Data; |
25 | 25 | import lombok.NoArgsConstructor; |
26 | -import org.thingsboard.server.common.data.EntityType; | |
27 | -import org.thingsboard.server.common.data.Event; | |
28 | 26 | import org.thingsboard.server.common.data.edge.EdgeEvent; |
29 | 27 | import org.thingsboard.server.common.data.edge.EdgeEventType; |
30 | 28 | import org.thingsboard.server.common.data.id.EdgeEventId; |
31 | 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 | 30 | import org.thingsboard.server.common.data.id.TenantId; |
35 | 31 | import org.thingsboard.server.dao.model.BaseEntity; |
36 | 32 | import org.thingsboard.server.dao.model.type.EdgeEventTypeCodec; |
37 | -import org.thingsboard.server.dao.model.type.EntityTypeCodec; | |
38 | 33 | import org.thingsboard.server.dao.model.type.JsonCodec; |
39 | 34 | |
40 | 35 | import java.util.UUID; |
... | ... | @@ -42,17 +37,11 @@ import java.util.UUID; |
42 | 37 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ACTION_PROPERTY; |
43 | 38 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_FAMILY_NAME; |
44 | 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 | 41 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ENTITY_ID_PROPERTY; |
47 | 42 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_TENANT_ID_PROPERTY; |
48 | 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 | 45 | import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY; |
57 | 46 | |
58 | 47 | @Data |
... | ... | @@ -71,25 +60,23 @@ public class EdgeEventEntity implements BaseEntity<EdgeEvent> { |
71 | 60 | @Column(name = EDGE_EVENT_EDGE_ID_PROPERTY) |
72 | 61 | private UUID edgeId; |
73 | 62 | |
74 | - @PartitionKey(value = 2) | |
63 | + @ClusteringColumn() | |
75 | 64 | @Column(name = EDGE_EVENT_TYPE_PROPERTY, codec = EdgeEventTypeCodec.class) |
76 | 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 | 68 | @Column(name = EDGE_EVENT_ACTION_PROPERTY) |
84 | 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 | 81 | public EdgeEventEntity(EdgeEvent edgeEvent) { |
95 | 82 | if (edgeEvent.getId() != null) { |
... | ... | @@ -101,13 +88,11 @@ public class EdgeEventEntity implements BaseEntity<EdgeEvent> { |
101 | 88 | if (edgeEvent.getEdgeId() != null) { |
102 | 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 | 98 | @Override |
... | ... | @@ -123,13 +108,14 @@ public class EdgeEventEntity implements BaseEntity<EdgeEvent> { |
123 | 108 | @Override |
124 | 109 | public EdgeEvent toData() { |
125 | 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 | 119 | return edgeEvent; |
134 | 120 | } |
135 | 121 | } | ... | ... |
... | ... | @@ -41,11 +41,13 @@ import java.util.UUID; |
41 | 41 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ACTION_PROPERTY; |
42 | 42 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_COLUMN_FAMILY_NAME; |
43 | 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 | 45 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_ENTITY_ID_PROPERTY; |
46 | 46 | import static org.thingsboard.server.dao.model.ModelConstants.EDGE_EVENT_TENANT_ID_PROPERTY; |
47 | 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 | 49 | import static org.thingsboard.server.dao.model.ModelConstants.EPOCH_DIFF; |
50 | +import static org.thingsboard.server.dao.model.ModelConstants.EVENT_UID_PROPERTY; | |
49 | 51 | import static org.thingsboard.server.dao.model.ModelConstants.TS_COLUMN; |
50 | 52 | |
51 | 53 | @Data |
... | ... | @@ -73,9 +75,12 @@ public class EdgeEventEntity extends BaseSqlEntity<EdgeEvent> implements BaseEnt |
73 | 75 | private String edgeEventAction; |
74 | 76 | |
75 | 77 | @Type(type = "json") |
76 | - @Column(name = EDGE_EVENT_ENTITY_BODY_PROPERTY) | |
78 | + @Column(name = EDGE_EVENT_BODY_PROPERTY) | |
77 | 79 | private JsonNode entityBody; |
78 | 80 | |
81 | + @Column(name = EDGE_EVENT_UID_PROPERTY) | |
82 | + private String edgeEventUid; | |
83 | + | |
79 | 84 | @Column(name = TS_COLUMN) |
80 | 85 | private long ts; |
81 | 86 | |
... | ... | @@ -95,9 +100,10 @@ public class EdgeEventEntity extends BaseSqlEntity<EdgeEvent> implements BaseEnt |
95 | 100 | if (edgeEvent.getEntityId() != null) { |
96 | 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 | 109 | @Override |
... | ... | @@ -109,9 +115,10 @@ public class EdgeEventEntity extends BaseSqlEntity<EdgeEvent> implements BaseEnt |
109 | 115 | if (entityId != null) { |
110 | 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 | 122 | return edgeEvent; |
116 | 123 | } |
117 | 124 | ... | ... |
... | ... | @@ -35,8 +35,10 @@ import org.thingsboard.server.dao.model.type.ComponentLifecycleStateCodec; |
35 | 35 | import org.thingsboard.server.dao.model.type.ComponentScopeCodec; |
36 | 36 | import org.thingsboard.server.dao.model.type.ComponentTypeCodec; |
37 | 37 | import org.thingsboard.server.dao.model.type.DeviceCredentialsTypeCodec; |
38 | +import org.thingsboard.server.dao.model.type.EdgeEventTypeCodec; | |
38 | 39 | import org.thingsboard.server.dao.model.type.EntityTypeCodec; |
39 | 40 | import org.thingsboard.server.dao.model.type.JsonCodec; |
41 | +import org.thingsboard.server.dao.model.type.RuleChainTypeCodec; | |
40 | 42 | |
41 | 43 | import java.util.concurrent.ConcurrentHashMap; |
42 | 44 | import java.util.concurrent.ConcurrentMap; |
... | ... | @@ -71,6 +73,8 @@ public abstract class CassandraAbstractDao { |
71 | 73 | registerCodecIfNotFound(registry, new ComponentTypeCodec()); |
72 | 74 | registerCodecIfNotFound(registry, new ComponentScopeCodec()); |
73 | 75 | registerCodecIfNotFound(registry, new EntityTypeCodec()); |
76 | + registerCodecIfNotFound(registry, new EdgeEventTypeCodec()); | |
77 | + registerCodecIfNotFound(registry, new RuleChainTypeCodec()); | |
74 | 78 | } |
75 | 79 | return session; |
76 | 80 | } | ... | ... |
... | ... | @@ -19,14 +19,12 @@ import com.google.common.base.Function; |
19 | 19 | import com.google.common.util.concurrent.Futures; |
20 | 20 | import com.google.common.util.concurrent.ListenableFuture; |
21 | 21 | import com.google.common.util.concurrent.MoreExecutors; |
22 | -import jnr.ffi.annotations.In; | |
23 | 22 | import lombok.extern.slf4j.Slf4j; |
24 | 23 | import org.apache.commons.lang3.StringUtils; |
25 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
26 | 25 | import org.springframework.stereotype.Service; |
27 | 26 | import org.thingsboard.server.common.data.BaseData; |
28 | 27 | import org.thingsboard.server.common.data.EntityType; |
29 | -import org.thingsboard.server.common.data.ShortEdgeInfo; | |
30 | 28 | import org.thingsboard.server.common.data.Tenant; |
31 | 29 | import org.thingsboard.server.common.data.edge.Edge; |
32 | 30 | import org.thingsboard.server.common.data.id.EdgeId; |
... | ... | @@ -46,14 +44,11 @@ import org.thingsboard.server.common.data.rule.RuleChainConnectionInfo; |
46 | 44 | import org.thingsboard.server.common.data.rule.RuleChainMetaData; |
47 | 45 | import org.thingsboard.server.common.data.rule.RuleChainType; |
48 | 46 | import org.thingsboard.server.common.data.rule.RuleNode; |
49 | -import org.thingsboard.server.dao.edge.EdgeDao; | |
50 | 47 | import org.thingsboard.server.dao.edge.EdgeService; |
51 | 48 | import org.thingsboard.server.dao.entity.AbstractEntityService; |
52 | 49 | import org.thingsboard.server.dao.exception.DataValidationException; |
53 | -import org.thingsboard.server.dao.relation.RelationDao; | |
54 | 50 | import org.thingsboard.server.dao.service.DataValidator; |
55 | 51 | import org.thingsboard.server.dao.service.PaginatedRemover; |
56 | -import org.thingsboard.server.dao.service.TimePaginatedRemover; | |
57 | 52 | import org.thingsboard.server.dao.service.Validator; |
58 | 53 | import org.thingsboard.server.dao.tenant.TenantDao; |
59 | 54 | |
... | ... | @@ -65,7 +60,6 @@ import java.util.Map; |
65 | 60 | import java.util.concurrent.ExecutionException; |
66 | 61 | |
67 | 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 | 65 | * Created by igor on 3/12/18. | ... | ... |
... | ... | @@ -730,9 +730,13 @@ CREATE TABLE IF NOT EXISTS thingsboard.edge ( |
730 | 730 | id timeuuid, |
731 | 731 | tenant_id timeuuid, |
732 | 732 | customer_id timeuuid, |
733 | - name text, | |
733 | + root_rule_chain_id timeuuid, | |
734 | 734 | type text, |
735 | + name text, | |
736 | + label text, | |
735 | 737 | search_text text, |
738 | + routing_key text, | |
739 | + secret text, | |
736 | 740 | configuration text, |
737 | 741 | additional_info text, |
738 | 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 | 749 | PRIMARY KEY ( tenant_id, name, id, customer_id, type) |
746 | 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 | 759 | CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_search_text AS |
749 | 760 | SELECT * |
750 | 761 | from thingsboard.edge |
... | ... | @@ -772,3 +783,23 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_customer_by_type_and_ |
772 | 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 | 784 | PRIMARY KEY ( customer_id, tenant_id, type, search_text, id ) |
774 | 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 | 275 | id varchar(31) NOT NULL CONSTRAINT edge_event_pkey PRIMARY KEY, |
276 | 276 | edge_id varchar(31), |
277 | 277 | edge_event_type varchar(255), |
278 | + edge_event_uid varchar(255), | |
278 | 279 | entity_id varchar(31), |
279 | 280 | edge_event_action varchar(255), |
280 | - entity_body varchar(10000000), | |
281 | + body varchar(10000000), | |
281 | 282 | tenant_id varchar(31), |
282 | 283 | ts bigint NOT NULL |
283 | -); | |
\ No newline at end of file | ||
284 | +); | ... | ... |
... | ... | @@ -275,14 +275,16 @@ CREATE TABLE IF NOT EXISTS edge_event ( |
275 | 275 | id varchar(31) NOT NULL CONSTRAINT edge_event_pkey PRIMARY KEY, |
276 | 276 | edge_id varchar(31), |
277 | 277 | edge_event_type varchar(255), |
278 | + edge_event_uid varchar(255), | |
278 | 279 | entity_id varchar(31), |
279 | 280 | edge_event_action varchar(255), |
280 | - entity_body varchar(10000000), | |
281 | + body varchar(10000000), | |
281 | 282 | tenant_id varchar(31), |
282 | 283 | ts bigint NOT NULL |
283 | 284 | ); |
284 | 285 | |
285 | 286 | |
287 | + | |
286 | 288 | CREATE OR REPLACE PROCEDURE cleanup_events_by_ttl(IN ttl bigint, IN debug_ttl bigint, INOUT deleted bigint) |
287 | 289 | LANGUAGE plpgsql AS |
288 | 290 | $$ | ... | ... |
... | ... | @@ -25,8 +25,7 @@ import java.util.Arrays; |
25 | 25 | |
26 | 26 | @RunWith(ClasspathSuite.class) |
27 | 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 | 30 | public class NoSqlDaoServiceTestSuite { |
32 | 31 | ... | ... |
... | ... | @@ -46,9 +46,9 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest { |
46 | 46 | Assert.assertEquals(saved.getTenantId(), edgeEvent.getTenantId()); |
47 | 47 | Assert.assertEquals(saved.getEdgeId(), edgeEvent.getEdgeId()); |
48 | 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 | 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 | 59 | edgeEvent.setTenantId(tenantId); |
60 | 60 | edgeEvent.setEdgeId(edgeId); |
61 | 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 | 65 | return edgeEvent; |
66 | 66 | } |
67 | 67 | |
... | ... | @@ -109,7 +109,7 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest { |
109 | 109 | TimePageLink pageLink = new TimePageLink(1); |
110 | 110 | |
111 | 111 | EdgeEvent edgeEventWithTsUpdate = generateEdgeEvent(tenantId, edgeId, deviceId, ActionType.TIMESERIES_UPDATED.name()); |
112 | - edgeEventService.saveAsync(edgeEventWithTsUpdate); | |
112 | + edgeEventService.saveAsync(edgeEventWithTsUpdate).get(); | |
113 | 113 | |
114 | 114 | TimePageData<EdgeEvent> allEdgeEvents = edgeEventService.findEdgeEvents(tenantId, edgeId, pageLink, true); |
115 | 115 | TimePageData<EdgeEvent> edgeEventsWithoutTsUpdate = edgeEventService.findEdgeEvents(tenantId, edgeId, pageLink, false); | ... | ... |
... | ... | @@ -22,9 +22,13 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
22 | 22 | import org.thingsboard.rule.engine.api.TbNodeException; |
23 | 23 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
24 | 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 | 31 | import org.thingsboard.server.common.data.plugin.ComponentType; |
27 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
28 | 32 | import org.thingsboard.server.common.msg.TbMsg; |
29 | 33 | |
30 | 34 | @Slf4j |
... | ... | @@ -37,7 +41,8 @@ import org.thingsboard.server.common.msg.TbMsg; |
37 | 41 | "Will create new Customer if it doesn't exists and 'Create new Customer if not exists' is set to true.", |
38 | 42 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
39 | 43 | configDirective = "tbActionNodeAssignToCustomerConfig", |
40 | - icon = "add_circle") | |
44 | + icon = "add_circle" | |
45 | +) | |
41 | 46 | public class TbAssignToCustomerNode extends TbAbstractCustomerActionNode<TbAssignToCustomerNodeConfiguration> { |
42 | 47 | |
43 | 48 | @Override | ... | ... |
... | ... | @@ -29,7 +29,6 @@ import org.thingsboard.server.common.data.alarm.Alarm; |
29 | 29 | import org.thingsboard.server.common.data.alarm.AlarmStatus; |
30 | 30 | import org.thingsboard.server.common.data.id.AlarmId; |
31 | 31 | import org.thingsboard.server.common.data.plugin.ComponentType; |
32 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
33 | 32 | import org.thingsboard.server.common.msg.TbMsg; |
34 | 33 | |
35 | 34 | @Slf4j |
... | ... | @@ -46,7 +45,8 @@ import org.thingsboard.server.common.msg.TbMsg; |
46 | 45 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>'name = ' + metadata.customerName;</code>.", |
47 | 46 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
48 | 47 | configDirective = "tbActionNodeClearAlarmConfig", |
49 | - icon = "notifications_off") | |
48 | + icon = "notifications_off" | |
49 | +) | |
50 | 50 | public class TbClearAlarmNode extends TbAbstractAlarmNode<TbClearAlarmNodeConfiguration> { |
51 | 51 | |
52 | 52 | @Override | ... | ... |
... | ... | @@ -21,19 +21,18 @@ import com.google.gson.JsonElement; |
21 | 21 | import com.google.gson.JsonParser; |
22 | 22 | import com.google.gson.JsonPrimitive; |
23 | 23 | import lombok.extern.slf4j.Slf4j; |
24 | +import org.thingsboard.common.util.DonAsynchron; | |
24 | 25 | import org.thingsboard.rule.engine.api.EmptyNodeConfiguration; |
25 | 26 | import org.thingsboard.rule.engine.api.RuleNode; |
26 | 27 | import org.thingsboard.rule.engine.api.TbContext; |
27 | 28 | import org.thingsboard.rule.engine.api.TbNode; |
28 | 29 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
29 | 30 | import org.thingsboard.rule.engine.api.TbNodeException; |
30 | -import org.thingsboard.common.util.DonAsynchron; | |
31 | 31 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
32 | 32 | import org.thingsboard.server.common.data.DataConstants; |
33 | 33 | import org.thingsboard.server.common.data.EntityView; |
34 | 34 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
35 | 35 | import org.thingsboard.server.common.data.plugin.ComponentType; |
36 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
37 | 36 | import org.thingsboard.server.common.msg.TbMsg; |
38 | 37 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
39 | 38 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; |
... | ... | @@ -57,7 +56,8 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; |
57 | 56 | "Changes message originator to related entity view and produces new messages according to count of updated entity views", |
58 | 57 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
59 | 58 | configDirective = "tbNodeEmptyConfig", |
60 | - icon = "content_copy") | |
59 | + icon = "content_copy" | |
60 | +) | |
61 | 61 | public class TbCopyAttributesToEntityViewNode implements TbNode { |
62 | 62 | |
63 | 63 | EmptyNodeConfiguration config; | ... | ... |
... | ... | @@ -31,7 +31,6 @@ import org.thingsboard.server.common.data.alarm.Alarm; |
31 | 31 | import org.thingsboard.server.common.data.alarm.AlarmStatus; |
32 | 32 | import org.thingsboard.server.common.data.id.TenantId; |
33 | 33 | import org.thingsboard.server.common.data.plugin.ComponentType; |
34 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
35 | 34 | import org.thingsboard.server.common.msg.TbMsg; |
36 | 35 | |
37 | 36 | import java.io.IOException; |
... | ... | @@ -51,7 +50,8 @@ import java.util.List; |
51 | 50 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>'name = ' + metadata.customerName;</code>.", |
52 | 51 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
53 | 52 | configDirective = "tbActionNodeCreateAlarmConfig", |
54 | - icon = "notifications_active") | |
53 | + icon = "notifications_active" | |
54 | +) | |
55 | 55 | public class TbCreateAlarmNode extends TbAbstractAlarmNode<TbCreateAlarmNodeConfiguration> { |
56 | 56 | |
57 | 57 | private static ObjectMapper mapper = new ObjectMapper(); | ... | ... |
... | ... | @@ -34,7 +34,6 @@ import org.thingsboard.server.common.data.id.TenantId; |
34 | 34 | import org.thingsboard.server.common.data.plugin.ComponentType; |
35 | 35 | import org.thingsboard.server.common.data.relation.EntityRelation; |
36 | 36 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
37 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
38 | 37 | import org.thingsboard.server.common.msg.TbMsg; |
39 | 38 | |
40 | 39 | import java.util.ArrayList; |
... | ... | @@ -54,7 +53,8 @@ import java.util.List; |
54 | 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 | 54 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
56 | 55 | configDirective = "tbActionNodeCreateRelationConfig", |
57 | - icon = "add_circle") | |
56 | + icon = "add_circle" | |
57 | +) | |
58 | 58 | public class TbCreateRelationNode extends TbAbstractRelationActionNode<TbCreateRelationNodeConfiguration> { |
59 | 59 | |
60 | 60 | @Override | ... | ... |
... | ... | @@ -27,7 +27,6 @@ import org.thingsboard.rule.engine.util.EntityContainer; |
27 | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
28 | 28 | import org.thingsboard.server.common.data.relation.EntityRelation; |
29 | 29 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
30 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
31 | 30 | import org.thingsboard.server.common.msg.TbMsg; |
32 | 31 | |
33 | 32 | import java.util.ArrayList; |
... | ... | @@ -44,7 +43,8 @@ import java.util.List; |
44 | 43 | nodeDetails = "If the relation(s) successfully deleted - Message send via <b>Success</b> chain, otherwise <b>Failure</b> chain will be used.", |
45 | 44 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
46 | 45 | configDirective = "tbActionNodeDeleteRelationConfig", |
47 | - icon = "remove_circle") | |
46 | + icon = "remove_circle" | |
47 | +) | |
48 | 48 | public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteRelationNodeConfiguration> { |
49 | 49 | |
50 | 50 | @Override | ... | ... |
... | ... | @@ -17,14 +17,17 @@ package org.thingsboard.rule.engine.action; |
17 | 17 | |
18 | 18 | import lombok.extern.slf4j.Slf4j; |
19 | 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 | 26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
21 | -import org.thingsboard.rule.engine.api.*; | |
22 | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
23 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
24 | 28 | import org.thingsboard.server.common.msg.TbMsg; |
25 | 29 | |
26 | 30 | import static org.thingsboard.common.util.DonAsynchron.withCallback; |
27 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | |
28 | 31 | |
29 | 32 | @Slf4j |
30 | 33 | @RuleNode( |
... | ... | @@ -37,7 +40,8 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; |
37 | 40 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>'name = ' + metadata.customerName;</code>.", |
38 | 41 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
39 | 42 | configDirective = "tbActionNodeLogConfig", |
40 | - icon = "menu") | |
43 | + icon = "menu" | |
44 | +) | |
41 | 45 | public class TbLogNode implements TbNode { |
42 | 46 | |
43 | 47 | private TbLogNodeConfiguration config; | ... | ... |
... | ... | @@ -15,16 +15,17 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.rule.engine.action; |
17 | 17 | |
18 | -import com.datastax.driver.core.utils.UUIDs; | |
19 | 18 | import com.google.gson.Gson; |
20 | 19 | import com.google.gson.JsonObject; |
21 | 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 | 26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
24 | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
25 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
26 | 28 | import org.thingsboard.server.common.msg.TbMsg; |
27 | -import org.thingsboard.server.common.msg.TbMsgDataType; | |
28 | 29 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
29 | 30 | import org.thingsboard.server.common.msg.queue.ServiceQueue; |
30 | 31 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
... | ... | @@ -44,7 +45,8 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; |
44 | 45 | nodeDetails = "Count incoming messages for specified interval and produces POST_TELEMETRY_REQUEST msg with messages count", |
45 | 46 | icon = "functions", |
46 | 47 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
47 | - configDirective = "tbActionNodeMsgCountConfig") | |
48 | + configDirective = "tbActionNodeMsgCountConfig" | |
49 | +) | |
48 | 50 | public class TbMsgCountNode implements TbNode { |
49 | 51 | |
50 | 52 | private static final String TB_MSG_COUNT_NODE_MSG = "TbMsgCountNodeMsg"; | ... | ... |
... | ... | @@ -48,8 +48,10 @@ import org.thingsboard.server.dao.model.type.ComponentLifecycleStateCodec; |
48 | 48 | import org.thingsboard.server.dao.model.type.ComponentScopeCodec; |
49 | 49 | import org.thingsboard.server.dao.model.type.ComponentTypeCodec; |
50 | 50 | import org.thingsboard.server.dao.model.type.DeviceCredentialsTypeCodec; |
51 | +import org.thingsboard.server.dao.model.type.EdgeEventTypeCodec; | |
51 | 52 | import org.thingsboard.server.dao.model.type.EntityTypeCodec; |
52 | 53 | import org.thingsboard.server.dao.model.type.JsonCodec; |
54 | +import org.thingsboard.server.dao.model.type.RuleChainTypeCodec; | |
53 | 55 | import org.thingsboard.server.dao.nosql.CassandraStatementTask; |
54 | 56 | |
55 | 57 | import javax.annotation.Nullable; |
... | ... | @@ -144,6 +146,8 @@ public class TbSaveToCustomCassandraTableNode implements TbNode { |
144 | 146 | registerCodecIfNotFound(registry, new ComponentTypeCodec()); |
145 | 147 | registerCodecIfNotFound(registry, new ComponentScopeCodec()); |
146 | 148 | registerCodecIfNotFound(registry, new EntityTypeCodec()); |
149 | + registerCodecIfNotFound(registry, new EdgeEventTypeCodec()); | |
150 | + registerCodecIfNotFound(registry, new RuleChainTypeCodec()); | |
147 | 151 | } |
148 | 152 | return session; |
149 | 153 | } | ... | ... |
... | ... | @@ -24,10 +24,13 @@ import com.amazonaws.services.sns.model.PublishRequest; |
24 | 24 | import com.amazonaws.services.sns.model.PublishResult; |
25 | 25 | import com.google.common.util.concurrent.ListenableFuture; |
26 | 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 | 32 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
28 | -import org.thingsboard.rule.engine.api.*; | |
29 | 33 | import org.thingsboard.server.common.data.plugin.ComponentType; |
30 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
31 | 34 | import org.thingsboard.server.common.msg.TbMsg; |
32 | 35 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
33 | 36 | ... | ... |
... | ... | @@ -26,16 +26,18 @@ import com.amazonaws.services.sqs.model.SendMessageResult; |
26 | 26 | import com.google.common.util.concurrent.ListenableFuture; |
27 | 27 | import lombok.extern.slf4j.Slf4j; |
28 | 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 | 34 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
30 | -import org.thingsboard.rule.engine.api.*; | |
31 | 35 | import org.thingsboard.server.common.data.plugin.ComponentType; |
32 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
33 | 36 | import org.thingsboard.server.common.msg.TbMsg; |
34 | 37 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
35 | 38 | |
36 | 39 | import java.util.HashMap; |
37 | 40 | import java.util.Map; |
38 | -import java.util.concurrent.ExecutionException; | |
39 | 41 | |
40 | 42 | import static org.thingsboard.common.util.DonAsynchron.withCallback; |
41 | 43 | ... | ... |
... | ... | @@ -18,12 +18,16 @@ package org.thingsboard.rule.engine.debug; |
18 | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import lombok.extern.slf4j.Slf4j; |
20 | 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 | 27 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
22 | -import org.thingsboard.rule.engine.api.*; | |
23 | 28 | import org.thingsboard.server.common.data.id.EntityId; |
24 | 29 | import org.thingsboard.server.common.data.id.EntityIdFactory; |
25 | 30 | import org.thingsboard.server.common.data.plugin.ComponentType; |
26 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
27 | 31 | import org.thingsboard.server.common.msg.TbMsg; |
28 | 32 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
29 | 33 | import org.thingsboard.server.common.msg.queue.PartitionChangeMsg; | ... | ... |
... | ... | @@ -24,7 +24,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
24 | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | 25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
26 | 26 | import org.thingsboard.server.common.data.plugin.ComponentType; |
27 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
28 | 27 | import org.thingsboard.server.common.msg.TbMsg; |
29 | 28 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
30 | 29 | import org.thingsboard.server.common.msg.queue.ServiceQueue; |
... | ... | @@ -34,7 +33,6 @@ import java.util.Map; |
34 | 33 | import java.util.UUID; |
35 | 34 | import java.util.concurrent.TimeUnit; |
36 | 35 | |
37 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.FAILURE; | |
38 | 36 | import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; |
39 | 37 | |
40 | 38 | @Slf4j | ... | ... |
... | ... | @@ -154,10 +154,10 @@ public class TbMsgPushToEdgeNode implements TbNode { |
154 | 154 | private EdgeEvent buildEdgeEvent(TenantId tenantId, ActionType edgeEventAction, UUID entityId, EdgeEventType edgeEventType, JsonNode entityBody) { |
155 | 155 | EdgeEvent edgeEvent = new EdgeEvent(); |
156 | 156 | edgeEvent.setTenantId(tenantId); |
157 | - edgeEvent.setEdgeEventAction(edgeEventAction.name()); | |
157 | + edgeEvent.setAction(edgeEventAction.name()); | |
158 | 158 | edgeEvent.setEntityId(entityId); |
159 | - edgeEvent.setEdgeEventType(edgeEventType); | |
160 | - edgeEvent.setEntityBody(entityBody); | |
159 | + edgeEvent.setType(edgeEventType); | |
160 | + edgeEvent.setBody(entityBody); | |
161 | 161 | return edgeEvent; |
162 | 162 | } |
163 | 163 | ... | ... |
... | ... | @@ -24,7 +24,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
24 | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | 25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
26 | 26 | import org.thingsboard.server.common.data.plugin.ComponentType; |
27 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
28 | 27 | import org.thingsboard.server.common.msg.TbMsg; |
29 | 28 | |
30 | 29 | import java.util.List; |
... | ... | @@ -40,8 +39,7 @@ import java.util.Map; |
40 | 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 | 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 | 41 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
43 | - configDirective = "tbFilterNodeCheckMessageConfig" | |
44 | -) | |
42 | + configDirective = "tbFilterNodeCheckMessageConfig") | |
45 | 43 | public class TbCheckMessageNode implements TbNode { |
46 | 44 | |
47 | 45 | private static final Gson gson = new Gson(); | ... | ... |
... | ... | @@ -31,7 +31,6 @@ import org.thingsboard.server.common.data.plugin.ComponentType; |
31 | 31 | import org.thingsboard.server.common.data.relation.EntityRelation; |
32 | 32 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
33 | 33 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
34 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
35 | 34 | import org.thingsboard.server.common.msg.TbMsg; |
36 | 35 | |
37 | 36 | import java.util.List; |
... | ... | @@ -52,8 +51,7 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback; |
52 | 51 | " any relation to the originator of the message by type and direction.", |
53 | 52 | nodeDetails = "If at least one relation exists - send Message via <b>True</b> chain, otherwise <b>False</b> chain is used.", |
54 | 53 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
55 | - configDirective = "tbFilterNodeCheckRelationConfig" | |
56 | -) | |
54 | + configDirective = "tbFilterNodeCheckRelationConfig") | |
57 | 55 | public class TbCheckRelationNode implements TbNode { |
58 | 56 | |
59 | 57 | private TbCheckRelationNodeConfiguration config; | ... | ... |
... | ... | @@ -16,11 +16,14 @@ |
16 | 16 | package org.thingsboard.rule.engine.filter; |
17 | 17 | |
18 | 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 | 25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
21 | -import org.thingsboard.rule.engine.api.*; | |
22 | 26 | import org.thingsboard.server.common.data.plugin.ComponentType; |
23 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
24 | 27 | import org.thingsboard.server.common.msg.TbMsg; |
25 | 28 | |
26 | 29 | import static org.thingsboard.common.util.DonAsynchron.withCallback; |
... | ... | @@ -37,8 +40,7 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback; |
37 | 40 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>metadata.customerName === 'John';</code><br/>" + |
38 | 41 | "Message type can be accessed via <code>msgType</code> property.", |
39 | 42 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
40 | - configDirective = "tbFilterNodeScriptConfig" | |
41 | -) | |
43 | + configDirective = "tbFilterNodeScriptConfig") | |
42 | 44 | |
43 | 45 | public class TbJsFilterNode implements TbNode { |
44 | 46 | ... | ... |
... | ... | @@ -17,10 +17,14 @@ package org.thingsboard.rule.engine.filter; |
17 | 17 | |
18 | 18 | import lombok.extern.slf4j.Slf4j; |
19 | 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 | 26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
21 | -import org.thingsboard.rule.engine.api.*; | |
22 | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
23 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
24 | 28 | import org.thingsboard.server.common.msg.TbMsg; |
25 | 29 | |
26 | 30 | import java.util.Set; |
... | ... | @@ -40,8 +44,7 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback; |
40 | 44 | "Message metadata can be accessed via <code>metadata</code> property. For example <code>metadata.customerName === 'John';</code><br/>" + |
41 | 45 | "Message type can be accessed via <code>msgType</code> property.", |
42 | 46 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
43 | - configDirective = "tbFilterNodeSwitchConfig" | |
44 | -) | |
47 | + configDirective = "tbFilterNodeSwitchConfig") | |
45 | 48 | public class TbJsSwitchNode implements TbNode { |
46 | 49 | |
47 | 50 | private TbJsSwitchNodeConfiguration config; | ... | ... |
... | ... | @@ -16,10 +16,13 @@ |
16 | 16 | package org.thingsboard.rule.engine.filter; |
17 | 17 | |
18 | 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 | 24 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
20 | -import org.thingsboard.rule.engine.api.*; | |
21 | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
22 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
23 | 26 | import org.thingsboard.server.common.msg.TbMsg; |
24 | 27 | |
25 | 28 | /** |
... | ... | @@ -34,8 +37,7 @@ import org.thingsboard.server.common.msg.TbMsg; |
34 | 37 | nodeDescription = "Filter incoming messages by Message Type", |
35 | 38 | nodeDetails = "If incoming MessageType is expected - send Message via <b>True</b> chain, otherwise <b>False</b> chain is used.", |
36 | 39 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
37 | - configDirective = "tbFilterNodeMessageTypeConfig" | |
38 | -) | |
40 | + configDirective = "tbFilterNodeMessageTypeConfig") | |
39 | 41 | public class TbMsgTypeFilterNode implements TbNode { |
40 | 42 | |
41 | 43 | TbMsgTypeFilterNodeConfiguration config; | ... | ... |
... | ... | @@ -25,7 +25,6 @@ import org.thingsboard.rule.engine.api.TbNodeException; |
25 | 25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
26 | 26 | import org.thingsboard.server.common.data.DataConstants; |
27 | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
28 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
29 | 28 | import org.thingsboard.server.common.msg.TbMsg; |
30 | 29 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
31 | 30 | |
... | ... | @@ -40,8 +39,7 @@ import org.thingsboard.server.common.msg.session.SessionMsgType; |
40 | 39 | nodeDescription = "Route incoming messages by Message Type", |
41 | 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 | 41 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
43 | - configDirective = "tbNodeEmptyConfig" | |
44 | -) | |
42 | + configDirective = "tbNodeEmptyConfig") | |
45 | 43 | public class TbMsgTypeSwitchNode implements TbNode { |
46 | 44 | |
47 | 45 | EmptyNodeConfiguration config; | ... | ... |
... | ... | @@ -16,11 +16,14 @@ |
16 | 16 | package org.thingsboard.rule.engine.filter; |
17 | 17 | |
18 | 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 | 24 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
20 | -import org.thingsboard.rule.engine.api.*; | |
21 | 25 | import org.thingsboard.server.common.data.EntityType; |
22 | 26 | import org.thingsboard.server.common.data.plugin.ComponentType; |
23 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
24 | 27 | import org.thingsboard.server.common.msg.TbMsg; |
25 | 28 | |
26 | 29 | @Slf4j |
... | ... | @@ -32,8 +35,7 @@ import org.thingsboard.server.common.msg.TbMsg; |
32 | 35 | nodeDescription = "Filter incoming messages by message Originator Type", |
33 | 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 | 37 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
35 | - configDirective = "tbFilterNodeOriginatorTypeConfig" | |
36 | -) | |
38 | + configDirective = "tbFilterNodeOriginatorTypeConfig") | |
37 | 39 | public class TbOriginatorTypeFilterNode implements TbNode { |
38 | 40 | |
39 | 41 | TbOriginatorTypeFilterNodeConfiguration config; | ... | ... |
... | ... | @@ -16,11 +16,15 @@ |
16 | 16 | package org.thingsboard.rule.engine.filter; |
17 | 17 | |
18 | 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 | 25 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
20 | -import org.thingsboard.rule.engine.api.*; | |
21 | 26 | import org.thingsboard.server.common.data.EntityType; |
22 | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
23 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
24 | 28 | import org.thingsboard.server.common.msg.TbMsg; |
25 | 29 | |
26 | 30 | @Slf4j |
... | ... | @@ -32,8 +36,7 @@ import org.thingsboard.server.common.msg.TbMsg; |
32 | 36 | nodeDescription = "Route incoming messages by Message Originator Type", |
33 | 37 | nodeDetails = "Routes messages to chain according to the originator type ('Device', 'Asset', etc.).", |
34 | 38 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
35 | - configDirective = "tbNodeEmptyConfig" | |
36 | -) | |
39 | + configDirective = "tbNodeEmptyConfig") | |
37 | 40 | public class TbOriginatorTypeSwitchNode implements TbNode { |
38 | 41 | |
39 | 42 | EmptyNodeConfiguration config; | ... | ... |
... | ... | @@ -26,10 +26,13 @@ import com.google.protobuf.ByteString; |
26 | 26 | import com.google.pubsub.v1.ProjectTopicName; |
27 | 27 | import com.google.pubsub.v1.PubsubMessage; |
28 | 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 | 34 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
31 | 35 | import org.thingsboard.server.common.data.plugin.ComponentType; |
32 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
33 | 36 | import org.thingsboard.server.common.msg.TbMsg; |
34 | 37 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
35 | 38 | |
... | ... | @@ -37,8 +40,6 @@ import java.io.ByteArrayInputStream; |
37 | 40 | import java.io.IOException; |
38 | 41 | import java.util.concurrent.TimeUnit; |
39 | 42 | |
40 | -import static org.thingsboard.common.util.DonAsynchron.withCallback; | |
41 | - | |
42 | 43 | @Slf4j |
43 | 44 | @RuleNode( |
44 | 45 | type = ComponentType.EXTERNAL, | ... | ... |
... | ... | @@ -28,7 +28,6 @@ import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
28 | 28 | import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; |
29 | 29 | import org.thingsboard.server.common.data.kv.StringDataEntry; |
30 | 30 | import org.thingsboard.server.common.data.plugin.ComponentType; |
31 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
32 | 31 | import org.thingsboard.server.common.msg.TbMsg; |
33 | 32 | |
34 | 33 | import java.util.Collections; | ... | ... |
... | ... | @@ -15,32 +15,13 @@ |
15 | 15 | */ |
16 | 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 | 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 | 19 | import org.thingsboard.rule.engine.api.RuleNode; |
31 | 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 | 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 | 22 | import org.thingsboard.server.common.data.plugin.ComponentType; |
38 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
39 | 23 | import org.thingsboard.server.common.msg.TbMsg; |
40 | 24 | |
41 | -import java.util.Collections; | |
42 | -import java.util.List; | |
43 | - | |
44 | 25 | /** |
45 | 26 | * Created by ashvayka on 19.01.18. |
46 | 27 | */ |
... | ... | @@ -53,8 +34,7 @@ import java.util.List; |
53 | 34 | nodeDescription = "Filter incoming messages by GPS based geofencing", |
54 | 35 | nodeDetails = "Extracts latitude and longitude parameters from incoming message and returns 'True' if they are inside configured perimeters, 'False' otherwise.", |
55 | 36 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
56 | - configDirective = "tbFilterNodeGpsGeofencingConfig" | |
57 | -) | |
37 | + configDirective = "tbFilterNodeGpsGeofencingConfig") | |
58 | 38 | public class TbGpsGeofencingFilterNode extends AbstractGeofencingNode<TbGpsGeofencingFilterNodeConfiguration> { |
59 | 39 | |
60 | 40 | @Override | ... | ... |
... | ... | @@ -33,7 +33,6 @@ import org.thingsboard.rule.engine.api.TbNodeException; |
33 | 33 | import org.thingsboard.rule.engine.api.TbRelationTypes; |
34 | 34 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
35 | 35 | import org.thingsboard.server.common.data.plugin.ComponentType; |
36 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
37 | 36 | import org.thingsboard.server.common.msg.TbMsg; |
38 | 37 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
39 | 38 | ... | ... |
... | ... | @@ -19,10 +19,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; |
19 | 19 | import com.fasterxml.jackson.databind.ObjectMapper; |
20 | 20 | import lombok.extern.slf4j.Slf4j; |
21 | 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 | 27 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
23 | -import org.thingsboard.rule.engine.api.*; | |
24 | 28 | import org.thingsboard.server.common.data.plugin.ComponentType; |
25 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
26 | 29 | import org.thingsboard.server.common.msg.TbMsg; |
27 | 30 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
28 | 31 | ... | ... |
... | ... | @@ -27,7 +27,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
27 | 27 | import org.thingsboard.rule.engine.api.TbNodeException; |
28 | 28 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
29 | 29 | import org.thingsboard.server.common.data.plugin.ComponentType; |
30 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
31 | 30 | import org.thingsboard.server.common.msg.TbMsg; |
32 | 31 | |
33 | 32 | import javax.mail.internet.MimeMessage; | ... | ... |
... | ... | @@ -18,14 +18,13 @@ package org.thingsboard.rule.engine.metadata; |
18 | 18 | import com.google.common.util.concurrent.Futures; |
19 | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | 20 | import lombok.extern.slf4j.Slf4j; |
21 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
22 | 21 | import org.thingsboard.rule.engine.api.RuleNode; |
23 | 22 | import org.thingsboard.rule.engine.api.TbContext; |
24 | 23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
25 | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | +import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
26 | 26 | import org.thingsboard.server.common.data.id.EntityId; |
27 | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
28 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
29 | 28 | import org.thingsboard.server.common.msg.TbMsg; |
30 | 29 | |
31 | 30 | /** |
... | ... | @@ -41,8 +40,7 @@ import org.thingsboard.server.common.msg.TbMsg; |
41 | 40 | "To access those attributes in other nodes this template can be used " + |
42 | 41 | "<code>metadata.cs_temperature</code> or <code>metadata.shared_limit</code> ", |
43 | 42 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
44 | - configDirective = "tbEnrichmentNodeOriginatorAttributesConfig" | |
45 | -) | |
43 | + configDirective = "tbEnrichmentNodeOriginatorAttributesConfig") | |
46 | 44 | public class TbGetAttributesNode extends TbAbstractGetAttributesNode<TbGetAttributesNodeConfiguration, EntityId> { |
47 | 45 | |
48 | 46 | @Override | ... | ... |
... | ... | @@ -22,7 +22,6 @@ import org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader; |
22 | 22 | import org.thingsboard.server.common.data.id.CustomerId; |
23 | 23 | import org.thingsboard.server.common.data.id.EntityId; |
24 | 24 | import org.thingsboard.server.common.data.plugin.ComponentType; |
25 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
26 | 25 | |
27 | 26 | @RuleNode( |
28 | 27 | type = ComponentType.ENRICHMENT, |
... | ... | @@ -34,8 +33,7 @@ import org.thingsboard.server.common.data.rule.RuleChainType; |
34 | 33 | "To access those attributes in other nodes this template can be used " + |
35 | 34 | "<code>metadata.temperature</code>.", |
36 | 35 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
37 | - configDirective = "tbEnrichmentNodeCustomerAttributesConfig" | |
38 | -) | |
36 | + configDirective = "tbEnrichmentNodeCustomerAttributesConfig") | |
39 | 37 | public class TbGetCustomerAttributeNode extends TbEntityGetAttrNode<CustomerId> { |
40 | 38 | |
41 | 39 | @Override | ... | ... |
... | ... | @@ -31,7 +31,6 @@ import org.thingsboard.server.common.data.id.DeviceId; |
31 | 31 | import org.thingsboard.server.common.data.id.EdgeId; |
32 | 32 | import org.thingsboard.server.common.data.id.EntityViewId; |
33 | 33 | import org.thingsboard.server.common.data.plugin.ComponentType; |
34 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
35 | 34 | import org.thingsboard.server.common.msg.TbMsg; |
36 | 35 | |
37 | 36 | @Slf4j |
... | ... | @@ -43,8 +42,7 @@ import org.thingsboard.server.common.msg.TbMsg; |
43 | 42 | "<b>Note:</b> only Device, Asset, and Entity View type are allowed.<br><br>" + |
44 | 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 | 44 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
46 | - configDirective = "tbEnrichmentNodeEntityDetailsConfig" | |
47 | -) | |
45 | + configDirective = "tbEnrichmentNodeEntityDetailsConfig") | |
48 | 46 | public class TbGetCustomerDetailsNode extends TbAbstractGetEntityDetailsNode<TbGetCustomerDetailsNodeConfiguration> { |
49 | 47 | |
50 | 48 | private static final String CUSTOMER_PREFIX = "customer_"; | ... | ... |
... | ... | @@ -17,16 +17,14 @@ package org.thingsboard.rule.engine.metadata; |
17 | 17 | |
18 | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | 19 | import lombok.extern.slf4j.Slf4j; |
20 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
21 | 20 | import org.thingsboard.rule.engine.api.RuleNode; |
22 | 21 | import org.thingsboard.rule.engine.api.TbContext; |
23 | 22 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
24 | 23 | import org.thingsboard.rule.engine.api.TbNodeException; |
24 | +import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
25 | 25 | import org.thingsboard.rule.engine.util.EntitiesRelatedDeviceIdAsyncLoader; |
26 | 26 | import org.thingsboard.server.common.data.id.DeviceId; |
27 | -import org.thingsboard.server.common.data.id.EntityId; | |
28 | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
29 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
30 | 28 | import org.thingsboard.server.common.msg.TbMsg; |
31 | 29 | |
32 | 30 | @Slf4j |
... | ... | @@ -39,8 +37,7 @@ import org.thingsboard.server.common.msg.TbMsg; |
39 | 37 | "To access those attributes in other nodes this template can be used " + |
40 | 38 | "<code>metadata.cs_temperature</code> or <code>metadata.shared_limit</code> ", |
41 | 39 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
42 | - configDirective = "tbEnrichmentNodeDeviceAttributesConfig" | |
43 | -) | |
40 | + configDirective = "tbEnrichmentNodeDeviceAttributesConfig") | |
44 | 41 | public class TbGetDeviceAttrNode extends TbAbstractGetAttributesNode<TbGetDeviceAttrNodeConfiguration, DeviceId> { |
45 | 42 | |
46 | 43 | @Override | ... | ... |
... | ... | @@ -28,11 +28,9 @@ import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
28 | 28 | import org.thingsboard.rule.engine.util.EntitiesFieldsAsyncLoader; |
29 | 29 | import org.thingsboard.server.common.data.id.EntityId; |
30 | 30 | import org.thingsboard.server.common.data.plugin.ComponentType; |
31 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
32 | 31 | import org.thingsboard.server.common.msg.TbMsg; |
33 | 32 | |
34 | 33 | import static org.thingsboard.common.util.DonAsynchron.withCallback; |
35 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | |
36 | 34 | |
37 | 35 | /** |
38 | 36 | * Created by ashvayka on 19.01.18. |
... | ... | @@ -44,8 +42,7 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; |
44 | 42 | nodeDescription = "Add Message Originator fields values into Message Metadata", |
45 | 43 | nodeDetails = "Will fetch fields values specified in mapping. If specified field is not part of originator fields it will be ignored.", |
46 | 44 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
47 | - configDirective = "tbEnrichmentNodeOriginatorFieldsConfig" | |
48 | -) | |
45 | + configDirective = "tbEnrichmentNodeOriginatorFieldsConfig") | |
49 | 46 | public class TbGetOriginatorFieldsNode implements TbNode { |
50 | 47 | |
51 | 48 | private TbGetOriginatorFieldsConfiguration config; | ... | ... |
... | ... | @@ -16,13 +16,14 @@ |
16 | 16 | package org.thingsboard.rule.engine.metadata; |
17 | 17 | |
18 | 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 | 23 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
20 | -import org.thingsboard.rule.engine.api.*; | |
21 | 24 | import org.thingsboard.rule.engine.util.EntitiesRelatedEntityIdAsyncLoader; |
22 | - | |
23 | 25 | import org.thingsboard.server.common.data.id.EntityId; |
24 | 26 | import org.thingsboard.server.common.data.plugin.ComponentType; |
25 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
26 | 27 | |
27 | 28 | @RuleNode( |
28 | 29 | type = ComponentType.ENRICHMENT, |
... | ... | @@ -36,8 +37,7 @@ import org.thingsboard.server.common.data.rule.RuleChainType; |
36 | 37 | "To access those attributes in other nodes this template can be used " + |
37 | 38 | "<code>metadata.temperature</code>.", |
38 | 39 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
39 | - configDirective = "tbEnrichmentNodeRelatedAttributesConfig" | |
40 | -) | |
40 | + configDirective = "tbEnrichmentNodeRelatedAttributesConfig") | |
41 | 41 | |
42 | 42 | public class TbGetRelatedAttributeNode extends TbEntityGetAttrNode<EntityId> { |
43 | 43 | ... | ... |
... | ... | @@ -38,7 +38,6 @@ import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery; |
38 | 38 | import org.thingsboard.server.common.data.kv.ReadTsKvQuery; |
39 | 39 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
40 | 40 | import org.thingsboard.server.common.data.plugin.ComponentType; |
41 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
42 | 41 | import org.thingsboard.server.common.msg.TbMsg; |
43 | 42 | |
44 | 43 | import java.io.IOException; |
... | ... | @@ -47,7 +46,6 @@ import java.util.concurrent.ExecutionException; |
47 | 46 | import java.util.concurrent.TimeUnit; |
48 | 47 | import java.util.stream.Collectors; |
49 | 48 | |
50 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | |
51 | 49 | import static org.thingsboard.rule.engine.metadata.TbGetTelemetryNodeConfiguration.FETCH_MODE_ALL; |
52 | 50 | import static org.thingsboard.rule.engine.metadata.TbGetTelemetryNodeConfiguration.FETCH_MODE_FIRST; |
53 | 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 | 65 | "Also, the rule node allows you to select telemetry sampling order: <b>ASC</b> or <b>DESC</b>. </br>" + |
68 | 66 | "<b>Note</b>: The maximum size of the fetched array is 1000 records.\n ", |
69 | 67 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
70 | - configDirective = "tbEnrichmentNodeGetTelemetryFromDatabase" | |
71 | -) | |
68 | + configDirective = "tbEnrichmentNodeGetTelemetryFromDatabase") | |
72 | 69 | public class TbGetTelemetryNode implements TbNode { |
73 | 70 | |
74 | 71 | private static final String DESC_ORDER = "DESC"; | ... | ... |
... | ... | @@ -23,7 +23,6 @@ import org.thingsboard.rule.engine.util.EntitiesTenantIdAsyncLoader; |
23 | 23 | import org.thingsboard.server.common.data.id.EntityId; |
24 | 24 | import org.thingsboard.server.common.data.id.TenantId; |
25 | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
26 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
27 | 26 | |
28 | 27 | @Slf4j |
29 | 28 | @RuleNode( |
... | ... | @@ -36,8 +35,7 @@ import org.thingsboard.server.common.data.rule.RuleChainType; |
36 | 35 | "To access those attributes in other nodes this template can be used " + |
37 | 36 | "<code>metadata.temperature</code>.", |
38 | 37 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
39 | - configDirective = "tbEnrichmentNodeTenantAttributesConfig" | |
40 | -) | |
38 | + configDirective = "tbEnrichmentNodeTenantAttributesConfig") | |
41 | 39 | public class TbGetTenantAttributeNode extends TbEntityGetAttrNode<TenantId> { |
42 | 40 | |
43 | 41 | @Override | ... | ... |
... | ... | @@ -26,7 +26,6 @@ import org.thingsboard.rule.engine.api.TbNodeException; |
26 | 26 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
27 | 27 | import org.thingsboard.server.common.data.ContactBased; |
28 | 28 | import org.thingsboard.server.common.data.plugin.ComponentType; |
29 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
30 | 29 | import org.thingsboard.server.common.msg.TbMsg; |
31 | 30 | |
32 | 31 | @Slf4j |
... | ... | @@ -38,8 +37,7 @@ import org.thingsboard.server.common.msg.TbMsg; |
38 | 37 | "<b>Note:</b> only Device, Asset, and Entity View type are allowed.<br><br>" + |
39 | 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 | 39 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
41 | - configDirective = "tbEnrichmentNodeEntityDetailsConfig" | |
42 | -) | |
40 | + configDirective = "tbEnrichmentNodeEntityDetailsConfig") | |
43 | 41 | public class TbGetTenantDetailsNode extends TbAbstractGetEntityDetailsNode<TbGetTenantDetailsNodeConfiguration> { |
44 | 42 | |
45 | 43 | private static final String TENANT_PREFIX = "tenant_"; | ... | ... |
... | ... | @@ -21,14 +21,17 @@ import io.netty.handler.ssl.SslContext; |
21 | 21 | import io.netty.handler.ssl.SslContextBuilder; |
22 | 22 | import io.netty.util.concurrent.Future; |
23 | 23 | import lombok.extern.slf4j.Slf4j; |
24 | +import org.springframework.util.StringUtils; | |
24 | 25 | import org.thingsboard.mqtt.MqttClient; |
25 | 26 | import org.thingsboard.mqtt.MqttClientConfig; |
26 | 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 | 33 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
29 | -import org.thingsboard.rule.engine.api.*; | |
30 | 34 | import org.thingsboard.server.common.data.plugin.ComponentType; |
31 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
32 | 35 | import org.thingsboard.server.common.msg.TbMsg; |
33 | 36 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
34 | 37 | ... | ... |
... | ... | @@ -16,18 +16,24 @@ |
16 | 16 | package org.thingsboard.rule.engine.rabbitmq; |
17 | 17 | |
18 | 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 | 24 | import lombok.extern.slf4j.Slf4j; |
21 | 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 | 31 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
23 | -import org.thingsboard.rule.engine.api.*; | |
24 | 32 | import org.thingsboard.server.common.data.plugin.ComponentType; |
25 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
26 | 33 | import org.thingsboard.server.common.msg.TbMsg; |
27 | 34 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
28 | 35 | |
29 | 36 | import java.nio.charset.Charset; |
30 | -import java.util.concurrent.ExecutionException; | |
31 | 37 | |
32 | 38 | import static org.thingsboard.common.util.DonAsynchron.withCallback; |
33 | 39 | ... | ... |
... | ... | @@ -23,7 +23,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
23 | 23 | import org.thingsboard.rule.engine.api.TbNodeException; |
24 | 24 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
25 | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
26 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
27 | 26 | import org.thingsboard.server.common.msg.TbMsg; |
28 | 27 | |
29 | 28 | @Slf4j | ... | ... |
... | ... | @@ -17,16 +17,14 @@ package org.thingsboard.rule.engine.rpc; |
17 | 17 | |
18 | 18 | import lombok.extern.slf4j.Slf4j; |
19 | 19 | import org.springframework.util.StringUtils; |
20 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
21 | 20 | import org.thingsboard.rule.engine.api.RuleNode; |
22 | 21 | import org.thingsboard.rule.engine.api.TbContext; |
23 | 22 | import org.thingsboard.rule.engine.api.TbNode; |
24 | 23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
25 | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | +import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
26 | 26 | import org.thingsboard.server.common.data.EntityType; |
27 | -import org.thingsboard.server.common.data.id.DeviceId; | |
28 | 27 | import org.thingsboard.server.common.data.plugin.ComponentType; |
29 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
30 | 28 | import org.thingsboard.server.common.msg.TbMsg; |
31 | 29 | |
32 | 30 | import java.util.UUID; | ... | ... |
... | ... | @@ -145,19 +145,21 @@ public class TbSendRPCRequestNode implements TbNode { |
145 | 145 | List<EntityRelation> result = |
146 | 146 | ctx.getRelationService().findByToAndType(ctx.getTenantId(), msg.getOriginator(), EntityRelation.EDGE_TYPE, RelationTypeGroup.COMMON); |
147 | 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 | 156 | private void sendRpcRequestToEdgeDevice(TbContext ctx, TbMsg msg, EdgeId edgeId, RuleEngineDeviceRpcRequest request) { |
155 | 157 | EdgeEvent edgeEvent = new EdgeEvent(); |
156 | 158 | edgeEvent.setTenantId(ctx.getTenantId()); |
157 | - edgeEvent.setEdgeEventAction(ActionType.RPC_CALL.name()); | |
159 | + edgeEvent.setAction(ActionType.RPC_CALL.name()); | |
158 | 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 | 163 | edgeEvent.setEdgeId(edgeId); |
162 | 164 | ListenableFuture<EdgeEvent> saveFuture = ctx.getEdgeEventService().saveAsync(edgeEvent); |
163 | 165 | Futures.addCallback(saveFuture, new FutureCallback<EdgeEvent>() { | ... | ... |
... | ... | @@ -24,12 +24,8 @@ import org.thingsboard.rule.engine.api.TbNode; |
24 | 24 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
25 | 25 | import org.thingsboard.rule.engine.api.TbNodeException; |
26 | 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 | 27 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
31 | 28 | import org.thingsboard.server.common.data.plugin.ComponentType; |
32 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
33 | 29 | import org.thingsboard.server.common.msg.TbMsg; |
34 | 30 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
35 | 31 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; |
... | ... | @@ -67,12 +63,11 @@ public class TbMsgAttributesNode implements TbNode { |
67 | 63 | } |
68 | 64 | String src = msg.getData(); |
69 | 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 | 73 | @Override | ... | ... |
... | ... | @@ -18,17 +18,16 @@ package org.thingsboard.rule.engine.telemetry; |
18 | 18 | import com.google.gson.JsonParser; |
19 | 19 | import lombok.extern.slf4j.Slf4j; |
20 | 20 | import org.springframework.util.StringUtils; |
21 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
22 | 21 | import org.thingsboard.rule.engine.api.RuleNode; |
23 | 22 | import org.thingsboard.rule.engine.api.TbContext; |
24 | 23 | import org.thingsboard.rule.engine.api.TbNode; |
25 | 24 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
26 | 25 | import org.thingsboard.rule.engine.api.TbNodeException; |
26 | +import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
27 | 27 | import org.thingsboard.server.common.data.kv.BasicTsKvEntry; |
28 | 28 | import org.thingsboard.server.common.data.kv.KvEntry; |
29 | 29 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
30 | 30 | import org.thingsboard.server.common.data.plugin.ComponentType; |
31 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
32 | 31 | import org.thingsboard.server.common.msg.TbMsg; |
33 | 32 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
34 | 33 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; | ... | ... |
... | ... | @@ -22,13 +22,9 @@ import org.thingsboard.rule.engine.api.TbContext; |
22 | 22 | import org.thingsboard.rule.engine.api.TbNode; |
23 | 23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
24 | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
26 | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
27 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
28 | 26 | import org.thingsboard.server.common.msg.TbMsg; |
29 | 27 | |
30 | -import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; | |
31 | - | |
32 | 28 | @Slf4j |
33 | 29 | @RuleNode( |
34 | 30 | type = ComponentType.ACTION, |
... | ... | @@ -39,8 +35,7 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; |
39 | 35 | "Subsequent messages will not be processed until the previous message processing is completed or timeout event occurs.\n" + |
40 | 36 | "Size of the queue per originator and timeout values are configurable on a system level", |
41 | 37 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
42 | - configDirective = "tbNodeEmptyConfig" | |
43 | -) | |
38 | + configDirective = "tbNodeEmptyConfig") | |
44 | 39 | @Deprecated |
45 | 40 | public class TbSynchronizationBeginNode implements TbNode { |
46 | 41 | ... | ... |
... | ... | @@ -22,15 +22,9 @@ import org.thingsboard.rule.engine.api.TbContext; |
22 | 22 | import org.thingsboard.rule.engine.api.TbNode; |
23 | 23 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
24 | 24 | import org.thingsboard.rule.engine.api.TbNodeException; |
25 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
26 | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
27 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
28 | 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 | 28 | @Slf4j |
35 | 29 | @RuleNode( |
36 | 30 | type = ComponentType.ACTION, | ... | ... |
... | ... | @@ -20,18 +20,17 @@ import com.google.common.collect.Sets; |
20 | 20 | import com.google.common.util.concurrent.Futures; |
21 | 21 | import com.google.common.util.concurrent.ListenableFuture; |
22 | 22 | import lombok.extern.slf4j.Slf4j; |
23 | -import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
24 | 23 | import org.thingsboard.rule.engine.api.RuleNode; |
25 | 24 | import org.thingsboard.rule.engine.api.TbContext; |
26 | 25 | import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
27 | 26 | import org.thingsboard.rule.engine.api.TbNodeException; |
27 | +import org.thingsboard.rule.engine.api.util.TbNodeUtils; | |
28 | 28 | import org.thingsboard.rule.engine.util.EntitiesAlarmOriginatorIdAsyncLoader; |
29 | 29 | import org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader; |
30 | 30 | import org.thingsboard.rule.engine.util.EntitiesRelatedEntityIdAsyncLoader; |
31 | 31 | import org.thingsboard.rule.engine.util.EntitiesTenantIdAsyncLoader; |
32 | 32 | import org.thingsboard.server.common.data.id.EntityId; |
33 | 33 | import org.thingsboard.server.common.data.plugin.ComponentType; |
34 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
35 | 34 | import org.thingsboard.server.common.msg.TbMsg; |
36 | 35 | |
37 | 36 | import java.util.HashSet; | ... | ... |
... | ... | @@ -16,15 +16,15 @@ |
16 | 16 | package org.thingsboard.rule.engine.transform; |
17 | 17 | |
18 | 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 | 24 | import org.thingsboard.rule.engine.api.util.TbNodeUtils; |
20 | -import org.thingsboard.rule.engine.api.*; | |
21 | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
22 | -import org.thingsboard.server.common.data.rule.RuleChainType; | |
23 | 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 | 28 | @RuleNode( |
29 | 29 | type = ComponentType.TRANSFORMATION, |
30 | 30 | name = "script", |
... | ... | @@ -38,8 +38,7 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS; |
38 | 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 | 39 | "All fields in resulting object are optional and will be taken from original message if not specified.", |
40 | 40 | uiResources = {"static/rulenode/rulenode-core-config.js", "static/rulenode/rulenode-core-config.css"}, |
41 | - configDirective = "tbTransformationNodeScriptConfig" | |
42 | -) | |
41 | + configDirective = "tbTransformationNodeScriptConfig") | |
43 | 42 | public class TbTransformMsgNode extends TbAbstractTransformNode { |
44 | 43 | |
45 | 44 | private TbTransformMsgNodeConfiguration config; | ... | ... |