From c0e5edded2d06261c83b25687b6beb370cad2b29 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Thu, 17 Mar 2022 23:39:31 +0530 Subject: [PATCH] Add sql scripts to favourites table Fix error logging in DAO layer --- .../application/GenericApplicationDAOImpl.java | 2 +- .../dbscripts/cdm/application-mgt/h2.sql | 14 ++++++++++++++ .../dbscripts/cdm/application-mgt/mssql.sql | 16 +++++++++++++++- .../dbscripts/cdm/application-mgt/mysql.sql | 16 +++++++++++++++- .../dbscripts/cdm/application-mgt/oracle.sql | 12 ++++++++++++ .../dbscripts/cdm/application-mgt/postgresql.sql | 15 +++++++++++++++ 6 files changed, 72 insertions(+), 3 deletions(-) diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 431369d449..679f2ed713 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -823,7 +823,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "Error occurred while obtaining the DB connection to check whether the application with the id " + String msg = "SQL Error occurred while checking whether the application with the id " + appId + " is a favourite app. executed query " + sql; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); diff --git a/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql b/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql index 150480f68d..6b07c6b757 100644 --- a/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql +++ b/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql @@ -278,3 +278,17 @@ CREATE TABLE IF NOT EXISTS AP_SCHEDULED_SUBSCRIPTION( FOREIGN KEY (APPLICATION_UUID) REFERENCES AP_APP_RELEASE (UUID) ON DELETE NO ACTION ON UPDATE NO ACTION ); + +-- ----------------------------------------------------- +-- Table AP_APP_FAVOURITES +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_APP_FAVOURITES( + ID INTEGER NOT NULL AUTO_INCREMENT, + AP_APP_ID INTEGER NOT NULL, + USER_NAME VARCHAR(100) NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY(ID), + CONSTRAINT AP_APP_FAVOURITES_AP_APP_ID_fk + FOREIGN KEY (AP_APP_ID) + REFERENCES AP_APP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); diff --git a/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql b/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql index 5d29525a8c..f1a4195699 100644 --- a/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql +++ b/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql @@ -278,4 +278,18 @@ CREATE TABLE AP_SCHEDULED_SUBSCRIPTION( CONSTRAINT fk_AP_SCHEDULED_SUBSCRIPTION_AP_APP_RELEASE FOREIGN KEY (APPLICATION_UUID) REFERENCES AP_APP_RELEASE (UUID) ON DELETE NO ACTION ON UPDATE NO ACTION -); \ No newline at end of file +); + +-- ----------------------------------------------------- +-- Table AP_APP_FAVOURITES +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_APP_FAVOURITES( + ID INTEGER NOT NULL IDENTITY, + AP_APP_ID INTEGER NOT NULL, + USER_NAME VARCHAR(100) NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY(ID), + CONSTRAINT AP_APP_FAVOURITES_AP_APP_ID_fk + FOREIGN KEY (AP_APP_ID) + REFERENCES AP_APP (ID) +); diff --git a/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql b/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql index 110ccdc606..375621018e 100644 --- a/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql +++ b/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql @@ -274,4 +274,18 @@ CREATE TABLE IF NOT EXISTS AP_SCHEDULED_SUBSCRIPTION( SCHEDULED_TIMESTAMP TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, DELETED BOOLEAN, PRIMARY KEY (ID) -); \ No newline at end of file +); + +-- ----------------------------------------------------- +-- Table AP_APP_FAVOURITES +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_APP_FAVOURITES( + ID INTEGER NOT NULL AUTO_INCREMENT, + AP_APP_ID INTEGER NOT NULL, + USER_NAME VARCHAR(100) NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY(ID), + CONSTRAINT AP_APP_FAVOURITES_AP_APP_ID_fk + FOREIGN KEY (AP_APP_ID) + REFERENCES AP_APP (ID) +); diff --git a/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql b/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql index edbc277ab2..b15ef930f6 100644 --- a/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql +++ b/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql @@ -382,3 +382,15 @@ CREATE TABLE AP_SCHEDULED_SUBSCRIPTION ( REFERENCES AP_APP_RELEASE (UUID) ) / + +CREATE TABLE IF NOT EXISTS AP_APP_FAVOURITES( + ID number GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL, + AP_APP_ID INTEGER NOT NULL, + USER_NAME VARCHAR(100) NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY(ID), + CONSTRAINT AP_APP_FAVOURITES_AP_APP_ID_fk + FOREIGN KEY (AP_APP_ID) + REFERENCES AP_APP (ID) +) +/ diff --git a/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql b/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql index c799b03245..e5f83986d6 100644 --- a/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql +++ b/features/application-mgt/io.entgra.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql @@ -305,3 +305,18 @@ CREATE TABLE IF NOT EXISTS AP_SCHEDULED_SUBSCRIPTION( DELETED BOOLEAN, PRIMARY KEY (ID) ); + + +-- ----------------------------------------------------- +-- Table AP_APP_FAVOURITES +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_APP_FAVOURITES( + ID INTEGER NOT NULL DEFAULT NEXTVAL ('AP_APP_FAVOURITES_seq'), + AP_APP_ID INTEGER NOT NULL, + USER_NAME VARCHAR(100) NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY(ID), + CONSTRAINT AP_APP_FAVOURITES_AP_APP_ID_fk + FOREIGN KEY (AP_APP_ID) + REFERENCES AP_APP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +);