Commit b48d43f4dd23980a5d39040845312aaa3c21e943

Authored by Volodymyr Babak
1 parent 0ce12872

Added support for EDGE entity

... ... @@ -66,6 +66,7 @@ import org.thingsboard.server.common.data.security.UserCredentials;
66 66 import org.thingsboard.server.common.data.widget.WidgetType;
67 67 import org.thingsboard.server.common.data.widget.WidgetsBundle;
68 68 import org.thingsboard.server.common.transport.util.JsonUtils;
  69 +import org.thingsboard.server.dao.util.mapping.JacksonUtil;
69 70 import org.thingsboard.server.gen.edge.AdminSettingsUpdateMsg;
70 71 import org.thingsboard.server.gen.edge.AlarmUpdateMsg;
71 72 import org.thingsboard.server.gen.edge.AssetUpdateMsg;
... ... @@ -957,17 +958,24 @@ public final class EdgeGrpcSession implements Closeable {
957 958 }
958 959
959 960 private EdgeConfiguration constructEdgeConfigProto(Edge edge) {
960   - return EdgeConfiguration.newBuilder()
  961 + EdgeConfiguration.Builder builder = EdgeConfiguration.newBuilder()
961 962 .setEdgeIdMSB(edge.getId().getId().getMostSignificantBits())
962 963 .setEdgeIdLSB(edge.getId().getId().getLeastSignificantBits())
963 964 .setTenantIdMSB(edge.getTenantId().getId().getMostSignificantBits())
964 965 .setTenantIdLSB(edge.getTenantId().getId().getLeastSignificantBits())
965 966 .setName(edge.getName())
966   - .setRoutingKey(edge.getRoutingKey())
967 967 .setType(edge.getType())
  968 + .setRoutingKey(edge.getRoutingKey())
  969 + .setSecret(edge.getSecret())
968 970 .setEdgeLicenseKey(edge.getEdgeLicenseKey())
969 971 .setCloudEndpoint(edge.getCloudEndpoint())
970   - .setCloudType("CE")
  972 + .setConfiguration(JacksonUtil.toString(edge.getConfiguration()))
  973 + .setCloudType("CE");
  974 + if (edge.getCustomerId() != null) {
  975 + builder.setCustomerIdMSB(edge.getCustomerId().getId().getMostSignificantBits())
  976 + .setCustomerIdLSB(edge.getCustomerId().getId().getLeastSignificantBits());
  977 + }
  978 + return builder
971 979 .build();
972 980 }
973 981
... ...
... ... @@ -79,12 +79,16 @@ message EdgeConfiguration {
79 79 int64 edgeIdLSB = 2;
80 80 int64 tenantIdMSB = 3;
81 81 int64 tenantIdLSB = 4;
82   - string name = 5;
83   - string routingKey = 6;
84   - string type = 7;
85   - string edgeLicenseKey = 8;
86   - string cloudEndpoint = 9;
87   - string cloudType = 10;
  82 + int64 customerIdMSB = 5;
  83 + int64 customerIdLSB = 6;
  84 + string name = 7;
  85 + string type = 8;
  86 + string routingKey = 9;
  87 + string secret = 10;
  88 + string edgeLicenseKey = 11;
  89 + string cloudEndpoint = 12;
  90 + string configuration = 13;
  91 + string cloudType = 14;
88 92 }
89 93
90 94 enum UpdateMsgType {
... ...
... ... @@ -195,9 +195,11 @@ public class HashPartitionService implements PartitionService {
195 195 if (current.getServiceTypesList().contains(serviceType.name())) {
196 196 result.add(current.getServiceId());
197 197 }
198   - for (ServiceInfo serviceInfo : currentOtherServices) {
199   - if (serviceInfo.getServiceTypesList().contains(serviceType.name())) {
200   - result.add(serviceInfo.getServiceId());
  198 + if (currentOtherServices != null) {
  199 + for (ServiceInfo serviceInfo : currentOtherServices) {
  200 + if (serviceInfo.getServiceTypesList().contains(serviceType.name())) {
  201 + result.add(serviceInfo.getServiceId());
  202 + }
201 203 }
202 204 }
203 205 return result;
... ...
... ... @@ -153,6 +153,7 @@ export default function EntityFilterViewDirective($compile, $templateCache, $q,
153 153 case types.aliasFilterType.assetSearchQuery.value:
154 154 case types.aliasFilterType.deviceSearchQuery.value:
155 155 case types.aliasFilterType.entityViewSearchQuery.value:
  156 + case types.aliasFilterType.edgeSearchQuery.value:
156 157 allEntitiesText = $translate.instant('alias.all-entities');
157 158 anyRelationText = $translate.instant('alias.any-relation');
158 159 if (scope.filter.rootStateEntity) {
... ... @@ -204,6 +205,16 @@ export default function EntityFilterViewDirective($compile, $templateCache, $q,
204 205 scope.filterDisplayValue = $translate.instant('alias.filter-type-entity-view-search-query-description',
205 206 translationValues
206 207 );
  208 + } else if (scope.filter.type == types.aliasFilterType.edgeSearchQuery.value) {
  209 + var edgeTypesQuoted = [];
  210 + scope.filter.edgeTypes.forEach(function(edgeType) {
  211 + edgeTypesQuoted.push("'"+edgeType+"'");
  212 + });
  213 + var edgeTypesText = edgeTypesQuoted.join(', ');
  214 + translationValues.edgeTypes = edgeTypesText;
  215 + scope.filterDisplayValue = $translate.instant('alias.filter-type-edge-search-query-description',
  216 + translationValues
  217 + );
207 218 }
208 219 break;
209 220 default:
... ...
... ... @@ -200,10 +200,11 @@
200 200 "filter-type-device-type-description": "Devices of type '{{deviceType}}'",
201 201 "filter-type-device-type-and-name-description": "Devices of type '{{deviceType}}' and with name starting with '{{prefix}}'",
202 202 "filter-type-entity-view-type": "Entity View type",
203   - "filter-type-entity-view-type-description": "Entity Views of type '{{entityView}}'",
204   - "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityView}}' and with name starting with '{{prefix}}'",
  203 + "filter-type-entity-view-type-description": "Entity Views of type '{{entityViewType}}'",
  204 + "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityViewType}}' and with name starting with '{{prefix}}'",
205 205 "filter-type-edge-type": "Edge type",
206 206 "filter-type-edge-type-description": "Edges of type '{{edgeType}}'",
  207 + "filter-type-edge-type-and-name-description": "Edges of type '{{edgeType}}' and with name starting with '{{prefix}}'",
207 208 "filter-type-relations-query": "Relations query",
208 209 "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}",
209 210 "filter-type-asset-search-query": "Asset search query",
... ... @@ -779,6 +780,7 @@
779 780 "delete-edges-action-title": "Delete { count, plural, 1 {1 edge} other {# edges} }",
780 781 "delete-edges-text": "Be careful, after the confirmation all selected edges will be removed and all related data will become unrecoverable.",
781 782 "name": "Name",
  783 + "name-starts-with": "Edge name starts with",
782 784 "name-required": "Name is required.",
783 785 "edge-license-key": "Edge License Key",
784 786 "edge-license-key-required": "Edge License Key is required.",
... ...