Showing
6 changed files
with
77 additions
and
4 deletions
@@ -24,6 +24,7 @@ import org.thingsboard.server.dao.alarm.AlarmService; | @@ -24,6 +24,7 @@ import org.thingsboard.server.dao.alarm.AlarmService; | ||
24 | import org.thingsboard.server.dao.asset.AssetService; | 24 | import org.thingsboard.server.dao.asset.AssetService; |
25 | import org.thingsboard.server.dao.attributes.AttributesService; | 25 | import org.thingsboard.server.dao.attributes.AttributesService; |
26 | import org.thingsboard.server.dao.customer.CustomerService; | 26 | import org.thingsboard.server.dao.customer.CustomerService; |
27 | +import org.thingsboard.server.dao.dashboard.DashboardService; | ||
27 | import org.thingsboard.server.dao.device.DeviceService; | 28 | import org.thingsboard.server.dao.device.DeviceService; |
28 | import org.thingsboard.server.dao.edge.EdgeService; | 29 | import org.thingsboard.server.dao.edge.EdgeService; |
29 | import org.thingsboard.server.dao.entityview.EntityViewService; | 30 | import org.thingsboard.server.dao.entityview.EntityViewService; |
@@ -67,5 +68,9 @@ public class EdgeContextComponent { | @@ -67,5 +68,9 @@ public class EdgeContextComponent { | ||
67 | 68 | ||
68 | @Lazy | 69 | @Lazy |
69 | @Autowired | 70 | @Autowired |
71 | + private DashboardService dashboardService; | ||
72 | + | ||
73 | + @Lazy | ||
74 | + @Autowired | ||
70 | private ActorService actorService; | 75 | private ActorService actorService; |
71 | } | 76 | } |
@@ -25,12 +25,14 @@ import com.google.protobuf.ByteString; | @@ -25,12 +25,14 @@ import com.google.protobuf.ByteString; | ||
25 | import io.grpc.stub.StreamObserver; | 25 | import io.grpc.stub.StreamObserver; |
26 | import lombok.Data; | 26 | import lombok.Data; |
27 | import lombok.extern.slf4j.Slf4j; | 27 | import lombok.extern.slf4j.Slf4j; |
28 | +import org.thingsboard.server.common.data.Customer; | ||
28 | import org.thingsboard.server.common.data.Dashboard; | 29 | import org.thingsboard.server.common.data.Dashboard; |
29 | import org.thingsboard.server.common.data.DataConstants; | 30 | import org.thingsboard.server.common.data.DataConstants; |
30 | import org.thingsboard.server.common.data.Device; | 31 | import org.thingsboard.server.common.data.Device; |
31 | import org.thingsboard.server.common.data.EntityType; | 32 | import org.thingsboard.server.common.data.EntityType; |
32 | import org.thingsboard.server.common.data.EntityView; | 33 | import org.thingsboard.server.common.data.EntityView; |
33 | import org.thingsboard.server.common.data.Event; | 34 | import org.thingsboard.server.common.data.Event; |
35 | +import org.thingsboard.server.common.data.User; | ||
34 | import org.thingsboard.server.common.data.alarm.Alarm; | 36 | import org.thingsboard.server.common.data.alarm.Alarm; |
35 | import org.thingsboard.server.common.data.alarm.AlarmSeverity; | 37 | import org.thingsboard.server.common.data.alarm.AlarmSeverity; |
36 | import org.thingsboard.server.common.data.alarm.AlarmStatus; | 38 | import org.thingsboard.server.common.data.alarm.AlarmStatus; |
@@ -67,6 +69,7 @@ import org.thingsboard.server.gen.edge.AssetUpdateMsg; | @@ -67,6 +69,7 @@ import org.thingsboard.server.gen.edge.AssetUpdateMsg; | ||
67 | import org.thingsboard.server.gen.edge.ConnectRequestMsg; | 69 | import org.thingsboard.server.gen.edge.ConnectRequestMsg; |
68 | import org.thingsboard.server.gen.edge.ConnectResponseCode; | 70 | import org.thingsboard.server.gen.edge.ConnectResponseCode; |
69 | import org.thingsboard.server.gen.edge.ConnectResponseMsg; | 71 | import org.thingsboard.server.gen.edge.ConnectResponseMsg; |
72 | +import org.thingsboard.server.gen.edge.CustomerUpdateMsg; | ||
70 | import org.thingsboard.server.gen.edge.DashboardUpdateMsg; | 73 | import org.thingsboard.server.gen.edge.DashboardUpdateMsg; |
71 | import org.thingsboard.server.gen.edge.DeviceUpdateMsg; | 74 | import org.thingsboard.server.gen.edge.DeviceUpdateMsg; |
72 | import org.thingsboard.server.gen.edge.DownlinkMsg; | 75 | import org.thingsboard.server.gen.edge.DownlinkMsg; |
@@ -85,6 +88,7 @@ import org.thingsboard.server.gen.edge.RuleNodeProto; | @@ -85,6 +88,7 @@ import org.thingsboard.server.gen.edge.RuleNodeProto; | ||
85 | import org.thingsboard.server.gen.edge.UpdateMsgType; | 88 | import org.thingsboard.server.gen.edge.UpdateMsgType; |
86 | import org.thingsboard.server.gen.edge.UplinkMsg; | 89 | import org.thingsboard.server.gen.edge.UplinkMsg; |
87 | import org.thingsboard.server.gen.edge.UplinkResponseMsg; | 90 | import org.thingsboard.server.gen.edge.UplinkResponseMsg; |
91 | +import org.thingsboard.server.gen.edge.UserUpdateMsg; | ||
88 | import org.thingsboard.server.service.edge.EdgeContextComponent; | 92 | import org.thingsboard.server.service.edge.EdgeContextComponent; |
89 | 93 | ||
90 | import java.io.IOException; | 94 | import java.io.IOException; |
@@ -212,7 +216,7 @@ public final class EdgeGrpcSession implements Cloneable { | @@ -212,7 +216,7 @@ public final class EdgeGrpcSession implements Cloneable { | ||
212 | } | 216 | } |
213 | 217 | ||
214 | private void processCustomDownlinkMessage(EdgeQueueEntry entry) throws IOException { | 218 | private void processCustomDownlinkMessage(EdgeQueueEntry entry) throws IOException { |
215 | - log.trace("Executing processCustomDownlinkMessage, entry [{}], msgType [{}]", entry); | 219 | + log.trace("Executing processCustomDownlinkMessage, entry [{}]", entry); |
216 | TbMsg tbMsg = objectMapper.readValue(entry.getData(), TbMsg.class); | 220 | TbMsg tbMsg = objectMapper.readValue(entry.getData(), TbMsg.class); |
217 | String entityName = null; | 221 | String entityName = null; |
218 | switch (entry.getEntityType()) { | 222 | switch (entry.getEntityType()) { |
@@ -526,11 +530,25 @@ public final class EdgeGrpcSession implements Cloneable { | @@ -526,11 +530,25 @@ public final class EdgeGrpcSession implements Cloneable { | ||
526 | } | 530 | } |
527 | 531 | ||
528 | private DashboardUpdateMsg constructDashboardUpdatedMsg(UpdateMsgType msgType, Dashboard dashboard) { | 532 | private DashboardUpdateMsg constructDashboardUpdatedMsg(UpdateMsgType msgType, Dashboard dashboard) { |
533 | + dashboard = ctx.getDashboardService().findDashboardById(edge.getTenantId(), dashboard.getId()); | ||
529 | DashboardUpdateMsg.Builder builder = DashboardUpdateMsg.newBuilder() | 534 | DashboardUpdateMsg.Builder builder = DashboardUpdateMsg.newBuilder() |
530 | .setMsgType(msgType) | 535 | .setMsgType(msgType) |
531 | .setIdMSB(dashboard.getId().getId().getMostSignificantBits()) | 536 | .setIdMSB(dashboard.getId().getId().getMostSignificantBits()) |
532 | .setIdLSB(dashboard.getId().getId().getLeastSignificantBits()) | 537 | .setIdLSB(dashboard.getId().getId().getLeastSignificantBits()) |
533 | - .setName(dashboard.getName()); | 538 | + .setTitle(dashboard.getTitle()) |
539 | + .setConfiguration(JacksonUtil.toString(dashboard.getConfiguration())); | ||
540 | + return builder.build(); | ||
541 | + } | ||
542 | + | ||
543 | + private CustomerUpdateMsg constructCustomerUpdatedMsg(UpdateMsgType msgType, Customer customer) { | ||
544 | + CustomerUpdateMsg.Builder builder = CustomerUpdateMsg.newBuilder() | ||
545 | + .setMsgType(msgType); | ||
546 | + return builder.build(); | ||
547 | + } | ||
548 | + | ||
549 | + private UserUpdateMsg constructUserUpdatedMsg(UpdateMsgType msgType, User user) { | ||
550 | + UserUpdateMsg.Builder builder = UserUpdateMsg.newBuilder() | ||
551 | + .setMsgType(msgType); | ||
534 | return builder.build(); | 552 | return builder.build(); |
535 | } | 553 | } |
536 | 554 |
@@ -16,5 +16,5 @@ | @@ -16,5 +16,5 @@ | ||
16 | package org.thingsboard.server.common.data.edge; | 16 | package org.thingsboard.server.common.data.edge; |
17 | 17 | ||
18 | public enum EdgeQueueEntityType { | 18 | public enum EdgeQueueEntityType { |
19 | - DASHBOARD, ASSET, DEVICE, ENTITY_VIEW, ALARM, RULE_CHAIN, RULE_CHAIN_METADATA, EDGE | 19 | + DASHBOARD, ASSET, DEVICE, ENTITY_VIEW, ALARM, RULE_CHAIN, RULE_CHAIN_METADATA, EDGE, USER, CUSTOMER |
20 | } | 20 | } |
@@ -52,6 +52,8 @@ message EntityUpdateMsg { | @@ -52,6 +52,8 @@ message EntityUpdateMsg { | ||
52 | AssetUpdateMsg assetUpdateMsg = 5; | 52 | AssetUpdateMsg assetUpdateMsg = 5; |
53 | EntityViewUpdateMsg entityViewUpdateMsg = 6; | 53 | EntityViewUpdateMsg entityViewUpdateMsg = 6; |
54 | AlarmUpdateMsg alarmUpdateMsg = 7; | 54 | AlarmUpdateMsg alarmUpdateMsg = 7; |
55 | + UserUpdateMsg userUpdateMsg = 8; | ||
56 | + CustomerUpdateMsg customerUpdateMsg = 9; | ||
55 | } | 57 | } |
56 | 58 | ||
57 | enum RequestMsgType { | 59 | enum RequestMsgType { |
@@ -82,6 +84,7 @@ message EdgeConfiguration { | @@ -82,6 +84,7 @@ message EdgeConfiguration { | ||
82 | string name = 5; | 84 | string name = 5; |
83 | string routingKey = 6; | 85 | string routingKey = 6; |
84 | string type = 7; | 86 | string type = 7; |
87 | + string cloudType = 8; | ||
85 | } | 88 | } |
86 | 89 | ||
87 | enum UpdateMsgType { | 90 | enum UpdateMsgType { |
@@ -147,7 +150,8 @@ message DashboardUpdateMsg { | @@ -147,7 +150,8 @@ message DashboardUpdateMsg { | ||
147 | UpdateMsgType msgType = 1; | 150 | UpdateMsgType msgType = 1; |
148 | int64 idMSB = 2; | 151 | int64 idMSB = 2; |
149 | int64 idLSB = 3; | 152 | int64 idLSB = 3; |
150 | - string name = 4; | 153 | + string title = 4; |
154 | + string configuration = 5; | ||
151 | } | 155 | } |
152 | 156 | ||
153 | message DeviceUpdateMsg { | 157 | message DeviceUpdateMsg { |
@@ -187,6 +191,37 @@ message AlarmUpdateMsg { | @@ -187,6 +191,37 @@ message AlarmUpdateMsg { | ||
187 | bool propagate = 13; | 191 | bool propagate = 13; |
188 | } | 192 | } |
189 | 193 | ||
194 | +message CustomerUpdateMsg { | ||
195 | + UpdateMsgType msgType = 1; | ||
196 | + int64 idMSB = 2; | ||
197 | + int64 idLSB = 3; | ||
198 | + string title = 4; | ||
199 | + string country = 5; | ||
200 | + string state = 6; | ||
201 | + string city = 7; | ||
202 | + string address = 8; | ||
203 | + string address2 = 9; | ||
204 | + string zip = 10; | ||
205 | + string phone = 11; | ||
206 | + string email = 12; | ||
207 | + string additionalInfo = 13; | ||
208 | +} | ||
209 | + | ||
210 | +message UserUpdateMsg { | ||
211 | + UpdateMsgType msgType = 1; | ||
212 | + int64 idMSB = 2; | ||
213 | + int64 idLSB = 3; | ||
214 | + int64 customerIdMSB = 4; | ||
215 | + int64 customerIdLSB = 5; | ||
216 | + string email = 7; | ||
217 | + string authority = 8; | ||
218 | + string firstName = 9; | ||
219 | + string lastName = 10; | ||
220 | + string additionalInfo = 11; | ||
221 | + bool enabled = 12; | ||
222 | + string password = 13; | ||
223 | +} | ||
224 | + | ||
190 | enum EntityType { | 225 | enum EntityType { |
191 | DEVICE = 0; | 226 | DEVICE = 0; |
192 | ASSET = 1; | 227 | ASSET = 1; |
@@ -29,6 +29,7 @@ import org.springframework.cache.annotation.Cacheable; | @@ -29,6 +29,7 @@ import org.springframework.cache.annotation.Cacheable; | ||
29 | import org.springframework.stereotype.Service; | 29 | import org.springframework.stereotype.Service; |
30 | import org.springframework.util.StringUtils; | 30 | import org.springframework.util.StringUtils; |
31 | import org.thingsboard.server.common.data.Customer; | 31 | import org.thingsboard.server.common.data.Customer; |
32 | +import org.thingsboard.server.common.data.Dashboard; | ||
32 | import org.thingsboard.server.common.data.DataConstants; | 33 | import org.thingsboard.server.common.data.DataConstants; |
33 | import org.thingsboard.server.common.data.Device; | 34 | import org.thingsboard.server.common.data.Device; |
34 | import org.thingsboard.server.common.data.EntitySubtype; | 35 | import org.thingsboard.server.common.data.EntitySubtype; |
@@ -549,6 +550,16 @@ public class BaseEdgeService extends AbstractEntityService implements EdgeServic | @@ -549,6 +550,16 @@ public class BaseEdgeService extends AbstractEntityService implements EdgeServic | ||
549 | edgeId = new EdgeId(UUID.fromString(tbMsg.getMetaData().getValue("unassignedEdgeId"))); | 550 | edgeId = new EdgeId(UUID.fromString(tbMsg.getMetaData().getValue("unassignedEdgeId"))); |
550 | pushEventToEdge(tenantId, edgeId, entityType, tbMsg, callback); | 551 | pushEventToEdge(tenantId, edgeId, entityType, tbMsg, callback); |
551 | break; | 552 | break; |
553 | + case DataConstants.ENTITY_DELETED: | ||
554 | + case DataConstants.ENTITY_CREATED: | ||
555 | + case DataConstants.ENTITY_UPDATED: | ||
556 | + Dashboard dashboard = mapper.readValue(tbMsg.getData(), Dashboard.class); | ||
557 | + if (dashboard.getAssignedEdges() != null && !dashboard.getAssignedEdges().isEmpty()) { | ||
558 | + for (ShortEdgeInfo assignedEdge : dashboard.getAssignedEdges()) { | ||
559 | + pushEventToEdge(tenantId, assignedEdge.getEdgeId(), EdgeQueueEntityType.DASHBOARD, tbMsg, callback); | ||
560 | + } | ||
561 | + } | ||
562 | + break; | ||
552 | } | 563 | } |
553 | } | 564 | } |
554 | 565 |
@@ -184,6 +184,8 @@ | @@ -184,6 +184,8 @@ | ||
184 | "filter-type-entity-view-type": "Entity View type", | 184 | "filter-type-entity-view-type": "Entity View type", |
185 | "filter-type-entity-view-type-description": "Entity Views of type '{{entityView}}'", | 185 | "filter-type-entity-view-type-description": "Entity Views of type '{{entityView}}'", |
186 | "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityView}}' and with name starting with '{{prefix}}'", | 186 | "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityView}}' and with name starting with '{{prefix}}'", |
187 | + "filter-type-edge-type": "Edge type", | ||
188 | + "filter-type-edge-type-description": "Edges of type '{{edgeType}}'", | ||
187 | "filter-type-relations-query": "Relations query", | 189 | "filter-type-relations-query": "Relations query", |
188 | "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}", | 190 | "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}", |
189 | "filter-type-asset-search-query": "Asset search query", | 191 | "filter-type-asset-search-query": "Asset search query", |
@@ -192,6 +194,8 @@ | @@ -192,6 +194,8 @@ | ||
192 | "filter-type-device-search-query-description": "Devices with types {{deviceTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}", | 194 | "filter-type-device-search-query-description": "Devices with types {{deviceTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}", |
193 | "filter-type-entity-view-search-query": "Entity view search query", | 195 | "filter-type-entity-view-search-query": "Entity view search query", |
194 | "filter-type-entity-view-search-query-description": "Entity views with types {{entityViewTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}", | 196 | "filter-type-entity-view-search-query-description": "Entity views with types {{entityViewTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}", |
197 | + "filter-type-edge-search-query": "Edge search query", | ||
198 | + "filter-type-edge-search-query-description": "Edges with types {{edgeTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}", | ||
195 | "entity-filter": "Entity filter", | 199 | "entity-filter": "Entity filter", |
196 | "resolve-multiple": "Resolve as multiple entities", | 200 | "resolve-multiple": "Resolve as multiple entities", |
197 | "filter-type": "Filter type", | 201 | "filter-type": "Filter type", |