From f693311ed9183b49182542a9c2e32c330d484365 Mon Sep 17 00:00:00 2001 From: Dilshan Edirisuriya Date: Wed, 1 Apr 2015 17:11:36 +0530 Subject: [PATCH] iOS device DAO implementation --- .../impl/ios/dao/impl/IOSDeviceDAOImpl.java | 117 ++++++++++++------ .../impl => util}/IOSPluginConstants.java | 8 +- .../mgt/mobile/impl/ios/util/IOSUtils.java | 17 +++ .../util/MobileDeviceManagementUtil.java | 20 ++- .../resources/dbscripts/plugins/h2_ios.sql | 4 +- .../resources/dbscripts/plugins/mysql_ios.sql | 70 +++++------ 6 files changed, 150 insertions(+), 86 deletions(-) rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/{dao/impl => util}/IOSPluginConstants.java (84%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/util/IOSUtils.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/dao/impl/IOSDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/dao/impl/IOSDeviceDAOImpl.java index 36c4295f9..23e311a6d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/dao/impl/IOSDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/dao/impl/IOSDeviceDAOImpl.java @@ -24,6 +24,8 @@ import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceDAO; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.impl.ios.util.IOSPluginConstants; +import org.wso2.carbon.device.mgt.mobile.impl.ios.util.IOSUtils; import javax.sql.DataSource; import java.sql.Connection; @@ -44,14 +46,6 @@ public class IOSDeviceDAOImpl implements MobileDeviceDAO { this.dataSource = dataSource; } - public static final String SERIAL = "SERIAL"; - public static final String PRODUCT = "PRODUCT"; - public static final String MAC_ADDRESS = "MAC_ADDRESS"; - public static final String DEVICE_NAME = "DEVICE_NAME"; - public static final String ICCID = "ICCID"; - public static final String LATITUDE = "LATITUDE"; - public static final String LONGITUDE = "LONGITUDE"; - @Override public MobileDevice getMobileDevice(String deviceID) throws MobileDeviceManagementDAOException { Connection conn = null; @@ -62,7 +56,7 @@ public class IOSDeviceDAOImpl implements MobileDeviceDAO { String selectDBQuery = "SELECT MOBILE_DEVICE_ID, APNS_PUSH_TOKEN, MAGIC_TOKEN, MDM_TOKEN, UNLOCK_TOKEN, " + "CHALLENGE_TOKEN, DEVICE_INFO, SERIAL, PRODUCT, MAC_ADDRESS, DEVICE_NAME, ICCID," + - "LATITUDE, LONGITUDE FROM IOS_DEVICE WHERE MOBILE_DEVICE_ID = ?"; + "LATITUDE, LONGITUDE, IMEI, VERSION FROM IOS_DEVICE WHERE MOBILE_DEVICE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); stmt.setString(1, deviceID); ResultSet resultSet = stmt.executeQuery(); @@ -87,6 +81,8 @@ public class IOSDeviceDAOImpl implements MobileDeviceDAO { tokenMap.put(IOSPluginConstants.ICCID, resultSet.getString(IOSPluginConstants.ICCID)); tokenMap.put(IOSPluginConstants.LATITUDE, resultSet.getString(IOSPluginConstants.LATITUDE)); tokenMap.put(IOSPluginConstants.LONGITUDE, resultSet.getString(IOSPluginConstants.LONGITUDE)); + tokenMap.put(IOSPluginConstants.IMEI, resultSet.getString(IOSPluginConstants.IMEI)); + tokenMap.put(IOSPluginConstants.VERSION, resultSet.getString(IOSPluginConstants.VERSION)); mobileDevice.setDeviceProperties(tokenMap); @@ -105,6 +101,10 @@ public class IOSDeviceDAOImpl implements MobileDeviceDAO { return mobileDevice; } + public static final String IMEI = "IMEI"; + public static final String VERSION = "VERSION"; + public static final String MAC_ADDRESS = "MAC_ADDRESS"; + public static final String ICCID = "ICCID"; @Override public boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException { @@ -116,7 +116,8 @@ public class IOSDeviceDAOImpl implements MobileDeviceDAO { String createDBQuery = "INSERT INTO IOS_DEVICE(MOBILE_DEVICE_ID, APNS_PUSH_TOKEN, MAGIC_TOKEN, MDM_TOKEN, UNLOCK_TOKEN, " + "CHALLENGE_TOKEN, DEVICE_INFO, SERIAL, PRODUCT, MAC_ADDRESS, DEVICE_NAME, ICCID, " + - "LATITUDE, LONGITUDE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + "LATITUDE, LONGITUDE, IMEI, VERSION) VALUES " + + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); stmt.setString(1, mobileDevice.getMobileDeviceId()); @@ -125,19 +126,36 @@ public class IOSDeviceDAOImpl implements MobileDeviceDAO { mobileDevice.setDeviceProperties(new HashMap()); } - stmt.setString(2, mobileDevice.getDeviceProperties().get(IOSPluginConstants.APNS_PUSH_TOKEN)); - stmt.setString(3, mobileDevice.getDeviceProperties().get(IOSPluginConstants.MAGIC_TOKEN)); - stmt.setString(4, mobileDevice.getDeviceProperties().get(IOSPluginConstants.MDM_TOKEN)); - stmt.setString(5, mobileDevice.getDeviceProperties().get(IOSPluginConstants.UNLOCK_TOKEN)); - stmt.setString(6, mobileDevice.getDeviceProperties().get(IOSPluginConstants.CHALLENGE_TOKEN)); - stmt.setString(7, mobileDevice.getDeviceProperties().get(IOSPluginConstants.DEVICE_INFO)); - stmt.setString(8, mobileDevice.getDeviceProperties().get(IOSPluginConstants.SERIAL)); - stmt.setString(9, mobileDevice.getDeviceProperties().get(IOSPluginConstants.PRODUCT)); - stmt.setString(10, mobileDevice.getDeviceProperties().get(IOSPluginConstants.MAC_ADDRESS)); - stmt.setString(11, mobileDevice.getDeviceProperties().get(IOSPluginConstants.DEVICE_NAME)); - stmt.setString(12, mobileDevice.getDeviceProperties().get(IOSPluginConstants.ICCID)); - stmt.setString(13, mobileDevice.getDeviceProperties().get(IOSPluginConstants.LATITUDE)); - stmt.setString(14, mobileDevice.getDeviceProperties().get(IOSPluginConstants.LONGITUDE)); + stmt.setString(2, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.APNS_PUSH_TOKEN)); + stmt.setString(3, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.MAGIC_TOKEN)); + stmt.setString(4, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.MDM_TOKEN)); + stmt.setString(5, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.UNLOCK_TOKEN)); + stmt.setString(6, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.CHALLENGE_TOKEN)); + stmt.setString(7, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.DEVICE_INFO)); + stmt.setString(8, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.SERIAL)); + stmt.setString(9, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.PRODUCT)); + stmt.setString(10, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.MAC_ADDRESS)); + stmt.setString(11, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.DEVICE_NAME)); + stmt.setString(12, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.ICCID)); + stmt.setString(13, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.LATITUDE)); + stmt.setString(14, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.LONGITUDE)); + stmt.setString(15, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.IMEI)); + stmt.setString(16, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.VERSION)); int rows = stmt.executeUpdate(); if (rows > 0) { @@ -169,22 +187,41 @@ public class IOSDeviceDAOImpl implements MobileDeviceDAO { String updateDBQuery = "UPDATE IOS_DEVICE SET APNS_PUSH_TOKEN = ?, MAGIC_TOKEN = ?, MDM_TOKEN = ?, UNLOCK_TOKEN = ?, " + "CHALLENGE_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, PRODUCT = ?, MAC_ADDRESS = ?, " + - "DEVICE_NAME = ?, ICCID = ?, LATITUDE = ?, LONGITUDE = ? WHERE MOBILE_DEVICE_ID = ?"; + "DEVICE_NAME = ?, ICCID = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, VERSION = ? " + + "WHERE MOBILE_DEVICE_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); - stmt.setString(1, mobileDevice.getDeviceProperties().get(IOSPluginConstants.APNS_PUSH_TOKEN)); - stmt.setString(2, mobileDevice.getDeviceProperties().get(IOSPluginConstants.MAGIC_TOKEN)); - stmt.setString(3, mobileDevice.getDeviceProperties().get(IOSPluginConstants.MDM_TOKEN)); - stmt.setString(4, mobileDevice.getDeviceProperties().get(IOSPluginConstants.UNLOCK_TOKEN)); - stmt.setString(5, mobileDevice.getDeviceProperties().get(IOSPluginConstants.CHALLENGE_TOKEN)); - stmt.setString(6, mobileDevice.getDeviceProperties().get(IOSPluginConstants.DEVICE_INFO)); - stmt.setString(7, mobileDevice.getDeviceProperties().get(IOSPluginConstants.SERIAL)); - stmt.setString(8, mobileDevice.getDeviceProperties().get(IOSPluginConstants.PRODUCT)); - stmt.setString(9, mobileDevice.getDeviceProperties().get(IOSPluginConstants.MAC_ADDRESS)); - stmt.setString(10, mobileDevice.getDeviceProperties().get(IOSPluginConstants.DEVICE_NAME)); - stmt.setString(11, mobileDevice.getDeviceProperties().get(IOSPluginConstants.ICCID)); - stmt.setString(12, mobileDevice.getDeviceProperties().get(IOSPluginConstants.LATITUDE)); - stmt.setString(13, mobileDevice.getDeviceProperties().get(IOSPluginConstants.LONGITUDE)); - stmt.setString(14, mobileDevice.getDeviceProperties().get(IOSPluginConstants.MOBILE_DEVICE_ID)); + + stmt.setString(1, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.APNS_PUSH_TOKEN)); + stmt.setString(2, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.MAGIC_TOKEN)); + stmt.setString(3, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.MDM_TOKEN)); + stmt.setString(4, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.UNLOCK_TOKEN)); + stmt.setString(5, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.CHALLENGE_TOKEN)); + stmt.setString(6, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.DEVICE_INFO)); + stmt.setString(7, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.SERIAL)); + stmt.setString(8, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.PRODUCT)); + stmt.setString(9, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.MAC_ADDRESS)); + stmt.setString(10, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.DEVICE_NAME)); + stmt.setString(11, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.ICCID)); + stmt.setString(12, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.LATITUDE)); + stmt.setString(13, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.LONGITUDE)); + stmt.setString(14, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.IMEI)); + stmt.setString(15, IOSUtils.getDeviceProperty(mobileDevice.getDeviceProperties(), + IOSPluginConstants.VERSION)); + stmt.setString(16, mobileDevice.getMobileDeviceId()); int rows = stmt.executeUpdate(); if (rows > 0) { @@ -245,7 +282,7 @@ public class IOSDeviceDAOImpl implements MobileDeviceDAO { String selectDBQuery = "SELECT MOBILE_DEVICE_ID, APNS_PUSH_TOKEN, MAGIC_TOKEN, MDM_TOKEN, UNLOCK_TOKEN, " + "CHALLENGE_TOKEN, DEVICE_INFO, SERIAL, PRODUCT, MAC_ADDRESS, DEVICE_NAME, ICCID," + - "LATITUDE, LONGITUDE FROM IOS_DEVICE"; + "LATITUDE, LONGITUDE, IMEI, VERSION FROM IOS_DEVICE"; stmt = conn.prepareStatement(selectDBQuery); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { @@ -269,6 +306,8 @@ public class IOSDeviceDAOImpl implements MobileDeviceDAO { tokenMap.put(IOSPluginConstants.ICCID, resultSet.getString(IOSPluginConstants.ICCID)); tokenMap.put(IOSPluginConstants.LATITUDE, resultSet.getString(IOSPluginConstants.LATITUDE)); tokenMap.put(IOSPluginConstants.LONGITUDE, resultSet.getString(IOSPluginConstants.LONGITUDE)); + tokenMap.put(IOSPluginConstants.IMEI, resultSet.getString(IOSPluginConstants.IMEI)); + tokenMap.put(IOSPluginConstants.VERSION, resultSet.getString(IOSPluginConstants.VERSION)); mobileDevice.setDeviceProperties(tokenMap); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/dao/impl/IOSPluginConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/util/IOSPluginConstants.java similarity index 84% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/dao/impl/IOSPluginConstants.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/util/IOSPluginConstants.java index b3e089d67..561931c31 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/dao/impl/IOSPluginConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/util/IOSPluginConstants.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.device.mgt.mobile.impl.ios.dao.impl; +package org.wso2.carbon.device.mgt.mobile.impl.ios.util; public class IOSPluginConstants { @@ -11,10 +11,12 @@ public class IOSPluginConstants { public static final String DEVICE_INFO = "DEVICE_INFO"; public static final String SERIAL = "SERIAL"; public static final String PRODUCT = "PRODUCT"; - public static final String MAC_ADDRESS = "MAC_ADDRESS"; public static final String DEVICE_NAME = "DEVICE_NAME"; - public static final String ICCID = "ICCID"; public static final String LATITUDE = "LATITUDE"; public static final String LONGITUDE = "LONGITUDE"; + public static final String IMEI = "IMEI"; + public static final String VERSION = "VERSION"; + public static final String MAC_ADDRESS = "MAC_ADDRESS"; + public static final String ICCID = "ICCID"; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/util/IOSUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/util/IOSUtils.java new file mode 100644 index 000000000..e759e2f6a --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/util/IOSUtils.java @@ -0,0 +1,17 @@ +package org.wso2.carbon.device.mgt.mobile.impl.ios.util; + +import java.util.Map; + +public class IOSUtils { + + public static String getDeviceProperty(Map deviceProperties, String property) { + + String deviceProperty = deviceProperties.get(property); + + if (deviceProperty == null) { + return ""; + } + + return deviceProperty; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java index 110001d81..342b68d78 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java @@ -90,6 +90,17 @@ public class MobileDeviceManagementUtil { mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR)); mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE)); mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE)); + + if (device.getProperties() != null) { + Map deviceProperties = new HashMap(); + for (Device.Property deviceProperty : device.getProperties()) { + deviceProperties.put(deviceProperty.getName(), deviceProperty.getValue()); + } + + mobileDevice.setDeviceProperties(deviceProperties); + } else { + mobileDevice.setDeviceProperties(new HashMap()); + } } return mobileDevice; } @@ -107,7 +118,14 @@ public class MobileDeviceManagementUtil { propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude())); propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude())); propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial())); - device.setProperties(propertyList); + + if (mobileDevice.getDeviceProperties() != null) { + for (Map.Entry deviceProperty : mobileDevice.getDeviceProperties().entrySet()) { + propertyList.add(getProperty(deviceProperty.getKey(), deviceProperty.getValue())); + } + } + + device.setProperties(propertyList); device.setDeviceIdentifier(mobileDevice.getMobileDeviceId()); } return device; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/h2_ios.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/h2_ios.sql index d94ad0223..f3c69a21a 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/h2_ios.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/h2_ios.sql @@ -18,11 +18,13 @@ CREATE TABLE IF NOT EXISTS `IOS_FEATURE` ( `APNS_PUSH_TOKEN` VARCHAR(100) NULL DEFAULT NULL, `MAGIC_TOKEN` VARCHAR(100) NULL DEFAULT NULL, `MDM_TOKEN` VARCHAR(100) NULL DEFAULT NULL, - `UNLOCK_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, + `UNLOCK_TOKEN` VARCHAR(2000) NULL DEFAULT NULL, `CHALLENGE_TOKEN` VARCHAR(45) NULL DEFAULT NULL, `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, `SERIAL` VARCHAR(45) NULL DEFAULT NULL, `PRODUCT` VARCHAR(45) NULL DEFAULT NULL, + `IMEI` VARCHAR(45) NULL DEFAULT NULL, + `VERSION` VARCHAR(45) NULL DEFAULT NULL, `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, `ICCID` VARCHAR(45) NULL DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/mysql_ios.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/mysql_ios.sql index e69dc48ad..1b90f68c6 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/mysql_ios.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/mysql_ios.sql @@ -1,52 +1,38 @@ -- ----------------------------------------------------- --- Table `MBL_DEVICE` +-- Table `IOS_FEATURE` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `MBL_DEVICE` ( - `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL, - `PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL, - `IMEI` VARCHAR(45) NULL DEFAULT NULL, - `IMSI` VARCHAR(45) NULL DEFAULT NULL, - `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, - `VENDOR` VARCHAR(45) NULL DEFAULT NULL, - `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, - `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, - `CHALLENGE` VARCHAR(45) NULL DEFAULT NULL, - `TOKEN` VARCHAR(50) NULL DEFAULT NULL, - `UNLOCK_TOKEN` VARCHAR(2000) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NULL DEFAULT NULL, - PRIMARY KEY (`MOBILE_DEVICE_ID`)) -ENGINE = InnoDB; - - --- ----------------------------------------------------- --- Table `MBL_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `MBL_FEATURE` ( +CREATE TABLE IF NOT EXISTS `IOS_FEATURE` ( `FEATURE_ID` INT NOT NULL AUTO_INCREMENT, - `DEVICE_TYPE` VARCHAR(45) NOT NULL , - `CODE` VARCHAR(45) NULL, + `CODE` VARCHAR(45) NOT NULL, `NAME` VARCHAR(100) NULL, `DESCRIPTION` VARCHAR(200) NULL, - PRIMARY KEY (`FEATURE_ID`)) -ENGINE = InnoDB; + PRIMARY KEY (`FEATURE_ID`) ) + ENGINE = InnoDB; --- ----------------------------------------------------- --- Table `MBL_FEATURE_PROPERTY` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` ( - `PROPERTY` VARCHAR(45) NOT NULL , - `FEATURE_ID` INT NOT NULL , - PRIMARY KEY (`PROPERTY`), - CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1` - FOREIGN KEY (`FEATURE_ID`) - REFERENCES `MBL_FEATURE` (`FEATURE_ID`) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB; -- ----------------------------------------------------- --- Inserts +-- Table `IOS_DEVICE` -- ----------------------------------------------------- -INSERT INTO MBL_FEATURE (DEVICE_TYPE,NAME,CODE, DESCRIPTION) VALUES ('android','DEVICE_LOCK','503A','Device Lock'),('android','WIPE','504A','Device Wipe'),('android','CLEARPASSCODE','505A','Clear Passcode'),('android','APPLIST','502A','Get All Applications'),('android','LOCATION','501A','Location'),('android','INFO','500A','Device Information'),('android','NOTIFICATION','506A','Message'),('android','WIFI','507A','Setup Wifi'),('android','CAMERA','508A','Camera Control'),('android','MUTE','513A','Mute Device'),('android','INSTALLAPP','509A','Install Application'),('android','UNINSTALLAPP','510A','Uninstall Application'),('android','ENCRYPT','511A','Encrypt Storage'),('android','APN','512A','APN'),('android','WEBCLIP','518A','Create Webclips'),('android','PASSWORDPOLICY','519A','Passcode Policy'),('android','EMAIL','520A','Email Configuration'),('android','GOOGLECALENDAR','521A','Calender Subscription'),('android','VPN','523A','VPN'),('android','LDAP','524A','LDAP'),('android','CHANGEPASSWORD','526A','Set Passcode'),('android','ENTERPRISEWIPE','527A','Enterprise Wipe'),('android','POLICY','500P','Policy Enforcement'),('android','MONITORING','501P','Policy Monitoring '),('android','BLACKLISTAPPS','528B','Blacklist Apps'),('android','REVOKEPOLICY','502P','Revoke Policy'); + CREATE TABLE IF NOT EXISTS `IOS_DEVICE` ( + `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL, + `APNS_PUSH_TOKEN` VARCHAR(100) NULL DEFAULT NULL, + `MAGIC_TOKEN` VARCHAR(100) NULL DEFAULT NULL, + `MDM_TOKEN` VARCHAR(100) NULL DEFAULT NULL, + `UNLOCK_TOKEN` VARCHAR(2000) NULL DEFAULT NULL, + `CHALLENGE_TOKEN` VARCHAR(45) NULL DEFAULT NULL, + `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, + `SERIAL` VARCHAR(45) NULL DEFAULT NULL, + `PRODUCT` VARCHAR(45) NULL DEFAULT NULL, + `IMEI` VARCHAR(45) NULL DEFAULT NULL, + `VERSION` VARCHAR(45) NULL DEFAULT NULL, + `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, + `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, + `ICCID` VARCHAR(45) NULL DEFAULT NULL, + `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, + `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, + PRIMARY KEY (`MOBILE_DEVICE_ID`) ) + ENGINE = InnoDB; + + +long