From 20bbb6b91acd0e9da74359e4ee306f812a453c36 Mon Sep 17 00:00:00 2001 From: charitha Date: Fri, 20 Sep 2019 14:02:40 +0530 Subject: [PATCH] Re add missing method --- .../core/dao/impl/AbstractDeviceDAOImpl.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index a39d5df260..2a69ef188d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -1963,6 +1963,28 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } } + private int getDeviceId(Connection conn, DeviceIdentifier deviceIdentifier, int tenantId) + throws DeviceManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs = null; + int deviceId = -1; + try { + String sql = "SELECT ID FROM DM_DEVICE WHERE DEVICE_IDENTIFICATION = ? AND TENANT_ID = ?"; + stmt = conn.prepareStatement(sql); + stmt.setString(1, deviceIdentifier.getId()); + stmt.setInt(2, tenantId); + rs = stmt.executeQuery(); + if (rs.next()) { + deviceId = rs.getInt("ID"); + } + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving device id of the device", e); + } finally { + DeviceManagementDAOUtil.cleanupResources(stmt, rs); + } + return deviceId; + } + public boolean transferDevice(String deviceType, String deviceIdentifier, String owner, int destinationTenantId) throws DeviceManagementDAOException, SQLException { Connection conn = this.getConnection();