From 7d6cfaa3b1f91079d95ab80901d6ecb5e349038b Mon Sep 17 00:00:00 2001 From: osh Date: Tue, 23 May 2023 11:54:48 +0530 Subject: [PATCH] Add fix for serial number search fixes 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/SQLServerDeviceDAOImpl.java --- .../device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java | 4 ++-- .../device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java | 4 ++-- .../mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java | 4 ++-- .../mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java | 4 ++-- 4 files changed, 8 insertions(+), 8 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/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 93458c6dbc8..2021d8fb949 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 @@ -97,7 +97,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "WHERE DEVICE_TYPE_ID = t.ID " + "AND d.ID= i.DEVICE_ID " + "AND i.KEY_FIELD = 'serial' " + - "AND i.VALUE_FIELD = ? " + + "AND i.VALUE_FIELD LIKE ? " + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { @@ -141,7 +141,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; if (isSerialProvided) { - stmt.setString(paramIdx++, serial); + stmt.setString(paramIdx++, "%" + serial + "%"); } stmt.setInt(paramIdx++, tenantId); if (isSinceProvided) { 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/OracleDeviceDAOImpl.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/OracleDeviceDAOImpl.java index 98242e19020..1da26e841c4 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/OracleDeviceDAOImpl.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/OracleDeviceDAOImpl.java @@ -98,7 +98,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { "WHERE DEVICE_TYPE_ID = t.ID " + "AND d.ID= i.DEVICE_ID " + "AND i.KEY_FIELD = 'serial' " + - "AND i.VALUE_FIELD = ? " + + "AND i.VALUE_FIELD LIKE ? " + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { @@ -142,7 +142,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; if (isSerialProvided) { - stmt.setString(paramIdx++, serial); + stmt.setString(paramIdx++, "%" + serial + "%"); } stmt.setInt(paramIdx++, tenantId); if (isSinceProvided) { 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/PostgreSQLDeviceDAOImpl.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/PostgreSQLDeviceDAOImpl.java index aad74dc165f..7b72d1edf3b 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/PostgreSQLDeviceDAOImpl.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/PostgreSQLDeviceDAOImpl.java @@ -97,7 +97,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { "WHERE DEVICE_TYPE_ID = t.ID " + "AND d.ID= i.DEVICE_ID " + "AND i.KEY_FIELD = 'serial' " + - "AND i.VALUE_FIELD = ? " + + "AND i.VALUE_FIELD LIKE ? " + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { @@ -136,7 +136,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; if (isSerialProvided) { - stmt.setString(paramIdx++, serial); + stmt.setString(paramIdx++, "%" + serial + "%"); } stmt.setInt(paramIdx++, tenantId); if (isDeviceTypeProvided) { 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/SQLServerDeviceDAOImpl.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/SQLServerDeviceDAOImpl.java index 2e4ec9d0132..3d695e06705 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/SQLServerDeviceDAOImpl.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/SQLServerDeviceDAOImpl.java @@ -99,7 +99,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { "WHERE DEVICE_TYPE_ID = t.ID " + "AND d.ID= i.DEVICE_ID " + "AND i.KEY_FIELD = 'serial' " + - "AND i.VALUE_FIELD = ? " + + "AND i.VALUE_FIELD LIKE ? " + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { @@ -143,7 +143,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; if (isSerialProvided) { - stmt.setString(paramIdx++, serial); + stmt.setString(paramIdx++, "%" + serial + "%"); } stmt.setInt(paramIdx++, tenantId); if (isSinceProvided) {