From a5018afadf0936aa4d8f764a849217a316e83788 Mon Sep 17 00:00:00 2001 From: harshanL Date: Mon, 15 Dec 2014 18:43:56 +0530 Subject: [PATCH] Making the plugin resolution optional for the core component --- .../DeviceManagementServiceComponent.java | 2 +- .../MobileDeviceConfigurationManager.java | 73 ++++++++++++++++++ .../config/MobileDeviceManagementConfig.java | 38 ++++++++++ .../MobileDeviceManagementRepository.java | 40 ++++++++++ .../datasource/JNDILookupDefinition.java | 76 +++++++++++++++++++ .../datasource/MobileDataSourceConfig.java | 39 ++++++++++ .../dao/MobileDeviceManagementDAOFactory.java | 7 ++ ...mpl.java => MobileDeviceModelDAOImpl.java} | 14 +++- ...bileDeviceManagementSchemaInitializer.java | 44 +++++++++++ .../impl/util/MobileDeviceManagerUtil.java | 7 ++ .../src/main/resources/conf/mobile-config.xml | 0 .../repository/dbscripts/cdm/plugins/h2.sql | 0 .../dbscripts/cdm/plugins/mysql.sql | 63 +++++++++++++++ 13 files changed, 401 insertions(+), 2 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceConfigurationManager.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementConfig.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementRepository.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/JNDILookupDefinition.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/MobileDataSourceConfig.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOFactory.java rename components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/{MobileDeviceModelImpl.java => MobileDeviceModelDAOImpl.java} (78%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementSchemaInitializer.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagerUtil.java create mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml create mode 100644 product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql create mode 100644 product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index 85ae3ec4e5..102ca5fb70 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -41,7 +41,7 @@ import org.wso2.carbon.user.core.service.RealmService; * unbind="unsetRealmService" * @scr.reference name="device.manager.service" * interface="org.wso2.carbon.device.mgt.common.spi.DeviceManagerService" - * cardinality="1..n" + * cardinality="0..n" * policy="dynamic" * bind="setDeviceManagerService" * unbind="unsetDeviceManagerService" diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceConfigurationManager.java new file mode 100644 index 0000000000..3038387c63 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceConfigurationManager.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.mobile.impl.config; + +import org.w3c.dom.Document; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; +import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; +import org.wso2.carbon.utils.CarbonUtils; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Unmarshaller; +import java.io.File; + +/** + * Class responsible for the mobile device manager configuration initialization + */ +public class MobileDeviceConfigurationManager { + + private MobileDeviceManagementConfig currentDeviceConfig; + private static MobileDeviceConfigurationManager deviceConfigManager; + + private final String deviceMgtConfigXMLPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + + DeviceManagementConstants.DataSourceProperties.DEVICE_CONFIG_XML_NAME; + + public static MobileDeviceConfigurationManager getInstance() { + if (deviceConfigManager == null) { + synchronized (MobileDeviceConfigurationManager.class) { + if (deviceConfigManager == null) { + deviceConfigManager = new MobileDeviceConfigurationManager(); + } + } + } + return deviceConfigManager; + } + + public synchronized void initConfig() throws DeviceManagementException { + try { + File deviceMgtConfig = new File(deviceMgtConfigXMLPath); + Document doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig); + + /* Un-marshaling Device Management configuration */ + JAXBContext rssContext = JAXBContext.newInstance(MobileDeviceManagementConfig.class); + Unmarshaller unmarshaller = rssContext.createUnmarshaller(); + this.currentDeviceConfig = (MobileDeviceManagementConfig) unmarshaller.unmarshal(doc); + } catch (Exception e) { + throw new DeviceManagementException("Error occurred while initializing RSS config", e); + } + } + + public MobileDeviceManagementConfig getDeviceManagementConfig() { + return currentDeviceConfig; + } + + public DataSourceConfig getDataSourceConfig() { + return currentDeviceConfig.getMobileDeviceMgtRepository().getDataSourceConfig(); + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementConfig.java new file mode 100644 index 0000000000..0c9ff1a1b8 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementConfig.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.device.mgt.mobile.impl.config; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents Device Mgt configuration. + */ +@XmlRootElement(name = "MobileDeviceMgtConfiguration") +public final class MobileDeviceManagementConfig { + + private DeviceManagementRepository deviceMgtRepository; + + @XmlElement(name = "ManagementRepository", nillable = false) + public DeviceManagementRepository getDeviceMgtRepository() { + return deviceMgtRepository; + } + + public void setDeviceMgtRepository(DeviceManagementRepository deviceMgtRepository) { + this.deviceMgtRepository = deviceMgtRepository; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementRepository.java new file mode 100644 index 0000000000..e115d96cf9 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/MobileDeviceManagementRepository.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.device.mgt.mobile.impl.config; + +import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Class for holding management repository data + */ +@XmlRootElement(name = "ManagementRepository") +public class MobileDeviceManagementRepository { + + private DataSourceConfig dataSourceConfig; + + @XmlElement(name = "DataSourceConfiguration", nillable = false) + public DataSourceConfig getDataSourceConfig() { + return dataSourceConfig; + } + + public void setDataSourceConfig(DataSourceConfig dataSourceConfig) { + this.dataSourceConfig = dataSourceConfig; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/JNDILookupDefinition.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/JNDILookupDefinition.java new file mode 100644 index 0000000000..6eadecd50b --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/JNDILookupDefinition.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.mobile.impl.config.datasource; + +import javax.xml.bind.annotation.*; +import java.util.List; + +/** + * Class for hold JndiLookupDefinition of rss-manager.xml at parsing with JAXB + */ +@XmlRootElement(name = "JndiLookupDefinition") +public class JNDILookupDefinition { + + private String jndiName; + private List jndiProperties; + + @XmlElement(name = "Name", nillable = false) + public String getJndiName() { + return jndiName; + } + + public void setJndiName(String jndiName) { + this.jndiName = jndiName; + } + + @XmlElementWrapper(name = "Environment", nillable = false) + @XmlElement(name = "Property", nillable = false) + public List getJndiProperties() { + return jndiProperties; + } + + public void setJndiProperties(List jndiProperties) { + this.jndiProperties = jndiProperties; + } + + @XmlRootElement(name = "Property") + public static class JNDIProperty { + + private String name; + + private String value; + + @XmlAttribute(name = "Name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlValue + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + } + +} + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/MobileDataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/MobileDataSourceConfig.java new file mode 100644 index 0000000000..a3e3f6ae0b --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/config/datasource/MobileDataSourceConfig.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.mobile.impl.config.datasource; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Class for holding data source configuration in mobile-config.xml at parsing with JAXB + */ +@XmlRootElement(name = "DataSourceConfiguration") +public class MobileDataSourceConfig { + + private JNDILookupDefinition jndiLookupDefintion; + + @XmlElement(name = "JndiLookupDefinition", nillable = true) + public JNDILookupDefinition getJndiLookupDefintion() { + return jndiLookupDefintion; + } + + public void setJndiLookupDefintion(JNDILookupDefinition jndiLookupDefintion) { + this.jndiLookupDefintion = jndiLookupDefintion; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOFactory.java new file mode 100644 index 0000000000..dbc129a4e5 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOFactory.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dao; + +/** + * Created by harshan on 12/15/14. + */ +public class MobileDeviceManagementDAOFactory { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelDAOImpl.java similarity index 78% rename from components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java rename to components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelDAOImpl.java index 67179794cd..04dbd9c654 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelDAOImpl.java @@ -16,14 +16,26 @@ package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceModelDAO; import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceModel; +import javax.sql.DataSource; + /** * Implementation of MobileDeviceModel. */ -public class MobileDeviceModelImpl implements MobileDeviceModelDAO { +public class MobileDeviceModelDAOImpl implements MobileDeviceModelDAO { + + private DataSource dataSource; + private static final Log log = LogFactory.getLog(MobileDeviceModelDAOImpl.class); + + public MobileDeviceModelDAOImpl(DataSource dataSource) { + this.dataSource = dataSource; + } + @Override public MobileDeviceModel getDeviceModel(String modelId) throws MobileDeviceManagementDAOException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementSchemaInitializer.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementSchemaInitializer.java new file mode 100644 index 0000000000..e6d41a89aa --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagementSchemaInitializer.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.mobile.impl.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; +import org.wso2.carbon.utils.CarbonUtils; +import org.wso2.carbon.utils.dbcreator.DatabaseCreator; + +import java.io.File; + +public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreator { + + private static final Log log = LogFactory.getLog(DeviceManagementSchemaInitializer.class); + private static final String setupSQLScriptBaseLocation = + CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator + "cdm" + File.separator; + + public MobileDeviceManagementSchemaInitializer(DataSourceConfig config) { + super(DeviceManagerUtil.resolveDataSource(config)); + } + + protected String getDbScriptLocation(String databaseType) { + String scriptName = databaseType + ".sql"; + if (log.isDebugEnabled()) { + log.debug("Loading database script from :" + scriptName); + } + return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagerUtil.java new file mode 100644 index 0000000000..d876b9ccb6 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/util/MobileDeviceManagerUtil.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.util; + +/** + * Created by harshan on 12/15/14. + */ +public class MobileDeviceManagerUtil { +} diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql new file mode 100644 index 0000000000..e69de29bb2 diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql new file mode 100644 index 0000000000..45207b39ac --- /dev/null +++ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql @@ -0,0 +1,63 @@ +-- ----------------------------------------------------- +-- Table `MBL_OS_VERSION` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `MBL_OS_VERSION` ( + `VERSION_ID` INT NOT NULL AUTO_INCREMENT, + `VERSION` VARCHAR(45) NULL, + PRIMARY KEY (`VERSION_ID`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `MBL_DEVICE_MODEL` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `MBL_DEVICE_MODEL` ( + `MODEL_ID` INT NOT NULL AUTO_INCREMENT, + `MODEL` VARCHAR(45) NULL, + PRIMARY KEY (`MODEL_ID`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `MBL_VENDOR` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `MBL_VENDOR` ( + `VENDOR_ID` INT NOT NULL AUTO_INCREMENT, + `VENDOR` VARCHAR(45) NULL, + PRIMARY KEY (`VENDOR_ID`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `MBL_DEVICE` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `MBL_DEVICE` ( + `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL, + `REG_ID` VARCHAR(45) NULL, + `IMEI` VARCHAR(45) NULL, + `IMSI` VARCHAR(45) NULL, + `OS_VERSION_ID` INT NOT NULL, + `DEVICE_MODEL_ID` INT NOT NULL, + `VENDOR_ID` INT NOT NULL, + PRIMARY KEY (`MOBILE_DEVICE_ID`), + INDEX `fk_DEVICE_OS_VERSION1_idx` (`OS_VERSION_ID` ASC), + INDEX `fk_DEVICE_DEVICE_MODEL2_idx` (`DEVICE_MODEL_ID` ASC), + INDEX `fk_DEVICE_VENDOR1_idx` (`VENDOR_ID` ASC), + CONSTRAINT `fk_DEVICE_OS_VERSION1` + FOREIGN KEY (`OS_VERSION_ID`) + REFERENCES `mydb`.`MBL_OS_VERSION` (`VERSION_ID`) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_DEVICE_DEVICE_MODEL2` + FOREIGN KEY (`DEVICE_MODEL_ID`) + REFERENCES `mydb`.`MBL_DEVICE_MODEL` (`MODEL_ID`) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_DEVICE_VENDOR1` + FOREIGN KEY (`VENDOR_ID`) + REFERENCES `mydb`.`MBL_VENDOR` (`VENDOR_ID`) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + +