From 8f631ce92e69f6a463854cf07366748656465100 Mon Sep 17 00:00:00 2001 From: harshanL Date: Wed, 8 Apr 2015 10:44:15 +0530 Subject: [PATCH] Fixed AndroidDAO layer to insert DEVICE_MODEL --- .../dao/impl/AndroidDeviceDAOImpl.java | 20 +++++++++++++------ .../dbscripts/plugins/h2_android.sql | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidDeviceDAOImpl.java index 64862705e0..cf98c8cec4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidDeviceDAOImpl.java @@ -58,7 +58,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ try { conn = this.getConnection(); String selectDBQuery = - "SELECT ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, SERIAL, VENDOR, MAC_ADDRESS, " + + "SELECT ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, VENDOR, MAC_ADDRESS, " + "DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, 0S_VERSION FROM AD_DEVICE WHERE" + " ANDROID_DEVICE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); @@ -74,6 +74,8 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ resultSet.getString(AndroidPluginConstants.GCM_TOKEN)); propertyMap.put(AndroidPluginConstants.DEVICE_INFO, resultSet.getString(AndroidPluginConstants.DEVICE_INFO)); + propertyMap.put(AndroidPluginConstants.DEVICE_MODEL, + resultSet.getString(AndroidPluginConstants.DEVICE_MODEL)); propertyMap.put(AndroidPluginConstants.SERIAL, resultSet.getString(AndroidPluginConstants.SERIAL)); propertyMap.put(AndroidPluginConstants.VENDOR, @@ -120,8 +122,8 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ conn = this.getConnection(); String createDBQuery = "INSERT INTO AD_DEVICE(ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, SERIAL, " + - "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION)" + - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION, DEVICE_MODEL)" + + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, mobileDevice.getMobileDeviceId()); @@ -153,6 +155,8 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ AndroidPluginConstants.IMSI)); stmt.setString(12, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), AndroidPluginConstants.OS_VERSION)); + stmt.setString(13, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + AndroidPluginConstants.DEVICE_MODEL)); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; @@ -182,7 +186,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ conn = this.getConnection(); String updateDBQuery = "UPDATE AD_DEVICE SET GCM_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, VENDOR = ?, MAC_ADDRESS = ?, " + - "DEVICE_NAME = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, IMSI = ?, OS_VERSION = ? " + + "DEVICE_NAME = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?, DEVICE_MODEL = ? " + "WHERE ANDROID_DEVICE_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); @@ -214,7 +218,9 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ AndroidPluginConstants.IMSI)); stmt.setString(11, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), AndroidPluginConstants.OS_VERSION)); - stmt.setString(12, mobileDevice.getMobileDeviceId()); + stmt.setString(12, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + AndroidPluginConstants.DEVICE_MODEL)); + stmt.setString(13, mobileDevice.getMobileDeviceId()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; @@ -274,7 +280,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ try { conn = this.getConnection(); String selectDBQuery = - "SELECT ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, SERIAL, VENDOR, MAC_ADDRESS," + + "SELECT ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, VENDOR, MAC_ADDRESS," + "DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, 0S_VERSION FROM AD_DEVICE"; stmt = conn.prepareStatement(selectDBQuery); ResultSet resultSet = stmt.executeQuery(); @@ -289,6 +295,8 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ resultSet.getString(AndroidPluginConstants.GCM_TOKEN)); propertyMap.put(AndroidPluginConstants.DEVICE_INFO, resultSet.getString(AndroidPluginConstants.DEVICE_INFO)); + propertyMap.put(AndroidPluginConstants.DEVICE_MODEL, + resultSet.getString(AndroidPluginConstants.DEVICE_MODEL)); propertyMap.put(AndroidPluginConstants.SERIAL, resultSet.getString(AndroidPluginConstants.SERIAL)); propertyMap.put(AndroidPluginConstants.VENDOR, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/h2_android.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/h2_android.sql index a3a1145faf..5d5b2b735d 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/h2_android.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/h2_android.sql @@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( `ANDROID_DEVICE_ID` VARCHAR(45) NOT NULL , `GCM_TOKEN` VARCHAR(45) NULL DEFAULT NULL , + `DEVICE_INFO` VARCHAR(100) NULL DEFAULT NULL , `IMEI` VARCHAR(45) NULL DEFAULT NULL , `IMSI` VARCHAR(45) NULL DEFAULT NULL , `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,