Compare commits

Invalid templates have been ignored

1 invalid template(s) found pull_request_template.md: frontmatter must start with a separator line

...

3 Commits

Author SHA1 Message Date
Ruwin Dissanayake 014889b237 Fix to display statistics in webapps
3 weeks ago
Lasantha Dharmakeerthi 52711fd94c Add device status filters updating logic (#519)
3 weeks ago
Ruwin Dissanayake 778f271252 Fix for incorrect statistics issue in User and Role
3 weeks ago

@ -44,6 +44,8 @@ import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo;
import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest;
import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult;
import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException;
import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException;
import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO;
import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -190,7 +192,7 @@ public class RoleBasedSubscriptionManagementHelperServiceImpl implements Subscri
List<Integer> deviceIdsOwnByRole = getDeviceIdsOwnByRole(subscriptionInfo.getIdentifier(), tenantId); List<Integer> deviceIdsOwnByRole = getDeviceIdsOwnByRole(subscriptionInfo.getIdentifier(), tenantId);
SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO.
getSubscriptionStatistic(deviceIdsOwnByRole, isUnsubscribe, tenantId, applicationReleaseDTO.getId()); getSubscriptionStatistic(deviceIdsOwnByRole, isUnsubscribe, tenantId, applicationReleaseDTO.getId());
int allDeviceCount = deviceIdsOwnByRole.size(); int allDeviceCount = getDeviceIdsOwnByRoleWithType(subscriptionInfo.getIdentifier(), tenantId, applicationReleaseDTO);
return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount);
} catch (DeviceManagementException | ApplicationManagementDAOException | UserStoreException e) { } catch (DeviceManagementException | ApplicationManagementDAOException | UserStoreException e) {
String msg = "Error encountered while getting subscription statistics for role: " + subscriptionInfo.getIdentifier(); String msg = "Error encountered while getting subscription statistics for role: " + subscriptionInfo.getIdentifier();
@ -212,7 +214,7 @@ public class RoleBasedSubscriptionManagementHelperServiceImpl implements Subscri
PaginationRequest paginationRequest = new PaginationRequest(-1, -1); PaginationRequest paginationRequest = new PaginationRequest(-1, -1);
paginationRequest.setOwner(user); paginationRequest.setOwner(user);
paginationRequest.setStatusList(Arrays.asList(EnrolmentInfo.Status.ACTIVE.name(), paginationRequest.setStatusList(Arrays.asList(EnrolmentInfo.Status.ACTIVE.name(),
EnrolmentInfo.Status.INACTIVE.name(),EnrolmentInfo.Status.UNREACHABLE.name())); EnrolmentInfo.Status.INACTIVE.name(), EnrolmentInfo.Status.UNREACHABLE.name()));
PaginationResult ownDeviceIds = HelperUtil.getDeviceManagementProviderService(). PaginationResult ownDeviceIds = HelperUtil.getDeviceManagementProviderService().
getAllDevicesIdList(paginationRequest); getAllDevicesIdList(paginationRequest);
if (ownDeviceIds.getData() != null) { if (ownDeviceIds.getData() != null) {
@ -222,6 +224,38 @@ public class RoleBasedSubscriptionManagementHelperServiceImpl implements Subscri
return deviceListOwnByRole.stream().map(Device::getId).collect(Collectors.toList()); return deviceListOwnByRole.stream().map(Device::getId).collect(Collectors.toList());
} }
private int getDeviceIdsOwnByRoleWithType(String roleName, int tenantId, ApplicationReleaseDTO applicationReleaseDTO)
throws UserStoreException, DeviceManagementException {
UserStoreManager userStoreManager = DataHolder.getInstance().getRealmService()
.getTenantUserRealm(tenantId).getUserStoreManager();
String[] usersWithRole = userStoreManager.getUserListOfRole(roleName);
int idCountOwnByRole = 0;
int deviceTypeId;
try {
deviceTypeId = applicationDAO.getApplication(applicationReleaseDTO.getUuid(), tenantId).getDeviceTypeId();
} catch (ApplicationManagementDAOException e) {
String msg = "Error encountered while accessing application management data.";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
for (String user : usersWithRole) {
try {
List<DeviceDetailsDTO> idsOwnByRole = HelperUtil.getDeviceManagementProviderService()
.getDevicesByTenantId(tenantId, deviceTypeId, user, null);
if (idsOwnByRole != null) {
idCountOwnByRole += idsOwnByRole.size();
}
} catch (DeviceManagementDAOException e) {
String msg = String.format("Error encountered while accessing device management data for user: %s", user);
log.error(msg, e);
} catch (Exception e) {
String msg = String.format("Unexpected error occurred for user: %s", user);
log.error(msg, e);
}
}
return idCountOwnByRole;
}
private static class RoleBasedSubscriptionManagementHelperServiceImplHolder { private static class RoleBasedSubscriptionManagementHelperServiceImplHolder {
private static final RoleBasedSubscriptionManagementHelperServiceImpl INSTANCE private static final RoleBasedSubscriptionManagementHelperServiceImpl INSTANCE
= new RoleBasedSubscriptionManagementHelperServiceImpl(); = new RoleBasedSubscriptionManagementHelperServiceImpl();

@ -43,6 +43,8 @@ import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo;
import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest;
import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult;
import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException;
import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException;
import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO;
import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -181,12 +183,16 @@ public class UserBasedSubscriptionManagementHelperServiceImpl implements Subscri
List<Integer> deviceIdsOwnByUser = getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier()); List<Integer> deviceIdsOwnByUser = getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier());
SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO.
getSubscriptionStatistic(deviceIdsOwnByUser, isUnsubscribe, tenantId, applicationReleaseDTO.getId()); getSubscriptionStatistic(deviceIdsOwnByUser, isUnsubscribe, tenantId, applicationReleaseDTO.getId());
int allDeviceCount = deviceIdsOwnByUser.size(); List <DeviceDetailsDTO> devices = HelperUtil.getDeviceManagementProviderService().getDevicesByTenantId(tenantId,
applicationDAO.getApplication(applicationReleaseDTO.getUuid(), tenantId).getDeviceTypeId(), subscriptionInfo.getIdentifier(), null);
int allDeviceCount = devices.size();
return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount);
} catch (DeviceManagementException | ApplicationManagementDAOException e) { } catch (DeviceManagementException | ApplicationManagementDAOException e) {
String msg = "Error encountered while getting subscription statistics for user: " + subscriptionInfo.getIdentifier(); String msg = "Error encountered while getting subscription statistics for user: " + subscriptionInfo.getIdentifier();
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (DeviceManagementDAOException e) {
throw new RuntimeException(e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }

@ -86,55 +86,134 @@
com.google.common.reflect;version="[32.1,33)";resolution:=optional, com.google.common.reflect;version="[32.1,33)";resolution:=optional,
com.google.gson;version="[2.9,3)", com.google.gson;version="[2.9,3)",
com.google.gson.reflect;version="[2.9,3)", com.google.gson.reflect;version="[2.9,3)",
io.entgra.device.mgt.core.apimgt.annotations;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.apimgt.annotations;version="[5.0,6)",
io.entgra.device.mgt.core.apimgt.extension.rest.api;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.apimgt.extension.rest.api;version="[5.0,6)",
io.entgra.device.mgt.core.apimgt.extension.rest.api.dto;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.apimgt.extension.rest.api.dto;version="[5.0,6)",
io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;version="[5.0,6)",
io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions;version="[5.0,6)",
io.entgra.device.mgt.core.apimgt.extension.rest.api.util;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.apimgt.extension.rest.api.util;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.app.mgt.android;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.app.mgt.android;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.app.mgt.ios;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.app.mgt.ios;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.authorization;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.authorization;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.configuration.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.configuration.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.cost.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.cost.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.device.details;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.device.details;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.enrollment.notification;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.enrollment.notification;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.event.config;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.event.config;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.general;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.general;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.geo.service;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.geo.service;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.invitation.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.invitation.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.license.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.license.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.notification.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.notification.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.otp.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.otp.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.pull.notification;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.pull.notification;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.push.notification;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.report.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.report.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.roles.config;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.roles.config;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.search;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.search;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.spi;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.spi;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.common.type.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.common.type.mgt;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.extensions.logger;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.app.mgt.config,
io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.archival,
io.entgra.device.mgt.core.identity.jwt.client.extension;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.archival.dao,
io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.archival.dao.impl,
io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.cache,
io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.cache.impl,
io.entgra.device.mgt.core.notification.logger;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.common.exception,
io.entgra.device.mgt.core.notification.logger.impl;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.common.util,
io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.config,
io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.config.analytics,
io.entgra.device.mgt.core.transport.mgt.email.sender.core;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.config.analytics.operation,
io.entgra.device.mgt.core.transport.mgt.email.sender.core.service;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.core.config.archival,
io.entgra.device.mgt.core.device.mgt.core.config.cache,
io.entgra.device.mgt.core.device.mgt.core.config.datasource,
io.entgra.device.mgt.core.device.mgt.core.config.enrollment.guide,
io.entgra.device.mgt.core.device.mgt.core.config.geo.location,
io.entgra.device.mgt.core.device.mgt.core.config.identity,
io.entgra.device.mgt.core.device.mgt.core.config.keymanager,
io.entgra.device.mgt.core.device.mgt.core.config.license,
io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt,
io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.whitelabel,
io.entgra.device.mgt.core.device.mgt.core.config.operation.timeout,
io.entgra.device.mgt.core.device.mgt.core.config.pagination,
io.entgra.device.mgt.core.device.mgt.core.config.permission,
io.entgra.device.mgt.core.device.mgt.core.config.policy,
io.entgra.device.mgt.core.device.mgt.core.config.pull.notification,
io.entgra.device.mgt.core.device.mgt.core.config.push.notification,
io.entgra.device.mgt.core.device.mgt.core.config.remote.session,
io.entgra.device.mgt.core.device.mgt.core.config.status.task,
io.entgra.device.mgt.core.device.mgt.core.config.task,
io.entgra.device.mgt.core.device.mgt.core.config.tenant,
io.entgra.device.mgt.core.device.mgt.core.config.ui,
io.entgra.device.mgt.core.device.mgt.core.dao,
io.entgra.device.mgt.core.device.mgt.core.dao.impl,
io.entgra.device.mgt.core.device.mgt.core.dao.impl.device,
io.entgra.device.mgt.core.device.mgt.core.dao.impl.enrolment,
io.entgra.device.mgt.core.device.mgt.core.dao.impl.event,
io.entgra.device.mgt.core.device.mgt.core.dao.impl.geofence,
io.entgra.device.mgt.core.device.mgt.core.dao.impl.group,
io.entgra.device.mgt.core.device.mgt.core.dao.impl.tracker,
io.entgra.device.mgt.core.device.mgt.core.device.details.mgt,
io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao,
io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao.impl,
io.entgra.device.mgt.core.device.mgt.core.dto,
io.entgra.device.mgt.core.device.mgt.core.dto.event.config,
io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt,
io.entgra.device.mgt.core.device.mgt.core.geo.geoHash,
io.entgra.device.mgt.core.device.mgt.core.geo.task,
io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao,
io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.impl,
io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util,
io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.util,
io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao,
io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.impl,
io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao,
io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl,
io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.operation,
io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util,
io.entgra.device.mgt.core.device.mgt.core.operation.mgt.util,
io.entgra.device.mgt.core.device.mgt.core.operation.timeout.task,
io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao,
io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl,
io.entgra.device.mgt.core.device.mgt.core.otp.mgt.exception,
io.entgra.device.mgt.core.device.mgt.core.otp.mgt.util,
io.entgra.device.mgt.core.device.mgt.core.privacy,
io.entgra.device.mgt.core.device.mgt.core.privacy.dao,
io.entgra.device.mgt.core.device.mgt.core.privacy.dao.impl,
io.entgra.device.mgt.core.device.mgt.core.report.mgt,
io.entgra.device.mgt.core.device.mgt.core.report.mgt.config,
io.entgra.device.mgt.core.device.mgt.core.search.mgt,
io.entgra.device.mgt.core.device.mgt.core.search.mgt.dao,
io.entgra.device.mgt.core.device.mgt.core.status.task,
io.entgra.device.mgt.core.device.mgt.core.task,
io.entgra.device.mgt.core.device.mgt.core.traccar.api.service,
io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.impl,
io.entgra.device.mgt.core.device.mgt.core.traccar.common.beans,
io.entgra.device.mgt.core.device.mgt.core.traccar.common.config,
io.entgra.device.mgt.core.device.mgt.core.traccar.common.util,
io.entgra.device.mgt.core.device.mgt.core.traccar.core.config,
io.entgra.device.mgt.core.device.mgt.extensions.logger;version="[5.0,6)",
io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="[5.0,6)",
io.entgra.device.mgt.core.identity.jwt.client.extension;version="[5.0,6)",
io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)",
io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="[5.0,6)",
io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="[5.0,6)",
io.entgra.device.mgt.core.notification.logger;version="[5.0,6)",
io.entgra.device.mgt.core.notification.logger.impl;version="[5.0,6)",
io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="[5.0,6)",
io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="[5.0,6)",
io.entgra.device.mgt.core.transport.mgt.email.sender.core;version="[5.0,6)",
io.entgra.device.mgt.core.transport.mgt.email.sender.core.service;version="[5.0,6)",
io.swagger.annotations;version="[1.6,2)", io.swagger.annotations;version="[1.6,2)",
javax.cache;version="[1.0,2)", javax.cache;version="[1.0,2)",
javax.naming, javax.naming,

@ -1590,20 +1590,23 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
int deviceCount = 0; int deviceCount = 0;
try { try {
Connection connection = GroupManagementDAOFactory.getConnection(); Connection connection = GroupManagementDAOFactory.getConnection();
String sql = "SELECT COUNT(e.ID) AS COUNT " + StringBuilder sql = new StringBuilder("SELECT COUNT(e.ID) AS COUNT " +
"FROM DM_GROUP d " + "FROM DM_GROUP d " +
"INNER JOIN DM_DEVICE_GROUP_MAP m ON d.ID = m.GROUP_ID " + "INNER JOIN DM_DEVICE_GROUP_MAP m ON d.ID = m.GROUP_ID " +
"INNER JOIN DM_ENROLMENT e ON m.DEVICE_ID = e.DEVICE_ID " + "INNER JOIN DM_ENROLMENT e ON m.DEVICE_ID = e.DEVICE_ID " +
"INNER JOIN DM_DEVICE r ON e.DEVICE_ID = r.ID " + "INNER JOIN DM_DEVICE r ON e.DEVICE_ID = r.ID " +
"WHERE d.TENANT_ID = ? " + "WHERE d.TENANT_ID = ? " +
"AND d.GROUP_NAME = ? " + "AND d.GROUP_NAME = ? " +
"AND r.DEVICE_TYPE_ID = ? " + "AND e.STATUS NOT IN ('REMOVED', 'DELETED')");
"AND e.STATUS NOT IN ('REMOVED', 'DELETED')"; if (deviceTypeId != 0) {
sql.append(" AND r.DEVICE_TYPE_ID = ?");
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { }
try (PreparedStatement preparedStatement = connection.prepareStatement(sql.toString())) {
preparedStatement.setInt(1, tenantId); preparedStatement.setInt(1, tenantId);
preparedStatement.setString(2, groupName); preparedStatement.setString(2, groupName);
preparedStatement.setInt(3, deviceTypeId); if (deviceTypeId != 0) {
preparedStatement.setInt(3, deviceTypeId);
}
try (ResultSet resultSet = preparedStatement.executeQuery()) { try (ResultSet resultSet = preparedStatement.executeQuery()) {
if (resultSet.next()) { if (resultSet.next()) {
deviceCount = resultSet.getInt("COUNT"); deviceCount = resultSet.getInt("COUNT");
@ -1617,4 +1620,4 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
throw new GroupManagementDAOException(msg, e); throw new GroupManagementDAOException(msg, e);
} }
} }
} }
Loading…
Cancel
Save