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.application.MySQLApplicationDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate.GenericLifecycleStateImpl; 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.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.exception.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.util.ApplicationMgtDatabaseCreator; import org.wso2.carbon.device.application.mgt.core.util.ApplicationMgtDatabaseCreator;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
@ -73,9 +73,11 @@ public class DAOFactory {
switch (databaseEngine) { switch (databaseEngine) {
case Constants.DataBaseTypes.DB_TYPE_H2: case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL: case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
return new GenericPlatformDAOImpl(); return new GenericPlatformDAOImpl();
case Constants.DataBaseTypes.DB_TYPE_MSSQL:
case Constants.DataBaseTypes.DB_TYPE_ORACLE: case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new OraclePlatformDAOImpl(); return new OracleMsSQLPlatformDAOImpl();
default: default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); 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; 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 @Override
public int getSuperTenantAndOwnPlatforms(String platformIdentifier, int tenantId) public int getSuperTenantAndOwnPlatforms(String platformIdentifier, int tenantId)

@ -1,44 +1,35 @@
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_TYPE ( IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APPM_PLATFORM]') AND TYPE IN (N'U'))
ID INTEGER AUTO_INCREMENT, 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), NAME VARCHAR (255),
DESCRIPTION TEXT, FILE_BASED BIT,
CODE VARCHAR (255), DESCRIPTION VARCHAR(2048),
PARAMTERS LONGTEXT, IS_SHARED BIT,
PRIMARY KEY (ID) IS_DEFAULT_TENANT_MAPPING BIT,
)ENGINE INNODB; ICON_NAME VARCHAR (100),
PRIMARY KEY (IDENTIFIER, TENANT_ID)
);
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_CATEGORY ( IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[APPM_PLATFORM_PROPERTIES]') AND TYPE IN (N'U'))
ID INTEGER AUTO_INCREMENT, CREATE TABLE APPM_PLATFORM_PROPERTIES (
NAME VARCHAR (255), ID INT IDENTITY(1,1) NOT NULL,
DESCRIPTION TEXT, PLATFORM_ID INT NOT NULL,
PRIMARY KEY (ID) PROP_NAME VARCHAR (100) NOT NULL,
)ENGINE INNODB; OPTIONAL BIT,
DEFAUL_VALUE VARCHAR (255),
FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE,
CREATE TABLE IF NOT EXISTS APPM_APPLICATION ( PRIMARY KEY (ID, PLATFORM_ID, PROP_NAME)
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;
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_PROPERTIES ( CREATE INDEX FK_PLATFROM_TENANT_MAPPING_PLATFORM ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC);
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;

@ -1,44 +1,44 @@
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_TYPE ( DROP TABLE IF EXISTS APPM_PLATFORM;
ID INTEGER AUTO_INCREMENT, DROP SEQUENCE IF EXISTS APPM_PLATFORM_PK_SEQ;
NAME VARCHAR (255), CREATE SEQUENCE APPM_PLATFORM_PK_SEQ;
DESCRIPTION TEXT,
CODE VARCHAR (255),
PARAMTERS LONGTEXT,
PRIMARY KEY (ID)
)ENGINE INNODB;
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_CATEGORY ( CREATE TABLE APPM_PLATFORM (
ID INTEGER AUTO_INCREMENT, ID INT DEFAULT NEXTVAL('APPM_PLATFORM_PK_SEQ') UNIQUE,
NAME VARCHAR (255), IDENTIFIER VARCHAR (100) NOT NULL,
DESCRIPTION TEXT, TENANT_ID INT NOT NULL ,
PRIMARY KEY (ID) NAME VARCHAR (255),
)ENGINE INNODB; 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 ( CREATE TABLE APPM_PLATFORM_PROPERTIES (
ID INTEGER AUTO_INCREMENT, ID INT DEFAULT NEXTVAL('APPM_PLATFORM_PROPERTIES_PK_SEQ'),
NAME VARCHAR (255), PLATFORM_ID INT NOT NULL,
UUID VARCHAR (255), PROP_NAME VARCHAR (100) NOT NULL,
DESCRIPTION MEDIUMTEXT, OPTIONAL BOOLEAN,
ICON_NAME VARCHAR (255), DEFAUL_VALUE VARCHAR (255),
BANNER_NAME VARCHAR (255), FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE,
VIDEO_NAME VARCHAR (255), PRIMARY KEY (ID, PLATFORM_ID, PROP_NAME)
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;
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 ( CREATE TABLE APPM_PLATFORM_TENANT_MAPPING (
PROP_KEY VARCHAR (255), ID INT DEFAULT NEXTVAL('APPM_PLATFORM_TENANT_MAPPING_PK_SEQ'),
PROP_VAL MEDIUMTEXT, TENANT_ID INT NOT NULL ,
APPLICATION_ID INTEGER, PLATFORM_ID INT NOT NULL,
PRIMARY KEY (APPLICATION_ID, PROP_KEY), FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE,
FOREIGN KEY (APPLICATION_ID) REFERENCES APPM_APPLICATION(ID) PRIMARY KEY (ID, TENANT_ID, PLATFORM_ID)
)ENGINE INNODB; );
CREATE INDEX FK_PLATFROM_TENANT_MAPPING_PLATFORM ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC);
Loading…
Cancel
Save