Browse Source

refactoring

pull/14355/head
dashevchenko 6 months ago
parent
commit
d62355e4bd
  1. 17
      application/src/main/java/org/thingsboard/server/controller/AssetProfileController.java
  2. 17
      application/src/main/java/org/thingsboard/server/controller/CustomerController.java
  3. 13
      application/src/main/java/org/thingsboard/server/controller/DashboardController.java
  4. 23
      application/src/main/java/org/thingsboard/server/controller/DeviceProfileController.java
  5. 14
      application/src/main/java/org/thingsboard/server/controller/EntityViewController.java
  6. 14
      application/src/main/java/org/thingsboard/server/controller/RuleChainController.java
  7. 17
      application/src/main/java/org/thingsboard/server/controller/TenantController.java
  8. 16
      application/src/main/java/org/thingsboard/server/controller/UserController.java
  9. 17
      application/src/main/java/org/thingsboard/server/controller/WidgetsBundleController.java
  10. 3
      common/dao-api/src/main/java/org/thingsboard/server/dao/asset/AssetProfileService.java
  11. 2
      common/dao-api/src/main/java/org/thingsboard/server/dao/customer/CustomerService.java
  12. 2
      common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java
  13. 3
      common/dao-api/src/main/java/org/thingsboard/server/dao/device/DeviceProfileService.java
  14. 2
      common/dao-api/src/main/java/org/thingsboard/server/dao/entityview/EntityViewService.java
  15. 2
      common/dao-api/src/main/java/org/thingsboard/server/dao/rule/RuleChainService.java
  16. 2
      common/dao-api/src/main/java/org/thingsboard/server/dao/tenant/TenantService.java
  17. 2
      common/dao-api/src/main/java/org/thingsboard/server/dao/user/UserService.java
  18. 5
      common/dao-api/src/main/java/org/thingsboard/server/dao/widget/WidgetsBundleService.java
  19. 3
      dao/src/main/java/org/thingsboard/server/dao/asset/AssetProfileDao.java
  20. 10
      dao/src/main/java/org/thingsboard/server/dao/asset/AssetProfileServiceImpl.java
  21. 3
      dao/src/main/java/org/thingsboard/server/dao/customer/CustomerDao.java
  22. 9
      dao/src/main/java/org/thingsboard/server/dao/customer/CustomerServiceImpl.java
  23. 3
      dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java
  24. 8
      dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java
  25. 3
      dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileDao.java
  26. 10
      dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java
  27. 2
      dao/src/main/java/org/thingsboard/server/dao/entityview/EntityViewDao.java
  28. 9
      dao/src/main/java/org/thingsboard/server/dao/entityview/EntityViewServiceImpl.java
  29. 8
      dao/src/main/java/org/thingsboard/server/dao/rule/BaseRuleChainService.java
  30. 4
      dao/src/main/java/org/thingsboard/server/dao/rule/RuleChainDao.java
  31. 5
      dao/src/main/java/org/thingsboard/server/dao/sql/asset/JpaAssetProfileDao.java
  32. 5
      dao/src/main/java/org/thingsboard/server/dao/sql/customer/JpaCustomerDao.java
  33. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/JpaDashboardInfoDao.java
  34. 5
      dao/src/main/java/org/thingsboard/server/dao/sql/device/JpaDeviceProfileDao.java
  35. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/entityview/JpaEntityViewDao.java
  36. 5
      dao/src/main/java/org/thingsboard/server/dao/sql/rule/JpaRuleChainDao.java
  37. 5
      dao/src/main/java/org/thingsboard/server/dao/sql/tenant/JpaTenantDao.java
  38. 5
      dao/src/main/java/org/thingsboard/server/dao/sql/user/JpaUserDao.java
  39. 11
      dao/src/main/java/org/thingsboard/server/dao/sql/widget/JpaWidgetsBundleDao.java
  40. 16
      dao/src/main/java/org/thingsboard/server/dao/sql/widget/WidgetsBundleRepository.java
  41. 3
      dao/src/main/java/org/thingsboard/server/dao/tenant/TenantDao.java
  42. 7
      dao/src/main/java/org/thingsboard/server/dao/tenant/TenantServiceImpl.java
  43. 3
      dao/src/main/java/org/thingsboard/server/dao/user/UserDao.java
  44. 9
      dao/src/main/java/org/thingsboard/server/dao/user/UserServiceImpl.java
  45. 5
      dao/src/main/java/org/thingsboard/server/dao/widget/WidgetsBundleDao.java
  46. 19
      dao/src/main/java/org/thingsboard/server/dao/widget/WidgetsBundleServiceImpl.java

17
application/src/main/java/org/thingsboard/server/controller/AssetProfileController.java

@ -48,9 +48,9 @@ import org.thingsboard.server.service.security.permission.Operation;
import org.thingsboard.server.service.security.permission.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.Set;
import java.util.UUID;
import static org.thingsboard.server.controller.ControllerConstants.ASSET_PROFILE_ID;
import static org.thingsboard.server.controller.ControllerConstants.ASSET_PROFILE_ID_PARAM_DESCRIPTION;
@ -234,16 +234,13 @@ public class AssetProfileController extends BaseController {
@GetMapping(value = "/assetProfileInfos", params = {"assetProfileIds"})
public List<AssetProfileInfo> getAssetProfilesByIds(
@Parameter(description = "A list of asset profile ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true)
@RequestParam("assetProfileIds") String[] strAssetProfileIds) throws ThingsboardException, ExecutionException, InterruptedException {
checkArrayParameter("assetProfileIds", strAssetProfileIds);
SecurityUser user = getCurrentUser();
TenantId tenantId = user.getTenantId();
@RequestParam("assetProfileIds") Set<UUID> assetProfileUUIDs) throws ThingsboardException {
TenantId tenantId = getCurrentUser().getTenantId();
List<AssetProfileId> assetProfileIds = new ArrayList<>();
for (String strAssetProfileId : strAssetProfileIds) {
assetProfileIds.add(new AssetProfileId(toUUID(strAssetProfileId)));
for (UUID assetProfileUUID : assetProfileUUIDs) {
assetProfileIds.add(new AssetProfileId(assetProfileUUID));
}
return assetProfileService.findAssetProfilesByIdsAsync(tenantId, assetProfileIds).get();
return assetProfileService.findAssetProfilesByIds(tenantId, assetProfileIds);
}
}

17
application/src/main/java/org/thingsboard/server/controller/CustomerController.java

@ -42,14 +42,13 @@ import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.config.annotations.ApiOperation;
import org.thingsboard.server.queue.util.TbCoreComponent;
import org.thingsboard.server.service.entitiy.customer.TbCustomerService;
import org.thingsboard.server.service.security.model.SecurityUser;
import org.thingsboard.server.service.security.permission.Operation;
import org.thingsboard.server.service.security.permission.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.Set;
import java.util.UUID;
import static org.thingsboard.server.controller.ControllerConstants.CUSTOMER_ID;
import static org.thingsboard.server.controller.ControllerConstants.CUSTOMER_ID_PARAM_DESCRIPTION;
@ -198,15 +197,13 @@ public class CustomerController extends BaseController {
@GetMapping(value = "/customers", params = {"customerIds"})
public List<Customer> getCustomersByIds(
@Parameter(description = "A list of customer ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true)
@RequestParam("customerIds") String[] strCustomerIds) throws ThingsboardException, ExecutionException, InterruptedException {
checkArrayParameter("customerIds", strCustomerIds);
SecurityUser user = getCurrentUser();
TenantId tenantId = user.getTenantId();
@RequestParam("customerIds") Set<UUID> customerUUIDs) throws ThingsboardException {
TenantId tenantId = getCurrentUser().getTenantId();
List<CustomerId> customerIds = new ArrayList<>();
for (String strCustomerId : strCustomerIds) {
customerIds.add(new CustomerId(toUUID(strCustomerId)));
for (UUID customerUUID : customerUUIDs) {
customerIds.add(new CustomerId(customerUUID));
}
return customerService.findCustomersByTenantIdAndIdsAsync(tenantId, customerIds).get();
return customerService.findCustomersByTenantIdAndIds(tenantId, customerIds);
}
}

13
application/src/main/java/org/thingsboard/server/controller/DashboardController.java

@ -70,7 +70,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@ -621,15 +620,13 @@ public class DashboardController extends BaseController {
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
@GetMapping(value = "/dashboards", params = {"dashboardIds"})
public List<DashboardInfo> getDashboardsByIds(@Parameter(description = "A list of dashboard ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true)
@RequestParam("dashboardIds") String[] strDashboardIds) throws ThingsboardException, ExecutionException, InterruptedException {
checkArrayParameter("dashboardIds", strDashboardIds);
SecurityUser user = getCurrentUser();
TenantId tenantId = user.getTenantId();
@RequestParam("dashboardIds") Set<UUID> dashboardUUIDs) throws ThingsboardException {
TenantId tenantId = getCurrentUser().getTenantId();
List<DashboardId> dashboardIds = new ArrayList<>();
for (String strDashboardId : strDashboardIds) {
dashboardIds.add(new DashboardId(toUUID(strDashboardId)));
for (UUID dashboardUUID : dashboardUUIDs) {
dashboardIds.add(new DashboardId(dashboardUUID));
}
List<DashboardInfo> dashboards = checkNotNull(dashboardService.findDashboardInfoByIdsAsync(tenantId, dashboardIds).get());
List<DashboardInfo> dashboards = dashboardService.findDashboardInfoByIds(tenantId, dashboardIds);
return filterDashboardsByReadPermission(dashboards);
}

23
application/src/main/java/org/thingsboard/server/controller/DeviceProfileController.java

@ -51,10 +51,9 @@ import org.thingsboard.server.service.security.permission.Operation;
import org.thingsboard.server.service.security.permission.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import static org.thingsboard.server.controller.ControllerConstants.DEVICE_PROFILE_DATA;
import static org.thingsboard.server.controller.ControllerConstants.DEVICE_PROFILE_ID;
@ -283,26 +282,20 @@ public class DeviceProfileController extends BaseController {
return checkNotNull(deviceProfileService.findDeviceProfileNamesByTenantId(tenantId, activeOnly));
}
@ApiOperation(value = "Get Device Profiles By Ids (getDeviceProfilesByIds)",
@ApiOperation(value = "Get Device Profile Infos By Ids (getDeviceProfilesByIds)",
notes = "Requested device profiles must be owned by tenant which is performing the request. " +
NEW_LINE)
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@GetMapping(value = "/deviceProfileInfos", params = {"deviceProfileIds"})
public List<DeviceProfileInfo> getDeviceProfilesByIds(
public List<DeviceProfileInfo> getDeviceProfileInfosByIds(
@Parameter(description = "A list of device profile ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true)
@RequestParam("deviceProfileIds") String[] strDeviceProfileIds) throws ThingsboardException, ExecutionException, InterruptedException {
checkArrayParameter("deviceProfileIds", strDeviceProfileIds);
SecurityUser user = getCurrentUser();
if (!accessControlService.hasPermission(user, Resource.DEVICE_PROFILE, Operation.READ)) {
return Collections.emptyList();
}
TenantId tenantId = user.getTenantId();
@RequestParam("deviceProfileIds") Set<UUID> deviceProfileUUIDs) throws ThingsboardException {
TenantId tenantId = getCurrentUser().getTenantId();
List<DeviceProfileId> deviceProfileIds = new ArrayList<>();
for (String strDeviceProfileId : strDeviceProfileIds) {
deviceProfileIds.add(new DeviceProfileId(toUUID(strDeviceProfileId)));
for (UUID deviceProfileUUID : deviceProfileUUIDs) {
deviceProfileIds.add(new DeviceProfileId(deviceProfileUUID));
}
return checkNotNull(deviceProfileService.findDeviceProfilesByIdsAsync(tenantId, deviceProfileIds).get());
return deviceProfileService.findDeviceProfilesByIds(tenantId, deviceProfileIds);
}
}

14
application/src/main/java/org/thingsboard/server/controller/EntityViewController.java

@ -57,6 +57,8 @@ import org.thingsboard.server.service.security.permission.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
@ -468,15 +470,13 @@ public class EntityViewController extends BaseController {
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
@GetMapping(value = "/entityViews", params = {"entityViewIds"})
public List<EntityView> getEntityViewsByIds(@Parameter(description = "A list of entity view ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true)
@RequestParam("entityViewIds") String[] strEntityViewIds) throws ThingsboardException, ExecutionException, InterruptedException {
checkArrayParameter("entityViewIds", strEntityViewIds);
SecurityUser user = getCurrentUser();
TenantId tenantId = user.getTenantId();
@RequestParam("entityViewIds") Set<UUID> entityViewUUIDs) throws ThingsboardException {
TenantId tenantId = getCurrentUser().getTenantId();
List<EntityViewId> entityViewIds = new ArrayList<>();
for (String strEntityViewId : strEntityViewIds) {
entityViewIds.add(new EntityViewId(toUUID(strEntityViewId)));
for (UUID entityViewUUID : entityViewUUIDs) {
entityViewIds.add(new EntityViewId(entityViewUUID));
}
List<EntityView> entityViews = checkNotNull(entityViewService.findEntityViewsByTenantIdAndIdsAsync(tenantId, entityViewIds).get());
List<EntityView> entityViews = entityViewService.findEntityViewsByTenantIdAndIds(tenantId, entityViewIds);
return filterEntityViewsByReadPermission(entityViews);
}

14
application/src/main/java/org/thingsboard/server/controller/RuleChainController.java

@ -72,7 +72,6 @@ import org.thingsboard.server.queue.util.TbCoreComponent;
import org.thingsboard.server.service.rule.TbRuleChainService;
import org.thingsboard.server.service.script.RuleNodeJsScriptEngine;
import org.thingsboard.server.service.script.RuleNodeTbelScriptEngine;
import org.thingsboard.server.service.security.model.SecurityUser;
import org.thingsboard.server.service.security.permission.Operation;
import org.thingsboard.server.service.security.permission.Resource;
@ -81,6 +80,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
@ -589,15 +589,13 @@ public class RuleChainController extends BaseController {
@GetMapping(value = "/ruleChains", params = {"ruleChainIds"})
public List<RuleChain> getRuleChainsByIds(
@Parameter(description = "A list of rule chain ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true)
@RequestParam("ruleChainIds") String[] strRuleChainIds) throws Exception {
checkArrayParameter("ruleChainIds", strRuleChainIds);
SecurityUser user = getCurrentUser();
TenantId tenantId = user.getTenantId();
@RequestParam("ruleChainIds") Set<UUID> ruleChainUUIDs) throws Exception {
TenantId tenantId = getCurrentUser().getTenantId();
List<RuleChainId> ruleChainIds = new ArrayList<>();
for (String strRuleChainId : strRuleChainIds) {
ruleChainIds.add(new RuleChainId(toUUID(strRuleChainId)));
for (UUID ruleChainUUID : ruleChainUUIDs) {
ruleChainIds.add(new RuleChainId(ruleChainUUID));
}
return ruleChainService.findRuleChainsByIdsAsync(tenantId, ruleChainIds).get();
return ruleChainService.findRuleChainsByIds(tenantId, ruleChainIds);
}
}

17
application/src/main/java/org/thingsboard/server/controller/TenantController.java

@ -41,14 +41,13 @@ import org.thingsboard.server.config.annotations.ApiOperation;
import org.thingsboard.server.dao.tenant.TenantService;
import org.thingsboard.server.queue.util.TbCoreComponent;
import org.thingsboard.server.service.entitiy.tenant.TbTenantService;
import org.thingsboard.server.service.security.model.SecurityUser;
import org.thingsboard.server.service.security.permission.Operation;
import org.thingsboard.server.service.security.permission.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.Set;
import java.util.UUID;
import static org.thingsboard.server.controller.ControllerConstants.HOME_DASHBOARD;
import static org.thingsboard.server.controller.ControllerConstants.PAGE_DATA_PARAMETERS;
@ -178,15 +177,13 @@ public class TenantController extends BaseController {
@GetMapping(value = "/tenants", params = {"tenantIds"})
public List<Tenant> getTenantsByIds(
@Parameter(description = "A list of tenant ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")))
@RequestParam("tenantIds") String[] strTenantIds) throws ThingsboardException, ExecutionException, InterruptedException {
checkArrayParameter("tenantIds", strTenantIds);
SecurityUser user = getCurrentUser();
TenantId tenantId = user.getTenantId();
@RequestParam("tenantIds") Set<UUID> tenantUUIDs) throws ThingsboardException {
TenantId tenantId = getCurrentUser().getTenantId();
List<TenantId> tenantIds = new ArrayList<>();
for (String strTenantId : strTenantIds) {
tenantIds.add(new TenantId(toUUID(strTenantId)));
for (UUID tenantIdUUID : tenantUUIDs) {
tenantIds.add(TenantId.fromUUID(tenantIdUUID));
}
return tenantService.findTenantsByIdsAsync(tenantId, tenantIds).get();
return tenantService.findTenantsByIds(tenantId, tenantIds);
}
}

16
application/src/main/java/org/thingsboard/server/controller/UserController.java

@ -85,8 +85,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import static org.thingsboard.server.common.data.query.EntityKeyType.ENTITY_FIELD;
@ -603,15 +603,13 @@ public class UserController extends BaseController {
@GetMapping(value = "/users", params = {"userIds"})
public List<User> getUsersByIds(
@Parameter(description = "A list of user ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true)
@RequestParam("userIds") String[] strUserIds) throws ThingsboardException, ExecutionException, InterruptedException {
checkArrayParameter("userIds", strUserIds);
SecurityUser user = getCurrentUser();
TenantId tenantId = user.getTenantId();
@RequestParam("userIds") Set<UUID> userUUIDs) throws ThingsboardException {
TenantId tenantId = getCurrentUser().getTenantId();
List<UserId> userIds = new ArrayList<>();
for (String strUserId : strUserIds) {
userIds.add(new UserId(toUUID(strUserId)));
for (UUID userUUID : userUUIDs) {
userIds.add(new UserId(userUUID));
}
List<User> users = checkNotNull(userService.findUsersByTenantIdAndIdsAsync(tenantId, userIds).get());
List<User> users = userService.findUsersByTenantIdAndIds(tenantId, userIds);
return filterUsersByReadPermission(users);
}

17
application/src/main/java/org/thingsboard/server/controller/WidgetsBundleController.java

@ -47,12 +47,10 @@ import org.thingsboard.server.service.security.permission.Operation;
import org.thingsboard.server.service.security.permission.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.UUID;
import static org.thingsboard.server.controller.ControllerConstants.AVAILABLE_FOR_ANY_AUTHORIZED_USER;
import static org.thingsboard.server.controller.ControllerConstants.INLINE_IMAGES;
@ -247,17 +245,12 @@ public class WidgetsBundleController extends BaseController {
@GetMapping(value = "/widgetsBundles", params = {"widgetsBundleIds"})
public List<WidgetsBundle> getWidgetsBundlesByIds(
@Parameter(description = "A list of widgets bundle ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true)
@RequestParam("widgetsBundleIds") String[] strWidgetsBundleIds) throws ThingsboardException, ExecutionException, InterruptedException {
checkArrayParameter("widgetsBundleIds", strWidgetsBundleIds);
@RequestParam("widgetsBundleIds") Set<UUID> widgetsBundleUUIDs) throws ThingsboardException {
List<WidgetsBundleId> widgetsBundleIds = new ArrayList<>();
for (String strWidgetsBundleId : strWidgetsBundleIds) {
widgetsBundleIds.add(new WidgetsBundleId(toUUID(strWidgetsBundleId)));
}
if (Authority.SYS_ADMIN.equals(getCurrentUser().getAuthority())) {
return widgetsBundleService.findSystemWidgetsBundlesByIdsAsync(getTenantId(), widgetsBundleIds).get();
} else {
return widgetsBundleService.findAllTenantWidgetsBundlesByIdsAsync(getTenantId(), widgetsBundleIds).get();
for (UUID widgetsBundleUUID : widgetsBundleUUIDs) {
widgetsBundleIds.add(new WidgetsBundleId(widgetsBundleUUID));
}
return widgetsBundleService.findSystemOrTenantWidgetsBundlesByIds(getTenantId(), widgetsBundleIds);
}
}

3
common/dao-api/src/main/java/org/thingsboard/server/dao/asset/AssetProfileService.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.asset;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.EntityInfo;
import org.thingsboard.server.common.data.asset.AssetProfile;
import org.thingsboard.server.common.data.asset.AssetProfileInfo;
@ -63,6 +62,6 @@ public interface AssetProfileService extends EntityDaoService {
List<EntityInfo> findAssetProfileNamesByTenantId(TenantId tenantId, boolean activeOnly);
ListenableFuture<List<AssetProfileInfo>> findAssetProfilesByIdsAsync(TenantId tenantId, List<AssetProfileId> assetProfileIds);
List<AssetProfileInfo> findAssetProfilesByIds(TenantId tenantId, List<AssetProfileId> assetProfileIds);
}

2
common/dao-api/src/main/java/org/thingsboard/server/dao/customer/CustomerService.java

@ -48,6 +48,6 @@ public interface CustomerService extends EntityDaoService {
void deleteCustomersByTenantId(TenantId tenantId);
ListenableFuture<List<Customer>> findCustomersByTenantIdAndIdsAsync(TenantId tenantId, List<CustomerId> customerIds);
List<Customer> findCustomersByTenantIdAndIds(TenantId tenantId, List<CustomerId> customerIds);
}

2
common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java

@ -80,6 +80,6 @@ public interface DashboardService extends EntityDaoService {
PageData<DashboardId> findAllDashboardsIds(PageLink pageLink);
ListenableFuture<List<DashboardInfo>> findDashboardInfoByIdsAsync(TenantId tenantId, List<DashboardId> dashboardIds);
List<DashboardInfo> findDashboardInfoByIds(TenantId tenantId, List<DashboardId> dashboardIds);
}

3
common/dao-api/src/main/java/org/thingsboard/server/dao/device/DeviceProfileService.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.device;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.DeviceProfileInfo;
import org.thingsboard.server.common.data.EntityInfo;
@ -65,6 +64,6 @@ public interface DeviceProfileService extends EntityDaoService {
List<EntityInfo> findDeviceProfileNamesByTenantId(TenantId tenantId, boolean activeOnly);
ListenableFuture<List<DeviceProfileInfo>> findDeviceProfilesByIdsAsync(TenantId tenantId, List<DeviceProfileId> deviceProfileIds);
List<DeviceProfileInfo> findDeviceProfilesByIds(TenantId tenantId, List<DeviceProfileId> deviceProfileIds);
}

2
common/dao-api/src/main/java/org/thingsboard/server/dao/entityview/EntityViewService.java

@ -65,7 +65,7 @@ public interface EntityViewService extends EntityDaoService {
PageData<EntityView> findEntityViewsByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, PageLink pageLink);
ListenableFuture<List<EntityView>> findEntityViewsByTenantIdAndIdsAsync(TenantId tenantId, List<EntityViewId> entityViewIds);
List<EntityView> findEntityViewsByTenantIdAndIds(TenantId tenantId, List<EntityViewId> entityViewIds);
PageData<EntityViewInfo> findEntityViewInfosByTenantIdAndCustomerId(TenantId tenantId, CustomerId customerId, PageLink pageLink);

2
common/dao-api/src/main/java/org/thingsboard/server/dao/rule/RuleChainService.java

@ -117,6 +117,6 @@ public interface RuleChainService extends EntityDaoService {
void deleteRuleNodes(TenantId tenantId, RuleChainId ruleChainId);
ListenableFuture<List<RuleChain>> findRuleChainsByIdsAsync(TenantId tenantId, List<RuleChainId> ruleChainIds);
List<RuleChain> findRuleChainsByIds(TenantId tenantId, List<RuleChainId> ruleChainIds);
}

2
common/dao-api/src/main/java/org/thingsboard/server/dao/tenant/TenantService.java

@ -55,6 +55,6 @@ public interface TenantService extends EntityDaoService {
PageData<TenantId> findTenantsIds(PageLink pageLink);
ListenableFuture<List<Tenant>> findTenantsByIdsAsync(TenantId callerId, List<TenantId> tenantIds);
List<Tenant> findTenantsByIds(TenantId callerId, List<TenantId> tenantIds);
}

2
common/dao-api/src/main/java/org/thingsboard/server/dao/user/UserService.java

@ -111,6 +111,6 @@ public interface UserService extends EntityDaoService {
int countTenantAdmins(TenantId tenantId);
ListenableFuture<List<User>> findUsersByTenantIdAndIdsAsync(TenantId tenantId, List<UserId> userIds);
List<User> findUsersByTenantIdAndIds(TenantId tenantId, List<UserId> userIds);
}

5
common/dao-api/src/main/java/org/thingsboard/server/dao/widget/WidgetsBundleService.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.widget;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.WidgetsBundleId;
import org.thingsboard.server.common.data.page.PageData;
@ -53,8 +52,6 @@ public interface WidgetsBundleService extends EntityDaoService {
void updateSystemWidgets(Stream<String> bundles, Stream<String> widgets);
ListenableFuture<List<WidgetsBundle>> findSystemWidgetsBundlesByIdsAsync(TenantId tenantId, List<WidgetsBundleId> widgetsBundleIds);
ListenableFuture<List<WidgetsBundle>> findAllTenantWidgetsBundlesByIdsAsync(TenantId tenantId, List<WidgetsBundleId> widgetsBundleIds);
List<WidgetsBundle> findSystemOrTenantWidgetsBundlesByIds(TenantId tenantId, List<WidgetsBundleId> widgetsBundleIds);
}

3
dao/src/main/java/org/thingsboard/server/dao/asset/AssetProfileDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.asset;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.EntityInfo;
import org.thingsboard.server.common.data.asset.AssetProfile;
import org.thingsboard.server.common.data.asset.AssetProfileInfo;
@ -52,6 +51,6 @@ public interface AssetProfileDao extends Dao<AssetProfile>, ExportableEntityDao<
List<EntityInfo> findTenantAssetProfileNames(UUID tenantId, boolean activeOnly);
ListenableFuture<List<AssetProfileInfo>> findAssetProfilesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> assetProfileIds);
List<AssetProfileInfo> findAssetProfilesByTenantIdAndIds(UUID tenantId, List<UUID> assetProfileIds);
}

10
dao/src/main/java/org/thingsboard/server/dao/asset/AssetProfileServiceImpl.java

@ -16,7 +16,6 @@
package org.thingsboard.server.dao.asset;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.exception.ConstraintViolationException;
import org.springframework.beans.factory.annotation.Autowired;
@ -54,7 +53,6 @@ import java.util.stream.Collectors;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static org.thingsboard.server.dao.DaoUtil.toUUIDs;
import static org.thingsboard.server.dao.service.Validator.validateId;
import static org.thingsboard.server.dao.service.Validator.validateIds;
@Service("AssetProfileDaoService")
@Slf4j
@ -349,11 +347,9 @@ public class AssetProfileServiceImpl extends CachedVersionedEntityService<AssetP
}
@Override
public ListenableFuture<List<AssetProfileInfo>> findAssetProfilesByIdsAsync(TenantId tenantId, List<AssetProfileId> assetProfileIds) {
log.trace("Executing findAssetProfilesByIdsAsync, tenantId [{}], assetProfileIds [{}]", tenantId, assetProfileIds);
validateId(tenantId, id -> INCORRECT_TENANT_ID + id);
validateIds(assetProfileIds, ids -> "Incorrect assetProfileIds " + ids);
return assetProfileDao.findAssetProfilesByTenantIdAndIdsAsync(tenantId.getId(), toUUIDs(assetProfileIds));
public List<AssetProfileInfo> findAssetProfilesByIds(TenantId tenantId, List<AssetProfileId> assetProfileIds) {
log.trace("Executing findAssetProfilesByIds, tenantId [{}], assetProfileIds [{}]", tenantId, assetProfileIds);
return assetProfileDao.findAssetProfilesByTenantIdAndIds(tenantId.getId(), toUUIDs(assetProfileIds));
}
private final PaginatedRemover<TenantId, AssetProfile> tenantAssetProfilesRemover =

3
dao/src/main/java/org/thingsboard/server/dao/customer/CustomerDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.customer;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.id.CustomerId;
import org.thingsboard.server.common.data.id.TenantId;
@ -80,6 +79,6 @@ public interface CustomerDao extends Dao<Customer>, TenantEntityDao<Customer>, E
*/
PageData<Customer> findCustomersWithTheSameTitle(PageLink pageLink);
ListenableFuture<List<Customer>> findCustomersByTenantIdAndIdsAsync(UUID tenantId, List<UUID> customerIds);
List<Customer> findCustomersByTenantIdAndIds(UUID tenantId, List<UUID> customerIds);
}

9
dao/src/main/java/org/thingsboard/server/dao/customer/CustomerServiceImpl.java

@ -59,7 +59,6 @@ import java.util.stream.Collectors;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static org.thingsboard.server.dao.service.Validator.validateId;
import static org.thingsboard.server.dao.service.Validator.validateIds;
@Service("CustomerDaoService")
@Slf4j
@ -266,11 +265,9 @@ public class CustomerServiceImpl extends AbstractCachedEntityService<CustomerCac
}
@Override
public ListenableFuture<List<Customer>> findCustomersByTenantIdAndIdsAsync(TenantId tenantId, List<CustomerId> customerIds) {
log.trace("Executing findCustomersByTenantIdAndIdsAsync, tenantId [{}], customerIds [{}]", tenantId, customerIds);
validateId(tenantId, id -> INCORRECT_TENANT_ID + id);
validateIds(customerIds, ids -> "Incorrect customerIds " + ids);
return customerDao.findCustomersByTenantIdAndIdsAsync(tenantId.getId(), customerIds.stream().map(CustomerId::getId).collect(Collectors.toList()));
public List<Customer> findCustomersByTenantIdAndIds(TenantId tenantId, List<CustomerId> customerIds) {
log.trace("Executing findCustomersByTenantIdAndIds, tenantId [{}], customerIds [{}]", tenantId, customerIds);
return customerDao.findCustomersByTenantIdAndIds(tenantId.getId(), customerIds.stream().map(CustomerId::getId).collect(Collectors.toList()));
}
@Override

3
dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.dashboard;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.DashboardInfo;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
@ -83,6 +82,6 @@ public interface DashboardInfoDao extends Dao<DashboardInfo>, ImageContainerDao<
String findTitleById(UUID tenantId, UUID dashboardId);
ListenableFuture<List<DashboardInfo>> findDashboardsByIdsAsync(UUID tenantId, List<UUID> dashboardIds);
List<DashboardInfo> findDashboardsByIds(UUID tenantId, List<UUID> dashboardIds);
}

8
dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java

@ -65,7 +65,6 @@ import java.util.Optional;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static org.thingsboard.server.dao.DaoUtil.toUUIDs;
import static org.thingsboard.server.dao.service.Validator.validateId;
import static org.thingsboard.server.dao.service.Validator.validateIds;
@Service("DashboardDaoService")
@Slf4j
@ -412,10 +411,9 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb
}
@Override
public ListenableFuture<List<DashboardInfo>> findDashboardInfoByIdsAsync(TenantId tenantId, List<DashboardId> dashboardIds) {
log.trace("Executing findDashboardInfoByIdsAsync, dashboardIds [{}]", dashboardIds);
validateIds(dashboardIds, ids -> "Incorrect dashboardIds " + ids);
return dashboardInfoDao.findDashboardsByIdsAsync(tenantId.getId(), toUUIDs(dashboardIds));
public List<DashboardInfo> findDashboardInfoByIds(TenantId tenantId, List<DashboardId> dashboardIds) {
log.trace("Executing findDashboardInfoByIds, dashboardIds [{}]", dashboardIds);
return dashboardInfoDao.findDashboardsByIds(tenantId.getId(), toUUIDs(dashboardIds));
}
private final PaginatedRemover<TenantId, DashboardId> tenantDashboardsRemover = new PaginatedRemover<>() {

3
dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.device;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.DeviceProfileInfo;
import org.thingsboard.server.common.data.EntityInfo;
@ -54,6 +53,6 @@ public interface DeviceProfileDao extends Dao<DeviceProfile>, ExportableEntityDa
List<EntityInfo> findTenantDeviceProfileNames(UUID tenantId, boolean activeOnly);
ListenableFuture<List<DeviceProfileInfo>> findDeviceProfilesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceProfileIds);
List<DeviceProfileInfo> findDeviceProfilesByTenantIdAndIds(UUID tenantId, List<UUID> deviceProfileIds);
}

10
dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java

@ -16,7 +16,6 @@
package org.thingsboard.server.dao.device;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -69,7 +68,6 @@ import java.util.stream.Collectors;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static org.thingsboard.server.dao.DaoUtil.toUUIDs;
import static org.thingsboard.server.dao.service.Validator.validateId;
import static org.thingsboard.server.dao.service.Validator.validateIds;
import static org.thingsboard.server.dao.service.Validator.validateString;
@Service("DeviceProfileDaoService")
@ -395,11 +393,9 @@ public class DeviceProfileServiceImpl extends CachedVersionedEntityService<Devic
}
@Override
public ListenableFuture<List<DeviceProfileInfo>> findDeviceProfilesByIdsAsync(TenantId tenantId, List<DeviceProfileId> deviceProfileIds) {
log.trace("Executing findDeviceProfilesByIdsAsync, tenantId [{}], deviceProfileIds [{}]", tenantId, deviceProfileIds);
validateId(tenantId, id -> INCORRECT_TENANT_ID + id);
validateIds(deviceProfileIds, ids -> "Incorrect deviceProfileIds " + ids);
return deviceProfileDao.findDeviceProfilesByTenantIdAndIdsAsync(tenantId.getId(), toUUIDs(deviceProfileIds));
public List<DeviceProfileInfo> findDeviceProfilesByIds(TenantId tenantId, List<DeviceProfileId> deviceProfileIds) {
log.trace("Executing findDeviceProfilesByIds, tenantId [{}], deviceProfileIds [{}]", tenantId, deviceProfileIds);
return deviceProfileDao.findDeviceProfilesByTenantIdAndIds(tenantId.getId(), toUUIDs(deviceProfileIds));
}
private final PaginatedRemover<TenantId, DeviceProfile> tenantDeviceProfilesRemover =

2
dao/src/main/java/org/thingsboard/server/dao/entityview/EntityViewDao.java

@ -169,7 +169,7 @@ public interface EntityViewDao extends Dao<EntityView>, ExportableEntityDao<Enti
UUID edgeId,
PageLink pageLink);
ListenableFuture<List<EntityView>> findEntityViewsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> entityViewIds);
List<EntityView> findEntityViewsByTenantIdAndIds(UUID tenantId, List<UUID> entityViewIds);
/**
* Find entity views by tenantId, edgeId, type and page link.

9
dao/src/main/java/org/thingsboard/server/dao/entityview/EntityViewServiceImpl.java

@ -64,7 +64,6 @@ import java.util.stream.Collectors;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static org.thingsboard.server.dao.DaoUtil.toUUIDs;
import static org.thingsboard.server.dao.service.Validator.validateId;
import static org.thingsboard.server.dao.service.Validator.validateIds;
import static org.thingsboard.server.dao.service.Validator.validatePageLink;
import static org.thingsboard.server.dao.service.Validator.validateString;
@ -258,11 +257,9 @@ public class EntityViewServiceImpl extends CachedVersionedEntityService<EntityVi
}
@Override
public ListenableFuture<List<EntityView>> findEntityViewsByTenantIdAndIdsAsync(TenantId tenantId, List<EntityViewId> entityViewIds) {
log.trace("Executing findEntityViewsByTenantIdAndIdsAsync, tenantId [{}], entityViewIds [{}]", tenantId, entityViewIds);
validateId(tenantId, id -> INCORRECT_TENANT_ID + id);
validateIds(entityViewIds, ids -> "Incorrect entityViewIds " + ids);
return entityViewDao.findEntityViewsByTenantIdAndIdsAsync(tenantId.getId(), toUUIDs(entityViewIds));
public List<EntityView> findEntityViewsByTenantIdAndIds(TenantId tenantId, List<EntityViewId> entityViewIds) {
log.trace("Executing findEntityViewsByTenantIdAndIds, tenantId [{}], entityViewIds [{}]", tenantId, entityViewIds);
return entityViewDao.findEntityViewsByTenantIdAndIds(tenantId.getId(), toUUIDs(entityViewIds));
}
@Override

8
dao/src/main/java/org/thingsboard/server/dao/rule/BaseRuleChainService.java

@ -871,11 +871,9 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC
}
@Override
public ListenableFuture<List<RuleChain>> findRuleChainsByIdsAsync(TenantId tenantId, List<RuleChainId> ruleChainIds) {
log.trace("Executing findRuleChainsByIdsAsync, tenantId [{}], ruleChainIds [{}]", tenantId, ruleChainIds);
validateId(tenantId, id -> INCORRECT_TENANT_ID + id);
validateIds(ruleChainIds, ids -> "Incorrect ruleChainIds " + ids);
return ruleChainDao.findRuleChainsByTenantIdAndIdsAsync(tenantId.getId(), toUUIDs(ruleChainIds));
public List<RuleChain> findRuleChainsByIds(TenantId tenantId, List<RuleChainId> ruleChainIds) {
log.trace("Executing findRuleChainsByIds, tenantId [{}], ruleChainIds [{}]", tenantId, ruleChainIds);
return ruleChainDao.findRuleChainsByTenantIdAndIds(tenantId.getId(), toUUIDs(ruleChainIds));
}

4
dao/src/main/java/org/thingsboard/server/dao/rule/RuleChainDao.java

@ -15,14 +15,12 @@
*/
package org.thingsboard.server.dao.rule;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.id.RuleChainId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.rule.RuleChain;
import org.thingsboard.server.common.data.rule.RuleChainType;
import org.thingsboard.server.common.data.rule.RuleNode;
import org.thingsboard.server.dao.Dao;
import org.thingsboard.server.dao.ExportableEntityDao;
import org.thingsboard.server.dao.ResourceContainerDao;
@ -85,6 +83,6 @@ public interface RuleChainDao extends Dao<RuleChain>, TenantEntityDao<RuleChain>
Collection<RuleChain> findByTenantIdAndTypeAndName(TenantId tenantId, RuleChainType type, String name);
ListenableFuture<List<RuleChain>> findRuleChainsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> ruleChainIds);
List<RuleChain> findRuleChainsByTenantIdAndIds(UUID tenantId, List<UUID> ruleChainIds);
}

5
dao/src/main/java/org/thingsboard/server/dao/sql/asset/JpaAssetProfileDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.sql.asset;
import com.google.common.util.concurrent.ListenableFuture;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Limit;
import org.springframework.data.domain.PageRequest;
@ -107,8 +106,8 @@ public class JpaAssetProfileDao extends JpaAbstractDao<AssetProfileEntity, Asset
}
@Override
public ListenableFuture<List<AssetProfileInfo>> findAssetProfilesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> assetProfileIds) {
return service.submit(() -> assetProfileRepository.findAssetProfileInfosByTenantIdAndIdIn(tenantId, assetProfileIds));
public List<AssetProfileInfo> findAssetProfilesByTenantIdAndIds(UUID tenantId, List<UUID> assetProfileIds) {
return assetProfileRepository.findAssetProfileInfosByTenantIdAndIdIn(tenantId, assetProfileIds);
}
@Override

5
dao/src/main/java/org/thingsboard/server/dao/sql/customer/JpaCustomerDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.sql.customer;
import com.google.common.util.concurrent.ListenableFuture;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Limit;
import org.springframework.data.jpa.repository.JpaRepository;
@ -109,8 +108,8 @@ public class JpaCustomerDao extends JpaAbstractDao<CustomerEntity, Customer> imp
}
@Override
public ListenableFuture<List<Customer>> findCustomersByTenantIdAndIdsAsync(UUID tenantId, List<UUID> customerIds) {
return service.submit(() -> DaoUtil.convertDataList(customerRepository.findCustomersByTenantIdAndIdIn(tenantId, customerIds)));
public List<Customer> findCustomersByTenantIdAndIds(UUID tenantId, List<UUID> customerIds) {
return DaoUtil.convertDataList(customerRepository.findCustomersByTenantIdAndIdIn(tenantId, customerIds));
}
@Override

4
dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/JpaDashboardInfoDao.java

@ -128,8 +128,8 @@ public class JpaDashboardInfoDao extends JpaAbstractDao<DashboardInfoEntity, Das
}
@Override
public ListenableFuture<List<DashboardInfo>> findDashboardsByIdsAsync(UUID tenantId, List<UUID> dashboardIds) {
return service.submit(() -> DaoUtil.convertDataList(dashboardInfoRepository.findByIdIn(dashboardIds)));
public List<DashboardInfo> findDashboardsByIds(UUID tenantId, List<UUID> dashboardIds) {
return DaoUtil.convertDataList(dashboardInfoRepository.findByIdIn(dashboardIds));
}
@Override

5
dao/src/main/java/org/thingsboard/server/dao/sql/device/JpaDeviceProfileDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.sql.device;
import com.google.common.util.concurrent.ListenableFuture;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Limit;
import org.springframework.data.domain.PageRequest;
@ -125,8 +124,8 @@ public class JpaDeviceProfileDao extends JpaAbstractDao<DeviceProfileEntity, Dev
}
@Override
public ListenableFuture<List<DeviceProfileInfo>> findDeviceProfilesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceProfileIds) {
return service.submit(() -> deviceProfileRepository.findDeviceProfileInfosByTenantIdAndIdIn(tenantId, deviceProfileIds));
public List<DeviceProfileInfo> findDeviceProfilesByTenantIdAndIds(UUID tenantId, List<UUID> deviceProfileIds) {
return deviceProfileRepository.findDeviceProfileInfosByTenantIdAndIdIn(tenantId, deviceProfileIds);
}
@Override

4
dao/src/main/java/org/thingsboard/server/dao/sql/entityview/JpaEntityViewDao.java

@ -188,8 +188,8 @@ public class JpaEntityViewDao extends JpaAbstractDao<EntityViewEntity, EntityVie
}
@Override
public ListenableFuture<List<EntityView>> findEntityViewsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> entityViewIds) {
return service.submit(() -> DaoUtil.convertDataList(entityViewRepository.findEntityViewsByTenantIdAndIdIn(tenantId, entityViewIds)));
public List<EntityView> findEntityViewsByTenantIdAndIds(UUID tenantId, List<UUID> entityViewIds) {
return DaoUtil.convertDataList(entityViewRepository.findEntityViewsByTenantIdAndIdIn(tenantId, entityViewIds));
}
@Override

5
dao/src/main/java/org/thingsboard/server/dao/sql/rule/JpaRuleChainDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.sql.rule;
import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Limit;
@ -114,8 +113,8 @@ public class JpaRuleChainDao extends JpaAbstractDao<RuleChainEntity, RuleChain>
}
@Override
public ListenableFuture<List<RuleChain>> findRuleChainsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> ruleChainIds) {
return service.submit(() -> DaoUtil.convertDataList(ruleChainRepository.findRuleChainsByTenantIdAndIdIn(tenantId, ruleChainIds)));
public List<RuleChain> findRuleChainsByTenantIdAndIds(UUID tenantId, List<UUID> ruleChainIds) {
return DaoUtil.convertDataList(ruleChainRepository.findRuleChainsByTenantIdAndIdIn(tenantId, ruleChainIds));
}
@Override

5
dao/src/main/java/org/thingsboard/server/dao/sql/tenant/JpaTenantDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.sql.tenant;
import com.google.common.util.concurrent.ListenableFuture;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Limit;
import org.springframework.data.jpa.repository.JpaRepository;
@ -100,8 +99,8 @@ public class JpaTenantDao extends JpaAbstractDao<TenantEntity, Tenant> implement
}
@Override
public ListenableFuture<List<Tenant>> findTenantsByIdsAsync(UUID tenantId, List<UUID> tenantIds) {
return service.submit(() -> DaoUtil.convertDataList(tenantRepository.findTenantsByIdIn(tenantIds)));
public List<Tenant> findTenantsByIds(UUID tenantId, List<UUID> tenantIds) {
return DaoUtil.convertDataList(tenantRepository.findTenantsByIdIn(tenantIds));
}
@Override

5
dao/src/main/java/org/thingsboard/server/dao/sql/user/JpaUserDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.sql.user;
import com.google.common.util.concurrent.ListenableFuture;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Limit;
import org.springframework.data.jpa.repository.JpaRepository;
@ -143,8 +142,8 @@ public class JpaUserDao extends JpaAbstractDao<UserEntity, User> implements User
}
@Override
public ListenableFuture<List<User>> findUsersByTenantIdAndIdsAsync(UUID tenantId, List<UUID> userIds) {
return service.submit(() -> DaoUtil.convertDataList(userRepository.findUsersByTenantIdAndIdIn(tenantId, userIds)));
public List<User> findUsersByTenantIdAndIds(UUID tenantId, List<UUID> userIds) {
return DaoUtil.convertDataList(userRepository.findUsersByTenantIdAndIdIn(tenantId, userIds));
}
@Override

11
dao/src/main/java/org/thingsboard/server/dao/sql/widget/JpaWidgetsBundleDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.sql.widget;
import com.google.common.util.concurrent.ListenableFuture;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Limit;
import org.springframework.data.jpa.repository.JpaRepository;
@ -113,14 +112,8 @@ public class JpaWidgetsBundleDao extends JpaAbstractDao<WidgetsBundleEntity, Wid
}
@Override
public ListenableFuture<List<WidgetsBundle>> findSystemWidgetBundlesByIdsAsync(UUID tenantId, List<UUID> widgetsBundleIds) {
return service.submit(() -> DaoUtil.convertDataList(widgetsBundleRepository.findSystemWidgetsBundlesByIdIn(NULL_UUID, widgetsBundleIds)));
}
@Override
public ListenableFuture<List<WidgetsBundle>> findAllTenantWidgetBundlesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> widgetsBundleIds) {
return service.submit(() -> DaoUtil.convertDataList(widgetsBundleRepository
.findAllTenantWidgetsBundlesByTenantIdAndIdIn(tenantId, NULL_UUID, widgetsBundleIds)));
public List<WidgetsBundle> findSystemOrTenantWidgetBundlesByIds(UUID tenantId, List<UUID> widgetsBundleIds) {
return DaoUtil.convertDataList(widgetsBundleRepository.findSystemOrTenantWidgetsBundlesByIdIn(tenantId, TenantId.NULL_UUID, widgetsBundleIds));
}
private PageData<WidgetsBundle> findTenantWidgetsBundlesByTenantIds(List<UUID> tenantIds, WidgetsBundleFilter widgetsBundleFilter, PageLink pageLink) {

16
dao/src/main/java/org/thingsboard/server/dao/sql/widget/WidgetsBundleRepository.java

@ -21,7 +21,6 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.thingsboard.server.common.data.edqs.fields.WidgetTypeFields;
import org.thingsboard.server.common.data.edqs.fields.WidgetsBundleFields;
import org.thingsboard.server.dao.ExportableEntityRepository;
import org.thingsboard.server.dao.model.sql.WidgetsBundleEntity;
@ -147,15 +146,10 @@ public interface WidgetsBundleRepository extends JpaRepository<WidgetsBundleEnti
"w.alias, w.version) FROM WidgetsBundleEntity w WHERE w.id > :id ORDER BY w.id")
List<WidgetsBundleFields> findNextBatch(@Param("id") UUID id, Limit limit);
@Query("SELECT wb FROM WidgetsBundleEntity wb WHERE wb.tenantId = :systemTenantId " +
"AND wb.id IN :widgetsBundleIds")
List<WidgetsBundleEntity> findSystemWidgetsBundlesByIdIn(@Param("systemTenantId") UUID systemTenantId,
@Param("widgetsBundleIds") List<UUID> widgetsBundleIds);
@Query("SELECT wb FROM WidgetsBundleEntity wb WHERE wb.tenantId IN (:tenantId, :nullTenantId) " +
"AND wb.id IN :widgetsBundleIds")
List<WidgetsBundleEntity> findAllTenantWidgetsBundlesByTenantIdAndIdIn(@Param("tenantId") UUID tenantId,
@Param("nullTenantId") UUID nullTenantId,
@Param("widgetsBundleIds") List<UUID> widgetsBundleIds);
@Query("SELECT wb FROM WidgetsBundleEntity wb WHERE " +
"wb.id IN (:widgetsBundleIds) AND (wb.tenantId = :tenantId OR wb.tenantId = :systemTenantId)")
List<WidgetsBundleEntity> findSystemOrTenantWidgetsBundlesByIdIn(@Param("tenantId") UUID tenantId,
@Param("systemTenantId") UUID systemTenantId,
@Param("widgetsBundleIds") List<UUID> widgetsBundleIds);
}

3
dao/src/main/java/org/thingsboard/server/dao/tenant/TenantDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.tenant;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.TenantInfo;
import org.thingsboard.server.common.data.id.TenantId;
@ -43,6 +42,6 @@ public interface TenantDao extends Dao<Tenant> {
Tenant findTenantByName(TenantId tenantId, String name);
ListenableFuture<List<Tenant>> findTenantsByIdsAsync(UUID tenantId, List<UUID> tenantIds);
List<Tenant> findTenantsByIds(UUID tenantId, List<UUID> tenantIds);
}

7
dao/src/main/java/org/thingsboard/server/dao/tenant/TenantServiceImpl.java

@ -227,10 +227,9 @@ public class TenantServiceImpl extends AbstractCachedEntityService<TenantId, Ten
}
@Override
public ListenableFuture<List<Tenant>> findTenantsByIdsAsync(TenantId callerId, List<TenantId> tenantIds) {
log.trace("Executing findTenantsByIdsAsync, callerId [{}], tenantIds [{}]", callerId, tenantIds);
validateIds(tenantIds, ids -> "Incorrect tenantIds " + ids);
return tenantDao.findTenantsByIdsAsync(callerId.getId(), toUUIDs(tenantIds));
public List<Tenant> findTenantsByIds(TenantId callerId, List<TenantId> tenantIds) {
log.trace("Executing findTenantsByIds, callerId [{}], tenantIds [{}]", callerId, tenantIds);
return tenantDao.findTenantsByIds(callerId.getId(), toUUIDs(tenantIds));
}
@Override

3
dao/src/main/java/org/thingsboard/server/dao/user/UserDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.user;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.id.CustomerId;
import org.thingsboard.server.common.data.id.TenantId;
@ -104,6 +103,6 @@ public interface UserDao extends Dao<User>, TenantEntityDao<User> {
int countTenantAdmins(UUID tenantId);
ListenableFuture<List<User>> findUsersByTenantIdAndIdsAsync(UUID tenantId, List<UUID> userIds);
List<User> findUsersByTenantIdAndIds(UUID tenantId, List<UUID> userIds);
}

9
dao/src/main/java/org/thingsboard/server/dao/user/UserServiceImpl.java

@ -77,7 +77,6 @@ import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static org.thingsboard.server.common.data.StringUtils.generateSafeToken;
import static org.thingsboard.server.dao.DaoUtil.toUUIDs;
import static org.thingsboard.server.dao.service.Validator.validateId;
import static org.thingsboard.server.dao.service.Validator.validateIds;
import static org.thingsboard.server.dao.service.Validator.validatePageLink;
import static org.thingsboard.server.dao.service.Validator.validateString;
@ -495,11 +494,9 @@ public class UserServiceImpl extends AbstractCachedEntityService<UserCacheKey, U
}
@Override
public ListenableFuture<List<User>> findUsersByTenantIdAndIdsAsync(TenantId tenantId, List<UserId> userIds) {
log.trace("Executing findUsersByTenantIdAndIdsAsync, tenantId [{}], userIds [{}]", tenantId, userIds);
validateId(tenantId, id -> INCORRECT_TENANT_ID + id);
validateIds(userIds, ids -> "Incorrect userIds " + ids);
return userDao.findUsersByTenantIdAndIdsAsync(tenantId.getId(), toUUIDs(userIds));
public List<User> findUsersByTenantIdAndIds(TenantId tenantId, List<UserId> userIds) {
log.trace("Executing findUsersByTenantIdAndIds, tenantId [{}], userIds [{}]", tenantId, userIds);
return userDao.findUsersByTenantIdAndIds(tenantId.getId(), toUUIDs(userIds));
}
private Optional<UserMobileSessionInfo> findMobileSessionInfo(TenantId tenantId, UserId userId) {

5
dao/src/main/java/org/thingsboard/server/dao/widget/WidgetsBundleDao.java

@ -15,7 +15,6 @@
*/
package org.thingsboard.server.dao.widget;
import com.google.common.util.concurrent.ListenableFuture;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.WidgetsBundleId;
import org.thingsboard.server.common.data.page.PageData;
@ -89,9 +88,7 @@ public interface WidgetsBundleDao extends Dao<WidgetsBundle>, ExportableEntityDa
PageData<WidgetsBundle> findAllWidgetsBundles(PageLink pageLink);
ListenableFuture<List<WidgetsBundle>> findSystemWidgetBundlesByIdsAsync(UUID tenantId, List<UUID> widgetsBundleIds);
ListenableFuture<List<WidgetsBundle>> findAllTenantWidgetBundlesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> widgetsBundleIds);
List<WidgetsBundle> findSystemOrTenantWidgetBundlesByIds(UUID tenantId, List<UUID> widgetsBundleIds);
}

19
dao/src/main/java/org/thingsboard/server/dao/widget/WidgetsBundleServiceImpl.java

@ -17,7 +17,6 @@ package org.thingsboard.server.dao.widget;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
@ -51,8 +50,6 @@ import java.util.stream.Stream;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static org.thingsboard.server.dao.DaoUtil.toUUIDs;
import static org.thingsboard.server.dao.entity.AbstractEntityService.checkConstraintViolation;
import static org.thingsboard.server.dao.service.Validator.validateId;
import static org.thingsboard.server.dao.service.Validator.validateIds;
@Service("WidgetsBundleDaoService")
@Slf4j
@ -257,19 +254,9 @@ public class WidgetsBundleServiceImpl implements WidgetsBundleService {
}
@Override
public ListenableFuture<List<WidgetsBundle>> findSystemWidgetsBundlesByIdsAsync(TenantId tenantId, List<WidgetsBundleId> widgetsBundleIds) {
log.trace("Executing findSystemWidgetsBundlesByIdsAsync, tenantId [{}], widgetsBundleIds [{}]", tenantId, widgetsBundleIds);
validateId(tenantId, id -> INCORRECT_TENANT_ID + id);
validateIds(widgetsBundleIds, ids -> "Incorrect widgetsBundleIds " + ids);
return widgetsBundleDao.findSystemWidgetBundlesByIdsAsync(tenantId.getId(), toUUIDs(widgetsBundleIds));
}
@Override
public ListenableFuture<List<WidgetsBundle>> findAllTenantWidgetsBundlesByIdsAsync(TenantId tenantId, List<WidgetsBundleId> widgetsBundleIds) {
log.trace("Executing findAllTenantWidgetsBundlesByIdsAsync, tenantId [{}], widgetsBundleIds [{}]", tenantId, widgetsBundleIds);
validateId(tenantId, id -> INCORRECT_TENANT_ID + id);
validateIds(widgetsBundleIds, ids -> "Incorrect widgetsBundleIds " + ids);
return widgetsBundleDao.findAllTenantWidgetBundlesByTenantIdAndIdsAsync(tenantId.getId(), toUUIDs(widgetsBundleIds));
public List<WidgetsBundle> findSystemOrTenantWidgetsBundlesByIds(TenantId tenantId, List<WidgetsBundleId> widgetsBundleIds) {
log.trace("Executing findSystemOrTenantWidgetsBundlesByIds, tenantId [{}], widgetsBundleIds [{}]", tenantId, widgetsBundleIds);
return widgetsBundleDao.findSystemOrTenantWidgetBundlesByIds(tenantId.getId(), toUUIDs(widgetsBundleIds));
}
private WidgetTypeDetails updateSystemWidget(JsonNode widgetTypeJson) {

Loading…
Cancel
Save