From 2154dcbbff06af2de42f488f17760909f8cffe7a Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Tue, 8 Aug 2023 10:05:05 +0530 Subject: [PATCH] Temo changes --- .../mgt/core/device/mgt/common/PaginationRequest.java | 6 ++++++ .../core/dao/impl/device/GenericDeviceDAOImpl.java | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java index d9c2c62d47..42033c2184 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java @@ -41,6 +41,8 @@ public class PaginationRequest { private Date since; private String filter; private String serialNumber; + + private String firmawareVersion; private Map property = new HashMap<>(); private List statusList = new ArrayList<>(); private OperationLogFilters operationLogFilters = new OperationLogFilters(); @@ -159,6 +161,10 @@ public class PaginationRequest { public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; } + public String getFirmawareVersion() { return firmawareVersion; } + + public void setFirmawareVersion(String firmawareVersion) { this.firmawareVersion = firmawareVersion; } + public Map getProperties() { Map temp = new HashMap<>(); temp.putAll(property); 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/device/GenericDeviceDAOImpl.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/device/GenericDeviceDAOImpl.java index b3c6b8f18a..18ae27255f 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/device/GenericDeviceDAOImpl.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/device/GenericDeviceDAOImpl.java @@ -1185,6 +1185,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { String user = request.getOwner(); String ownership = request.getOwnership(); String serial = request.getSerialNumber(); + String firmawareVersion = request.getFirmawareVersion(); String query = null; try { List devices = new ArrayList<>(); @@ -1199,6 +1200,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isOwnerProvided = false; boolean isOwnershipProvided = false; boolean isSerialProvided = false; + boolean isFirmawareVersionProvided = false; StringJoiner joiner = new StringJoiner(",", "SELECT " @@ -1224,6 +1226,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { + "INNER JOIN DM_DEVICE_INFO i ON " + "DM_DEVICE.ID = i.DEVICE_ID " + "AND i.KEY_FIELD = 'serial' " + + "OR i.KEY_FIELD = 'FIRMWARE_VERSION' " + "WHERE DM_DEVICE.ID IN (", ") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ?"); @@ -1242,6 +1245,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { query += " AND i.VALUE_FIELD LIKE ?" ; isSerialProvided = true; } + if (firmawareVersion != null && !firmawareVersion.isEmpty()) { + query += " OR i.VALUE_FIELD LIKE ?" ; + isFirmawareVersionProvided = true; + } if (user != null && !user.isEmpty()) { query += " AND e.OWNER = ?"; isOwnerProvided = true; @@ -1269,6 +1276,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { if (isSerialProvided) { ps.setString(index++, "%" + serial + "%"); } + if (isFirmawareVersionProvided) { + ps.setString(index++, "%" + firmawareVersion + "%"); + } if (isOwnerProvided) { ps.setString(index++, user); } @@ -1291,6 +1301,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { String msg = "Error occurred while retrieving information of all registered devices " + "according to device ids and the limit area. Executed query " + query; log.error(msg, e); + System.out.println(msg); throw new DeviceManagementDAOException(msg, e); } }