Adding postgre mssql database supports for PlatformManagement

feature/appm-store/pbac
megala21 7 years ago
parent 612905bc5f
commit 1ab9807dbd

@ -29,7 +29,7 @@ import org.wso2.carbon.device.application.mgt.core.dao.impl.application.H2Applic
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.MySQLApplicationDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate.GenericLifecycleStateImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.platform.GenericPlatformDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.platform.OraclePlatformDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.platform.OracleMsSQLPlatformDAOImpl;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.util.ApplicationMgtDatabaseCreator;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
@ -73,9 +73,11 @@ public class DAOFactory {
switch (databaseEngine) {
case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
return new GenericPlatformDAOImpl();
case Constants.DataBaseTypes.DB_TYPE_MSSQL:
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new OraclePlatformDAOImpl();
return new OracleMsSQLPlatformDAOImpl();
default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
}

@ -25,9 +25,9 @@ import org.wso2.carbon.device.application.mgt.core.exception.PlatformManagementD
import java.util.List;
/**
* Oracle specific implementation for Platform DAO.
* Oracle and MsSQL specific implementation for Platform DAO.
*/
public class OraclePlatformDAOImpl extends GenericPlatformDAOImpl {
public class OracleMsSQLPlatformDAOImpl extends GenericPlatformDAOImpl {
@Override
public int getSuperTenantAndOwnPlatforms(String platformIdentifier, int tenantId)

@ -1,44 +1,35 @@
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_TYPE (
ID INTEGER AUTO_INCREMENT,
NAME VARCHAR (255),
DESCRIPTION TEXT,
CODE VARCHAR (255),
PARAMTERS LONGTEXT,
PRIMARY KEY (ID)
)ENGINE INNODB;
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APPM_PLATFORM]') AND TYPE IN (N'U'))
CREATE TABLE APPM_PLATFORM (
ID INT IDENTITY(1,1) NOT NULL UNIQUE,
IDENTIFIER VARCHAR (100) NOT NULL,
TENANT_ID INT NOT NULL ,
NAME VARCHAR (255),
FILE_BASED BIT,
DESCRIPTION VARCHAR(2048),
IS_SHARED BIT,
IS_DEFAULT_TENANT_MAPPING BIT,
ICON_NAME VARCHAR (100),
PRIMARY KEY (IDENTIFIER, TENANT_ID)
);
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_CATEGORY (
ID INTEGER AUTO_INCREMENT,
NAME VARCHAR (255),
DESCRIPTION TEXT,
PRIMARY KEY (ID)
)ENGINE INNODB;
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APPM_PLATFORM_PROPERTIES]') AND TYPE IN (N'U'))
CREATE TABLE APPM_PLATFORM_PROPERTIES (
ID INT IDENTITY(1,1) NOT NULL,
PLATFORM_ID INT NOT NULL,
PROP_NAME VARCHAR (100) NOT NULL,
OPTIONAL BIT,
DEFAUL_VALUE VARCHAR (255),
FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE,
PRIMARY KEY (ID, PLATFORM_ID, PROP_NAME)
);
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APPM_PLATFORM_TENANT_MAPPING]') AND TYPE IN (N'U'))
CREATE TABLE APPM_PLATFORM_TENANT_MAPPING (
ID INT IDENTITY(1,1) NOT NULL,
TENANT_ID INT NOT NULL ,
PLATFORM_ID INT NOT NULL,
FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE,
PRIMARY KEY (ID, TENANT_ID, PLATFORM_ID)
);
CREATE TABLE IF NOT EXISTS APPM_APPLICATION (
ID INTEGER AUTO_INCREMENT,
NAME VARCHAR (255),
UUID VARCHAR (255),
DESCRIPTION MEDIUMTEXT,
ICON_NAME VARCHAR (255),
BANNER_NAME VARCHAR (255),
VIDEO_NAME VARCHAR (255),
SCREENSHOTS TEXT,
TAGS TEXT,
APPLICATION_TYPE_ID INTEGER,
CATEGORY_ID INTEGER,
CREATED_AT DATETIME,
MODIFIED_AT DATETIME,
PRIMARY KEY (ID),
FOREIGN KEY (CATEGORY_ID) REFERENCES APPM_APPLICATION_CATEGORY(ID),
FOREIGN KEY (APPLICATION_TYPE_ID) REFERENCES APPM_APPLICATION_TYPE(ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_PROPERTIES (
PROP_KEY VARCHAR (255),
PROP_VAL MEDIUMTEXT,
APPLICATION_ID INTEGER,
PRIMARY KEY (APPLICATION_ID, PROP_KEY),
FOREIGN KEY (APPLICATION_ID) REFERENCES APPM_APPLICATION(ID)
)ENGINE INNODB;
CREATE INDEX FK_PLATFROM_TENANT_MAPPING_PLATFORM ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC);

@ -1,44 +1,44 @@
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_TYPE (
ID INTEGER AUTO_INCREMENT,
NAME VARCHAR (255),
DESCRIPTION TEXT,
CODE VARCHAR (255),
PARAMTERS LONGTEXT,
PRIMARY KEY (ID)
)ENGINE INNODB;
DROP TABLE IF EXISTS APPM_PLATFORM;
DROP SEQUENCE IF EXISTS APPM_PLATFORM_PK_SEQ;
CREATE SEQUENCE APPM_PLATFORM_PK_SEQ;
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_CATEGORY (
ID INTEGER AUTO_INCREMENT,
NAME VARCHAR (255),
DESCRIPTION TEXT,
PRIMARY KEY (ID)
)ENGINE INNODB;
CREATE TABLE APPM_PLATFORM (
ID INT DEFAULT NEXTVAL('APPM_PLATFORM_PK_SEQ') UNIQUE,
IDENTIFIER VARCHAR (100) NOT NULL,
TENANT_ID INT NOT NULL ,
NAME VARCHAR (255),
FILE_BASED BOOLEAN,
DESCRIPTION VARCHAR(2048),
IS_SHARED BOOLEAN,
IS_DEFAULT_TENANT_MAPPING BOOLEAN,
ICON_NAME VARCHAR (100),
PRIMARY KEY (IDENTIFIER, TENANT_ID)
);
DROP TABLE IF EXISTS APPM_PLATFORM_PROPERTIES;
DROP SEQUENCE IF EXISTS APPM_PLATFORM_PROPERTIES_PK_SEQ;
CREATE SEQUENCE APPM_PLATFORM_PROPERTIES_PK_SEQ;
CREATE TABLE IF NOT EXISTS APPM_APPLICATION (
ID INTEGER AUTO_INCREMENT,
NAME VARCHAR (255),
UUID VARCHAR (255),
DESCRIPTION MEDIUMTEXT,
ICON_NAME VARCHAR (255),
BANNER_NAME VARCHAR (255),
VIDEO_NAME VARCHAR (255),
SCREENSHOTS TEXT,
TAGS TEXT,
APPLICATION_TYPE_ID INTEGER,
CATEGORY_ID INTEGER,
CREATED_AT DATETIME,
MODIFIED_AT DATETIME,
PRIMARY KEY (ID),
FOREIGN KEY (CATEGORY_ID) REFERENCES APPM_APPLICATION_CATEGORY(ID),
FOREIGN KEY (APPLICATION_TYPE_ID) REFERENCES APPM_APPLICATION_TYPE(ID)
)ENGINE INNODB;
CREATE TABLE APPM_PLATFORM_PROPERTIES (
ID INT DEFAULT NEXTVAL('APPM_PLATFORM_PROPERTIES_PK_SEQ'),
PLATFORM_ID INT NOT NULL,
PROP_NAME VARCHAR (100) NOT NULL,
OPTIONAL BOOLEAN,
DEFAUL_VALUE VARCHAR (255),
FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE,
PRIMARY KEY (ID, PLATFORM_ID, PROP_NAME)
);
DROP TABLE IF EXISTS APPM_PLATFORM_TENANT_MAPPING;
DROP SEQUENCE IF EXISTS APPM_PLATFORM_TENANT_MAPPING_PK_SEQ;
CREATE SEQUENCE APPM_PLATFORM_TENANT_MAPPING_PK_SEQ;
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_PROPERTIES (
PROP_KEY VARCHAR (255),
PROP_VAL MEDIUMTEXT,
APPLICATION_ID INTEGER,
PRIMARY KEY (APPLICATION_ID, PROP_KEY),
FOREIGN KEY (APPLICATION_ID) REFERENCES APPM_APPLICATION(ID)
)ENGINE INNODB;
CREATE TABLE APPM_PLATFORM_TENANT_MAPPING (
ID INT DEFAULT NEXTVAL('APPM_PLATFORM_TENANT_MAPPING_PK_SEQ'),
TENANT_ID INT NOT NULL ,
PLATFORM_ID INT NOT NULL,
FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE,
PRIMARY KEY (ID, TENANT_ID, PLATFORM_ID)
);
CREATE INDEX FK_PLATFROM_TENANT_MAPPING_PLATFORM ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC);
Loading…
Cancel
Save