Commit 90643f397c1a83ea9d6b058af80592bc9c6bbc48

Authored by Volodymyr Babak
1 parent 928f8f84

Fixes for entity_views update schemas

@@ -14,13 +14,6 @@ @@ -14,13 +14,6 @@
14 -- limitations under the License. 14 -- limitations under the License.
15 -- 15 --
16 16
17 -DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_view_by_tenant_and_name;  
18 -DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_view_by_tenant_and_search_text;  
19 -DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_view_by_tenant_and_customer;  
20 -DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_view_by_tenant_and_entity_id;  
21 -  
22 -DROP TABLE IF EXISTS thingsboard.entity_views;  
23 -  
24 CREATE TABLE IF NOT EXISTS thingsboard.entity_views ( 17 CREATE TABLE IF NOT EXISTS thingsboard.entity_views (
25 id timeuuid, 18 id timeuuid,
26 entity_id timeuuid, 19 entity_id timeuuid,
@@ -14,10 +14,8 @@ @@ -14,10 +14,8 @@
14 -- limitations under the License. 14 -- limitations under the License.
15 -- 15 --
16 16
17 -DROP TABLE IF EXISTS entity_views;  
18 -  
19 CREATE TABLE IF NOT EXISTS entity_views ( 17 CREATE TABLE IF NOT EXISTS entity_views (
20 - id varchar(31) NOT NULL CONSTRAINT entity_view_pkey PRIMARY KEY, 18 + id varchar(31) NOT NULL CONSTRAINT entity_views_pkey PRIMARY KEY,
21 entity_id varchar(31), 19 entity_id varchar(31),
22 entity_type varchar(255), 20 entity_type varchar(255),
23 tenant_id varchar(31), 21 tenant_id varchar(31),
@@ -36,6 +36,7 @@ import org.thingsboard.server.common.data.id.DeviceId; @@ -36,6 +36,7 @@ import org.thingsboard.server.common.data.id.DeviceId;
36 import org.thingsboard.server.common.data.id.EntityId; 36 import org.thingsboard.server.common.data.id.EntityId;
37 import org.thingsboard.server.common.data.relation.EntityRelation; 37 import org.thingsboard.server.common.data.relation.EntityRelation;
38 import org.thingsboard.server.common.data.security.DeviceCredentials; 38 import org.thingsboard.server.common.data.security.DeviceCredentials;
  39 +import org.thingsboard.server.common.data.security.DeviceCredentialsType;
39 40
40 import java.io.IOException; 41 import java.io.IOException;
41 import java.util.Collections; 42 import java.util.Collections;
@@ -120,6 +121,21 @@ public class RestClient implements ClientHttpRequestInterceptor { @@ -120,6 +121,21 @@ public class RestClient implements ClientHttpRequestInterceptor {
120 return restTemplate.postForEntity(baseURL + "/api/device", device, Device.class).getBody(); 121 return restTemplate.postForEntity(baseURL + "/api/device", device, Device.class).getBody();
121 } 122 }
122 123
  124 + public void deleteDevice(DeviceId deviceId) {
  125 + restTemplate.delete(baseURL + "/api/device/" + deviceId.getId().toString());
  126 + }
  127 +
  128 + public DeviceCredentials updateDeviceCredentials(DeviceId deviceId, String token) {
  129 + DeviceCredentials deviceCredentials = getCredentials(deviceId);
  130 + deviceCredentials.setCredentialsType(DeviceCredentialsType.ACCESS_TOKEN);
  131 + deviceCredentials.setCredentialsId(token);
  132 + return saveDeviceCredentials(deviceCredentials);
  133 + }
  134 +
  135 + public DeviceCredentials saveDeviceCredentials(DeviceCredentials deviceCredentials) {
  136 + return restTemplate.postForEntity(baseURL + "/api/device/credentials", deviceCredentials, DeviceCredentials.class).getBody();
  137 + }
  138 +
123 public Asset createAsset(String name, String type) { 139 public Asset createAsset(String name, String type) {
124 Asset asset = new Asset(); 140 Asset asset = new Asset();
125 asset.setName(name); 141 asset.setName(name);