From 4af989c27874966cfae8f6e47b8baa86c132f74b Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Tue, 12 Sep 2017 16:59:15 +0300 Subject: [PATCH] Unassign assets from removed customer. --- .../thingsboard/server/dao/customer/CustomerServiceImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dao/src/main/java/org/thingsboard/server/dao/customer/CustomerServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/customer/CustomerServiceImpl.java index d7dde12932..29fc14a755 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/customer/CustomerServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/customer/CustomerServiceImpl.java @@ -28,6 +28,7 @@ import org.thingsboard.server.common.data.id.CustomerId; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.page.TextPageData; import org.thingsboard.server.common.data.page.TextPageLink; +import org.thingsboard.server.dao.asset.AssetService; import org.thingsboard.server.dao.dashboard.DashboardService; import org.thingsboard.server.dao.device.DeviceService; import org.thingsboard.server.dao.entity.AbstractEntityService; @@ -60,6 +61,9 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom @Autowired private TenantDao tenantDao; + @Autowired + private AssetService assetService; + @Autowired private DeviceService deviceService; @@ -96,6 +100,7 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom throw new IncorrectParameterException("Unable to delete non-existent customer."); } dashboardService.unassignCustomerDashboards(customer.getTenantId(), customerId); + assetService.unassignCustomerAssets(customer.getTenantId(), customerId); deviceService.unassignCustomerDevices(customer.getTenantId(), customerId); userService.deleteCustomerUsers(customer.getTenantId(), customerId); deleteEntityRelations(customerId);