Merge pull request #952 from Megala21/appm_new

Adding oracle support to application and application release
feature/appm-store/pbac
Megala Uthayakumar 7 years ago committed by GitHub
commit 05e220477d

@ -28,6 +28,7 @@ import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
import org.wso2.carbon.device.application.mgt.core.dao.PlatformDAO; 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.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.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.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.OracleMsSQLPlatformDAOImpl; import org.wso2.carbon.device.application.mgt.core.dao.impl.platform.OracleMsSQLPlatformDAOImpl;
@ -62,6 +63,8 @@ public class DAOFactory {
case Constants.DataBaseTypes.DB_TYPE_MYSQL: case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
return new GenericApplicationDAOImpl(); return new GenericApplicationDAOImpl();
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new OracleApplicationDAOImpl();
default: default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
} }
@ -92,6 +95,7 @@ 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:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new GenericLifecycleStateImpl(); return new GenericLifecycleStateImpl();
default: default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
@ -110,6 +114,7 @@ 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:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL: case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new GenericApplicationReleaseDAOImpl(); return new GenericApplicationReleaseDAOImpl();
default: default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);

@ -63,6 +63,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql = "";
String generatedColumns[] = { "ID" };
boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported(); boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported();
int index = 0; int index = 0;
try { try {
@ -73,7 +74,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "LIFECYCLE_STATE_MODIFIED_AT, LIFECYCLE_STATE_MODIFIED_BY) VALUES " + "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.getUuid());
stmt.setString(++index, application.getIdentifier()); stmt.setString(++index, application.getIdentifier());
stmt.setString(++index, application.getName()); stmt.setString(++index, application.getName());
@ -133,35 +134,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
sql += "SELECT APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER, " stmt = this.generateGetApplicationsStatement(filter, conn, tenantId);
+ "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());
rs = stmt.executeQuery(); rs = stmt.executeQuery();
int length = 0; int length = 0;
@ -204,6 +177,51 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
return applicationList; 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 @Override
public int getApplicationCount(Filter filter) throws ApplicationManagementDAOException { public int getApplicationCount(Filter filter) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -266,13 +284,17 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
sql += "SELECT APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER, " sql += "SELECT APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER, CAT.ID AS CAT_ID, "
+ "CAT.ID AS CAT_ID, CAT.NAME AS CAT_NAME, LS.NAME AS LS_NAME, LS.IDENTIFIER AS LS_IDENTIFIER, " + "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 " + "LS.DESCRIPTION AS LS_DESCRIPTION "
+ "APL ON APP.PLATFORM_ID = APL.ID INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON " + "FROM APPM_APPLICATION APP "
+ "APP.APPLICATION_CATEGORY_ID = CAT.ID INNER JOIN APPM_LIFECYCLE_STATE AS " + "INNER JOIN APPM_PLATFORM APL "
+ "LS ON APP.LIFECYCLE_STATE_ID = LS.ID WHERE UUID = ? AND APP.TENANT_ID = ? "; + "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 = conn.prepareStatement(sql);
stmt.setString(1, uuid); stmt.setString(1, uuid);
@ -308,7 +330,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
return application; return application;
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException( 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) { } catch (JSONException e) {
throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e); throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
@ -360,7 +383,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
ResultSet resultSet = null; ResultSet resultSet = null;
String sql = "SELECT STATE.NAME, TRANSITION.DESCRIPTION, TRANSITION.PERMISSION FROM ( SELECT * FROM " 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 = ?)) " + "INITIAL_STATE = (SELECT LIFECYCLE_STATE_ID FROM APPM_APPLICATION WHERE UUID = ? AND TENANT_ID = ?)) "
+ "TRANSITION ON TRANSITION.NEXT_STATE = STATE.ID"; + "TRANSITION ON TRANSITION.NEXT_STATE = STATE.ID";

@ -53,13 +53,13 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
if (applicationRelease.isDefault()) { 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 (?, ?, ?, ?, ?, ?, ?)"; + "RELEASE_DETAILS, CREATED_AT, APPM_APPLICATION_ID, IS_DEFAULT) values (?, ?, ?, ?, ?, ?, ?)";
int index = 0; int index = 0;
String generatedColumns[] = { "ID" };
try { try {
connection = this.getDBConnection(); 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.getVersionName());
statement.setString(++index, applicationRelease.getResource()); statement.setString(++index, applicationRelease.getResource());
statement.setString(++index, String.valueOf(applicationRelease.getReleaseChannel())); statement.setString(++index, String.valueOf(applicationRelease.getReleaseChannel()));
@ -113,7 +113,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
applicationRelease.setCreatedAt(resultSet.getDate("CREATED_AT")); applicationRelease.setCreatedAt(resultSet.getDate("CREATED_AT"));
applicationRelease.setReleaseChannel(resultSet.getString("RELEASE_CHANNEL")); applicationRelease.setReleaseChannel(resultSet.getString("RELEASE_CHANNEL"));
applicationRelease.setReleaseDetails(resultSet.getString("RELEASE_DETAILS")); 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=?"; sql = "SELECT * FROM APPM_RELEASE_PROPERTY WHERE APPLICATION_RELEASE_ID=?";
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
@ -166,7 +166,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
applicationRelease.setCreatedAt(resultSet.getDate("CREATED_AT")); applicationRelease.setCreatedAt(resultSet.getDate("CREATED_AT"));
applicationRelease.setReleaseChannel(resultSet.getString("RELEASE_CHANNEL")); applicationRelease.setReleaseChannel(resultSet.getString("RELEASE_CHANNEL"));
applicationRelease.setReleaseDetails(resultSet.getString("RELEASE_DETAILS")); 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= ?"; sql = "SELECT * FROM APPM_RELEASE_PROPERTY WHERE APPLICATION_RELEASE_ID= ?";
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
@ -199,7 +199,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
throws ApplicationManagementDAOException { throws ApplicationManagementDAOException {
Connection connection; Connection connection;
PreparedStatement statement = null; 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 " + "(?, RELEASE_CHANNEL), RELEASE_DETAILS = IFNULL (?, RELEASE_DETAILS), IS_DEFAULT = IFNULL "
+ "(?, IS_DEFAULT) WHERE APPM_APPLICATION_ID = ? AND VERSION_NAME = ?"; + "(?, IS_DEFAULT) WHERE APPM_APPLICATION_ID = ? AND VERSION_NAME = ?";
try { try {

@ -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;
}
}

@ -80,7 +80,7 @@ INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION)
VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,'); 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, ID INT NOT NULL AUTO_INCREMENT UNIQUE,
INITIAL_STATE INT, INITIAL_STATE INT,
@ -92,27 +92,27 @@ CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE_TRANSITION
FOREIGN KEY (NEXT_STATE) REFERENCES APPM_LIFECYCLE_STATE(ID) ON DELETE CASCADE 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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (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 ( CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
VERSION_NAME VARCHAR(100) NOT NULL, VERSION_NAME VARCHAR(100) NOT NULL,
RESOURCE TEXT NULL, RELEASE_RESOURCE TEXT NULL,
RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA', RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA',
RELEASE_DETAILS TEXT NULL, RELEASE_DETAILS TEXT NULL,
CREATED_AT DATETIME NOT NULL, CREATED_AT DATETIME NOT NULL,

@ -37,6 +37,24 @@ FOREIGN KEY(PLATFORM_ID) REFERENCES APPM_PLATFORM(ID) ON DELETE CASCADE,
PRIMARY KEY (ID, PLATFORM_ID, PROP_NAME) 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` -- 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,'); 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, ID INT NOT NULL AUTO_INCREMENT UNIQUE,
INITIAL_STATE INT, 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 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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (6, 7, null, 'Retire');
-- ----------------------------------------------------- -- -----------------------------------------------------
@ -188,7 +206,7 @@ CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_PROPERTY` (
CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_RELEASE` ( CREATE TABLE IF NOT EXISTS `APPM_APPLICATION_RELEASE` (
`ID` INT NOT NULL AUTO_INCREMENT UNIQUE , `ID` INT NOT NULL AUTO_INCREMENT UNIQUE ,
`VERSION_NAME` VARCHAR(100) NOT NULL, `VERSION_NAME` VARCHAR(100) NOT NULL,
`RESOURCE` TEXT NULL, `RELEASE_RESOURCE` TEXT NULL,
`RELEASE_CHANNEL` VARCHAR(50) DEFAULT 'ALPHA', `RELEASE_CHANNEL` VARCHAR(50) DEFAULT 'ALPHA',
`RELEASE_DETAILS` TEXT NULL, `RELEASE_DETAILS` TEXT NULL,
`CREATED_AT` DATETIME NOT NULL, `CREATED_AT` DATETIME NOT NULL,
@ -293,24 +311,6 @@ CREATE TABLE IF NOT EXISTS `APPM_COMMENT` (
COMMENT = 'This table contains the data related to the application comments'; 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` -- Table `APPM_PLATFORM_TAG`
-- ----------------------------------------------------- -- -----------------------------------------------------

@ -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) 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)
/

@ -91,13 +91,13 @@ VALUES ('UNPUBLISHED', 'UNPUBLISHED', 'State in which Application is in un publi
INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION) INSERT INTO APPM_LIFECYCLE_STATE (NAME, IDENTIFIER, DESCRIPTION)
VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,'); VALUES ('RETIRED', 'RETIRED', 'Retiring an application to indicate end of life state,');
DROP TABLE IF EXISTS APPM_LIFECYCLE_STATE_TRANSITION; DROP TABLE IF EXISTS APPM_LC_STATE_TRANSITION;
DROP SEQUENCE IF EXISTS APPM_LIFECYCLE_STATE_TRANSITION_PK_SEQ; DROP SEQUENCE IF EXISTS APPM_LC_STATE_TRANSITION_PK_SEQ;
CREATE SEQUENCE APPM_LIFECYCLE_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, INITIAL_STATE INT,
NEXT_STATE INT, NEXT_STATE INT,
PERMISSION VARCHAR(1024), 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 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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (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'); (6, 7, null, 'Retire');
@ -213,7 +213,7 @@ CREATE SEQUENCE APPM_APPLICATION_RELEASE_PK_SEQ;
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE ( CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE (
ID INT DEFAULT NEXTVAL('APPM_APPLICATION_RELEASE_PK_SEQ') UNIQUE, ID INT DEFAULT NEXTVAL('APPM_APPLICATION_RELEASE_PK_SEQ') UNIQUE,
VERSION_NAME VARCHAR(100) NOT NULL, VERSION_NAME VARCHAR(100) NOT NULL,
RESOURCE TEXT NULL, RELEASE_RESOURCE TEXT NULL,
RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA', RELEASE_CHANNEL VARCHAR(50) DEFAULT 'ALPHA',
RELEASE_DETAILS TEXT NULL, RELEASE_DETAILS TEXT NULL,
CREATED_AT TIMESTAMP NOT NULL, CREATED_AT TIMESTAMP NOT NULL,

Loading…
Cancel
Save