Commit 4af989c27874966cfae8f6e47b8baa86c132f74b

Authored by Igor Kulikov
1 parent d8d84b68

Unassign assets from removed customer.

@@ -28,6 +28,7 @@ import org.thingsboard.server.common.data.id.CustomerId; @@ -28,6 +28,7 @@ import org.thingsboard.server.common.data.id.CustomerId;
28 import org.thingsboard.server.common.data.id.TenantId; 28 import org.thingsboard.server.common.data.id.TenantId;
29 import org.thingsboard.server.common.data.page.TextPageData; 29 import org.thingsboard.server.common.data.page.TextPageData;
30 import org.thingsboard.server.common.data.page.TextPageLink; 30 import org.thingsboard.server.common.data.page.TextPageLink;
  31 +import org.thingsboard.server.dao.asset.AssetService;
31 import org.thingsboard.server.dao.dashboard.DashboardService; 32 import org.thingsboard.server.dao.dashboard.DashboardService;
32 import org.thingsboard.server.dao.device.DeviceService; 33 import org.thingsboard.server.dao.device.DeviceService;
33 import org.thingsboard.server.dao.entity.AbstractEntityService; 34 import org.thingsboard.server.dao.entity.AbstractEntityService;
@@ -61,6 +62,9 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom @@ -61,6 +62,9 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom
61 private TenantDao tenantDao; 62 private TenantDao tenantDao;
62 63
63 @Autowired 64 @Autowired
  65 + private AssetService assetService;
  66 +
  67 + @Autowired
64 private DeviceService deviceService; 68 private DeviceService deviceService;
65 69
66 @Autowired 70 @Autowired
@@ -96,6 +100,7 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom @@ -96,6 +100,7 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom
96 throw new IncorrectParameterException("Unable to delete non-existent customer."); 100 throw new IncorrectParameterException("Unable to delete non-existent customer.");
97 } 101 }
98 dashboardService.unassignCustomerDashboards(customer.getTenantId(), customerId); 102 dashboardService.unassignCustomerDashboards(customer.getTenantId(), customerId);
  103 + assetService.unassignCustomerAssets(customer.getTenantId(), customerId);
99 deviceService.unassignCustomerDevices(customer.getTenantId(), customerId); 104 deviceService.unassignCustomerDevices(customer.getTenantId(), customerId);
100 userService.deleteCustomerUsers(customer.getTenantId(), customerId); 105 userService.deleteCustomerUsers(customer.getTenantId(), customerId);
101 deleteEntityRelations(customerId); 106 deleteEntityRelations(customerId);