Showing
19 changed files
with
102 additions
and
270 deletions
... | ... | @@ -14,10 +14,9 @@ |
14 | 14 | -- limitations under the License. |
15 | 15 | -- |
16 | 16 | |
17 | -DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_views_by_tenant_and_name; | |
18 | -DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_views_by_tenant_and_entity; | |
19 | -DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_views_by_tenant_and_customer; | |
20 | -DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_views_by_tenant_and_customer_and_entity; | |
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; | |
21 | 20 | |
22 | 21 | DROP TABLE IF EXISTS thingsboard.entity_views; |
23 | 22 | |
... | ... | @@ -36,7 +35,7 @@ CREATE TABLE IF NOT EXISTS thingsboard.entity_views ( |
36 | 35 | PRIMARY KEY (id, entity_id, tenant_id, customer_id) |
37 | 36 | ); |
38 | 37 | |
39 | -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_name AS | |
38 | +CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_name AS | |
40 | 39 | SELECT * |
41 | 40 | from thingsboard.entity_views |
42 | 41 | WHERE tenant_id IS NOT NULL |
... | ... | @@ -58,18 +57,7 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_sea |
58 | 57 | PRIMARY KEY (tenant_id, search_text, id, customer_id, entity_id) |
59 | 58 | WITH CLUSTERING ORDER BY (search_text ASC, id DESC, customer_id DESC); |
60 | 59 | |
61 | -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_entity AS | |
62 | - SELECT * | |
63 | - from thingsboard.entity_views | |
64 | - WHERE tenant_id IS NOT NULL | |
65 | - AND customer_id IS NOT NULL | |
66 | - AND entity_id IS NOT NULL | |
67 | - AND search_text IS NOT NULL | |
68 | - AND id IS NOT NULL | |
69 | - PRIMARY KEY (tenant_id, entity_id, search_text, id, customer_id) | |
70 | - WITH CLUSTERING ORDER BY (entity_id ASC, search_text ASC, id DESC, customer_id DESC); | |
71 | - | |
72 | -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer AS | |
60 | +CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_customer AS | |
73 | 61 | SELECT * |
74 | 62 | from thingsboard.entity_views |
75 | 63 | WHERE tenant_id IS NOT NULL |
... | ... | @@ -79,14 +67,3 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_cu |
79 | 67 | AND id IS NOT NULL |
80 | 68 | PRIMARY KEY (tenant_id, customer_id, search_text, id, entity_id) |
81 | 69 | WITH CLUSTERING ORDER BY (customer_id DESC, search_text ASC, id DESC); |
82 | - | |
83 | -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer_and_entity AS | |
84 | - SELECT * | |
85 | - from thingsboard.entity_views | |
86 | - WHERE tenant_id IS NOT NULL | |
87 | - AND customer_id IS NOT NULL | |
88 | - AND entity_id IS NOT NULL | |
89 | - AND search_text IS NOT NULL | |
90 | - AND id IS NOT NULL | |
91 | - PRIMARY KEY (tenant_id, customer_id, entity_id, search_text, id) | |
92 | - WITH CLUSTERING ORDER BY (customer_id DESC, entity_id ASC, search_text ASC, id DESC); | ... | ... |
... | ... | @@ -93,8 +93,6 @@ public class ThingsboardInstallService { |
93 | 93 | |
94 | 94 | databaseUpgradeService.upgradeDatabase("2.0.0"); |
95 | 95 | |
96 | - dataUpdateService.updateData("2.0.0"); | |
97 | - | |
98 | 96 | log.info("Updating system data..."); |
99 | 97 | |
100 | 98 | systemDataLoaderService.deleteSystemWidgetBundle("charts"); | ... | ... |
... | ... | @@ -49,10 +49,6 @@ public class DefaultDataUpdateService implements DataUpdateService { |
49 | 49 | log.info("Updating data from version 1.4.0 to 2.0.0 ..."); |
50 | 50 | tenantsDefaultRuleChainUpdater.updateEntities(null); |
51 | 51 | break; |
52 | - case "2.0.0": | |
53 | - log.info("Updating data from version 2.0.0 to 2.1.1 ..."); | |
54 | - tenantsDefaultRuleChainUpdater.updateEntities(null); | |
55 | - break; | |
56 | 52 | default: |
57 | 53 | throw new RuntimeException("Unable to update data, unsupported fromVersion: " + fromVersion); |
58 | 54 | } | ... | ... |
... | ... | @@ -30,7 +30,15 @@ import org.thingsboard.server.common.data.EntityView; |
30 | 30 | import org.thingsboard.server.common.data.Tenant; |
31 | 31 | import org.thingsboard.server.common.data.asset.Asset; |
32 | 32 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
33 | -import org.thingsboard.server.common.data.id.*; | |
33 | +import org.thingsboard.server.common.data.id.AssetId; | |
34 | +import org.thingsboard.server.common.data.id.CustomerId; | |
35 | +import org.thingsboard.server.common.data.id.DeviceId; | |
36 | +import org.thingsboard.server.common.data.id.EntityId; | |
37 | +import org.thingsboard.server.common.data.id.EntityIdFactory; | |
38 | +import org.thingsboard.server.common.data.id.EntityViewId; | |
39 | +import org.thingsboard.server.common.data.id.RuleChainId; | |
40 | +import org.thingsboard.server.common.data.id.RuleNodeId; | |
41 | +import org.thingsboard.server.common.data.id.TenantId; | |
34 | 42 | import org.thingsboard.server.common.data.rule.RuleChain; |
35 | 43 | import org.thingsboard.server.common.data.rule.RuleNode; |
36 | 44 | import org.thingsboard.server.controller.HttpValidationCallback; | ... | ... |
... | ... | @@ -22,7 +22,11 @@ import org.junit.After; |
22 | 22 | import org.junit.Assert; |
23 | 23 | import org.junit.Before; |
24 | 24 | import org.junit.Test; |
25 | -import org.thingsboard.server.common.data.*; | |
25 | +import org.thingsboard.server.common.data.Customer; | |
26 | +import org.thingsboard.server.common.data.Device; | |
27 | +import org.thingsboard.server.common.data.EntityView; | |
28 | +import org.thingsboard.server.common.data.Tenant; | |
29 | +import org.thingsboard.server.common.data.User; | |
26 | 30 | import org.thingsboard.server.common.data.id.CustomerId; |
27 | 31 | import org.thingsboard.server.common.data.objects.AttributesEntityView; |
28 | 32 | import org.thingsboard.server.common.data.objects.TelemetryEntityView; |
... | ... | @@ -31,7 +35,10 @@ import org.thingsboard.server.common.data.page.TextPageLink; |
31 | 35 | import org.thingsboard.server.common.data.security.Authority; |
32 | 36 | import org.thingsboard.server.dao.model.ModelConstants; |
33 | 37 | |
34 | -import java.util.*; | |
38 | +import java.util.ArrayList; | |
39 | +import java.util.Arrays; | |
40 | +import java.util.Collections; | |
41 | +import java.util.List; | |
35 | 42 | |
36 | 43 | import static org.hamcrest.Matchers.containsString; |
37 | 44 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
... | ... | @@ -43,7 +50,6 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
43 | 50 | private Tenant savedTenant; |
44 | 51 | private User tenantAdmin; |
45 | 52 | private Device testDevice; |
46 | - private TelemetryEntityView obj; | |
47 | 53 | |
48 | 54 | @Before |
49 | 55 | public void beforeTest() throws Exception { |
... | ... | @@ -67,14 +73,6 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
67 | 73 | device.setName("Test device"); |
68 | 74 | device.setType("default"); |
69 | 75 | testDevice = doPost("/api/device", device, Device.class); |
70 | - obj = new TelemetryEntityView( | |
71 | - Arrays.asList("109L", "209L"), | |
72 | - new AttributesEntityView( | |
73 | - Arrays.asList("caKey1", "caKey2"), | |
74 | - Arrays.asList("saKey1", "saKey2", "saKey3"), | |
75 | - Arrays.asList("shKey1", "shKey2", "shKey3", "shKey4") | |
76 | - ) | |
77 | - ); | |
78 | 76 | } |
79 | 77 | |
80 | 78 | @After |
... | ... | @@ -239,14 +237,16 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
239 | 237 | doDelete("/api/customer/entityView/" + view.getId().getId().toString()).andExpect(status().isOk()); |
240 | 238 | } |
241 | 239 | TextPageData<EntityView> pageData = doGetTypedWithPageLink(urlTemplate, |
242 | - new TypeReference<TextPageData<EntityView>>(){}, new TextPageLink(4, name1)); | |
240 | + new TypeReference<TextPageData<EntityView>>() { | |
241 | + }, new TextPageLink(4, name1)); | |
243 | 242 | Assert.assertFalse(pageData.hasNext()); |
244 | 243 | Assert.assertEquals(0, pageData.getData().size()); |
245 | 244 | |
246 | 245 | for (EntityView view : loadedNamesOfView2) { |
247 | 246 | doDelete("/api/customer/entityView/" + view.getId().getId().toString()).andExpect(status().isOk()); |
248 | 247 | } |
249 | - pageData = doGetTypedWithPageLink(urlTemplate, new TypeReference<TextPageData<EntityView>>(){}, | |
248 | + pageData = doGetTypedWithPageLink(urlTemplate, new TypeReference<TextPageData<EntityView>>() { | |
249 | + }, | |
250 | 250 | new TextPageLink(4, name2)); |
251 | 251 | Assert.assertFalse(pageData.hasNext()); |
252 | 252 | Assert.assertEquals(0, pageData.getData().size()); |
... | ... | @@ -287,14 +287,16 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
287 | 287 | doDelete("/api/entityView/" + view.getId().getId().toString()).andExpect(status().isOk()); |
288 | 288 | } |
289 | 289 | TextPageData<EntityView> pageData = doGetTypedWithPageLink("/api/tenant/entityViews?", |
290 | - new TypeReference<TextPageData<EntityView>>(){}, new TextPageLink(4, name1)); | |
290 | + new TypeReference<TextPageData<EntityView>>() { | |
291 | + }, new TextPageLink(4, name1)); | |
291 | 292 | Assert.assertFalse(pageData.hasNext()); |
292 | 293 | Assert.assertEquals(0, pageData.getData().size()); |
293 | 294 | |
294 | 295 | for (EntityView view : loadedNamesOfView2) { |
295 | 296 | doDelete("/api/entityView/" + view.getId().getId().toString()).andExpect(status().isOk()); |
296 | 297 | } |
297 | - pageData = doGetTypedWithPageLink("/api/tenant/entityViews?", new TypeReference<TextPageData<EntityView>>(){}, | |
298 | + pageData = doGetTypedWithPageLink("/api/tenant/entityViews?", new TypeReference<TextPageData<EntityView>>() { | |
299 | + }, | |
298 | 300 | new TextPageLink(4, name2)); |
299 | 301 | Assert.assertFalse(pageData.hasNext()); |
300 | 302 | Assert.assertEquals(0, pageData.getData().size()); |
... | ... | @@ -305,7 +307,14 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
305 | 307 | view.setEntityId(testDevice.getId()); |
306 | 308 | view.setTenantId(savedTenant.getId()); |
307 | 309 | view.setName(name); |
308 | - view.setKeys(new TelemetryEntityView(obj)); | |
310 | + | |
311 | + view.setKeys(new TelemetryEntityView( | |
312 | + Arrays.asList("109L", "209L"), | |
313 | + new AttributesEntityView( | |
314 | + Arrays.asList("caKey1", "caKey2"), | |
315 | + Arrays.asList("saKey1", "saKey2", "saKey3"), | |
316 | + Arrays.asList("shKey1", "shKey2", "shKey3", "shKey4")))); | |
317 | + | |
309 | 318 | return doPost("/api/entityView", view, EntityView.class); |
310 | 319 | } |
311 | 320 | |
... | ... | @@ -346,7 +355,8 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes |
346 | 355 | List<EntityView> loadedItems = new ArrayList<>(); |
347 | 356 | TextPageData<EntityView> pageData; |
348 | 357 | do { |
349 | - pageData = doGetTypedWithPageLink(urlTemplate, new TypeReference<TextPageData<EntityView>>(){}, pageLink); | |
358 | + pageData = doGetTypedWithPageLink(urlTemplate, new TypeReference<TextPageData<EntityView>>() { | |
359 | + }, pageLink); | |
350 | 360 | loadedItems.addAll(pageData.getData()); |
351 | 361 | if (pageData.hasNext()) { |
352 | 362 | pageLink = pageData.getNextPageLink(); | ... | ... |
... | ... | @@ -15,7 +15,9 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.data; |
17 | 17 | |
18 | -import lombok.*; | |
18 | +import lombok.AllArgsConstructor; | |
19 | +import lombok.Data; | |
20 | +import lombok.EqualsAndHashCode; | |
19 | 21 | import org.thingsboard.server.common.data.id.CustomerId; |
20 | 22 | import org.thingsboard.server.common.data.id.EntityId; |
21 | 23 | import org.thingsboard.server.common.data.id.EntityViewId; | ... | ... |
... | ... | @@ -32,6 +32,7 @@ import org.thingsboard.server.dao.asset.AssetService; |
32 | 32 | import org.thingsboard.server.dao.dashboard.DashboardService; |
33 | 33 | import org.thingsboard.server.dao.device.DeviceService; |
34 | 34 | import org.thingsboard.server.dao.entity.AbstractEntityService; |
35 | +import org.thingsboard.server.dao.entityview.EntityViewService; | |
35 | 36 | import org.thingsboard.server.dao.exception.DataValidationException; |
36 | 37 | import org.thingsboard.server.dao.exception.IncorrectParameterException; |
37 | 38 | import org.thingsboard.server.dao.service.DataValidator; |
... | ... | @@ -70,6 +71,9 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom |
70 | 71 | private DeviceService deviceService; |
71 | 72 | |
72 | 73 | @Autowired |
74 | + private EntityViewService entityViewService; | |
75 | + | |
76 | + @Autowired | |
73 | 77 | private DashboardService dashboardService; |
74 | 78 | |
75 | 79 | @Override |
... | ... | @@ -113,6 +117,7 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom |
113 | 117 | dashboardService.unassignCustomerDashboards(customerId); |
114 | 118 | assetService.unassignCustomerAssets(customer.getTenantId(), customerId); |
115 | 119 | deviceService.unassignCustomerDevices(customer.getTenantId(), customerId); |
120 | + entityViewService.unassignCustomerEntityViews(customer.getTenantId(), customerId); | |
116 | 121 | userService.deleteCustomerUsers(customer.getTenantId(), customerId); |
117 | 122 | deleteEntityRelations(customerId); |
118 | 123 | customerDao.removeById(customerId.getId()); | ... | ... |
... | ... | @@ -30,11 +30,23 @@ import org.thingsboard.server.dao.model.nosql.EntityViewEntity; |
30 | 30 | import org.thingsboard.server.dao.nosql.CassandraAbstractSearchTextDao; |
31 | 31 | import org.thingsboard.server.dao.util.NoSqlDao; |
32 | 32 | |
33 | -import java.util.*; | |
33 | +import java.util.Arrays; | |
34 | +import java.util.Collections; | |
35 | +import java.util.List; | |
36 | +import java.util.Optional; | |
37 | +import java.util.UUID; | |
34 | 38 | |
35 | 39 | import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; |
36 | 40 | import static com.datastax.driver.core.querybuilder.QueryBuilder.select; |
37 | -import static org.thingsboard.server.dao.model.ModelConstants.*; | |
41 | +import static org.thingsboard.server.dao.model.ModelConstants.CUSTOMER_ID_PROPERTY; | |
42 | +import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_ID_COLUMN; | |
43 | +import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_VIEW_BY_TENANT_AND_CUSTOMER_AND_SEARCH_TEXT; | |
44 | +import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_VIEW_BY_TENANT_AND_NAME; | |
45 | +import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_VIEW_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME; | |
46 | +import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_VIEW_NAME_PROPERTY; | |
47 | +import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_VIEW_TABLE_FAMILY_NAME; | |
48 | +import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_VIEW_TENANT_ID_PROPERTY; | |
49 | +import static org.thingsboard.server.dao.model.ModelConstants.TENANT_ID_PROPERTY; | |
38 | 50 | |
39 | 51 | /** |
40 | 52 | * Created by Victor Basanets on 9/06/2017. |
... | ... | @@ -85,19 +97,6 @@ public class CassandraEntityViewDao extends CassandraAbstractSearchTextDao<Entit |
85 | 97 | } |
86 | 98 | |
87 | 99 | @Override |
88 | - public List<EntityView> findEntityViewByTenantIdAndEntityId(UUID tenantId, UUID entityId, TextPageLink pageLink) { | |
89 | - log.debug("Try to find entity views by tenantId [{}], entityId [{}] and pageLink [{}]", | |
90 | - tenantId, entityId, pageLink); | |
91 | - List<EntityViewEntity> entityViewEntities = findPageWithTextSearch( | |
92 | - ENTITY_VIEW_BY_TENANT_AND_ENTITY_AND_SEARCH_TEXT, | |
93 | - Arrays.asList(eq(CUSTOMER_ID_PROPERTY, entityId), eq(TENANT_ID_PROPERTY, tenantId)), | |
94 | - pageLink); | |
95 | - log.trace("Found entity views [{}] by tenantId [{}], entityId [{}] and pageLink [{}]", | |
96 | - entityViewEntities, tenantId, entityId, pageLink); | |
97 | - return DaoUtil.convertDataList(entityViewEntities); | |
98 | - } | |
99 | - | |
100 | - @Override | |
101 | 100 | public List<EntityView> findEntityViewsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink) { |
102 | 101 | log.debug("Try to find entity views by tenantId [{}], customerId[{}] and pageLink [{}]", |
103 | 102 | tenantId, customerId, pageLink); |
... | ... | @@ -111,26 +110,6 @@ public class CassandraEntityViewDao extends CassandraAbstractSearchTextDao<Entit |
111 | 110 | } |
112 | 111 | |
113 | 112 | @Override |
114 | - public List<EntityView> findEntityViewsByTenantIdAndCustomerIdAndEntityId(UUID tenantId, | |
115 | - UUID customerId, | |
116 | - UUID entityId, | |
117 | - TextPageLink pageLink) { | |
118 | - | |
119 | - log.debug("Try to find entity views by tenantId [{}], customerId [{}], entityId [{}] and pageLink [{}]", | |
120 | - tenantId, customerId, entityId, pageLink); | |
121 | - List<EntityViewEntity> entityViewEntities = findPageWithTextSearch( | |
122 | - ENTITY_VIEW_BY_TENANT_AND_CUSTOMER_AND_ENTITY_AND_SEARCH_TEXT, | |
123 | - Arrays.asList( | |
124 | - eq(TENANT_ID_PROPERTY, tenantId), | |
125 | - eq(CUSTOMER_ID_PROPERTY, customerId), | |
126 | - eq(ENTITY_ID_COLUMN, entityId)), | |
127 | - pageLink); | |
128 | - log.trace("Found devices [{}] by tenantId [{}], customerId [{}], entityId [{}] and pageLink [{}]", | |
129 | - entityViewEntities, tenantId, customerId, entityId, pageLink); | |
130 | - return DaoUtil.convertDataList(entityViewEntities); | |
131 | - } | |
132 | - | |
133 | - @Override | |
134 | 113 | public ListenableFuture<List<EntityView>> findEntityViewsByTenantIdAndEntityIdAsync(UUID tenantId, UUID entityId) { |
135 | 114 | log.debug("Try to find entity views by tenantId [{}] and entityId [{}]", tenantId, entityId); |
136 | 115 | Select.Where query = select().from(getColumnFamilyName()).where(); | ... | ... |
... | ... | @@ -57,18 +57,6 @@ public interface EntityViewDao extends Dao<EntityView> { |
57 | 57 | Optional<EntityView> findEntityViewByTenantIdAndName(UUID tenantId, String name); |
58 | 58 | |
59 | 59 | /** |
60 | - * Find entity views by tenantId, entityId and page link. | |
61 | - * | |
62 | - * @param tenantId the tenantId | |
63 | - * @param entityId the entityId | |
64 | - * @param pageLink the page link | |
65 | - * @return the list of entity view objects | |
66 | - */ | |
67 | - List<EntityView> findEntityViewByTenantIdAndEntityId(UUID tenantId, | |
68 | - UUID entityId, | |
69 | - TextPageLink pageLink); | |
70 | - | |
71 | - /** | |
72 | 60 | * Find entity views by tenantId, customerId and page link. |
73 | 61 | * |
74 | 62 | * @param tenantId the tenantId |
... | ... | @@ -80,19 +68,6 @@ public interface EntityViewDao extends Dao<EntityView> { |
80 | 68 | UUID customerId, |
81 | 69 | TextPageLink pageLink); |
82 | 70 | |
83 | - /** | |
84 | - * Find entity views by tenantId, customerId, entityId and page link. | |
85 | - * | |
86 | - * @param tenantId the tenantId | |
87 | - * @param customerId the customerId | |
88 | - * @param entityId the entityId | |
89 | - * @param pageLink the page link | |
90 | - * @return the list of entity view objects | |
91 | - */ | |
92 | - List<EntityView> findEntityViewsByTenantIdAndCustomerIdAndEntityId(UUID tenantId, | |
93 | - UUID customerId, | |
94 | - UUID entityId, | |
95 | - TextPageLink pageLink); | |
96 | 71 | |
97 | 72 | ListenableFuture<List<EntityView>> findEntityViewsByTenantIdAndEntityIdAsync(UUID tenantId, UUID entityId); |
98 | 73 | } | ... | ... |
... | ... | @@ -16,14 +16,12 @@ |
16 | 16 | package org.thingsboard.server.dao.entityview; |
17 | 17 | |
18 | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | -import org.thingsboard.server.common.data.Device; | |
20 | -import org.thingsboard.server.common.data.EntitySubtype; | |
21 | -import org.thingsboard.server.common.data.EntityType; | |
22 | 19 | import org.thingsboard.server.common.data.EntityView; |
23 | -import org.thingsboard.server.common.data.Tenant; | |
24 | -import org.thingsboard.server.common.data.device.DeviceSearchQuery; | |
25 | 20 | import org.thingsboard.server.common.data.entityview.EntityViewSearchQuery; |
26 | -import org.thingsboard.server.common.data.id.*; | |
21 | +import org.thingsboard.server.common.data.id.CustomerId; | |
22 | +import org.thingsboard.server.common.data.id.EntityId; | |
23 | +import org.thingsboard.server.common.data.id.EntityViewId; | |
24 | +import org.thingsboard.server.common.data.id.TenantId; | |
27 | 25 | import org.thingsboard.server.common.data.page.TextPageData; |
28 | 26 | import org.thingsboard.server.common.data.page.TextPageLink; |
29 | 27 | |
... | ... | @@ -36,8 +34,6 @@ public interface EntityViewService { |
36 | 34 | |
37 | 35 | EntityView findEntityViewById(EntityViewId entityViewId); |
38 | 36 | |
39 | - EntityView findEntityViewByTenantIdAndName(TenantId tenantId, String name); | |
40 | - | |
41 | 37 | EntityView saveEntityView(EntityView entityView); |
42 | 38 | |
43 | 39 | EntityView assignEntityViewToCustomer(EntityViewId entityViewId, CustomerId customerId); |
... | ... | @@ -48,19 +44,11 @@ public interface EntityViewService { |
48 | 44 | |
49 | 45 | TextPageData<EntityView> findEntityViewByTenantId(TenantId tenantId, TextPageLink pageLink); |
50 | 46 | |
51 | - TextPageData<EntityView> findEntityViewByTenantIdAndEntityId(TenantId tenantId, EntityId entityId, | |
52 | - TextPageLink pageLink); | |
53 | - | |
54 | - void deleteEntityViewByTenantId(TenantId tenantId); | |
47 | + void deleteEntityViewsByTenantId(TenantId tenantId); | |
55 | 48 | |
56 | 49 | TextPageData<EntityView> findEntityViewsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, |
57 | 50 | TextPageLink pageLink); |
58 | 51 | |
59 | - TextPageData<EntityView> findEntityViewsByTenantIdAndCustomerIdAndEntityId(TenantId tenantId, | |
60 | - CustomerId customerId, | |
61 | - EntityId entityId, | |
62 | - TextPageLink pageLink); | |
63 | - | |
64 | 52 | void unassignCustomerEntityViews(TenantId tenantId, CustomerId customerId); |
65 | 53 | |
66 | 54 | ListenableFuture<EntityView> findEntityViewByIdAsync(EntityViewId entityViewId); | ... | ... |
... | ... | @@ -96,15 +96,6 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
96 | 96 | return entityViewDao.findById(entityViewId.getId()); |
97 | 97 | } |
98 | 98 | |
99 | - @Cacheable(cacheNames = ENTITY_VIEW_CACHE, key = "{#tenantId, #name}") | |
100 | - @Override | |
101 | - public EntityView findEntityViewByTenantIdAndName(TenantId tenantId, String name) { | |
102 | - log.trace("Executing findEntityViewByTenantIdAndName [{}][{}]", tenantId, name); | |
103 | - validateId(tenantId, INCORRECT_TENANT_ID + tenantId); | |
104 | - return entityViewDao.findEntityViewByTenantIdAndName(tenantId.getId(), name) | |
105 | - .orElse(null); | |
106 | - } | |
107 | - | |
108 | 99 | @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityView.tenantId, #entityView.name}") |
109 | 100 | @Override |
110 | 101 | public EntityView saveEntityView(EntityView entityView) { |
... | ... | @@ -187,24 +178,8 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
187 | 178 | } |
188 | 179 | |
189 | 180 | @Override |
190 | - public TextPageData<EntityView> findEntityViewByTenantIdAndEntityId(TenantId tenantId, EntityId entityId, | |
191 | - TextPageLink pageLink) { | |
192 | - | |
193 | - log.trace("Executing findEntityViewByTenantIdAndType, tenantId [{}], entityId [{}], pageLink [{}]", | |
194 | - tenantId, entityId, pageLink); | |
195 | - | |
196 | - validateId(tenantId, INCORRECT_TENANT_ID + tenantId); | |
197 | - validateString(entityId.toString(), "Incorrect entityId " + entityId.toString()); | |
198 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
199 | - List<EntityView> entityViews = entityViewDao.findEntityViewByTenantIdAndEntityId(tenantId.getId(), | |
200 | - entityId.getId(), pageLink); | |
201 | - | |
202 | - return new TextPageData<>(entityViews, pageLink); | |
203 | - } | |
204 | - | |
205 | - @Override | |
206 | - public void deleteEntityViewByTenantId(TenantId tenantId) { | |
207 | - log.trace("Executing deleteEntityViewByTenantId, tenantId [{}]", tenantId); | |
181 | + public void deleteEntityViewsByTenantId(TenantId tenantId) { | |
182 | + log.trace("Executing deleteEntityViewsByTenantId, tenantId [{}]", tenantId); | |
208 | 183 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); |
209 | 184 | tenantEntityViewRemover.removeEntities(tenantId); |
210 | 185 | } |
... | ... | @@ -226,25 +201,6 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti |
226 | 201 | } |
227 | 202 | |
228 | 203 | @Override |
229 | - public TextPageData<EntityView> findEntityViewsByTenantIdAndCustomerIdAndEntityId(TenantId tenantId, | |
230 | - CustomerId customerId, | |
231 | - EntityId entityId, | |
232 | - TextPageLink pageLink) { | |
233 | - | |
234 | - log.trace("Executing findEntityViewsByTenantIdAndCustomerIdAndType, tenantId [{}], customerId [{}]," + | |
235 | - " entityId [{}], pageLink [{}]", tenantId, customerId, entityId, pageLink); | |
236 | - | |
237 | - validateId(tenantId, INCORRECT_TENANT_ID + tenantId); | |
238 | - validateId(customerId, INCORRECT_CUSTOMER_ID + customerId); | |
239 | - validateString(entityId.toString(), "Incorrect entityId " + entityId.toString()); | |
240 | - validatePageLink(pageLink, INCORRECT_PAGE_LINK + pageLink); | |
241 | - List<EntityView> entityViews = entityViewDao.findEntityViewsByTenantIdAndCustomerIdAndEntityId( | |
242 | - tenantId.getId(), customerId.getId(), entityId.getId(), pageLink); | |
243 | - | |
244 | - return new TextPageData<>(entityViews, pageLink); | |
245 | - } | |
246 | - | |
247 | - @Override | |
248 | 204 | public void unassignCustomerEntityViews(TenantId tenantId, CustomerId customerId) { |
249 | 205 | log.trace("Executing unassignCustomerEntityViews, tenantId [{}], customerId [{}]", tenantId, customerId); |
250 | 206 | validateId(tenantId, INCORRECT_TENANT_ID + tenantId); | ... | ... |
... | ... | @@ -150,15 +150,13 @@ public class ModelConstants { |
150 | 150 | public static final String ENTITY_VIEW_TENANT_ID_PROPERTY = TENANT_ID_PROPERTY; |
151 | 151 | public static final String ENTITY_VIEW_CUSTOMER_ID_PROPERTY = CUSTOMER_ID_PROPERTY; |
152 | 152 | public static final String ENTITY_VIEW_NAME_PROPERTY = DEVICE_NAME_PROPERTY; |
153 | - public static final String ENTITY_VIEW_BY_TENANT_AND_CUSTOMER_AND_ENTITY_AND_SEARCH_TEXT = "entity_views_by_tenant_and_customer_and_entity"; | |
154 | - public static final String ENTITY_VIEW_BY_TENANT_AND_CUSTOMER_AND_SEARCH_TEXT = "entity_views_by_tenant_and_customer"; | |
153 | + public static final String ENTITY_VIEW_BY_TENANT_AND_CUSTOMER_AND_SEARCH_TEXT = "entity_view_by_tenant_and_customer"; | |
155 | 154 | public static final String ENTITY_VIEW_KEYS_PROPERTY = "keys"; |
156 | 155 | public static final String ENTITY_VIEW_START_TS_PROPERTY = "start_ts"; |
157 | 156 | public static final String ENTITY_VIEW_END_TS_PROPERTY = "end_ts"; |
158 | 157 | public static final String ENTITY_VIEW_ADDITIONAL_INFO_PROPERTY = ADDITIONAL_INFO_PROPERTY; |
159 | 158 | public static final String ENTITY_VIEW_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "entity_view_by_tenant_and_search_text"; |
160 | - public static final String ENTITY_VIEW_BY_TENANT_AND_NAME = "entity_views_by_tenant_and_name"; | |
161 | - public static final String ENTITY_VIEW_BY_TENANT_AND_ENTITY_AND_SEARCH_TEXT = "entity_view_by_tenant_and_entity"; | |
159 | + public static final String ENTITY_VIEW_BY_TENANT_AND_NAME = "entity_view_by_tenant_and_name"; | |
162 | 160 | |
163 | 161 | /** |
164 | 162 | * Cassandra audit log constants. | ... | ... |
... | ... | @@ -24,10 +24,14 @@ import com.fasterxml.jackson.databind.ObjectMapper; |
24 | 24 | import lombok.Data; |
25 | 25 | import lombok.EqualsAndHashCode; |
26 | 26 | import lombok.ToString; |
27 | +import lombok.extern.slf4j.Slf4j; | |
27 | 28 | import org.hibernate.annotations.Type; |
28 | 29 | import org.thingsboard.server.common.data.EntityType; |
29 | 30 | import org.thingsboard.server.common.data.EntityView; |
30 | -import org.thingsboard.server.common.data.id.*; | |
31 | +import org.thingsboard.server.common.data.id.CustomerId; | |
32 | +import org.thingsboard.server.common.data.id.EntityIdFactory; | |
33 | +import org.thingsboard.server.common.data.id.EntityViewId; | |
34 | +import org.thingsboard.server.common.data.id.TenantId; | |
31 | 35 | import org.thingsboard.server.common.data.objects.TelemetryEntityView; |
32 | 36 | import org.thingsboard.server.dao.model.ModelConstants; |
33 | 37 | import org.thingsboard.server.dao.model.SearchTextEntity; |
... | ... | @@ -48,6 +52,7 @@ import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY; |
48 | 52 | @Table(name = ENTITY_VIEW_TABLE_FAMILY_NAME) |
49 | 53 | @EqualsAndHashCode |
50 | 54 | @ToString |
55 | +@Slf4j | |
51 | 56 | public class EntityViewEntity implements SearchTextEntity<EntityView> { |
52 | 57 | |
53 | 58 | @PartitionKey(value = 0) |
... | ... | @@ -112,7 +117,7 @@ public class EntityViewEntity implements SearchTextEntity<EntityView> { |
112 | 117 | try { |
113 | 118 | this.keys = mapper.writeValueAsString(entityView.getKeys()); |
114 | 119 | } catch (IOException e) { |
115 | - e.printStackTrace(); | |
120 | + log.error("Unable to serialize entity view keys!", e); | |
116 | 121 | } |
117 | 122 | this.startTs = entityView.getStartTimeMs(); |
118 | 123 | this.endTs = entityView.getEndTimeMs(); |
... | ... | @@ -142,7 +147,7 @@ public class EntityViewEntity implements SearchTextEntity<EntityView> { |
142 | 147 | try { |
143 | 148 | entityView.setKeys(mapper.readValue(keys, TelemetryEntityView.class)); |
144 | 149 | } catch (IOException e) { |
145 | - e.printStackTrace(); | |
150 | + log.error("Unable to read entity view keys!", e); | |
146 | 151 | } |
147 | 152 | entityView.setStartTimeMs(startTs); |
148 | 153 | entityView.setEndTimeMs(endTs); | ... | ... |
... | ... | @@ -20,18 +20,26 @@ import com.fasterxml.jackson.databind.JsonNode; |
20 | 20 | import com.fasterxml.jackson.databind.ObjectMapper; |
21 | 21 | import lombok.Data; |
22 | 22 | import lombok.EqualsAndHashCode; |
23 | +import lombok.extern.slf4j.Slf4j; | |
23 | 24 | import org.hibernate.annotations.Type; |
24 | 25 | import org.hibernate.annotations.TypeDef; |
25 | 26 | import org.thingsboard.server.common.data.EntityType; |
26 | 27 | import org.thingsboard.server.common.data.EntityView; |
27 | -import org.thingsboard.server.common.data.id.*; | |
28 | +import org.thingsboard.server.common.data.id.CustomerId; | |
29 | +import org.thingsboard.server.common.data.id.EntityIdFactory; | |
30 | +import org.thingsboard.server.common.data.id.EntityViewId; | |
31 | +import org.thingsboard.server.common.data.id.TenantId; | |
28 | 32 | import org.thingsboard.server.common.data.objects.TelemetryEntityView; |
29 | 33 | import org.thingsboard.server.dao.model.BaseSqlEntity; |
30 | 34 | import org.thingsboard.server.dao.model.ModelConstants; |
31 | 35 | import org.thingsboard.server.dao.model.SearchTextEntity; |
32 | 36 | import org.thingsboard.server.dao.util.mapping.JsonStringType; |
33 | 37 | |
34 | -import javax.persistence.*; | |
38 | +import javax.persistence.Column; | |
39 | +import javax.persistence.Entity; | |
40 | +import javax.persistence.EnumType; | |
41 | +import javax.persistence.Enumerated; | |
42 | +import javax.persistence.Table; | |
35 | 43 | import java.io.IOException; |
36 | 44 | |
37 | 45 | import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_TYPE_PROPERTY; |
... | ... | @@ -45,6 +53,7 @@ import static org.thingsboard.server.dao.model.ModelConstants.ENTITY_TYPE_PROPER |
45 | 53 | @Entity |
46 | 54 | @TypeDef(name = "json", typeClass = JsonStringType.class) |
47 | 55 | @Table(name = ModelConstants.ENTITY_VIEW_TABLE_FAMILY_NAME) |
56 | +@Slf4j | |
48 | 57 | public class EntityViewEntity extends BaseSqlEntity<EntityView> implements SearchTextEntity<EntityView> { |
49 | 58 | |
50 | 59 | @Column(name = ModelConstants.ENTITY_VIEW_ENTITY_ID_PROPERTY) |
... | ... | @@ -103,7 +112,7 @@ public class EntityViewEntity extends BaseSqlEntity<EntityView> implements Searc |
103 | 112 | try { |
104 | 113 | this.keys = mapper.writeValueAsString(entityView.getKeys()); |
105 | 114 | } catch (IOException e) { |
106 | - e.printStackTrace(); | |
115 | + log.error("Unable to serialize entity view keys!", e); | |
107 | 116 | } |
108 | 117 | this.startTs = entityView.getStartTimeMs(); |
109 | 118 | this.endTs = entityView.getEndTimeMs(); |
... | ... | @@ -139,7 +148,7 @@ public class EntityViewEntity extends BaseSqlEntity<EntityView> implements Searc |
139 | 148 | try { |
140 | 149 | entityView.setKeys(mapper.readValue(keys, TelemetryEntityView.class)); |
141 | 150 | } catch (IOException e) { |
142 | - e.printStackTrace(); | |
151 | + log.error("Unable to read entity view keys!", e); | |
143 | 152 | } |
144 | 153 | entityView.setStartTimeMs(startTs); |
145 | 154 | entityView.setEndTimeMs(endTs); | ... | ... |
... | ... | @@ -41,16 +41,6 @@ public interface EntityViewRepository extends CrudRepository<EntityViewEntity, S |
41 | 41 | Pageable pageable); |
42 | 42 | |
43 | 43 | @Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " + |
44 | - "AND e.entityId = :entityId " + | |
45 | - "AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%')) " + | |
46 | - "AND e.id > :idOffset ORDER BY e.id") | |
47 | - List<EntityViewEntity> findByTenantIdAndEntityId(@Param("tenantId") String tenantId, | |
48 | - @Param("entityId") String entityId, | |
49 | - @Param("textSearch") String textSearch, | |
50 | - @Param("idOffset") String idOffset, | |
51 | - Pageable pageable); | |
52 | - | |
53 | - @Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " + | |
54 | 44 | "AND e.customerId = :customerId " + |
55 | 45 | "AND LOWER(e.searchText) LIKE LOWER(CONCAT(:searchText, '%')) " + |
56 | 46 | "AND e.id > :idOffset ORDER BY e.id") |
... | ... | @@ -60,25 +50,7 @@ public interface EntityViewRepository extends CrudRepository<EntityViewEntity, S |
60 | 50 | @Param("idOffset") String idOffset, |
61 | 51 | Pageable pageable); |
62 | 52 | |
63 | - @Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " + | |
64 | - "AND e.customerId = :customerId " + | |
65 | - "AND e.entityId = :entityId " + | |
66 | - "AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%')) " + | |
67 | - "AND e.id > :idOffset ORDER BY e.id") | |
68 | - List<EntityViewEntity> findByTenantIdAndCustomerIdAndEntityId(@Param("tenantId") String tenantId, | |
69 | - @Param("customerId") String customerId, | |
70 | - @Param("entityId") String entityId, | |
71 | - @Param("textSearch") String textSearch, | |
72 | - @Param("idOffset") String idOffset, | |
73 | - Pageable pageable); | |
74 | - | |
75 | 53 | EntityViewEntity findByTenantIdAndName(String tenantId, String name); |
76 | 54 | |
77 | - List<EntityViewEntity> findAllByTenantIdAndCustomerIdAndIdIn(String tenantId, | |
78 | - String customerId, | |
79 | - List<String> entityViewsIds); | |
80 | - | |
81 | - List<EntityViewEntity> findAllByTenantIdAndIdIn(String tenantId, List<String> entityViewsIds); | |
82 | - | |
83 | 55 | List<EntityViewEntity> findAllByTenantIdAndEntityId(String tenantId, String entityId); |
84 | 56 | } | ... | ... |
... | ... | @@ -53,7 +53,7 @@ public class JpaEntityViewDao extends JpaAbstractSearchTextDao<EntityViewEntity, |
53 | 53 | implements EntityViewDao { |
54 | 54 | |
55 | 55 | @Autowired |
56 | - EntityViewRepository entityViewRepository; | |
56 | + private EntityViewRepository entityViewRepository; | |
57 | 57 | |
58 | 58 | @Override |
59 | 59 | protected Class<EntityViewEntity> getEntityClass() { |
... | ... | @@ -82,19 +82,6 @@ public class JpaEntityViewDao extends JpaAbstractSearchTextDao<EntityViewEntity, |
82 | 82 | } |
83 | 83 | |
84 | 84 | @Override |
85 | - public List<EntityView> findEntityViewByTenantIdAndEntityId(UUID tenantId, | |
86 | - UUID entityId, | |
87 | - TextPageLink pageLink) { | |
88 | - return DaoUtil.convertDataList( | |
89 | - entityViewRepository.findByTenantIdAndEntityId( | |
90 | - fromTimeUUID(tenantId), | |
91 | - fromTimeUUID(entityId), | |
92 | - Objects.toString(pageLink.getTextSearch(), ""), | |
93 | - pageLink.getIdOffset() == null ? NULL_UUID_STR : fromTimeUUID(pageLink.getIdOffset()), | |
94 | - new PageRequest(0, pageLink.getLimit()))); | |
95 | - } | |
96 | - | |
97 | - @Override | |
98 | 85 | public List<EntityView> findEntityViewsByTenantIdAndCustomerId(UUID tenantId, |
99 | 86 | UUID customerId, |
100 | 87 | TextPageLink pageLink) { |
... | ... | @@ -109,22 +96,6 @@ public class JpaEntityViewDao extends JpaAbstractSearchTextDao<EntityViewEntity, |
109 | 96 | } |
110 | 97 | |
111 | 98 | @Override |
112 | - public List<EntityView> findEntityViewsByTenantIdAndCustomerIdAndEntityId(UUID tenantId, | |
113 | - UUID customerId, | |
114 | - UUID entityId, | |
115 | - TextPageLink pageLink) { | |
116 | - return DaoUtil.convertDataList( | |
117 | - entityViewRepository.findByTenantIdAndCustomerIdAndEntityId( | |
118 | - fromTimeUUID(tenantId), | |
119 | - fromTimeUUID(customerId), | |
120 | - fromTimeUUID(entityId), | |
121 | - Objects.toString(pageLink.getTextSearch(), ""), | |
122 | - pageLink.getIdOffset() == null ? NULL_UUID_STR : fromTimeUUID(pageLink.getIdOffset()), | |
123 | - new PageRequest(0, pageLink.getLimit()) | |
124 | - )); | |
125 | - } | |
126 | - | |
127 | - @Override | |
128 | 99 | public ListenableFuture<List<EntityView>> findEntityViewsByTenantIdAndEntityIdAsync(UUID tenantId, UUID entityId) { |
129 | 100 | return service.submit(() -> DaoUtil.convertDataList( |
130 | 101 | entityViewRepository.findAllByTenantIdAndEntityId(UUIDConverter.fromTimeUUID(tenantId), UUIDConverter.fromTimeUUID(entityId)))); | ... | ... |
... | ... | @@ -29,6 +29,7 @@ import org.thingsboard.server.dao.customer.CustomerService; |
29 | 29 | import org.thingsboard.server.dao.dashboard.DashboardService; |
30 | 30 | import org.thingsboard.server.dao.device.DeviceService; |
31 | 31 | import org.thingsboard.server.dao.entity.AbstractEntityService; |
32 | +import org.thingsboard.server.dao.entityview.EntityViewService; | |
32 | 33 | import org.thingsboard.server.dao.exception.DataValidationException; |
33 | 34 | import org.thingsboard.server.dao.rule.RuleChainService; |
34 | 35 | import org.thingsboard.server.dao.service.DataValidator; |
... | ... | @@ -64,6 +65,9 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe |
64 | 65 | private DeviceService deviceService; |
65 | 66 | |
66 | 67 | @Autowired |
68 | + private EntityViewService entityViewService; | |
69 | + | |
70 | + @Autowired | |
67 | 71 | private WidgetsBundleService widgetsBundleService; |
68 | 72 | |
69 | 73 | @Autowired |
... | ... | @@ -103,6 +107,7 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe |
103 | 107 | dashboardService.deleteDashboardsByTenantId(tenantId); |
104 | 108 | assetService.deleteAssetsByTenantId(tenantId); |
105 | 109 | deviceService.deleteDevicesByTenantId(tenantId); |
110 | + entityViewService.deleteEntityViewsByTenantId(tenantId); | |
106 | 111 | userService.deleteTenantAdmins(tenantId); |
107 | 112 | ruleChainService.deleteRuleChainsByTenantId(tenantId); |
108 | 113 | tenantDao.removeById(tenantId.getId()); | ... | ... |
... | ... | @@ -674,7 +674,7 @@ CREATE TABLE IF NOT EXISTS thingsboard.entity_views ( |
674 | 674 | PRIMARY KEY (id, entity_id, tenant_id, customer_id) |
675 | 675 | ); |
676 | 676 | |
677 | -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_name AS | |
677 | +CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_name AS | |
678 | 678 | SELECT * |
679 | 679 | from thingsboard.entity_views |
680 | 680 | WHERE tenant_id IS NOT NULL |
... | ... | @@ -696,18 +696,7 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_sea |
696 | 696 | PRIMARY KEY (tenant_id, search_text, id, customer_id, entity_id) |
697 | 697 | WITH CLUSTERING ORDER BY (search_text ASC, id DESC, customer_id DESC); |
698 | 698 | |
699 | -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_entity AS | |
700 | - SELECT * | |
701 | - from thingsboard.entity_views | |
702 | - WHERE tenant_id IS NOT NULL | |
703 | - AND customer_id IS NOT NULL | |
704 | - AND entity_id IS NOT NULL | |
705 | - AND search_text IS NOT NULL | |
706 | - AND id IS NOT NULL | |
707 | - PRIMARY KEY (tenant_id, entity_id, search_text, id, customer_id) | |
708 | - WITH CLUSTERING ORDER BY (entity_id ASC, search_text ASC, id DESC, customer_id DESC); | |
709 | - | |
710 | -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer AS | |
699 | +CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_customer AS | |
711 | 700 | SELECT * |
712 | 701 | from thingsboard.entity_views |
713 | 702 | WHERE tenant_id IS NOT NULL |
... | ... | @@ -717,14 +706,3 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_cu |
717 | 706 | AND id IS NOT NULL |
718 | 707 | PRIMARY KEY (tenant_id, customer_id, search_text, id, entity_id) |
719 | 708 | WITH CLUSTERING ORDER BY (customer_id DESC, search_text ASC, id DESC); |
720 | - | |
721 | -CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer_and_entity AS | |
722 | - SELECT * | |
723 | - from thingsboard.entity_views | |
724 | - WHERE tenant_id IS NOT NULL | |
725 | - AND customer_id IS NOT NULL | |
726 | - AND entity_id IS NOT NULL | |
727 | - AND search_text IS NOT NULL | |
728 | - AND id IS NOT NULL | |
729 | - PRIMARY KEY (tenant_id, customer_id, entity_id, search_text, id) | |
730 | - WITH CLUSTERING ORDER BY (customer_id DESC, entity_id ASC, search_text ASC, id DESC); | ... | ... |