Fix for subscription table pagination is not loading correctly

pull/390/head
Pahansith Gunathilake 7 months ago
parent 62722718f2
commit afbdd89f4d

@ -840,4 +840,7 @@ public interface DeviceDAO {
List<String> getAgentVersions(int tenantId) throws DeviceManagementDAOException; List<String> getAgentVersions(int tenantId) throws DeviceManagementDAOException;
List<Device> getDevicesEnrolledSince(Date since) throws DeviceManagementDAOException; List<Device> getDevicesEnrolledSince(Date since) throws DeviceManagementDAOException;
List<Device> getDevicesEnrolledPriorTo(Date priorTo) throws DeviceManagementDAOException; List<Device> getDevicesEnrolledPriorTo(Date priorTo) throws DeviceManagementDAOException;
int getSubscribedDeviceCountOfFilteredList() throws DeviceManagementDAOException;
} }

@ -3343,4 +3343,25 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} }
return devices; return devices;
} }
@Override
public int getSubscribedDeviceCountOfFilteredList() throws DeviceManagementDAOException {
try {
Connection conn = getConnection();
String sql = "SELECT FOUND_ROWS();";
try (PreparedStatement ps = conn.prepareStatement(sql)) {
try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
return rs.getInt(1);
}
return 0;
}
}
} catch (SQLException e) {
String msg = "Error occurred while retrieving the count of devices that matches the filtering criteria";
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}
}
} }

@ -1268,7 +1268,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isOwnershipProvided = false; boolean isOwnershipProvided = false;
boolean isSerialProvided = false; boolean isSerialProvided = false;
query = "SELECT " query = "SELECT SQL_CALC_FOUND_ROWS "
+ "DM_DEVICE.ID AS DEVICE_ID, " + "DM_DEVICE.ID AS DEVICE_ID, "
+ "DM_DEVICE.NAME AS DEVICE_NAME, " + "DM_DEVICE.NAME AS DEVICE_NAME, "
+ "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "

@ -4661,8 +4661,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
paginationResult.setRecordsTotal(0); paginationResult.setRecordsTotal(0);
return paginationResult; return paginationResult;
} }
int count = deviceDAO.getSubscribedDeviceCount(devicesIds, tenantId, request.getStatusList()); //int count = deviceDAO.getSubscribedDeviceCount(devicesIds, tenantId, request.getStatusList());
paginationResult.setRecordsFiltered(count); int count = deviceDAO.getSubscribedDeviceCountOfFilteredList();
paginationResult.setRecordsFiltered(subscribedDeviceDetails.size());
paginationResult.setRecordsTotal(count); paginationResult.setRecordsTotal(count);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
String msg = "Error occurred while retrieving device list for device ids " + devicesIds; String msg = "Error occurred while retrieving device list for device ids " + devicesIds;

Loading…
Cancel
Save