Unassign assets from removed customer.

This commit is contained in:
Igor Kulikov 2017-09-12 16:59:15 +03:00
parent d8d84b6868
commit 4af989c278

View File

@ -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);