Commit 78a4710c66292470f6a76d22ccf16fbe29fd05a2

Authored by Volodymyr Babak
2 parents b2de96fb e5753c03

Merge remote-tracking branch 'origin/develop/2.6-edge' into develop/3.3-edge

Showing 22 changed files with 224 additions and 318 deletions
application/src/main/data/json/demo/edge_management/rule_chains/edge_root_rule_chain.json renamed from application/src/main/data/json/demo/rule_chains/edge_root_rule_chain.json
application/src/main/data/json/tenant/edge_management/rule_chains/edge_root_rule_chain.json renamed from application/src/main/data/json/tenant/rule_chains/edge_root_rule_chain.json
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   -
17   -DROP MATERIALIZED VIEW IF EXISTS thingsboard.rule_chain_by_tenant_and_search_text;
18   -
19   -DROP TABLE IF EXISTS thingsboard.rule_chain;
20   -
21   -CREATE TABLE IF NOT EXISTS thingsboard.rule_chain (
22   - id uuid,
23   - tenant_id uuid,
24   - name text,
25   - type text,
26   - search_text text,
27   - first_rule_node_id uuid,
28   - root boolean,
29   - debug_mode boolean,
30   - configuration text,
31   - additional_info text,
32   - PRIMARY KEY (id, tenant_id, type)
33   -);
34   -
35   -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.rule_chain_by_tenant_and_search_text AS
36   - SELECT *
37   - from thingsboard.rule_chain
38   - WHERE tenant_id IS NOT NULL AND search_text IS NOT NULL AND id IS NOT NULL AND type IS NOT NULL
39   - PRIMARY KEY ( tenant_id, search_text, id, type )
40   - WITH CLUSTERING ORDER BY ( search_text ASC, id DESC );
41   -
42   -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.rule_chain_by_tenant_by_type_and_search_text AS
43   - SELECT *
44   - from thingsboard.rule_chain
45   - WHERE tenant_id IS NOT NULL AND search_text IS NOT NULL AND id IS NOT NULL AND type IS NOT NULL
46   - PRIMARY KEY ( tenant_id, type, search_text, id )
47   - WITH CLUSTERING ORDER BY ( type ASC, search_text ASC, id DESC );
48   -
49   -CREATE TABLE IF NOT EXISTS thingsboard.edge (
50   - id timeuuid,
51   - tenant_id timeuuid,
52   - customer_id timeuuid,
53   - root_rule_chain_id timeuuid,
54   - type text,
55   - name text,
56   - label text,
57   - search_text text,
58   - routing_key text,
59   - secret text,
60   - edge_license_key text,
61   - cloud_endpoint text,
62   - additional_info text,
63   - PRIMARY KEY (id, tenant_id, customer_id, type)
64   -);
65   -
66   -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_name AS
67   - SELECT *
68   - from thingsboard.edge
69   - WHERE tenant_id IS NOT NULL AND customer_id IS NOT NULL AND type IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
70   - PRIMARY KEY ( tenant_id, name, id, customer_id, type)
71   - WITH CLUSTERING ORDER BY ( name ASC, id DESC, customer_id DESC);
72   -
73   -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_routing_key AS
74   - SELECT *
75   - from thingsboard.edge
76   - 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
77   - PRIMARY KEY ( routing_key, tenant_id, id, customer_id, type)
78   - WITH CLUSTERING ORDER BY ( tenant_id DESC, id DESC, customer_id DESC);
79   -
80   -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_and_search_text AS
81   - SELECT *
82   - from thingsboard.edge
83   - 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
84   - PRIMARY KEY ( tenant_id, search_text, id, customer_id, type)
85   - WITH CLUSTERING ORDER BY ( search_text ASC, id DESC, customer_id DESC);
86   -
87   -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_tenant_by_type_and_search_text AS
88   - SELECT *
89   - from thingsboard.edge
90   - 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
91   - PRIMARY KEY ( tenant_id, type, search_text, id, customer_id)
92   - WITH CLUSTERING ORDER BY ( type ASC, search_text ASC, id DESC, customer_id DESC);
93   -
94   -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_customer_and_search_text AS
95   - SELECT *
96   - from thingsboard.edge
97   - 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
98   - PRIMARY KEY ( customer_id, tenant_id, search_text, id, type )
99   - WITH CLUSTERING ORDER BY ( tenant_id DESC, search_text ASC, id DESC );
100   -
101   -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_by_customer_by_type_and_search_text AS
102   - SELECT *
103   - from thingsboard.edge
104   - 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
105   - PRIMARY KEY ( customer_id, tenant_id, type, search_text, id )
106   - WITH CLUSTERING ORDER BY ( tenant_id DESC, type ASC, search_text ASC, id DESC );
107   -
108   -CREATE TABLE IF NOT EXISTS thingsboard.edge_event (
109   - id timeuuid,
110   - tenant_id timeuuid,
111   - edge_id timeuuid,
112   - edge_event_type text,
113   - edge_event_action text,
114   - edge_event_uid text,
115   - entity_id timeuuid,
116   - body text,
117   - PRIMARY KEY ((tenant_id, edge_id), edge_event_type, edge_event_uid)
118   -);
119   -
120   -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.edge_event_by_id AS
121   - SELECT *
122   - FROM thingsboard.edge_event
123   - WHERE tenant_id IS NOT NULL AND edge_id IS NOT NULL AND edge_event_type IS NOT NULL
124   - AND id IS NOT NULL AND edge_event_uid IS NOT NULL
125   - PRIMARY KEY ((tenant_id, edge_id), id, edge_event_type, edge_event_uid)
126   - WITH CLUSTERING ORDER BY (id ASC);
\ No newline at end of file
application/src/main/data/upgrade/3.2.0/schema_update.sql renamed from application/src/main/data/upgrade/2.6.0/schema_update.sql
... ... @@ -15,10 +15,11 @@
15 15 --
16 16
17 17 CREATE TABLE IF NOT EXISTS edge (
18   - id varchar(31) NOT NULL CONSTRAINT edge_pkey PRIMARY KEY,
  18 + id uuid NOT NULL CONSTRAINT edge_pkey PRIMARY KEY,
  19 + created_time bigint NOT NULL,
19 20 additional_info varchar,
20   - customer_id varchar(31),
21   - root_rule_chain_id varchar(31),
  21 + customer_id uuid,
  22 + root_rule_chain_id uuid,
22 23 type varchar(255),
23 24 name varchar(255),
24 25 label varchar(255),
... ... @@ -27,19 +28,20 @@ CREATE TABLE IF NOT EXISTS edge (
27 28 edge_license_key varchar(30),
28 29 cloud_endpoint varchar(255),
29 30 search_text varchar(255),
30   - tenant_id varchar(31),
  31 + tenant_id uuid,
31 32 CONSTRAINT edge_name_unq_key UNIQUE (tenant_id, name),
32 33 CONSTRAINT edge_routing_key_unq_key UNIQUE (routing_key)
33 34 );
34 35
35 36 CREATE TABLE IF NOT EXISTS edge_event (
36   - id varchar(31) NOT NULL CONSTRAINT edge_event_pkey PRIMARY KEY,
37   - edge_id varchar(31),
  37 + id uuid NOT NULL CONSTRAINT edge_event_pkey PRIMARY KEY,
  38 + created_time bigint NOT NULL,
  39 + edge_id uuid,
38 40 edge_event_type varchar(255),
39 41 edge_event_uid varchar(255),
40   - entity_id varchar(31),
  42 + entity_id uuid,
41 43 edge_event_action varchar(255),
42 44 body varchar(10000000),
43   - tenant_id varchar(31),
  45 + tenant_id uuid,
44 46 ts bigint NOT NULL
45 47 );
... ...
application/src/main/data/upgrade/3.2.0/schema_update_ttl.sql renamed from application/src/main/data/upgrade/2.6.0/schema_update_ttl.sql
... ... @@ -106,10 +106,10 @@ public class EdgeController extends BaseController {
106 106 edge.setTenantId(tenantId);
107 107 boolean created = edge.getId() == null;
108 108
109   - RuleChain defaultRootEdgeRuleChain = null;
  109 + RuleChain edgeTemplateRootRuleChain = null;
110 110 if (created) {
111   - defaultRootEdgeRuleChain = ruleChainService.getEdgeTemplateRootRuleChain(tenantId);
112   - if (defaultRootEdgeRuleChain == null) {
  111 + edgeTemplateRootRuleChain = ruleChainService.getEdgeTemplateRootRuleChain(tenantId);
  112 + if (edgeTemplateRootRuleChain == null) {
113 113 throw new DataValidationException("Root edge rule chain is not available!");
114 114 }
115 115 }
... ... @@ -122,8 +122,8 @@ public class EdgeController extends BaseController {
122 122 Edge savedEdge = checkNotNull(edgeService.saveEdge(edge));
123 123
124 124 if (created) {
125   - ruleChainService.assignRuleChainToEdge(tenantId, defaultRootEdgeRuleChain.getId(), savedEdge.getId());
126   - edgeNotificationService.setEdgeRootRuleChain(tenantId, savedEdge, defaultRootEdgeRuleChain.getId());
  125 + ruleChainService.assignRuleChainToEdge(tenantId, edgeTemplateRootRuleChain.getId(), savedEdge.getId());
  126 + edgeNotificationService.setEdgeRootRuleChain(tenantId, savedEdge, edgeTemplateRootRuleChain.getId());
127 127 edgeService.assignDefaultRuleChainsToEdge(tenantId, savedEdge.getId());
128 128 }
129 129
... ... @@ -456,10 +456,12 @@ public class EdgeController extends BaseController {
456 456 checkNotNull(query.getEdgeTypes());
457 457 checkEntityId(query.getParameters().getEntityId(), Operation.READ);
458 458 try {
459   - List<Edge> edges = checkNotNull(edgeService.findEdgesByQuery(getCurrentUser().getTenantId(), query).get());
  459 + SecurityUser user = getCurrentUser();
  460 + TenantId tenantId = user.getTenantId();
  461 + List<Edge> edges = checkNotNull(edgeService.findEdgesByQuery(tenantId, query).get());
460 462 edges = edges.stream().filter(edge -> {
461 463 try {
462   - accessControlService.checkPermission(getCurrentUser(), Resource.EDGE, Operation.READ, edge.getId(), edge);
  464 + accessControlService.checkPermission(user, Resource.EDGE, Operation.READ, edge.getId(), edge);
463 465 return true;
464 466 } catch (ThingsboardException e) {
465 467 return false;
... ...
... ... @@ -90,6 +90,9 @@ public class TenantController extends BaseController {
90 90 tenant = checkNotNull(tenantService.saveTenant(tenant));
91 91 if (newTenant) {
92 92 installScripts.createDefaultRuleChains(tenant.getId());
  93 + if (edgesEnabled) {
  94 + installScripts.createDefaultEdgeRuleChains(tenant.getId());
  95 + }
93 96 }
94 97 tenantProfileCache.evict(tenant.getId());
95 98 tbClusterService.onTenantChange(tenant, null);
... ...
... ... @@ -192,6 +192,13 @@ public class ThingsboardInstallService {
192 192 }
193 193 databaseEntitiesUpgradeService.upgradeDatabase("3.1.1");
194 194 dataUpdateService.updateData("3.1.1");
  195 + case "3.2.0":
  196 + log.info("Upgrading ThingsBoard from version 3.2.0 to 3.3.0 ...");
  197 + if (databaseTsUpgradeService != null) {
  198 + databaseTsUpgradeService.upgradeDatabase("3.2.0");
  199 + }
  200 + databaseEntitiesUpgradeService.upgradeDatabase("3.2.0");
  201 + dataUpdateService.updateData("3.2.0");
195 202 log.info("Updating system data...");
196 203 systemDataLoaderService.updateSystemWidgets();
197 204 systemDataLoaderService.createOAuth2Templates();
... ...
... ... @@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
28 28 import org.springframework.stereotype.Service;
29 29 import org.thingsboard.common.util.ThingsBoardThreadFactory;
30 30 import org.thingsboard.server.common.data.DataConstants;
  31 +import org.thingsboard.server.common.data.Tenant;
31 32 import org.thingsboard.server.common.data.edge.Edge;
32 33 import org.thingsboard.server.common.data.id.EdgeId;
33 34 import org.thingsboard.server.common.data.id.TenantId;
... ...
... ... @@ -52,6 +52,7 @@ public class CassandraTsDatabaseUpgradeService extends AbstractCassandraDatabase
52 52 case "2.5.4":
53 53 case "2.5.5":
54 54 case "3.1.1":
  55 + case "3.2.0":
55 56 break;
56 57 default:
57 58 throw new RuntimeException("Unable to upgrade Cassandra database, unsupported fromVersion: " + fromVersion);
... ...
... ... @@ -67,6 +67,8 @@ public class InstallScripts {
67 67 public static final String OAUTH2_CONFIG_TEMPLATES_DIR = "oauth2_config_templates";
68 68 public static final String DASHBOARDS_DIR = "dashboards";
69 69
  70 + public static final String EDGE_MANAGEMENT = "edge_management";
  71 +
70 72 public static final String JSON_EXT = ".json";
71 73
72 74 @Value("${install.data_dir:}")
... ... @@ -87,14 +89,18 @@ public class InstallScripts {
87 89 @Autowired
88 90 private OAuth2ConfigTemplateService oAuth2TemplateService;
89 91
90   - public Path getTenantRuleChainsDir() {
  92 + private Path getTenantRuleChainsDir() {
91 93 return Paths.get(getDataDir(), JSON_DIR, TENANT_DIR, RULE_CHAINS_DIR);
92 94 }
93 95
94   - public Path getDeviceProfileDefaultRuleChainTemplateFilePath() {
  96 + private Path getDeviceProfileDefaultRuleChainTemplateFilePath() {
95 97 return Paths.get(getDataDir(), JSON_DIR, TENANT_DIR, DEVICE_PROFILE_DIR, "rule_chain_template.json");
96 98 }
97 99
  100 + private Path getEdgeRuleChainsDir() {
  101 + return Paths.get(getDataDir(), JSON_DIR, TENANT_DIR, EDGE_MANAGEMENT, RULE_CHAINS_DIR);
  102 + }
  103 +
98 104 public String getDataDir() {
99 105 if (!StringUtils.isEmpty(dataDir)) {
100 106 if (!Paths.get(this.dataDir).toFile().isDirectory()) {
... ... @@ -118,7 +124,16 @@ public class InstallScripts {
118 124
119 125 public void createDefaultRuleChains(TenantId tenantId) throws IOException {
120 126 Path tenantChainsDir = getTenantRuleChainsDir();
121   - try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(tenantChainsDir, path -> path.toString().endsWith(InstallScripts.JSON_EXT))) {
  127 + loadRuleChainsFromPath(tenantId, tenantChainsDir);
  128 + }
  129 +
  130 + public void createDefaultEdgeRuleChains(TenantId tenantId) throws IOException {
  131 + Path edgeChainsDir = getEdgeRuleChainsDir();
  132 + loadRuleChainsFromPath(tenantId, edgeChainsDir);
  133 + }
  134 +
  135 + private void loadRuleChainsFromPath(TenantId tenantId, Path ruleChainsPath) throws IOException {
  136 + try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(ruleChainsPath, path -> path.toString().endsWith(InstallScripts.JSON_EXT))) {
122 137 dirStream.forEach(
123 138 path -> {
124 139 try {
... ... @@ -211,15 +226,16 @@ public class InstallScripts {
211 226 try {
212 227 createDefaultRuleChains(tenantId);
213 228 createDefaultRuleChain(tenantId, "Thermostat");
  229 + loadEdgeDemoRuleChains(tenantId);
214 230 } catch (Exception e) {
215 231 log.error("Unable to load dashboard from json", e);
216 232 throw new RuntimeException("Unable to load dashboard from json", e);
217 233 }
218 234 }
219 235
220   - public void createDefaultEdgeRuleChains(TenantId tenantId) throws IOException {
221   - Path tenantChainsDir = getTenantRuleChainsDir();
222   - createRuleChainFromFile(tenantId, tenantChainsDir.resolve("edge_root_rule_chain.json"), null);
  236 + private void loadEdgeDemoRuleChains(TenantId tenantId) throws Exception {
  237 + Path edgeDemoRuleChainsDir = Paths.get(getDataDir(), JSON_DIR, DEMO_DIR, EDGE_MANAGEMENT, RULE_CHAINS_DIR);
  238 + loadRuleChainsFromPath(tenantId, edgeDemoRuleChainsDir);
223 239 }
224 240
225 241 public void createOAuth2Templates() throws Exception {
... ...
... ... @@ -195,12 +195,6 @@ public class PsqlTsDatabaseUpgradeService extends AbstractSqlTsDatabaseUpgradeSe
195 195 executeQuery(conn, "UPDATE tb_schema_settings SET schema_version = 2005001");
196 196 }
197 197 break;
198   - case "2.5.5":
199   - try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
200   - log.info("Load TTL functions ...");
201   - loadSql(conn, "2.6.0", LOAD_TTL_FUNCTIONS_SQL);
202   - }
203   - break;
204 198 case "3.1.1":
205 199 try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
206 200 log.info("Load TTL functions ...");
... ... @@ -209,6 +203,12 @@ public class PsqlTsDatabaseUpgradeService extends AbstractSqlTsDatabaseUpgradeSe
209 203 loadSql(conn, "2.4.3", LOAD_DROP_PARTITIONS_FUNCTIONS_SQL);
210 204 }
211 205 break;
  206 + case "3.2.0":
  207 + try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
  208 + log.info("Load Edge TTL functions ...");
  209 + loadSql(conn, "3.2.0", LOAD_TTL_FUNCTIONS_SQL);
  210 + }
  211 + break;
212 212 default:
213 213 throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
214 214 }
... ...
... ... @@ -264,19 +264,6 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService
264 264 log.info("Schema updated.");
265 265 }
266 266 break;
267   - case "2.5.5":
268   - try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
269   - log.info("Updating schema ...");
270   - // TODO: voba - should be 2.6.0
271   - schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.5.0", SCHEMA_UPDATE_SQL);
272   - loadSql(schemaUpdateFile, conn);
273   -
274   - try {
275   - conn.createStatement().execute("ALTER TABLE rule_chain ADD type varchar(255) DEFAULT 'CORE'"); //NOSONAR, ignoring because method used to execute thingsboard database upgrade script
276   - } catch (Exception e) {}
277   - log.info("Schema updated.");
278   - }
279   - break;
280 267 case "3.0.1":
281 268 try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
282 269 log.info("Updating schema ...");
... ... @@ -434,7 +421,17 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService
434 421 log.error("Failed updating schema!!!", e);
435 422 }
436 423 break;
437   -
  424 + case "3.2.0":
  425 + try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
  426 + log.info("Updating schema ...");
  427 + schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "3.2.0", SCHEMA_UPDATE_SQL);
  428 + loadSql(schemaUpdateFile, conn);
  429 + try {
  430 + conn.createStatement().execute("ALTER TABLE rule_chain ADD type varchar(255) DEFAULT 'CORE'"); //NOSONAR, ignoring because method used to execute thingsboard database upgrade script
  431 + } catch (Exception e) {}
  432 + log.info("Schema updated.");
  433 + }
  434 + break;
438 435 default:
439 436 throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
440 437 }
... ...
... ... @@ -179,7 +179,7 @@ public class TimescaleTsDatabaseUpgradeService extends AbstractSqlTsDatabaseUpgr
179 179 break;
180 180 case "3.1.1":
181 181 break;
182   - case "2.5.5":
  182 + case "3.2.0":
183 183 break;
184 184 default:
185 185 throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
... ...
... ... @@ -79,10 +79,6 @@ public class DefaultDataUpdateService implements DataUpdateService {
79 79 log.info("Updating data from version 1.4.0 to 2.0.0 ...");
80 80 tenantsDefaultRuleChainUpdater.updateEntities(null);
81 81 break;
82   - case "2.5.5":
83   - log.info("Updating data from version 2.5.5 to 2.6.0 ...");
84   - tenantsDefaultEdgeRuleChainUpdater.updateEntities(null);
85   - break;
86 82 case "3.0.1":
87 83 log.info("Updating data from version 3.0.1 to 3.1.0 ...");
88 84 tenantsEntityViewsUpdater.updateEntities(null);
... ... @@ -91,6 +87,10 @@ public class DefaultDataUpdateService implements DataUpdateService {
91 87 log.info("Updating data from version 3.1.1 to 3.2.0 ...");
92 88 tenantsRootRuleChainUpdater.updateEntities(null);
93 89 break;
  90 + case "3.2.0":
  91 + log.info("Updating data from version 3.2.0 to 3.3.0 ...");
  92 + tenantsDefaultEdgeRuleChainUpdater.updateEntities(null);
  93 + break;
94 94 default:
95 95 throw new RuntimeException("Unable to update data, unsupported fromVersion: " + fromVersion);
96 96 }
... ...
... ... @@ -46,8 +46,6 @@ import org.thingsboard.server.common.data.EntityType;
46 46 import org.thingsboard.server.common.data.Tenant;
47 47 import org.thingsboard.server.common.data.User;
48 48 import org.thingsboard.server.common.data.edge.Edge;
49   -import org.thingsboard.server.common.data.edge.EdgeEventActionType;
50   -import org.thingsboard.server.common.data.edge.EdgeEventType;
51 49 import org.thingsboard.server.common.data.edge.EdgeInfo;
52 50 import org.thingsboard.server.common.data.edge.EdgeSearchQuery;
53 51 import org.thingsboard.server.common.data.id.CustomerId;
... ...
... ... @@ -105,7 +105,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC
105 105 EntityRelation.CONTAINS_TYPE, RelationTypeGroup.RULE_CHAIN));
106 106 } catch (Exception e) {
107 107 log.warn("[{}] Failed to create tenant to root rule chain relation. from: [{}], to: [{}]",
108   - savedRuleChain.getTenantId(), savedRuleChain.getId());
  108 + savedRuleChain.getTenantId(), savedRuleChain.getTenantId(), savedRuleChain.getId(), e);
109 109 throw new RuntimeException(e);
110 110 }
111 111 }
... ...
... ... @@ -2798,7 +2798,9 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
2798 2798 }
2799 2799
2800 2800 public void syncEdge(EdgeId edgeId) {
2801   - restTemplate.postForEntity(baseURL + "/api/edge/sync", edgeId, EdgeId.class);
  2801 + Map<String, String> params = new HashMap<>();
  2802 + params.put("edgeId", edgeId.toString());
  2803 + restTemplate.postForEntity(baseURL + "/api/edge/sync/{edgeId}", null, EdgeId.class, params);
2802 2804 }
2803 2805
2804 2806 @Deprecated
... ...
... ... @@ -431,7 +431,7 @@
431 431 "customer-required": "Kunde ist erforderlich",
432 432 "select-default-customer": "Wählen Sie den Standardkunden aus.",
433 433 "default-customer": "Standardkunde",
434   - "edges": "Kunden Rand",
  434 + "edge-instances": "Kunden Rand",
435 435 "default-customer-required": "Ein Standardkunde ist erforderlich, um das Dashboard auf Mandantenebene zu testen."
436 436 },
437 437 "datetime": {
... ... @@ -1404,7 +1404,8 @@
1404 1404 "set-auto-assign-to-edge-text": "Nach der Bestätigung wird die Kantenregelkette bei der Erstellung automatisch den Kanten zugewiesen.",
1405 1405 "unset-auto-assign-to-edge": "Deaktiviert die Zuordnung der Regelkette zu Kanten bei der Erstellung",
1406 1406 "unset-auto-assign-to-edge-title": "Möchten Sie die Kantenregelkette '{{ruleChainName}}' bei der Erstellung unbedingt den Kanten zuweisen?",
1407   - "unset-auto-assign-to-edge-text": "Nach der Bestätigung wird die Kantenregelkette bei der Erstellung nicht mehr automatisch den Kanten zugewiesen."
  1407 + "unset-auto-assign-to-edge-text": "Nach der Bestätigung wird die Kantenregelkette bei der Erstellung nicht mehr automatisch den Kanten zugewiesen.",
  1408 + "edge-template-root": "Vorlagenstamm"
1408 1409 },
1409 1410 "rulenode": {
1410 1411 "details": "Details",
... ...
... ... @@ -584,7 +584,6 @@
584 584 "devices": "Customer Devices",
585 585 "entity-views": "Customer Entity Views",
586 586 "assets": "Customer Assets",
587   - "edges": "Customer Edges",
588 587 "public-dashboards": "Public Dashboards",
589 588 "public-devices": "Public Devices",
590 589 "public-assets": "Public Assets",
... ... @@ -627,7 +626,8 @@
627 626 "default-customer": "Default customer",
628 627 "default-customer-required": "Default customer is required in order to debug dashboard on Tenant level",
629 628 "search": "Search customers",
630   - "selected-customers": "{ count, plural, 1 {1 customer} other {# customers} } selected"
  629 + "selected-customers": "{ count, plural, 1 {1 customer} other {# customers} } selected",
  630 + "edges": "Customer edge instances"
631 631 },
632 632 "datetime": {
633 633 "date-from": "Date from",
... ... @@ -1186,144 +1186,144 @@
1186 1186 "row": "Row"
1187 1187 },
1188 1188 "edge": {
1189   - "edge": "Edge",
1190   - "edge-instances": "Edge instances",
1191   - "edge-file": "Edge file",
1192   - "management": "Edge management",
1193   - "no-edges-matching": "No edges matching '{{entity}}' were found.",
1194   - "rulechain-templates": "Rule chain templates",
1195   - "rulechains": "Rule chains",
1196   - "edge-rulechains": "Edge Rule chains",
1197   - "add": "Add Edge",
1198   - "view": "View Edge",
1199   - "no-edges-text": "No edges found",
1200   - "edge-details": "Edge details",
1201   - "add-edge-text": "Add new edge",
1202   - "delete": "Delete edge",
1203   - "delete-edges": "Delete edges",
1204   - "delete-edge-title": "Are you sure you want to delete the edge '{{edgeName}}'?",
1205   - "delete-edge-text": "Be careful, after the confirmation the edge and all related data will become unrecoverable.",
1206   - "delete-edges-title": "Are you sure you want to edge { count, plural, 1 {1 edge} other {# edges} }?",
1207   - "delete-edges-text": "Be careful, after the confirmation all selected edges will be removed and all related data will become unrecoverable.",
1208   - "name": "Name",
1209   - "name-starts-with": "Edge name starts with",
1210   - "name-required": "Name is required.",
1211   - "edge-license-key": "Edge License Key",
1212   - "edge-license-key-required": "Edge License Key is required.",
1213   - "edge-license-key-hint": "To obtain your license please navigate to the <a href='https://thingsboard.io/pricing/?active=thingsboard-edge' target='_blank'>pricing page</a> and select the best license option for your case.",
1214   - "cloud-endpoint": "Cloud Endpoint",
1215   - "cloud-endpoint-required": "Cloud Endpoint is required.",
1216   - "cloud-endpoint-hint": "Edge requires HTTP(s) access to Cloud (ThingsBoard CE/PE) to verify the license key. Please specify Cloud URL that Edge is able to connect to.",
1217   - "description": "Description",
1218   - "entity-info": "Entity info",
1219   - "details": "Details",
1220   - "events": "Events",
1221   - "copy-id": "Copy Edge Id",
1222   - "id-copied-message": "Edge Id has been copied to clipboard",
1223   - "sync": "Sync Edge",
1224   - "sync-message": "Edge has been synchronized",
1225   - "permissions": "Permissions",
1226   - "edge-required": "Edge required",
1227   - "edge-type": "Edge type",
1228   - "edge-type-required": "Edge type is required.",
1229   - "event-action": "Event action",
1230   - "entity-id": "Entity ID",
1231   - "select-edge-type": "Select edge type",
1232   - "assign-to-customer": "Assign to customer",
1233   - "assign-to-customer-text": "Please select the customer to assign the edge(s)",
1234   - "assign-edge-to-customer": "Assign Edge(s) To Customer",
1235   - "assign-edge-to-customer-text": "Please select the edges to assign to the customer",
1236   - "assigned-to-customer": "Assigned to customer",
1237   - "unassign-from-customer": "Unassign from customer",
1238   - "assign-edges-text": "Assign { count, plural, 1 {1 edge} other {# edges} } to customer",
1239   - "unassign-edge-title": "Are you sure you want to unassign the edge '{{edgeName}}'?",
1240   - "unassign-edge-text": "After the confirmation the edge will be unassigned and won't be accessible by the customer.",
1241   - "unassign-edges-title": "Are you sure you want to unassign { count, plural, 1 {1 edge} other {# edges} }?",
1242   - "unassign-edges-text": "After the confirmation all selected edges will be unassigned and won't be accessible by the customer.",
1243   - "make-public": "Make edge public",
1244   - "make-public-edge-title": "Are you sure you want to make the edge '{{edgeName}}' public?",
1245   - "make-public-edge-text": "After the confirmation the edge and all its data will be made public and accessible by others.",
1246   - "make-private": "Make edge private",
1247   - "public": "Public",
1248   - "make-private-edge-title": "Are you sure you want to make the edge '{{edgeName}}' private?",
1249   - "make-private-edge-text": "After the confirmation the edge and all its data will be made private and won't be accessible by others.",
1250   - "import": "Import edge",
1251   - "label": "Label",
1252   - "load-entity-error": "Failed to load data. Entity not found or has been deleted.",
1253   - "assign-new-edge": "Assign new edge",
1254   - "manage-edge-dashboards": "Edge dashboards",
1255   - "unassign-from-edge": "Unassign from edge",
1256   - "dashboards": "Edge Dashboards",
1257   - "manage-edge-rulechains": "Edge rule chains",
1258   - "edge-key": "Edge key",
1259   - "copy-edge-key": "Copy Edge key",
1260   - "edge-key-copied-message": "Edge key has been copied to clipboard",
1261   - "edge-secret": "Edge secret",
1262   - "copy-edge-secret": "Copy Edge secret",
1263   - "edge-secret-copied-message": "Edge secret has been copied to clipboard",
1264   - "manage-edge-assets": "Edge assets",
1265   - "manage-edge-devices": "Edge devices",
1266   - "manage-edge-entity-views": "Edge entity views",
1267   - "assets": "Edge assets",
1268   - "devices": "Edge devices",
1269   - "entity-views": "Edge entity views",
1270   - "set-root-rule-chain-text": "Please select root rule chain for edge(s)",
1271   - "set-root-rule-chain-to-edges": "Set root rule chain for Edge(s)",
1272   - "set-root-rule-chain-to-edges-text": "Set root rule chain for { count, plural, 1 {1 edge} other {# edges} }",
1273   - "status": "Received by edge",
1274   - "success": "Deployed",
1275   - "failed": "Pending",
1276   - "search": "Search edges",
1277   - "selected-edges": "{ count, plural, 1 {1 edge} other {# edges} } selected",
1278   - "any-edge": "Any edge",
1279   - "no-edge-types-matching": "No edge types matching '{{entitySubtype}}' were found.",
1280   - "edge-type-list-empty": "No edge types selected.",
1281   - "edge-types": "Edge types",
1282   - "dashboard": "Edge dashboard",
1283   - "enter-edge-type": "Enter edge type",
1284   - "deployed": "Deployed",
1285   - "pending": "Pending",
1286   - "downlinks": "Downlinks",
1287   - "no-downlinks-prompt": "No downlinks found",
1288   - "sync-process-started-successfully": "Sync process started successfully!",
1289   - "missing-related-rule-chains-title": "Edge has missing related rule chain(s)",
1290   - "missing-related-rule-chains-text": "Assigned to edge rule chain(s) use rule nodes that forward message(s) to rule chain(s) that are not assigned to this edge. <br><br> List of missing rule chain(s): <br> {{missingRuleChains}}"
  1189 + "edge": "Edge",
  1190 + "edge-instances": "Edge instances",
  1191 + "edge-file": "Edge file",
  1192 + "management": "Edge management",
  1193 + "no-edges-matching": "No edges matching '{{entity}}' were found.",
  1194 + "rulechain-templates": "Rule chain templates",
  1195 + "rulechains": "Rule chains",
  1196 + "edge-rulechains": "Edge Rule chains",
  1197 + "add": "Add Edge",
  1198 + "view": "View Edge",
  1199 + "no-edges-text": "No edges found",
  1200 + "edge-details": "Edge details",
  1201 + "add-edge-text": "Add new edge",
  1202 + "delete": "Delete edge",
  1203 + "delete-edges": "Delete edges",
  1204 + "delete-edge-title": "Are you sure you want to delete the edge '{{edgeName}}'?",
  1205 + "delete-edge-text": "Be careful, after the confirmation the edge and all related data will become unrecoverable.",
  1206 + "delete-edges-title": "Are you sure you want to edge { count, plural, 1 {1 edge} other {# edges} }?",
  1207 + "delete-edges-text": "Be careful, after the confirmation all selected edges will be removed and all related data will become unrecoverable.",
  1208 + "name": "Name",
  1209 + "name-starts-with": "Edge name starts with",
  1210 + "name-required": "Name is required.",
  1211 + "edge-license-key": "Edge License Key",
  1212 + "edge-license-key-required": "Edge License Key is required.",
  1213 + "edge-license-key-hint": "To obtain your license please navigate to the <a href='https://thingsboard.io/pricing/?active=thingsboard-edge' target='_blank'>pricing page</a> and select the best license option for your case.",
  1214 + "cloud-endpoint": "Cloud Endpoint",
  1215 + "cloud-endpoint-required": "Cloud Endpoint is required.",
  1216 + "cloud-endpoint-hint": "Edge requires HTTP(s) access to Cloud (ThingsBoard CE/PE) to verify the license key. Please specify Cloud URL that Edge is able to connect to.",
  1217 + "description": "Description",
  1218 + "entity-info": "Entity info",
  1219 + "details": "Details",
  1220 + "events": "Events",
  1221 + "copy-id": "Copy Edge Id",
  1222 + "id-copied-message": "Edge Id has been copied to clipboard",
  1223 + "sync": "Sync Edge",
  1224 + "sync-message": "Edge has been synchronized",
  1225 + "permissions": "Permissions",
  1226 + "edge-required": "Edge required",
  1227 + "edge-type": "Edge type",
  1228 + "edge-type-required": "Edge type is required.",
  1229 + "event-action": "Event action",
  1230 + "entity-id": "Entity ID",
  1231 + "select-edge-type": "Select edge type",
  1232 + "assign-to-customer": "Assign to customer",
  1233 + "assign-to-customer-text": "Please select the customer to assign the edge(s)",
  1234 + "assign-edge-to-customer": "Assign Edge(s) To Customer",
  1235 + "assign-edge-to-customer-text": "Please select the edges to assign to the customer",
  1236 + "assigned-to-customer": "Assigned to customer",
  1237 + "unassign-from-customer": "Unassign from customer",
  1238 + "assign-edges-text": "Assign { count, plural, 1 {1 edge} other {# edges} } to customer",
  1239 + "unassign-edge-title": "Are you sure you want to unassign the edge '{{edgeName}}'?",
  1240 + "unassign-edge-text": "After the confirmation the edge will be unassigned and won't be accessible by the customer.",
  1241 + "unassign-edges-title": "Are you sure you want to unassign { count, plural, 1 {1 edge} other {# edges} }?",
  1242 + "unassign-edges-text": "After the confirmation all selected edges will be unassigned and won't be accessible by the customer.",
  1243 + "make-public": "Make edge public",
  1244 + "make-public-edge-title": "Are you sure you want to make the edge '{{edgeName}}' public?",
  1245 + "make-public-edge-text": "After the confirmation the edge and all its data will be made public and accessible by others.",
  1246 + "make-private": "Make edge private",
  1247 + "public": "Public",
  1248 + "make-private-edge-title": "Are you sure you want to make the edge '{{edgeName}}' private?",
  1249 + "make-private-edge-text": "After the confirmation the edge and all its data will be made private and won't be accessible by others.",
  1250 + "import": "Import edge",
  1251 + "label": "Label",
  1252 + "load-entity-error": "Failed to load data. Entity not found or has been deleted.",
  1253 + "assign-new-edge": "Assign new edge",
  1254 + "manage-edge-dashboards": "Edge dashboards",
  1255 + "unassign-from-edge": "Unassign from edge",
  1256 + "dashboards": "Edge Dashboards",
  1257 + "manage-edge-rulechains": "Edge rule chains",
  1258 + "edge-key": "Edge key",
  1259 + "copy-edge-key": "Copy Edge key",
  1260 + "edge-key-copied-message": "Edge key has been copied to clipboard",
  1261 + "edge-secret": "Edge secret",
  1262 + "copy-edge-secret": "Copy Edge secret",
  1263 + "edge-secret-copied-message": "Edge secret has been copied to clipboard",
  1264 + "manage-edge-assets": "Edge assets",
  1265 + "manage-edge-devices": "Edge devices",
  1266 + "manage-edge-entity-views": "Edge entity views",
  1267 + "assets": "Edge assets",
  1268 + "devices": "Edge devices",
  1269 + "entity-views": "Edge entity views",
  1270 + "set-root-rule-chain-text": "Please select root rule chain for edge(s)",
  1271 + "set-root-rule-chain-to-edges": "Set root rule chain for Edge(s)",
  1272 + "set-root-rule-chain-to-edges-text": "Set root rule chain for { count, plural, 1 {1 edge} other {# edges} }",
  1273 + "status": "Received by edge",
  1274 + "success": "Deployed",
  1275 + "failed": "Pending",
  1276 + "search": "Search edges",
  1277 + "selected-edges": "{ count, plural, 1 {1 edge} other {# edges} } selected",
  1278 + "any-edge": "Any edge",
  1279 + "no-edge-types-matching": "No edge types matching '{{entitySubtype}}' were found.",
  1280 + "edge-type-list-empty": "No edge types selected.",
  1281 + "edge-types": "Edge types",
  1282 + "dashboard": "Edge dashboard",
  1283 + "enter-edge-type": "Enter edge type",
  1284 + "deployed": "Deployed",
  1285 + "pending": "Pending",
  1286 + "downlinks": "Downlinks",
  1287 + "no-downlinks-prompt": "No downlinks found",
  1288 + "sync-process-started-successfully": "Sync process started successfully!",
  1289 + "missing-related-rule-chains-title": "Edge has missing related rule chain(s)",
  1290 + "missing-related-rule-chains-text": "Assigned to edge rule chain(s) use rule nodes that forward message(s) to rule chain(s) that are not assigned to this edge. <br><br> List of missing rule chain(s): <br> {{missingRuleChains}}"
1291 1291 },
1292 1292 "edge-event": {
1293   - "type-dashboard": "Dashboard",
1294   - "type-asset": "Asset",
1295   - "type-device": "Device",
1296   - "type-device-profile": "Device Profile",
1297   - "type-entity-view": "Entity View",
1298   - "type-alarm": "Alar",
1299   - "type-rule-chain": "Rule Chain",
1300   - "type-rule-chain-metadata": "Rule Chain Metadata",
1301   - "type-edge": "Edge",
1302   - "type-user": "User",
1303   - "type-customer": "Customer",
1304   - "type-relation": "Relation",
1305   - "type-widgets-bundle": "Widgets Bundle",
1306   - "type-widgets-type": "Widgets Type",
1307   - "type-admin-settings": "Admin Settings",
1308   - "action-type-added": "Added",
1309   - "action-type-deleted": "Deleted",
1310   - "action-type-updated": "Updated",
1311   - "action-type-post-attributes": "Post Attributes",
1312   - "action-type-attributes-updated": "Attributes Updated",
1313   - "action-type-attributes-deleted": "Attributes Deleted",
1314   - "action-type-timeseries-updated": "Timeseries Updated",
1315   - "action-type-credentials-updated": "Credentials Updated",
1316   - "action-type-assigned-to-customer": "Assigned to Customer",
1317   - "action-type-unassigned-from-customer": "Unassigned from Customer",
1318   - "action-type-relation-add-or-update": "Relation Add or Update",
1319   - "action-type-relation-deleted": "Relation Deleted",
1320   - "action-type-rpc-call": "RPC Call",
1321   - "action-type-alarm-ack": "Alarm Ack",
1322   - "action-type-alarm-clear": "Alarm Clear",
1323   - "action-type-assigned-to-edge": "Assigned to Edge",
1324   - "action-type-unassigned-from-edge": "Unassigned from Edge",
1325   - "action-type-credentials-request": "Credentials Request",
1326   - "action-type-entity-merge-request": "Entity Merge Request"
  1293 + "type-dashboard": "Dashboard",
  1294 + "type-asset": "Asset",
  1295 + "type-device": "Device",
  1296 + "type-device-profile": "Device Profile",
  1297 + "type-entity-view": "Entity View",
  1298 + "type-alarm": "Alar",
  1299 + "type-rule-chain": "Rule Chain",
  1300 + "type-rule-chain-metadata": "Rule Chain Metadata",
  1301 + "type-edge": "Edge",
  1302 + "type-user": "User",
  1303 + "type-customer": "Customer",
  1304 + "type-relation": "Relation",
  1305 + "type-widgets-bundle": "Widgets Bundle",
  1306 + "type-widgets-type": "Widgets Type",
  1307 + "type-admin-settings": "Admin Settings",
  1308 + "action-type-added": "Added",
  1309 + "action-type-deleted": "Deleted",
  1310 + "action-type-updated": "Updated",
  1311 + "action-type-post-attributes": "Post Attributes",
  1312 + "action-type-attributes-updated": "Attributes Updated",
  1313 + "action-type-attributes-deleted": "Attributes Deleted",
  1314 + "action-type-timeseries-updated": "Timeseries Updated",
  1315 + "action-type-credentials-updated": "Credentials Updated",
  1316 + "action-type-assigned-to-customer": "Assigned to Customer",
  1317 + "action-type-unassigned-from-customer": "Unassigned from Customer",
  1318 + "action-type-relation-add-or-update": "Relation Add or Update",
  1319 + "action-type-relation-deleted": "Relation Deleted",
  1320 + "action-type-rpc-call": "RPC Call",
  1321 + "action-type-alarm-ack": "Alarm Ack",
  1322 + "action-type-alarm-clear": "Alarm Clear",
  1323 + "action-type-assigned-to-edge": "Assigned to Edge",
  1324 + "action-type-unassigned-from-edge": "Unassigned from Edge",
  1325 + "action-type-credentials-request": "Credentials Request",
  1326 + "action-type-entity-merge-request": "Entity Merge Request"
1327 1327 },
1328 1328 "error": {
1329 1329 "unable-to-connect": "Unable to connect to the server! Please check your internet connection.",
... ...
... ... @@ -1575,7 +1575,8 @@
1575 1575 "set-auto-assign-to-edge-text": "Después de la confirmación, la cadena de reglas de borde se asignará automáticamente a los bordes en la creación.",
1576 1576 "unset-auto-assign-to-edge": "Desmarcar asignar cadena de reglas a los bordes en la creación",
1577 1577 "unset-auto-assign-to-edge-title": "¿Está seguro de que desea anular la asignación de la cadena de reglas de borde '{{ruleChainName}}' a los bordes en la creación?",
1578   - "unset-auto-assign-to-edge-text": "Después de la confirmación, la cadena de reglas de borde ya no se asignará automáticamente a los bordes en la creación."
  1578 + "unset-auto-assign-to-edge-text": "Después de la confirmación, la cadena de reglas de borde ya no se asignará automáticamente a los bordes en la creación.",
  1579 + "edge-template-root": "Raíz de plantilla"
1579 1580 },
1580 1581 "rulenode": {
1581 1582 "details": "Detalles",
... ...
... ... @@ -1449,7 +1449,8 @@
1449 1449 "set-auto-assign-to-edge-text": "Après la confirmation, la chaîne de règles d'arête sera automatiquement affectée à l'arête (s) lors de la création.",
1450 1450 "unset-auto-assign-to-edge": "Non défini, attribuer une chaîne de règles aux arêtes lors de la création",
1451 1451 "unset-auto-assign-to-edge-title": "Voulez-vous vraiment annuler l'attribution de la chaîne de règles d'arête \"{{ruleChainName}}\" aux arêtes lors de la création?",
1452   - "unset-auto-assign-to-edge-text": "Après la confirmation, la chaîne de règles d'arêtes ne sera plus automatiquement affectée aux arêtes lors de la création."
  1452 + "unset-auto-assign-to-edge-text": "Après la confirmation, la chaîne de règles d'arêtes ne sera plus automatiquement affectée aux arêtes lors de la création.",
  1453 + "edge-template-root": "Racine du modèle"
1453 1454 },
1454 1455 "rulenode": {
1455 1456 "add": "Ajouter un noeud de règle",
... ...