thingsboard-aplcache

Minor refactoring

11/12/2018 9:29:17 AM

Details

diff --git a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java
index 096484f..b32232e 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java
@@ -214,7 +214,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb
         if (customer == null) {
             throw new DataValidationException("Can't unassign dashboards from non-existent customer!");
         }
-        new CustomerDashboardsUnassigner(customer).removeEntities(customer);
+        new CustomerDashboardsUnassigner(customer).removeEntities(tenantId, customer);
     }
 
     @Override
@@ -225,7 +225,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb
         if (customer == null) {
             throw new DataValidationException("Can't update dashboards for non-existent customer!");
         }
-        new CustomerDashboardsUpdater(customer).removeEntities(customer);
+        new CustomerDashboardsUpdater(customer).removeEntities(tenantId, customer);
     }
 
     private DataValidator<Dashboard> dashboardValidator =
@@ -269,7 +269,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb
         }
 
         @Override
-        protected List<DashboardInfo> findEntities(Customer customer, TimePageLink pageLink) {
+        protected List<DashboardInfo> findEntities(TenantId tenantId, Customer customer, TimePageLink pageLink) {
             try {
                 return dashboardInfoDao.findDashboardsByTenantIdAndCustomerId(customer.getTenantId().getId(), customer.getId().getId(), pageLink).get();
             } catch (InterruptedException | ExecutionException e) {
@@ -279,7 +279,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb
         }
 
         @Override
-        protected void removeEntity(DashboardInfo entity) {
+        protected void removeEntity(TenantId tenantId, DashboardInfo entity) {
             unassignDashboardFromCustomer(customer.getTenantId(), new DashboardId(entity.getUuidId()), this.customer.getId());
         }
         
@@ -294,7 +294,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb
         }
 
         @Override
-        protected List<DashboardInfo> findEntities(Customer customer, TimePageLink pageLink) {
+        protected List<DashboardInfo> findEntities(TenantId tenantId, Customer customer, TimePageLink pageLink) {
             try {
                 return dashboardInfoDao.findDashboardsByTenantIdAndCustomerId(customer.getTenantId().getId(), customer.getId().getId(), pageLink).get();
             } catch (InterruptedException | ExecutionException e) {
@@ -304,7 +304,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb
         }
 
         @Override
-        protected void removeEntity(DashboardInfo entity) {
+        protected void removeEntity(TenantId tenantId, DashboardInfo entity) {
             updateAssignedCustomer(customer.getTenantId(), new DashboardId(entity.getUuidId()), this.customer);
         }
 
diff --git a/dao/src/main/java/org/thingsboard/server/dao/service/TimePaginatedRemover.java b/dao/src/main/java/org/thingsboard/server/dao/service/TimePaginatedRemover.java
index 52fcf85..c223b76 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/service/TimePaginatedRemover.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/service/TimePaginatedRemover.java
@@ -16,6 +16,7 @@
 package org.thingsboard.server.dao.service;
 
 import org.thingsboard.server.common.data.id.IdBased;
+import org.thingsboard.server.common.data.id.TenantId;
 import org.thingsboard.server.common.data.page.TimePageLink;
 
 import java.util.List;
@@ -25,13 +26,13 @@ public abstract class TimePaginatedRemover<I, D extends IdBased<?>> {
 
     private static final int DEFAULT_LIMIT = 100;
 
-    public void removeEntities(I id) {
+    public void removeEntities(TenantId tenantId, I id) {
         TimePageLink pageLink = new TimePageLink(DEFAULT_LIMIT);
         boolean hasNext = true;
         while (hasNext) {
-            List<D> entities = findEntities(id, pageLink);
+            List<D> entities = findEntities(tenantId, id, pageLink);
             for (D entity : entities) {
-                removeEntity(entity);
+                removeEntity(tenantId, entity);
             }
             hasNext = entities.size() == pageLink.getLimit();
             if (hasNext) {
@@ -42,8 +43,8 @@ public abstract class TimePaginatedRemover<I, D extends IdBased<?>> {
         }
     }
 
-    protected abstract List<D> findEntities(I id, TimePageLink pageLink);
+    protected abstract List<D> findEntities(TenantId tenantId, I id, TimePageLink pageLink);
 
-    protected abstract void removeEntity(D entity);
+    protected abstract void removeEntity(TenantId tenantId, D entity);
 
 }