Commit 90643f397c1a83ea9d6b058af80592bc9c6bbc48
1 parent
928f8f84
Fixes for entity_views update schemas
Showing
3 changed files
with
17 additions
and
10 deletions
... | ... | @@ -14,13 +14,6 @@ |
14 | 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 | 17 | CREATE TABLE IF NOT EXISTS thingsboard.entity_views ( |
25 | 18 | id timeuuid, |
26 | 19 | entity_id timeuuid, | ... | ... |
... | ... | @@ -14,10 +14,8 @@ |
14 | 14 | -- limitations under the License. |
15 | 15 | -- |
16 | 16 | |
17 | -DROP TABLE IF EXISTS entity_views; | |
18 | - | |
19 | 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 | 19 | entity_id varchar(31), |
22 | 20 | entity_type varchar(255), |
23 | 21 | tenant_id varchar(31), | ... | ... |
... | ... | @@ -36,6 +36,7 @@ import org.thingsboard.server.common.data.id.DeviceId; |
36 | 36 | import org.thingsboard.server.common.data.id.EntityId; |
37 | 37 | import org.thingsboard.server.common.data.relation.EntityRelation; |
38 | 38 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
39 | +import org.thingsboard.server.common.data.security.DeviceCredentialsType; | |
39 | 40 | |
40 | 41 | import java.io.IOException; |
41 | 42 | import java.util.Collections; |
... | ... | @@ -120,6 +121,21 @@ public class RestClient implements ClientHttpRequestInterceptor { |
120 | 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 | 139 | public Asset createAsset(String name, String type) { |
124 | 140 | Asset asset = new Asset(); |
125 | 141 | asset.setName(name); | ... | ... |