mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Adding oracle scripts and impl for PlatformManagement
This commit is contained in:
parent
ec0be0183e
commit
612905bc5f
@ -29,6 +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.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,6 +74,8 @@ public class DAOFactory {
|
|||||||
case Constants.DataBaseTypes.DB_TYPE_H2:
|
case Constants.DataBaseTypes.DB_TYPE_H2:
|
||||||
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
|
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
|
||||||
return new GenericPlatformDAOImpl();
|
return new GenericPlatformDAOImpl();
|
||||||
|
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
|
||||||
|
return new OraclePlatformDAOImpl();
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
|
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
|
||||||
}
|
}
|
||||||
@ -111,9 +114,9 @@ public class DAOFactory {
|
|||||||
DatabaseCreator databaseCreator = new ApplicationMgtDatabaseCreator(dataSourceName);
|
DatabaseCreator databaseCreator = new ApplicationMgtDatabaseCreator(dataSourceName);
|
||||||
if (!databaseCreator.isDatabaseStructureCreated(validationQuery)) {
|
if (!databaseCreator.isDatabaseStructureCreated(validationQuery)) {
|
||||||
databaseCreator.createRegistryDatabase();
|
databaseCreator.createRegistryDatabase();
|
||||||
if (log.isDebugEnabled()) {
|
log.info("Application Management tables are created in the database");
|
||||||
log.debug("Application Management tables are created in the database");
|
} else {
|
||||||
}
|
log.info("Application Management Database structure already exists. Not creating the database.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
@ -41,7 +41,8 @@ import java.util.List;
|
|||||||
public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformDAO {
|
public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformDAO {
|
||||||
private static Log log = LogFactory.getLog(GenericPlatformDAOImpl.class);
|
private static Log log = LogFactory.getLog(GenericPlatformDAOImpl.class);
|
||||||
|
|
||||||
@Override public int register(int tenantId, Platform platform) throws PlatformManagementDAOException {
|
@Override
|
||||||
|
public int register(int tenantId, Platform platform) throws PlatformManagementDAOException {
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
try {
|
try {
|
||||||
int platformId = getPlatformId(tenantId, platform.getIdentifier());
|
int platformId = getPlatformId(tenantId, platform.getIdentifier());
|
||||||
@ -113,7 +114,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void update(int tenantId, String oldPlatformIdentifier, Platform platform)
|
@Override
|
||||||
|
public void update(int tenantId, String oldPlatformIdentifier, Platform platform)
|
||||||
throws PlatformManagementDAOException {
|
throws PlatformManagementDAOException {
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
try {
|
try {
|
||||||
@ -200,8 +202,7 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
private int getPlatformId(int tenantId, String platformIdentifier) throws PlatformManagementDAOException {
|
private int getPlatformId(int tenantId, String platformIdentifier) throws PlatformManagementDAOException {
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
String query = "SELECT ID FROM APPM_PLATFORM WHERE (TENANT_ID=? AND IDENTIFIER=?) OR (IS_SHARED = TRUE AND "
|
String query = SQLQueries.queryToGetPlatformId;
|
||||||
+ "IDENTIFIER=?)";
|
|
||||||
try {
|
try {
|
||||||
Connection connection = this.getDBConnection();
|
Connection connection = this.getDBConnection();
|
||||||
preparedStatement = connection.prepareStatement(query);
|
preparedStatement = connection.prepareStatement(query);
|
||||||
@ -222,7 +223,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void unregister(int tenantId, String platformIdenfier, boolean isFileBased)
|
@Override
|
||||||
|
public void unregister(int tenantId, String platformIdenfier, boolean isFileBased)
|
||||||
throws PlatformManagementDAOException {
|
throws PlatformManagementDAOException {
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
try {
|
try {
|
||||||
@ -315,7 +317,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void removeMapping(int tenantId, String platformIdentifier) throws PlatformManagementDAOException {
|
@Override
|
||||||
|
public void removeMapping(int tenantId, String platformIdentifier) throws PlatformManagementDAOException {
|
||||||
String deleteMapping = "DELETE FROM APPM_PLATFORM_TENANT_MAPPING WHERE ID = ?";
|
String deleteMapping = "DELETE FROM APPM_PLATFORM_TENANT_MAPPING WHERE ID = ?";
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
try {
|
try {
|
||||||
@ -340,7 +343,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void removeMappingTenants(String platformIdentifier) throws PlatformManagementDAOException {
|
@Override
|
||||||
|
public void removeMappingTenants(String platformIdentifier) throws PlatformManagementDAOException {
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
int platformId = getPlatformId(MultitenantConstants.SUPER_TENANT_ID, platformIdentifier);
|
int platformId = getPlatformId(MultitenantConstants.SUPER_TENANT_ID, platformIdentifier);
|
||||||
String getMapping = "DELETE FROM APPM_PLATFORM_TENANT_MAPPING WHERE TENANT_ID != ? AND PLATFORM_ID=?";
|
String getMapping = "DELETE FROM APPM_PLATFORM_TENANT_MAPPING WHERE TENANT_ID != ? AND PLATFORM_ID=?";
|
||||||
@ -361,16 +365,15 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public List<Platform> getPlatforms(int tenantId) throws PlatformManagementDAOException {
|
@Override
|
||||||
|
public List<Platform> getPlatforms(int tenantId) throws PlatformManagementDAOException {
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("GetPlaforms request received for the tenant ID " + tenantId);
|
log.debug("GetPlaforms request received for the tenant ID " + tenantId);
|
||||||
}
|
}
|
||||||
String selectQuery = "SELECT MAPPING.ID, PLATFORM.IDENTIFIER FROM (SELECT * FROM APPM_PLATFORM "
|
String selectQuery = SQLQueries.queryToGetPlatforms;
|
||||||
+ "WHERE TENANT_ID=? OR IS_SHARED = TRUE ) PLATFORM LEFT JOIN APPM_PLATFORM_TENANT_MAPPING "
|
|
||||||
+ "MAPPING ON PLATFORM.ID = MAPPING.PLATFORM_ID AND MAPPING.TENANT_ID = ?";
|
|
||||||
try {
|
try {
|
||||||
Connection connection = this.getDBConnection();
|
Connection connection = this.getDBConnection();
|
||||||
preparedStatement = connection.prepareStatement(selectQuery);
|
preparedStatement = connection.prepareStatement(selectQuery);
|
||||||
@ -456,7 +459,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Platform getPlatform(int tenantId, String identifier) throws PlatformManagementDAOException {
|
@Override
|
||||||
|
public Platform getPlatform(int tenantId, String identifier) throws PlatformManagementDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
@ -464,12 +468,7 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
conn = this.getDBConnection();
|
conn = this.getDBConnection();
|
||||||
sql = "SELECT MAPPING.ID, PLATFORM.IDENTIFIER, PLATFORM.FILE_BASED, PLATFORM.ID, PLATFORM.NAME, PLATFORM"
|
sql = SQLQueries.queryToGetPlatform;
|
||||||
+ ".DESCRIPTION, PLATFORM.ICON_NAME, PLATFORM.IS_SHARED, PLATFORM.IS_DEFAULT_TENANT_MAPPING FROM "
|
|
||||||
+ "(SELECT * FROM APPM_PLATFORM WHERE IDENTIFIER= ? AND (TENANT_ID=? OR IS_SHARED = TRUE)) "
|
|
||||||
+ "PLATFORM LEFT JOIN APPM_PLATFORM_TENANT_MAPPING MAPPING ON PLATFORM.ID = MAPPING.PLATFORM_ID "
|
|
||||||
+ "AND MAPPING.TENANT_ID = ?";
|
|
||||||
|
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setString(1, identifier);
|
stmt.setString(1, identifier);
|
||||||
stmt.setInt(2, tenantId);
|
stmt.setInt(2, tenantId);
|
||||||
@ -509,7 +508,8 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void removePlatforms(int tenantId) throws PlatformManagementDAOException {
|
@Override
|
||||||
|
public void removePlatforms(int tenantId) throws PlatformManagementDAOException {
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
String sql = "DELETE FROM APPM_PLATFORM WHERE TENANT_ID = ?";
|
String sql = "DELETE FROM APPM_PLATFORM WHERE TENANT_ID = ?";
|
||||||
|
|
||||||
@ -529,12 +529,12 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getSuperTenantAndOwnPlatforms(String platformIdentifier, int tenantId)
|
@Override
|
||||||
|
public int getSuperTenantAndOwnPlatforms(String platformIdentifier, int tenantId)
|
||||||
throws PlatformManagementDAOException {
|
throws PlatformManagementDAOException {
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
String sql = "SELECT ID from APPM_PLATFORM where IDENTIFIER = ? AND (TENANT_ID = ? OR (TENANT_ID = ? AND "
|
String sql = SQLQueries.queryToGetSupertenantAndOwnPlatforms;
|
||||||
+ "IS_SHARED = true)";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Connection connection = this.getDBConnection();
|
Connection connection = this.getDBConnection();
|
||||||
@ -558,10 +558,10 @@ public class GenericPlatformDAOImpl extends AbstractDAOImpl implements PlatformD
|
|||||||
} finally {
|
} finally {
|
||||||
Util.cleanupResources(preparedStatement, resultSet);
|
Util.cleanupResources(preparedStatement, resultSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Platform getTenantOwnedPlatform(int tenantId, String platformIdentifier)
|
@Override
|
||||||
|
public Platform getTenantOwnedPlatform(int tenantId, String platformIdentifier)
|
||||||
throws PlatformManagementDAOException {
|
throws PlatformManagementDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
|
|||||||
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, 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.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.application.mgt.core.dao.impl.platform;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.Platform;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.exception.PlatformManagementDAOException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oracle specific implementation for Platform DAO.
|
||||||
|
*/
|
||||||
|
public class OraclePlatformDAOImpl extends GenericPlatformDAOImpl {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSuperTenantAndOwnPlatforms(String platformIdentifier, int tenantId)
|
||||||
|
throws PlatformManagementDAOException {
|
||||||
|
SQLQueries.queryToGetSupertenantAndOwnPlatforms = "SELECT ID from APPM_PLATFORM where IDENTIFIER "
|
||||||
|
+ "= ? AND (TENANT_ID = ? OR (TENANT_ID = ? AND IS_SHARED = 1))";
|
||||||
|
return super.getSuperTenantAndOwnPlatforms(platformIdentifier, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int register(int tenantId, Platform platform) throws PlatformManagementDAOException {
|
||||||
|
SQLQueries.queryToGetPlatformId =
|
||||||
|
"SELECT ID FROM APPM_PLATFORM WHERE (TENANT_ID=? AND IDENTIFIER=?) OR (IS_SHARED = 1 AND "
|
||||||
|
+ "IDENTIFIER=?)";
|
||||||
|
return super.register(tenantId, platform);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Platform getPlatform(int tenantId, String identifier) throws PlatformManagementDAOException {
|
||||||
|
SQLQueries.queryToGetPlatform =
|
||||||
|
"SELECT MAPPING.ID, PLATFORM.IDENTIFIER, PLATFORM.FILE_BASED, PLATFORM.ID, PLATFORM.NAME, "
|
||||||
|
+ "PLATFORM.DESCRIPTION, PLATFORM.ICON_NAME, PLATFORM.IS_SHARED, "
|
||||||
|
+ "PLATFORM.IS_DEFAULT_TENANT_MAPPING FROM (SELECT * FROM APPM_PLATFORM WHERE IDENTIFIER= ? "
|
||||||
|
+ "AND (TENANT_ID=? OR IS_SHARED = 1)) PLATFORM LEFT JOIN APPM_PLATFORM_TENANT_MAPPING "
|
||||||
|
+ "MAPPING ON PLATFORM.ID = MAPPING.PLATFORM_ID AND MAPPING.TENANT_ID = ?";
|
||||||
|
return super.getPlatform(tenantId, identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMappingTenants(String platformIdentifier) throws PlatformManagementDAOException {
|
||||||
|
SQLQueries.queryToGetPlatformId =
|
||||||
|
"SELECT ID FROM APPM_PLATFORM WHERE (TENANT_ID=? AND IDENTIFIER=?) OR (IS_SHARED = 1 AND "
|
||||||
|
+ "IDENTIFIER=?)";
|
||||||
|
super.removeMappingTenants(platformIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(int tenantId, String oldPlatformIdentifier, Platform platform)
|
||||||
|
throws PlatformManagementDAOException {
|
||||||
|
SQLQueries.queryToGetPlatformId =
|
||||||
|
"SELECT ID FROM APPM_PLATFORM WHERE (TENANT_ID=? AND IDENTIFIER=?) OR (IS_SHARED = 1 AND "
|
||||||
|
+ "IDENTIFIER=?)";
|
||||||
|
super.update(tenantId, oldPlatformIdentifier, platform);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMapping(int tenantId, List<String> platformIdentifiers) throws PlatformManagementDAOException {
|
||||||
|
SQLQueries.queryToGetPlatformId =
|
||||||
|
"SELECT ID FROM APPM_PLATFORM WHERE (TENANT_ID=? AND IDENTIFIER=?) OR (IS_SHARED = 1 AND "
|
||||||
|
+ "IDENTIFIER=?)";
|
||||||
|
super.addMapping(tenantId, platformIdentifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Platform> getPlatforms(int tenantId) throws PlatformManagementDAOException {
|
||||||
|
SQLQueries.queryToGetPlatforms = "SELECT MAPPING.ID, PLATFORM.IDENTIFIER FROM (SELECT * FROM APPM_PLATFORM "
|
||||||
|
+ "WHERE TENANT_ID=? OR IS_SHARED = 1) PLATFORM LEFT JOIN APPM_PLATFORM_TENANT_MAPPING "
|
||||||
|
+ "MAPPING ON PLATFORM.ID = MAPPING.PLATFORM_ID AND MAPPING.TENANT_ID = ?";
|
||||||
|
return super.getPlatforms(tenantId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, 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.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.application.mgt.core.dao.impl.platform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQL Queries specific to Platform.
|
||||||
|
*/
|
||||||
|
public class SQLQueries {
|
||||||
|
static String queryToGetSupertenantAndOwnPlatforms = "SELECT ID from APPM_PLATFORM where IDENTIFIER "
|
||||||
|
+ "= ? AND (TENANT_ID = ? OR (TENANT_ID = ? AND IS_SHARED = true))";
|
||||||
|
static String queryToGetPlatformId =
|
||||||
|
"SELECT ID FROM APPM_PLATFORM WHERE (TENANT_ID=? AND IDENTIFIER=?) OR (IS_SHARED = TRUE AND "
|
||||||
|
+ "IDENTIFIER=?)";
|
||||||
|
static String queryToGetPlatform =
|
||||||
|
"SELECT MAPPING.ID, PLATFORM.IDENTIFIER, PLATFORM.FILE_BASED, PLATFORM.ID, PLATFORM.NAME, PLATFORM"
|
||||||
|
+ ".DESCRIPTION, PLATFORM.ICON_NAME, PLATFORM.IS_SHARED, PLATFORM.IS_DEFAULT_TENANT_MAPPING FROM "
|
||||||
|
+ "(SELECT * FROM APPM_PLATFORM WHERE IDENTIFIER= ? AND (TENANT_ID=? OR IS_SHARED = TRUE)) "
|
||||||
|
+ "PLATFORM LEFT JOIN APPM_PLATFORM_TENANT_MAPPING MAPPING ON PLATFORM.ID = MAPPING.PLATFORM_ID "
|
||||||
|
+ "AND MAPPING.TENANT_ID = ?";
|
||||||
|
static String queryToGetPlatforms = "SELECT MAPPING.ID, PLATFORM.IDENTIFIER FROM (SELECT * FROM APPM_PLATFORM "
|
||||||
|
+ "WHERE TENANT_ID=? OR IS_SHARED = TRUE ) PLATFORM LEFT JOIN APPM_PLATFORM_TENANT_MAPPING "
|
||||||
|
+ "MAPPING ON PLATFORM.ID = MAPPING.PLATFORM_ID AND MAPPING.TENANT_ID = ?";
|
||||||
|
}
|
||||||
@ -548,7 +548,7 @@ public class PlatformManagerImpl implements PlatformManager {
|
|||||||
"Error while checking platform sharing conditions for " + " platform identifier '" + platform
|
"Error while checking platform sharing conditions for " + " platform identifier '" + platform
|
||||||
.getIdentifier() + "' for the tenant :" + tenantId);
|
.getIdentifier() + "' for the tenant :" + tenantId);
|
||||||
} finally {
|
} finally {
|
||||||
ConnectionManagerUtil.rollbackDBTransaction();
|
ConnectionManagerUtil.closeDBConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,44 +1,80 @@
|
|||||||
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_TYPE (
|
-- -----------------------------------------------------
|
||||||
ID INTEGER AUTO_INCREMENT,
|
-- Schema WSO2DM_APPM_DB
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
-- Table APPM_PLATFORM
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE APPM_PLATFORM (
|
||||||
|
ID INT UNIQUE,
|
||||||
|
IDENTIFIER VARCHAR (100) NOT NULL,
|
||||||
|
TENANT_ID INT NOT NULL ,
|
||||||
NAME VARCHAR (255),
|
NAME VARCHAR (255),
|
||||||
DESCRIPTION TEXT,
|
FILE_BASED NUMBER (1),
|
||||||
CODE VARCHAR (255),
|
DESCRIPTION VARCHAR (2048),
|
||||||
PARAMTERS LONGTEXT,
|
IS_SHARED NUMBER (1),
|
||||||
PRIMARY KEY (ID)
|
IS_DEFAULT_TENANT_MAPPING NUMBER (1),
|
||||||
)ENGINE INNODB;
|
ICON_NAME VARCHAR (100),
|
||||||
|
PRIMARY KEY (IDENTIFIER, TENANT_ID)
|
||||||
|
)
|
||||||
|
/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_CATEGORY (
|
CREATE SEQUENCE APPM_PLATFORM_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
|
||||||
ID INTEGER AUTO_INCREMENT,
|
/
|
||||||
NAME VARCHAR (255),
|
CREATE OR REPLACE TRIGGER APPM_PLATFORM_TRIG
|
||||||
DESCRIPTION TEXT,
|
BEFORE INSERT
|
||||||
PRIMARY KEY (ID)
|
ON APPM_PLATFORM
|
||||||
)ENGINE INNODB;
|
REFERENCING NEW AS NEW
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
SELECT APPM_PLATFORM_SEQ.nextval INTO :NEW.ID FROM dual;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS APPM_APPLICATION (
|
CREATE TABLE APPM_PLATFORM_PROPERTIES (
|
||||||
ID INTEGER AUTO_INCREMENT,
|
ID INT,
|
||||||
NAME VARCHAR (255),
|
PLATFORM_ID INT NOT NULL,
|
||||||
UUID VARCHAR (255),
|
PROP_NAME VARCHAR (100) NOT NULL,
|
||||||
DESCRIPTION MEDIUMTEXT,
|
OPTIONAL NUMBER (1),
|
||||||
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;
|
|
||||||
|
|
||||||
|
CREATE SEQUENCE APPM_PLATFORM_PROPERTIES_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
|
||||||
|
/
|
||||||
|
CREATE OR REPLACE TRIGGER APPM_PLATFORM_PROPERTIES_TRIG
|
||||||
|
BEFORE INSERT
|
||||||
|
ON APPM_PLATFORM_PROPERTIES
|
||||||
|
REFERENCING NEW AS NEW
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
SELECT APPM_PLATFORM_PROPERTIES_SEQ.nextval INTO :NEW.ID FROM dual;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_PROPERTIES (
|
CREATE TABLE APPM_PLATFORM_TENANT_MAPPING (
|
||||||
PROP_KEY VARCHAR (255),
|
ID INT,
|
||||||
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 SEQUENCE APPM_TENANT_MAPPING_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
|
||||||
|
/
|
||||||
|
CREATE OR REPLACE TRIGGER APPM_TENANT_MAPPING_TRIG
|
||||||
|
BEFORE INSERT
|
||||||
|
ON APPM_PLATFORM_TENANT_MAPPING
|
||||||
|
REFERENCING NEW AS NEW
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
SELECT APPM_TENANT_MAPPING_SEQ.nextval INTO :NEW.ID FROM dual;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
|
||||||
|
CREATE INDEX FK_PLATFROM_TENANT_MAPPING ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC)
|
||||||
|
/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user