...
|
...
|
@@ -27,9 +27,11 @@ import org.springframework.util.StringUtils; |
27
|
27
|
import org.thingsboard.rule.engine.api.util.DonAsynchron;
|
28
|
28
|
import org.thingsboard.server.common.data.DataConstants;
|
29
|
29
|
import org.thingsboard.server.common.data.EntityType;
|
|
30
|
+import org.thingsboard.server.common.data.EntityView;
|
30
|
31
|
import org.thingsboard.server.common.data.id.DeviceId;
|
31
|
32
|
import org.thingsboard.server.common.data.id.EntityId;
|
32
|
33
|
import org.thingsboard.server.common.data.id.EntityIdFactory;
|
|
34
|
+import org.thingsboard.server.common.data.id.EntityViewId;
|
33
|
35
|
import org.thingsboard.server.common.data.kv.AttributeKvEntry;
|
34
|
36
|
import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry;
|
35
|
37
|
import org.thingsboard.server.common.data.kv.BaseTsKvQuery;
|
...
|
...
|
@@ -44,6 +46,8 @@ import org.thingsboard.server.common.data.kv.TsKvEntry; |
44
|
46
|
import org.thingsboard.server.common.data.kv.TsKvQuery;
|
45
|
47
|
import org.thingsboard.server.common.msg.cluster.ServerAddress;
|
46
|
48
|
import org.thingsboard.server.dao.attributes.AttributesService;
|
|
49
|
+import org.thingsboard.server.dao.entityview.EntityViewService;
|
|
50
|
+import org.thingsboard.server.dao.model.ModelConstants;
|
47
|
51
|
import org.thingsboard.server.dao.timeseries.TimeseriesService;
|
48
|
52
|
import org.thingsboard.server.gen.cluster.ClusterAPIProtos;
|
49
|
53
|
import org.thingsboard.server.service.cluster.routing.ClusterRoutingService;
|
...
|
...
|
@@ -97,6 +101,9 @@ public class DefaultTelemetrySubscriptionService implements TelemetrySubscriptio |
97
|
101
|
@Autowired
|
98
|
102
|
private ClusterRpcService rpcService;
|
99
|
103
|
|
|
104
|
+ /*@Autowired
|
|
105
|
+ private EntityViewService entityViewService;*/
|
|
106
|
+
|
100
|
107
|
@Autowired
|
101
|
108
|
@Lazy
|
102
|
109
|
private DeviceStateService stateService;
|
...
|
...
|
@@ -125,17 +132,29 @@ public class DefaultTelemetrySubscriptionService implements TelemetrySubscriptio |
125
|
132
|
|
126
|
133
|
@Override
|
127
|
134
|
public void addLocalWsSubscription(String sessionId, EntityId entityId, SubscriptionState sub) {
|
|
135
|
+ String familyName = ModelConstants.DEVICE_FAMILY_NAME;
|
|
136
|
+
|
|
137
|
+ //To do
|
|
138
|
+ if (entityId.getEntityType().equals(EntityType.ENTITY_VIEW)) {
|
|
139
|
+ familyName = ModelConstants.ENTITY_VIEW_FAMILY_NAME;
|
|
140
|
+ //EntityView entityView = entityViewService.findEntityViewById((EntityViewId) entityId)
|
|
141
|
+ }
|
|
142
|
+
|
128
|
143
|
Optional<ServerAddress> server = routingService.resolveById(entityId);
|
129
|
144
|
Subscription subscription;
|
130
|
145
|
if (server.isPresent()) {
|
131
|
146
|
ServerAddress address = server.get();
|
132
|
|
- log.trace("[{}] Forwarding subscription [{}] for device [{}] to [{}]", sessionId, sub.getSubscriptionId(), entityId, address);
|
|
147
|
+ log.trace("[{}] Forwarding subscription [{}] for " + familyName + " [{}] to [{}]", sessionId, sub.getSubscriptionId(), entityId, address);
|
133
|
148
|
subscription = new Subscription(sub, true, address);
|
134
|
149
|
tellNewSubscription(address, sessionId, subscription);
|
135
|
150
|
} else {
|
136
|
|
- log.trace("[{}] Registering local subscription [{}] for device [{}]", sessionId, sub.getSubscriptionId(), entityId);
|
|
151
|
+ log.trace("[{}] Registering local subscription [{}] for " + familyName + " [{}]", sessionId, sub.getSubscriptionId(), entityId);
|
137
|
152
|
subscription = new Subscription(sub, true);
|
138
|
153
|
}
|
|
154
|
+
|
|
155
|
+ /*if (entityId.getEntityType().equals(EntityType.ENTITY_VIEW)) {
|
|
156
|
+ registerSubscription(sessionId, entityId, subscription);
|
|
157
|
+ }*/
|
139
|
158
|
registerSubscription(sessionId, entityId, subscription);
|
140
|
159
|
}
|
141
|
160
|
|
...
|
...
|
|