diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java index 8ba6eb7daf7..aad3ab53f4e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/DAOFactory.java @@ -29,6 +29,7 @@ import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO; import org.wso2.carbon.device.application.mgt.core.dao.PlatformDAO; import org.wso2.carbon.device.application.mgt.core.dao.impl.application.GenericApplicationDAOImpl; import org.wso2.carbon.device.application.mgt.core.dao.impl.application.release.GenericApplicationReleaseDAOImpl; +import org.wso2.carbon.device.application.mgt.core.dao.impl.application.release.OracleApplicationDAOImpl; 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.OracleMsSQLPlatformDAOImpl; @@ -64,6 +65,8 @@ public class DAOFactory { case Constants.DataBaseTypes.DB_TYPE_MYSQL: case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: return new GenericApplicationDAOImpl(); + case Constants.DataBaseTypes.DB_TYPE_ORACLE: + return new OracleApplicationDAOImpl(); default: throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); } @@ -94,6 +97,7 @@ public class DAOFactory { case Constants.DataBaseTypes.DB_TYPE_H2: case Constants.DataBaseTypes.DB_TYPE_MYSQL: case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: + case Constants.DataBaseTypes.DB_TYPE_ORACLE: return new GenericLifecycleStateImpl(); default: throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); @@ -112,6 +116,7 @@ public class DAOFactory { case Constants.DataBaseTypes.DB_TYPE_H2: case Constants.DataBaseTypes.DB_TYPE_MYSQL: case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: + case Constants.DataBaseTypes.DB_TYPE_ORACLE: return new GenericApplicationReleaseDAOImpl(); default: throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 966873f9573..76a9e33e2e8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -63,6 +63,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic PreparedStatement stmt = null; ResultSet rs = null; String sql = ""; + String generatedColumns[] = { "ID" }; boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported(); int index = 0; try { @@ -73,7 +74,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "LIFECYCLE_STATE_MODIFIED_AT, LIFECYCLE_STATE_MODIFIED_BY) VALUES " + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + stmt = conn.prepareStatement(sql, generatedColumns); stmt.setString(++index, application.getUuid()); stmt.setString(++index, application.getName()); stmt.setString(++index, application.getShortDescription()); @@ -132,35 +133,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic try { conn = this.getDBConnection(); - sql += "SELECT APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER," - + "CAT.ID AS CAT_ID, CAT.NAME AS CAT_NAME, LS.NAME AS LS_NAME, LS.IDENTIFIER AS LS_IDENTIFIER, " - + "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS " - + "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " - + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " - + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ? "; - - String userName = filter.getUserName(); - if (!userName.equals("ALL")) { - sql += " AND APP.CREATED_BY = ? "; - } - if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { - sql += "AND APP.NAME LIKE ? "; - } - sql += "LIMIT ? OFFSET ?;"; - - stmt = conn.prepareStatement(sql); - stmt.setInt(++index, tenantId); - - if (!userName.equals("ALL")) { - stmt.setString(++index, userName); - } - if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { - stmt.setString(++index, "%" + filter.getSearchQuery() + "%"); - } - - stmt.setInt(++index, filter.getLimit()); - stmt.setInt(++index, filter.getOffset()); - + stmt = this.generateGetApplicationsStatement(filter, conn, tenantId); rs = stmt.executeQuery(); int length = 0; @@ -203,6 +176,51 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic return applicationList; } + /** + * This method is used to generate the statement that is used to get the applications with the given filter. + * + * @param filter Filter to filter out the applications. + * @param conn Database Connection. + * @param tenantId ID of the tenant to retrieve the applications. + * @return the statement for getting applications that are belong to a particular filter. + * @throws SQLException SQL Exception + */ + protected PreparedStatement generateGetApplicationsStatement(Filter filter, Connection conn, + int tenantId) throws SQLException { + int index = 0; + String sql = "SELECT APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER, CAT.ID AS CAT_ID, " + + "CAT.NAME AS CAT_NAME, LS.NAME AS LS_NAME, LS.IDENTIFIER AS LS_IDENTIFIER, " + + "LS.DESCRIPTION AS LS_DESCRIPTION " + "FROM APPM_APPLICATION APP " + "INNER JOIN APPM_PLATFORM APL " + + "ON APP.PLATFORM_ID = APL.ID " + "INNER JOIN APPM_APPLICATION_CATEGORY CAT " + + "ON APP.APPLICATION_CATEGORY_ID = CAT.ID " + "INNER JOIN APPM_LIFECYCLE_STATE LS " + + "ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ? "; + + String userName = filter.getUserName(); + if (!userName.equals("ALL")) { + sql += " AND APP.CREATED_BY = ? "; + } + if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { + sql += "AND APP.NAME LIKE ? "; + } + + sql += "LIMIT ? OFFSET ?"; + + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setInt(++index, tenantId); + + if (!userName.equals("ALL")) { + stmt.setString(++index, userName); + } + if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { + stmt.setString(++index, "%" + filter.getSearchQuery() + "%"); + } + + stmt.setInt(++index, filter.getLimit()); + stmt.setInt(++index, filter.getOffset()); + + return stmt; + } + @Override public int getApplicationCount(Filter filter) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { @@ -265,13 +283,17 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic try { conn = this.getDBConnection(); - sql += "SELECT APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER," - + "CAT.ID AS CAT_ID, CAT.NAME AS CAT_NAME, LS.NAME AS LS_NAME, LS.IDENTIFIER AS LS_IDENTIFIER, " - + "LS.DESCRIPTION AS LS_DESCRIPTION FROM APPM_APPLICATION AS APP INNER JOIN APPM_PLATFORM AS " - + "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " - + "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " - + "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE UUID = ? AND APP.TENANT_ID = ? "; - + sql += "SELECT APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER, CAT.ID AS CAT_ID, " + + "CAT.NAME AS CAT_NAME, LS.NAME AS LS_NAME, LS.IDENTIFIER AS LS_IDENTIFIER, " + + "LS.DESCRIPTION AS LS_DESCRIPTION " + + "FROM APPM_APPLICATION APP " + + "INNER JOIN APPM_PLATFORM APL " + + "ON APP.PLATFORM_ID = APL.ID " + + "INNER JOIN APPM_APPLICATION_CATEGORY CAT " + + "ON APP.APPLICATION_CATEGORY_ID = CAT.ID " + + "INNER JOIN APPM_LIFECYCLE_STATE LS " + + " ON APP.LIFECYCLE_STATE_ID = LS.ID " + + "WHERE UUID = ? AND APP.TENANT_ID = ? "; stmt = conn.prepareStatement(sql); stmt.setString(1, uuid); @@ -307,7 +329,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic return application; } catch (SQLException e) { throw new ApplicationManagementDAOException( - "Error occurred while getting application details with UUID " + uuid, e); + "Error occurred while getting application details with UUID " + uuid + " While executing query " + + sql, e); } catch (JSONException e) { throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e); } catch (DBConnectionException e) { @@ -359,7 +382,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic ResultSet resultSet = null; String sql = "SELECT STATE.NAME, TRANSITION.DESCRIPTION, TRANSITION.PERMISSION FROM ( SELECT * FROM " - + "APPM_LIFECYCLE_STATE ) STATE RIGHT JOIN (SELECT * FROM APPM_LIFECYCLE_STATE_TRANSITION WHERE " + + "APPM_LIFECYCLE_STATE ) STATE RIGHT JOIN (SELECT * FROM APPM_LC_STATE_TRANSITION WHERE " + "INITIAL_STATE = (SELECT LIFECYCLE_STATE_ID FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?)) " + "TRANSITION ON TRANSITION.NEXT_STATE = STATE.ID"; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java index 163326f075f..fd9b2deaef5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java @@ -53,13 +53,13 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements if (applicationRelease.isDefault()) { } - String sql = "insert into APPM_APPLICATION_RELEASE(VERSION_NAME, RESOURCE, RELEASE_CHANNEL ," + String sql = "insert into APPM_APPLICATION_RELEASE(VERSION_NAME, RELEASE_RESOURCE, RELEASE_CHANNEL ," + "RELEASE_DETAILS, CREATED_AT, APPM_APPLICATION_ID, IS_DEFAULT) values (?, ?, ?, ?, ?, ?, ?)"; int index = 0; - + String generatedColumns[] = { "ID" }; try { connection = this.getDBConnection(); - statement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + statement = connection.prepareStatement(sql, generatedColumns); statement.setString(++index, applicationRelease.getVersionName()); statement.setString(++index, applicationRelease.getResource()); statement.setString(++index, String.valueOf(applicationRelease.getReleaseChannel())); @@ -113,7 +113,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements applicationRelease.setCreatedAt(resultSet.getDate("CREATED_AT")); applicationRelease.setReleaseChannel(resultSet.getString("RELEASE_CHANNEL")); applicationRelease.setReleaseDetails(resultSet.getString("RELEASE_DETAILS")); - applicationRelease.setResource(resultSet.getString("RESOURCE")); + applicationRelease.setResource(resultSet.getString("RELEASE_RESOURCE")); sql = "SELECT * FROM APPM_RELEASE_PROPERTY WHERE APPLICATION_RELEASE_ID=?"; statement = connection.prepareStatement(sql); @@ -166,7 +166,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements applicationRelease.setCreatedAt(resultSet.getDate("CREATED_AT")); applicationRelease.setReleaseChannel(resultSet.getString("RELEASE_CHANNEL")); applicationRelease.setReleaseDetails(resultSet.getString("RELEASE_DETAILS")); - applicationRelease.setResource(resultSet.getString("RESOURCE")); + applicationRelease.setResource(resultSet.getString("RELEASE_RESOURCE")); sql = "SELECT * FROM APPM_RELEASE_PROPERTY WHERE APPLICATION_RELEASE_ID= ?"; statement = connection.prepareStatement(sql); @@ -199,7 +199,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; - String sql = "UPDATE APPM_APPLICATION_RELEASE SET RESOURCE = IFNULL (?, RESOURCE), RELEASE_CHANNEL = IFNULL " + String sql = "UPDATE APPM_APPLICATION_RELEASE SET RELEASE_RESOURCE = IFNULL (?, RELEASE_RESOURCE), RELEASE_CHANNEL = IFNULL " + "(?, RELEASE_CHANNEL), RELEASE_DETAILS = IFNULL (?, RELEASE_DETAILS), IS_DEFAULT = IFNULL " + "(?, IS_DEFAULT) WHERE APPM_APPLICATION_ID = ? AND VERSION_NAME = ?"; try { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/OracleApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/OracleApplicationDAOImpl.java new file mode 100644 index 00000000000..f1126b337a9 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/OracleApplicationDAOImpl.java @@ -0,0 +1,69 @@ +/* + * 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.application.release; + +import org.wso2.carbon.device.application.mgt.common.Filter; +import org.wso2.carbon.device.application.mgt.core.dao.impl.application.GenericApplicationDAOImpl; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * This is a ApplicationDAO Implementation specific to Oracle. + */ +public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl { + + @Override + protected PreparedStatement generateGetApplicationsStatement(Filter filter, Connection conn, + int tenantId) throws SQLException { + int index = 0; + String sql = "SELECT APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER, CAT.ID AS CAT_ID, " + + "CAT.NAME AS CAT_NAME, LS.NAME AS LS_NAME, LS.IDENTIFIER AS LS_IDENTIFIER, " + + "LS.DESCRIPTION AS LS_DESCRIPTION " + "FROM APPM_APPLICATION APP " + "INNER JOIN APPM_PLATFORM APL " + + "ON APP.PLATFORM_ID = APL.ID " + "INNER JOIN APPM_APPLICATION_CATEGORY CAT " + + "ON APP.APPLICATION_CATEGORY_ID = CAT.ID " + "INNER JOIN APPM_LIFECYCLE_STATE LS " + + "ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE APP.TENANT_ID = ? "; + + String userName = filter.getUserName(); + if (!userName.equals("ALL")) { + sql += " AND APP.CREATED_BY = ? "; + } + if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { + sql += "AND APP.NAME LIKE ? "; + } + + sql += " ORDER BY APP.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setInt(++index, tenantId); + + if (!userName.equals("ALL")) { + stmt.setString(++index, userName); + } + if (filter.getSearchQuery() != null && !filter.getSearchQuery().isEmpty()) { + stmt.setString(++index, "%" + filter.getSearchQuery() + "%"); + } + stmt.setInt(++index, filter.getOffset()); + stmt.setInt(++index, filter.getLimit()); + return stmt; + } + +} diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql index 323bacca5c4..f8596375b34 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql @@ -81,7 +81,7 @@ INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,'); -CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE_TRANSITION +CREATE TABLE IF NOT EXISTS APPM_LC_STATE_TRANSITION ( ID INT NOT NULL AUTO_INCREMENT UNIQUE, INITIAL_STATE INT, @@ -93,27 +93,27 @@ CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE_TRANSITION FOREIGN KEY (NEXT_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE ); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (1, 2, null, 'Submit for review'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (2, 1, null, 'Revoke from review'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (2, 3, '/permission/admin/manage/device-mgt/application/review', 'APPROVE'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (2, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (3, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (3, 5, null, 'PUBLISH'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (5, 6, null, 'UN PUBLISH'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (6, 5, null, 'PUBLISH'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (4, 1, null, 'Return to CREATE STATE'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (6, 1, null, 'Return to CREATE STATE'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (6, 7, null, 'Retire'); -- ----------------------------------------------------- @@ -180,7 +180,7 @@ CREATE INDEX FK_APPLICATION_PROPERTY_APPLICATION ON APPM_APPLICATION_PROPERTY(AP CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE ( ID INT NOT NULL AUTO_INCREMENT, VERSION_NAME VARCHAR(100) NOT NULL, - RESOURCE TEXT NULL, + RELEASE_RESOURCE TEXT NULL, RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA', RELEASE_DETAILS TEXT NULL, CREATED_AT DATETIME NOT NULL, diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql index f11791f0079..c8ecd3c81a5 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql @@ -37,6 +37,24 @@ FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE, PRIMARY KEY (ID, PLATFORM_ID, PROP_NAME) ); + +-- ----------------------------------------------------- +-- Table `APPM_PLATFORM_TENENT_MAPPING` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `APPM_PLATFORM_TENANT_MAPPING` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `PLATFORM_ID` INT NOT NULL, + `TENANT_ID` INT NOT NULL, + PRIMARY KEY (`ID`, `PLATFORM_ID`), + INDEX `FK_PLATFROM_TENANT_MAPPING_PLATFORM` (`PLATFORM_ID` ASC), + CONSTRAINT `fk_APPM_PLATFORM_TENANT_MAPPING_APPM_SUPPORTED_PLATFORM1` + FOREIGN KEY (`PLATFORM_ID`) + REFERENCES `APPM_PLATFORM` (`ID`) + ON DELETE CASCADE + ON UPDATE CASCADE ) + ENGINE = InnoDB + COMMENT = 'This table contains the data related relationship between application platofrm and appication mappings'; + -- ----------------------------------------------------- -- Table `APPM_APPLICATION_CATEGORY` -- ----------------------------------------------------- @@ -81,7 +99,7 @@ INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,'); -CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE_TRANSITION +CREATE TABLE IF NOT EXISTS APPM_LC_STATE_TRANSITION ( ID INT NOT NULL AUTO_INCREMENT UNIQUE, INITIAL_STATE INT, @@ -93,27 +111,27 @@ CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE_TRANSITION FOREIGN KEY (NEXT_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE ); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (1, 2, null, 'Submit for review'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (2, 1, null, 'Revoke from review'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (2, 3, '/permission/admin/manage/device-mgt/application/review', 'APPROVE'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (2, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (3, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (3, 5, null, 'PUBLISH'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (5, 6, null, 'UN PUBLISH'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (6, 5, null, 'PUBLISH'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (4, 1, null, 'Return to CREATE STATE'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (6, 1, null, 'Return to CREATE STATE'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (6, 7, null, 'Retire'); -- ----------------------------------------------------- @@ -187,7 +205,7 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_PROPERTY` ( CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_RELEASE` ( `ID` INT NOT NULL AUTO_INCREMENT UNIQUE , `VERSION_NAME` VARCHAR(100) NOT NULL, - `RESOURCE` TEXT NULL, + `RELEASE_RESOURCE` TEXT NULL, `RELEASE_CHANNEL` VARCHAR(50) DEFAULT 'ALPHA', `RELEASE_DETAILS` TEXT NULL, `CREATED_AT` DATETIME NOT NULL, @@ -298,24 +316,6 @@ CREATE TABLE IF NOT EXISTS `APPM_COMMENT` ( COMMENT = 'This table contains the data related to the application comments'; --- ----------------------------------------------------- --- Table `APPM_PLATFORM_TENENT_MAPPING` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `APPM_PLATFORM_TENANT_MAPPING` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `PLATFORM_ID` INT NOT NULL, - `TENANT_ID` INT NOT NULL, - PRIMARY KEY (`ID`, `PLATFORM_ID`), - INDEX `FK_PLATFROM_TENANT_MAPPING_PLATFORM` (`PLATFORM_ID` ASC), - CONSTRAINT `fk_APPM_PLATFORM_TENANT_MAPPING_APPM_SUPPORTED_PLATFORM1` - FOREIGN KEY (`PLATFORM_ID`) - REFERENCES `APPM_PLATFORM` (`ID`) - ON DELETE CASCADE - ON UPDATE CASCADE ) - ENGINE = InnoDB - COMMENT = 'This table contains the data related relationship between application platofrm and appication mappings'; - - -- ----------------------------------------------------- -- Table `APPM_PLATFORM_TAG` -- ----------------------------------------------------- diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql index 4489a049877..174b1d6fc5d 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql @@ -78,3 +78,278 @@ CREATE OR REPLACE TRIGGER APPM_TENANT_MAPPING_TRIG CREATE INDEX FK_PLATFROM_TENANT_MAPPING ON APPM_PLATFORM_TENANT_MAPPING(PLATFORM_ID ASC) / + + +-- ----------------------------------------------------- +-- Table APPM_APPLICATION_CATEGORY +-- ----------------------------------------------------- +CREATE TABLE APPM_APPLICATION_CATEGORY ( + ID INT, + NAME VARCHAR(100) NOT NULL, + DESCRIPTION VARCHAR(2048) NULL, + PUBLISHED NUMBER(1) NULL, + PRIMARY KEY (ID)) +/ + +CREATE SEQUENCE APPM_APPLICATION_CATEGORY_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER APPM_APPLICATION_CATEGORY_TRIG + BEFORE INSERT + ON APPM_APPLICATION_CATEGORY + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT APPM_APPLICATION_CATEGORY_SEQ.nextval INTO :NEW.ID FROM dual; + END; +/ + +INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION, PUBLISHED) VALUES ('Enterprise', +'Enterprise level applications which the artifacts need to be provided', 1) +/ +INSERT INTO APPM_APPLICATION_CATEGORY (NAME, DESCRIPTION, PUBLISHED) VALUES ('Public', +'Public category in which the application need to be downloaded from the public application store', 1) +/ + +-- ----------------------------------------------------- +-- Table APPM_LIFECYCLE_STATE +-- ----------------------------------------------------- +CREATE TABLE APPM_LIFECYCLE_STATE ( + ID INT, + NAME VARCHAR(100) NOT NULL, + IDENTIFIER VARCHAR(100) NOT NULL, + DESCRIPTION VARCHAR(2048) NULL, + PRIMARY KEY (ID)) +/ + +CREATE INDEX LIFECYCLE_STATE_ID_UNIQUE ON APPM_LIFECYCLE_STATE(IDENTIFIER ASC) +/ + +CREATE SEQUENCE APPM_LIFECYCLE_STATE_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER APPM_LIFECYCLE_STATE_TRIG + BEFORE INSERT + ON APPM_LIFECYCLE_STATE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT APPM_LIFECYCLE_STATE_SEQ.nextval INTO :NEW.ID FROM dual; + END; +/ + +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) VALUES ('CREATED', 'CREATED', +'Application creation initial state') +/ + +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('IN REVIEW', 'IN REVIEW', 'Application is in in-review state') +/ + +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('APPROVED', 'APPROVED', 'State in which Application is approved after reviewing.') +/ + +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('REJECTED', 'REJECTED', 'State in which Application is rejected after reviewing.') +/ + +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('PUBLISHED', 'PUBLISHED', 'State in which Application is in published state.') +/ + +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('UNPUBLISHED', 'UNPUBLISHED', 'State in which Application is in un published state.') +/ + +INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) +VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,') +/ + +CREATE TABLE APPM_LC_STATE_TRANSITION ( + ID INT UNIQUE, + INITIAL_STATE INT, + NEXT_STATE INT, + PERMISSION VARCHAR(1024), + DESCRIPTION VARCHAR(2048), + PRIMARY KEY (INITIAL_STATE, NEXT_STATE), + FOREIGN KEY (INITIAL_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE, + FOREIGN KEY (NEXT_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE +) +/ + +CREATE SEQUENCE APPM_LC_STATE_TRANSITION_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER APPM_LC_STATE_TRANSITION_TRIG + BEFORE INSERT + ON APPM_LC_STATE_TRANSITION + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT APPM_LC_STATE_TRANSITION_SEQ.nextval INTO :NEW.ID FROM dual; + END; +/ + +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (1, 2, null, 'Submit for review') +/ +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (2, 1, null, 'Revoke from review') +/ +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (2, 3, '/permission/admin/manage/device-mgt/application/review', 'APPROVE') +/ +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (2, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT') +/ +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (3, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT') +/ +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (3, 5, null, 'PUBLISH') +/ +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (5, 6, null, 'UN PUBLISH') +/ +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (6, 5, null, 'PUBLISH') +/ +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (4, 1, null, 'Return to CREATE STATE') +/ +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (6, 1, null, 'Return to CREATE STATE') +/ +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES + (6, 7, null, 'Retire') +/ + +-- ----------------------------------------------------- +-- Table APPM_APPLICATION +-- ----------------------------------------------------- +CREATE TABLE APPM_APPLICATION ( + ID INT UNIQUE, + UUID VARCHAR(100) NOT NULL, + IDENTIFIER VARCHAR(255) NULL, + NAME VARCHAR(100) NOT NULL, + SHORT_DESCRIPTION VARCHAR(255) NULL, + DESCRIPTION VARCHAR(2048) NULL, + VIDEO_NAME VARCHAR(100) NULL, + SCREEN_SHOT_COUNT INT DEFAULT 0, + CREATED_BY VARCHAR(255) NULL, + CREATED_AT TIMESTAMP NOT NULL, + MODIFIED_AT TIMESTAMP NULL, + IS_FREE NUMBER(1) NULL, + PAYMENT_CURRENCY VARCHAR(45) NULL, + PAYMENT_PRICE DECIMAL(10,2) NULL, + APPLICATION_CATEGORY_ID INT NOT NULL, + LIFECYCLE_STATE_ID INT NOT NULL, + LIFECYCLE_STATE_MODIFIED_BY VARCHAR(255) NULL, + LIFECYCLE_STATE_MODIFIED_AT TIMESTAMP NULL, + TENANT_ID INT NULL, + PLATFORM_ID INT NOT NULL, + PRIMARY KEY (ID, APPLICATION_CATEGORY_ID, LIFECYCLE_STATE_ID, PLATFORM_ID), + CONSTRAINT FK_APP_APP_CATEGORY FOREIGN KEY (APPLICATION_CATEGORY_ID) REFERENCES APPM_APPLICATION_CATEGORY (ID), + CONSTRAINT FK_APP_LIFECYCLE_STATE FOREIGN KEY (LIFECYCLE_STATE_ID) REFERENCES APPM_LIFECYCLE_STATE (ID), + CONSTRAINT FK_APPM_APP_PLATFORM FOREIGN KEY (PLATFORM_ID) REFERENCES APPM_PLATFORM (ID)) +/ + +CREATE INDEX UUID_UNIQUE ON APPM_APPLICATION(UUID ASC) +/ + +CREATE INDEX FK_APP_APP_CATEGORY ON APPM_APPLICATION(APPLICATION_CATEGORY_ID ASC) +/ + +CREATE INDEX FK_APP_LIFECYCLE_STATE ON APPM_APPLICATION(LIFECYCLE_STATE_ID ASC) +/ + +CREATE INDEX FK_APPM_APP_PLATFORM ON APPM_APPLICATION(PLATFORM_ID ASC) +/ + +CREATE SEQUENCE APPM_APPLICATION_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ + +CREATE OR REPLACE TRIGGER APPM_APPLICATION_TRIG + BEFORE INSERT + ON APPM_APPLICATION + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT APPM_APPLICATION_SEQ.nextval INTO :NEW.ID FROM dual; + END; +/ + +-- ----------------------------------------------------- +-- Table APPM_APPLICATION_PROPERTY +-- ----------------------------------------------------- +CREATE TABLE APPM_APPLICATION_PROPERTY ( + PROP_KEY VARCHAR(255) NOT NULL, + PROP_VAL VARCHAR(2048) NULL, + APPLICATION_ID INT NOT NULL, + PRIMARY KEY (PROP_KEY, APPLICATION_ID), + CONSTRAINT FK_APP_PROPERTY_APP + FOREIGN KEY (APPLICATION_ID) + REFERENCES APPM_APPLICATION (ID)) +/ + +CREATE INDEX FK_APP_PROPERTY_APP ON APPM_APPLICATION_PROPERTY(APPLICATION_ID ASC) +/ + +-- ----------------------------------------------------- +-- Table APPM_APPLICATION_RELEASE +-- ----------------------------------------------------- +CREATE TABLE APPM_APPLICATION_RELEASE ( + ID INT UNIQUE , + VERSION_NAME VARCHAR(100) NOT NULL, + RELEASE_RESOURCE VARCHAR(2048) NULL, + RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA', + RELEASE_DETAILS VARCHAR(2048) NULL, + CREATED_AT TIMESTAMP NOT NULL, + APPM_APPLICATION_ID INT NOT NULL, + IS_DEFAULT NUMBER(1) NULL, + PRIMARY KEY (APPM_APPLICATION_ID, VERSION_NAME), + CONSTRAINT FK_APP_VERSION_APP + FOREIGN KEY (APPM_APPLICATION_ID) + REFERENCES APPM_APPLICATION (ID)) +/ + +CREATE INDEX FK_APP_VERSION_APP ON APPM_APPLICATION_RELEASE(APPM_APPLICATION_ID ASC) +/ + +CREATE SEQUENCE APPM_APPLICATION_RELEASE_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER APPM_APPLICATION_RELEASE_TRIG + BEFORE INSERT + ON APPM_APPLICATION_RELEASE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT APPM_APPLICATION_RELEASE_SEQ.nextval INTO :NEW.ID FROM dual; + END; +/ + +-- ----------------------------------------------------- +-- Table APPM_RELEASE_PROPERTY +-- ----------------------------------------------------- +CREATE TABLE APPM_RELEASE_PROPERTY ( + PROP_KEY VARCHAR(255) NOT NULL, + PROP_VALUE VARCHAR(2048) NULL, + APPLICATION_RELEASE_ID INT NOT NULL, + PRIMARY KEY (PROP_KEY, APPLICATION_RELEASE_ID), + CONSTRAINT FK_RP_APP_RELEASE + FOREIGN KEY (APPLICATION_RELEASE_ID) + REFERENCES APPM_APPLICATION_RELEASE (ID)) +/ + +CREATE INDEX FK_RP_APP_RELEASE ON APPM_RELEASE_PROPERTY(APPLICATION_RELEASE_ID ASC) +/ + +CREATE TABLE APPM_APPLICATION_TAG ( + NAME VARCHAR(45) NOT NULL, + APPLICATION_ID INT NOT NULL, + PRIMARY KEY (APPLICATION_ID, NAME), + CONSTRAINT FK_APPM_APP_TAG_APP + FOREIGN KEY (APPLICATION_ID) + REFERENCES APPM_APPLICATION (ID)) +/ + +CREATE INDEX FK_APPM_APP_TAG_APP ON APPM_APPLICATION_TAG(APPLICATION_ID ASC) +/ diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql index 7a309c09fb4..7259c736bf5 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql @@ -91,13 +91,13 @@ VALUES ('UNPUBLISHED', 'UNPUBLISHED', 'State in which Application is in un publi INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,'); -DROP TABLE IF EXISTS APPM_LIFECYCLE_STATE_TRANSITION; -DROP SEQUENCE IF EXISTS APPM_LIFECYCLE_STATE_TRANSITION_PK_SEQ; -CREATE SEQUENCE APPM_LIFECYCLE_STATE_TRANSITION_PK_SEQ; +DROP TABLE IF EXISTS APPM_LC_STATE_TRANSITION; +DROP SEQUENCE IF EXISTS APPM_LC_STATE_TRANSITION_PK_SEQ; +CREATE SEQUENCE APPM_LC_STATE_TRANSITION_PK_SEQ; -CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE_TRANSITION +CREATE TABLE IF NOT EXISTS APPM_LC_STATE_TRANSITION ( - ID INT DEFAULT NEXTVAL('APPM_LIFECYCLE_STATE_TRANSITION_PK_SEQ'), + ID INT DEFAULT NEXTVAL('APPM_LC_STATE_TRANSITION_PK_SEQ'), INITIAL_STATE INT, NEXT_STATE INT, PERMISSION VARCHAR(1024), @@ -107,27 +107,27 @@ CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE_TRANSITION FOREIGN KEY (NEXT_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE ); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (1, 2, null, 'Submit for review'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (2, 1, null, 'Revoke from review'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (2, 3, '/permission/admin/manage/device-mgt/application/review', 'APPROVE'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (2, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (3, 4, '/permission/admin/manage/device-mgt/application/review', 'REJECT'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (3, 5, null, 'PUBLISH'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (5, 6, null, 'UN PUBLISH'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (6, 5, null, 'PUBLISH'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (4, 1, null, 'Return to CREATE STATE'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (6, 1, null, 'Return to CREATE STATE'); -INSERT INTO APPM_LIFECYCLE_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES +INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESCRIPTION) VALUES (6, 7, null, 'Retire'); @@ -212,7 +212,7 @@ CREATE SEQUENCE APPM_APPLICATION_RELEASE_PK_SEQ; CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE ( ID INT DEFAULT NEXTVAL('APPM_APPLICATION_RELEASE_PK_SEQ') UNIQUE, VERSION_NAME VARCHAR(100) NOT NULL, - RESOURCE TEXT NULL, + RELEASE_RESOURCE TEXT NULL, RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA', RELEASE_DETAILS TEXT NULL, CREATED_AT TIMESTAMP NOT NULL,