Browse Source

Fixes for entity_views update schemas

pull/1349/head
Volodymyr Babak 8 years ago
parent
commit
90643f397c
  1. 7
      application/src/main/data/upgrade/2.1.1/schema_update.cql
  2. 4
      application/src/main/data/upgrade/2.1.1/schema_update.sql
  3. 16
      tools/src/main/java/org/thingsboard/client/tools/RestClient.java

7
application/src/main/data/upgrade/2.1.1/schema_update.cql

@ -14,13 +14,6 @@
-- limitations under the License.
--
DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_view_by_tenant_and_name;
DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_view_by_tenant_and_search_text;
DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_view_by_tenant_and_customer;
DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_view_by_tenant_and_entity_id;
DROP TABLE IF EXISTS thingsboard.entity_views;
CREATE TABLE IF NOT EXISTS thingsboard.entity_views (
id timeuuid,
entity_id timeuuid,

4
application/src/main/data/upgrade/2.1.1/schema_update.sql

@ -14,10 +14,8 @@
-- limitations under the License.
--
DROP TABLE IF EXISTS entity_views;
CREATE TABLE IF NOT EXISTS entity_views (
id varchar(31) NOT NULL CONSTRAINT entity_view_pkey PRIMARY KEY,
id varchar(31) NOT NULL CONSTRAINT entity_views_pkey PRIMARY KEY,
entity_id varchar(31),
entity_type varchar(255),
tenant_id varchar(31),

16
tools/src/main/java/org/thingsboard/client/tools/RestClient.java

@ -36,6 +36,7 @@ import org.thingsboard.server.common.data.id.DeviceId;
import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.relation.EntityRelation;
import org.thingsboard.server.common.data.security.DeviceCredentials;
import org.thingsboard.server.common.data.security.DeviceCredentialsType;
import java.io.IOException;
import java.util.Collections;
@ -120,6 +121,21 @@ public class RestClient implements ClientHttpRequestInterceptor {
return restTemplate.postForEntity(baseURL + "/api/device", device, Device.class).getBody();
}
public void deleteDevice(DeviceId deviceId) {
restTemplate.delete(baseURL + "/api/device/" + deviceId.getId().toString());
}
public DeviceCredentials updateDeviceCredentials(DeviceId deviceId, String token) {
DeviceCredentials deviceCredentials = getCredentials(deviceId);
deviceCredentials.setCredentialsType(DeviceCredentialsType.ACCESS_TOKEN);
deviceCredentials.setCredentialsId(token);
return saveDeviceCredentials(deviceCredentials);
}
public DeviceCredentials saveDeviceCredentials(DeviceCredentials deviceCredentials) {
return restTemplate.postForEntity(baseURL + "/api/device/credentials", deviceCredentials, DeviceCredentials.class).getBody();
}
public Asset createAsset(String name, String type) {
Asset asset = new Asset();
asset.setName(name);

Loading…
Cancel
Save