diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 6bb902d6b3..203740c6da 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1722,7 +1722,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - int deviceTypeId = applicationDTO.getDeviceTypeId(); List groupDetailsWithDevices = new ArrayList<>(); List groupDetails = @@ -1738,7 +1737,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { // Retrieve group details and device IDs for the group using the service layer GroupDetailsDTO groupDetailWithDevices = - groupManagementProviderService.getGroupDetailsWithDevices(groupName, deviceTypeId, offset, limit); + groupManagementProviderService.getGroupDetailsWithDevices(groupName, applicationDTO.getDeviceTypeId(), + offset, limit); SubscriptionsDTO groupDetailDTO = new SubscriptionsDTO(); groupDetailDTO.setId(groupDetailWithDevices.getGroupId()); @@ -1913,7 +1913,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - int deviceTypeId = applicationDTO.getDeviceTypeId(); List userSubscriptionsWithDevices = new ArrayList<>(); List userSubscriptions = @@ -1929,7 +1928,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { // Retrieve owner details and device IDs for the user using the service layer OwnerWithDeviceDTO ownerDetailsWithDevices = - deviceManagementProviderService.getOwnersWithDeviceIds(userName, deviceTypeId); + deviceManagementProviderService.getOwnersWithDeviceIds(userName, applicationDTO.getDeviceTypeId()); SubscriptionsDTO userSubscriptionDTO = new SubscriptionsDTO(); userSubscriptionDTO.setName(userSubscription.getName()); @@ -2101,7 +2100,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - int deviceTypeId = applicationDTO.getDeviceTypeId(); List roleSubscriptionsWithDevices = new ArrayList<>(); List roleSubscriptions = @@ -2142,7 +2140,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { for (String user : users) { OwnerWithDeviceDTO ownerDetailsWithDevices; try { - ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(user, deviceTypeId); + ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(user, applicationDTO.getDeviceTypeId()); } catch (DeviceManagementDAOException e) { throw new ApplicationManagementException("Error retrieving owner details with devices for user: " + user, e); } @@ -2312,7 +2310,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - int deviceTypeId = applicationDTO.getDeviceTypeId(); DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); List deviceSubscriptions = @@ -2326,7 +2323,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } List allDevices = - deviceManagementProviderService.getDevicesByTenantId(tenantId, deviceTypeId); + deviceManagementProviderService.getDevicesByTenantId(tenantId, applicationDTO.getDeviceTypeId()); List deviceIds = allDevices.stream() .map(DeviceDetailsDTO::getDeviceId) @@ -2500,7 +2497,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - int deviceTypeId = applicationDTO.getDeviceTypeId(); List allSubscriptions = subscriptionDAO.getAllSubscriptionsDetails(appReleaseId, unsubscribe, tenantId, offset, limit); @@ -2529,7 +2525,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { statusCounts.put("NEW", 0); List allDevices = - deviceManagementProviderService.getDevicesByTenantId(tenantId, deviceTypeId); + deviceManagementProviderService.getDevicesByTenantId(tenantId, applicationDTO.getDeviceTypeId()); for (DeviceDetailsDTO device : allDevices) { Integer deviceId = device.getDeviceId(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java index 158b86e0a3..e7419aa013 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java @@ -106,7 +106,8 @@ public interface EnrollmentDAO { * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId, int deviceTypeId) throws DeviceManagementDAOException; + OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId, int deviceTypeId) + throws DeviceManagementDAOException; /** * Retrieves a list of device IDs with owners and device status. @@ -128,5 +129,6 @@ public interface EnrollmentDAO { * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses, int deviceTypeId) throws DeviceManagementDAOException; + List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses, int deviceTypeId) + throws DeviceManagementDAOException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 2bb6c48fb4..abb12a6ea0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -481,7 +481,8 @@ public interface GroupDAO { * @return {@link GroupDetailsDTO} which containing group details and a list of device IDs * @throws GroupManagementDAOException if an error occurs while retrieving the group details and devices */ - GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowingDeviceStatuses, int deviceTypeId, int tenantId, int offset, int limit) + GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowingDeviceStatuses, int deviceTypeId, + int tenantId, int offset, int limit) throws GroupManagementDAOException; } \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 22e9fb18aa..7b9e918000 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1441,7 +1441,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } @Override - public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowedStatuses, int deviceTypeId, int tenantId, int offset, int limit) + public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowedStatuses, int deviceTypeId, + int tenantId, int offset, int limit) throws GroupManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get group details and device IDs for group: " + groupName); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 0d0e23cc48..d6114b5c04 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -1698,7 +1698,8 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid try { GroupManagementDAOFactory.openConnection(); - groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, allowingDeviceStatuses, deviceTypeId, tenantId, offset, limit); + groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, allowingDeviceStatuses, + deviceTypeId, tenantId, offset, limit); } catch (GroupManagementDAOException | SQLException e) { String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; log.error(msg, e);