Commit aa795578415a62b0ab129e57df0bdd09ace8e430
1 parent
b1f9ffb3
Fixes for cases when asset/device deleted but has entity view assigned
Showing
4 changed files
with
6 additions
and
5 deletions
... | ... | @@ -17,9 +17,10 @@ |
17 | 17 | DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_view_by_tenant_and_name; |
18 | 18 | DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_view_by_tenant_and_search_text; |
19 | 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; | |
20 | 21 | |
21 | 22 | DROP TABLE IF EXISTS thingsboard.entity_views; |
22 | - | |
23 | +ControllerSqlTestSuite | |
23 | 24 | CREATE TABLE IF NOT EXISTS thingsboard.entity_views ( |
24 | 25 | id timeuuid, |
25 | 26 | entity_id timeuuid, | ... | ... |
... | ... | @@ -115,9 +115,9 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom |
115 | 115 | throw new IncorrectParameterException("Unable to delete non-existent customer."); |
116 | 116 | } |
117 | 117 | dashboardService.unassignCustomerDashboards(customerId); |
118 | + entityViewService.unassignCustomerEntityViews(customer.getTenantId(), customerId); | |
118 | 119 | assetService.unassignCustomerAssets(customer.getTenantId(), customerId); |
119 | 120 | deviceService.unassignCustomerDevices(customer.getTenantId(), customerId); |
120 | - entityViewService.unassignCustomerEntityViews(customer.getTenantId(), customerId); | |
121 | 121 | userService.deleteCustomerUsers(customer.getTenantId(), customerId); |
122 | 122 | deleteEntityRelations(customerId); |
123 | 123 | customerDao.removeById(customerId.getId()); | ... | ... |
... | ... | @@ -155,8 +155,8 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe |
155 | 155 | Device device = deviceDao.findById(deviceId.getId()); |
156 | 156 | try { |
157 | 157 | List<EntityView> entityViews = entityViewService.findEntityViewsByTenantIdAndEntityIdAsync(device.getTenantId(), deviceId).get(); |
158 | - if (entityViews != null && !entityViews.isEmpty()) { | |
159 | - throw new DataValidationException("Can't delete device that is assigned to entity views!"); | |
158 | + if (entityViews != null && !entityViews.isEmpty()) { | |
159 | + throw new DataValidationException("Can't delete device that is assigned to entity views!"); | |
160 | 160 | } |
161 | 161 | } catch (Exception e) { |
162 | 162 | log.error("Exception while finding entity views for deviceId [{}]", deviceId, e); | ... | ... |
... | ... | @@ -105,9 +105,9 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe |
105 | 105 | customerService.deleteCustomersByTenantId(tenantId); |
106 | 106 | widgetsBundleService.deleteWidgetsBundlesByTenantId(tenantId); |
107 | 107 | dashboardService.deleteDashboardsByTenantId(tenantId); |
108 | + entityViewService.deleteEntityViewsByTenantId(tenantId); | |
108 | 109 | assetService.deleteAssetsByTenantId(tenantId); |
109 | 110 | deviceService.deleteDevicesByTenantId(tenantId); |
110 | - entityViewService.deleteEntityViewsByTenantId(tenantId); | |
111 | 111 | userService.deleteTenantAdmins(tenantId); |
112 | 112 | ruleChainService.deleteRuleChainsByTenantId(tenantId); |
113 | 113 | tenantDao.removeById(tenantId.getId()); | ... | ... |