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,6 +66,7 @@ import org.thingsboard.server.common.data.security.UserCredentials;
66 import org.thingsboard.server.common.data.widget.WidgetType; 66 import org.thingsboard.server.common.data.widget.WidgetType;
67 import org.thingsboard.server.common.data.widget.WidgetsBundle; 67 import org.thingsboard.server.common.data.widget.WidgetsBundle;
68 import org.thingsboard.server.common.transport.util.JsonUtils; 68 import org.thingsboard.server.common.transport.util.JsonUtils;
  69 +import org.thingsboard.server.dao.util.mapping.JacksonUtil;
69 import org.thingsboard.server.gen.edge.AdminSettingsUpdateMsg; 70 import org.thingsboard.server.gen.edge.AdminSettingsUpdateMsg;
70 import org.thingsboard.server.gen.edge.AlarmUpdateMsg; 71 import org.thingsboard.server.gen.edge.AlarmUpdateMsg;
71 import org.thingsboard.server.gen.edge.AssetUpdateMsg; 72 import org.thingsboard.server.gen.edge.AssetUpdateMsg;
@@ -957,17 +958,24 @@ public final class EdgeGrpcSession implements Closeable { @@ -957,17 +958,24 @@ public final class EdgeGrpcSession implements Closeable {
957 } 958 }
958 959
959 private EdgeConfiguration constructEdgeConfigProto(Edge edge) { 960 private EdgeConfiguration constructEdgeConfigProto(Edge edge) {
960 - return EdgeConfiguration.newBuilder() 961 + EdgeConfiguration.Builder builder = EdgeConfiguration.newBuilder()
961 .setEdgeIdMSB(edge.getId().getId().getMostSignificantBits()) 962 .setEdgeIdMSB(edge.getId().getId().getMostSignificantBits())
962 .setEdgeIdLSB(edge.getId().getId().getLeastSignificantBits()) 963 .setEdgeIdLSB(edge.getId().getId().getLeastSignificantBits())
963 .setTenantIdMSB(edge.getTenantId().getId().getMostSignificantBits()) 964 .setTenantIdMSB(edge.getTenantId().getId().getMostSignificantBits())
964 .setTenantIdLSB(edge.getTenantId().getId().getLeastSignificantBits()) 965 .setTenantIdLSB(edge.getTenantId().getId().getLeastSignificantBits())
965 .setName(edge.getName()) 966 .setName(edge.getName())
966 - .setRoutingKey(edge.getRoutingKey())  
967 .setType(edge.getType()) 967 .setType(edge.getType())
  968 + .setRoutingKey(edge.getRoutingKey())
  969 + .setSecret(edge.getSecret())
968 .setEdgeLicenseKey(edge.getEdgeLicenseKey()) 970 .setEdgeLicenseKey(edge.getEdgeLicenseKey())
969 .setCloudEndpoint(edge.getCloudEndpoint()) 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 .build(); 979 .build();
972 } 980 }
973 981
@@ -79,12 +79,16 @@ message EdgeConfiguration { @@ -79,12 +79,16 @@ message EdgeConfiguration {
79 int64 edgeIdLSB = 2; 79 int64 edgeIdLSB = 2;
80 int64 tenantIdMSB = 3; 80 int64 tenantIdMSB = 3;
81 int64 tenantIdLSB = 4; 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 enum UpdateMsgType { 94 enum UpdateMsgType {
@@ -195,9 +195,11 @@ public class HashPartitionService implements PartitionService { @@ -195,9 +195,11 @@ public class HashPartitionService implements PartitionService {
195 if (current.getServiceTypesList().contains(serviceType.name())) { 195 if (current.getServiceTypesList().contains(serviceType.name())) {
196 result.add(current.getServiceId()); 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 return result; 205 return result;
@@ -153,6 +153,7 @@ export default function EntityFilterViewDirective($compile, $templateCache, $q, @@ -153,6 +153,7 @@ export default function EntityFilterViewDirective($compile, $templateCache, $q,
153 case types.aliasFilterType.assetSearchQuery.value: 153 case types.aliasFilterType.assetSearchQuery.value:
154 case types.aliasFilterType.deviceSearchQuery.value: 154 case types.aliasFilterType.deviceSearchQuery.value:
155 case types.aliasFilterType.entityViewSearchQuery.value: 155 case types.aliasFilterType.entityViewSearchQuery.value:
  156 + case types.aliasFilterType.edgeSearchQuery.value:
156 allEntitiesText = $translate.instant('alias.all-entities'); 157 allEntitiesText = $translate.instant('alias.all-entities');
157 anyRelationText = $translate.instant('alias.any-relation'); 158 anyRelationText = $translate.instant('alias.any-relation');
158 if (scope.filter.rootStateEntity) { 159 if (scope.filter.rootStateEntity) {
@@ -204,6 +205,16 @@ export default function EntityFilterViewDirective($compile, $templateCache, $q, @@ -204,6 +205,16 @@ export default function EntityFilterViewDirective($compile, $templateCache, $q,
204 scope.filterDisplayValue = $translate.instant('alias.filter-type-entity-view-search-query-description', 205 scope.filterDisplayValue = $translate.instant('alias.filter-type-entity-view-search-query-description',
205 translationValues 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 break; 219 break;
209 default: 220 default:
@@ -200,10 +200,11 @@ @@ -200,10 +200,11 @@
200 "filter-type-device-type-description": "Devices of type '{{deviceType}}'", 200 "filter-type-device-type-description": "Devices of type '{{deviceType}}'",
201 "filter-type-device-type-and-name-description": "Devices of type '{{deviceType}}' and with name starting with '{{prefix}}'", 201 "filter-type-device-type-and-name-description": "Devices of type '{{deviceType}}' and with name starting with '{{prefix}}'",
202 "filter-type-entity-view-type": "Entity View type", 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 "filter-type-edge-type": "Edge type", 205 "filter-type-edge-type": "Edge type",
206 "filter-type-edge-type-description": "Edges of type '{{edgeType}}'", 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 "filter-type-relations-query": "Relations query", 208 "filter-type-relations-query": "Relations query",
208 "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}", 209 "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}",
209 "filter-type-asset-search-query": "Asset search query", 210 "filter-type-asset-search-query": "Asset search query",
@@ -779,6 +780,7 @@ @@ -779,6 +780,7 @@
779 "delete-edges-action-title": "Delete { count, plural, 1 {1 edge} other {# edges} }", 780 "delete-edges-action-title": "Delete { count, plural, 1 {1 edge} other {# edges} }",
780 "delete-edges-text": "Be careful, after the confirmation all selected edges will be removed and all related data will become unrecoverable.", 781 "delete-edges-text": "Be careful, after the confirmation all selected edges will be removed and all related data will become unrecoverable.",
781 "name": "Name", 782 "name": "Name",
  783 + "name-starts-with": "Edge name starts with",
782 "name-required": "Name is required.", 784 "name-required": "Name is required.",
783 "edge-license-key": "Edge License Key", 785 "edge-license-key": "Edge License Key",
784 "edge-license-key-required": "Edge License Key is required.", 786 "edge-license-key-required": "Edge License Key is required.",