From aa9f3da380f878837611bca8ddea46c7af60d378 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Sun, 30 Jun 2024 14:05:04 +0530 Subject: [PATCH] Fix issues in returning type in allsubscriptions --- .../dao/impl/AbstractEnrollmentDAOImpl.java | 10 ++++++++-- .../device/mgt/core/dto/DeviceDetailsDTO.java | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) 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/AbstractEnrollmentDAOImpl.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/AbstractEnrollmentDAOImpl.java index 2ee345fd77..e831e68a2e 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/AbstractEnrollmentDAOImpl.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/AbstractEnrollmentDAOImpl.java @@ -611,7 +611,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { throws DeviceManagementDAOException { OwnerWithDeviceDTO deviceOwnerWithStatus = new OwnerWithDeviceDTO(); Connection conn = null; - String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME " + + String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + "WHERE e.DEVICE_ID = ? AND e.TENANT_ID = ?"; @@ -629,6 +629,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { deviceIds.add(rs.getInt("DEVICE_ID")); deviceOwnerWithStatus.setDeviceIds(deviceIds); deviceOwnerWithStatus.setDeviceNames(rs.getString("DEVICE_NAME")); + deviceOwnerWithStatus.setDeviceTypes(rs.getString("DEVICE_TYPE")); + deviceOwnerWithStatus.setDeviceIdentifiers(rs.getString("DEVICE_IDENTIFICATION")); } } } @@ -644,7 +646,9 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { public List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException { List devices = new ArrayList<>(); - String sql = "SELECT DEVICE_ID, OWNER, STATUS FROM DM_ENROLMENT WHERE TENANT_ID = ?"; + String sql = "SELECT DEVICE_ID, OWNER, STATUS, DEVICE_TYPE, DEVICE_IDENTIFICATION " + + "FROM DM_ENROLMENT " + + "WHERE TENANT_ID = ?"; Connection conn = null; try { @@ -658,6 +662,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { device.setDeviceId(rs.getInt("DEVICE_ID")); device.setOwner(rs.getString("OWNER")); device.setStatus(rs.getString("STATUS")); + device.setType(rs.getString("DEVICE_TYPE")); + device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION")); devices.add(device); } } 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/dto/DeviceDetailsDTO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java index 2457e0bd3b..bb25d55c52 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java @@ -22,6 +22,8 @@ public class DeviceDetailsDTO { private int deviceId; private String owner; private String status; + private String type; + private String deviceIdentifier; public int getDeviceId() { return deviceId; @@ -46,4 +48,20 @@ public class DeviceDetailsDTO { public void setStatus(String status) { this.status = status; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDeviceIdentifier() { + return deviceIdentifier; + } + + public void setDeviceIdentifier(String deviceIdentifier) { + this.deviceIdentifier = deviceIdentifier; + } }