|
|
@ -236,41 +236,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String getUuidOfLatestRelease(int appId) throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Getting UUID from the latest app release");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
|
|
|
String sql = "";
|
|
|
|
|
|
|
|
String uuId = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
|
|
|
sql += "SELECT APP_RELEASE.UUID AS UUID FROM AP_APP_RELEASE AS APP_RELEASE, AP_APP_LIFECYCLE_STATE "
|
|
|
|
|
|
|
|
+ "AS LIFECYCLE WHERE APP_RELEASE.AP_APP_ID=? AND APP_RELEASE.ID = LIFECYCLE.AP_APP_RELEASE_ID "
|
|
|
|
|
|
|
|
+ "AND LIFECYCLE.CURRENT_STATE = ? ORDER BY APP_RELEASE.ID DESC;";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
stmt.setInt(1, appId);
|
|
|
|
|
|
|
|
stmt.setString(2, AppLifecycleState.PUBLISHED.toString());
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
uuId = rs.getString("UUID");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return uuId;
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while getting uuid of latest app release", e);
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection for "
|
|
|
|
|
|
|
|
+ "getting app release id", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DAOUtil.cleanupResources(stmt, rs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int getApplicationCount(Filter filter,int deviceTypeId, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
public int getApplicationCount(Filter filter,int deviceTypeId, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
@ -372,75 +337,73 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ApplicationDTO getApplication(String releaseUuid, int tenantId)
|
|
|
|
public ApplicationDTO getApplication(String releaseUuid, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Getting application with the release UUID: " + releaseUuid + " from the database");
|
|
|
|
log.debug("Getting application with the release UUID: " + releaseUuid + " from the database");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Connection conn;
|
|
|
|
String sql = "SELECT "
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
+ "AP_APP.ID AS APP_ID, "
|
|
|
|
ResultSet rs = null;
|
|
|
|
+ "AP_APP.NAME AS APP_NAME, "
|
|
|
|
|
|
|
|
+ "AP_APP.DESCRIPTION AS APP_DESCRIPTION, "
|
|
|
|
|
|
|
|
+ "AP_APP.TYPE AS APP_TYPE, "
|
|
|
|
|
|
|
|
+ "AP_APP.STATUS AS APP_STATUS, "
|
|
|
|
|
|
|
|
+ "AP_APP.SUB_TYPE AS APP_SUB_TYPE, "
|
|
|
|
|
|
|
|
+ "AP_APP.CURRENCY AS APP_CURRENCY, "
|
|
|
|
|
|
|
|
+ "AP_APP.RATING AS APP_RATING, "
|
|
|
|
|
|
|
|
+ "AP_APP.DEVICE_TYPE_ID AS APP_DEVICE_TYPE_ID, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.ID AS RELEASE_ID, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.DESCRIPTION AS RELEASE_DESCRIPTION, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.VERSION AS RELEASE_VERSION, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.UUID AS RELEASE_UUID, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RELEASE_TYPE AS RELEASE_TYPE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.INSTALLER_LOCATION AS AP_RELEASE_STORED_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.ICON_LOCATION AS AP_RELEASE_ICON_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.BANNER_LOCATION AS AP_RELEASE_BANNER_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_1_LOCATION AS AP_RELEASE_SC1, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_2_LOCATION AS AP_RELEASE_SC2, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_3_LOCATION AS AP_RELEASE_SC3, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_HASH_VALUE AS RELEASE_HASH_VALUE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_PRICE AS RELEASE_PRICE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_META_INFO AS RELEASE_META_INFO, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.PACKAGE_NAME AS PACKAGE_NAME, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RATING AS RELEASE_RATING, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT "
|
|
|
|
|
|
|
|
+ "FROM AP_APP "
|
|
|
|
|
|
|
|
+ "INNER JOIN AP_APP_RELEASE ON "
|
|
|
|
|
|
|
|
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID AND "
|
|
|
|
|
|
|
|
+ "AP_APP.TENANT_ID = AP_APP_RELEASE.TENANT_ID "
|
|
|
|
|
|
|
|
+ "WHERE "
|
|
|
|
|
|
|
|
+ "AP_APP.ID = (SELECT AP_APP_RELEASE.AP_APP_ID FROM AP_APP_RELEASE WHERE AP_APP_RELEASE.UUID = ?) "
|
|
|
|
|
|
|
|
+ "AND AP_APP.TENANT_ID = ?";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
String sql = "SELECT "
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)){
|
|
|
|
+ "AP_APP.ID AS APP_ID, "
|
|
|
|
stmt.setString(1, releaseUuid);
|
|
|
|
+ "AP_APP.NAME AS APP_NAME, "
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
+ "AP_APP.DESCRIPTION AS APP_DESCRIPTION, "
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
+ "AP_APP.TYPE AS APP_TYPE, "
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
+ "AP_APP.STATUS AS APP_STATUS, "
|
|
|
|
log.debug("Successfully retrieved basic details of the application for the application "
|
|
|
|
+ "AP_APP.SUB_TYPE AS APP_SUB_TYPE, "
|
|
|
|
+ "release UUID: " + releaseUuid);
|
|
|
|
+ "AP_APP.CURRENCY AS APP_CURRENCY, "
|
|
|
|
}
|
|
|
|
+ "AP_APP.RATING AS APP_RATING, "
|
|
|
|
return DAOUtil.loadApplication(rs);
|
|
|
|
+ "AP_APP.DEVICE_TYPE_ID AS APP_DEVICE_TYPE_ID, "
|
|
|
|
}
|
|
|
|
+ "AP_APP_RELEASE.ID AS RELEASE_ID, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.DESCRIPTION AS RELEASE_DESCRIPTION, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.VERSION AS RELEASE_VERSION, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.UUID AS RELEASE_UUID, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RELEASE_TYPE AS RELEASE_TYPE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.INSTALLER_LOCATION AS AP_RELEASE_STORED_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.ICON_LOCATION AS AP_RELEASE_ICON_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.BANNER_LOCATION AS AP_RELEASE_BANNER_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_1_LOCATION AS AP_RELEASE_SC1, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_2_LOCATION AS AP_RELEASE_SC2, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_3_LOCATION AS AP_RELEASE_SC3, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_HASH_VALUE AS RELEASE_HASH_VALUE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_PRICE AS RELEASE_PRICE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_META_INFO AS RELEASE_META_INFO, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.PACKAGE_NAME AS PACKAGE_NAME, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RATING AS RELEASE_RATING, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT "
|
|
|
|
|
|
|
|
+ "FROM AP_APP "
|
|
|
|
|
|
|
|
+ "INNER JOIN AP_APP_RELEASE ON "
|
|
|
|
|
|
|
|
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID AND "
|
|
|
|
|
|
|
|
+ "AP_APP.TENANT_ID = AP_APP_RELEASE.TENANT_ID "
|
|
|
|
|
|
|
|
+ "WHERE "
|
|
|
|
|
|
|
|
+ "AP_APP.ID = (SELECT AP_APP_RELEASE.AP_APP_ID FROM AP_APP_RELEASE WHERE AP_APP_RELEASE.UUID = ?) "
|
|
|
|
|
|
|
|
+ "AND AP_APP.TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
stmt.setString(1, releaseUuid);
|
|
|
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Successfully retrieved basic details of the application for the application release UUID: "
|
|
|
|
|
|
|
|
+ releaseUuid);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return DAOUtil.loadApplication(rs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
|
|
|
"Error occurred while getting application details with app release uuid " + releaseUuid +
|
|
|
|
|
|
|
|
" while executing query.", e);
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
|
|
String msg = "Error occurred while obtaining the DB connection to get application for application release "
|
|
|
|
|
|
|
|
+ "UUID: " + releaseUuid;
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while getting application details with app release uuid " + releaseUuid
|
|
|
|
|
|
|
|
+ " while executing query. Executed query: " + sql;
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (UnexpectedServerErrorException e) {
|
|
|
|
} catch (UnexpectedServerErrorException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
|
|
String msg = "Found more than one application for application release UUID: " + releaseUuid;
|
|
|
|
} finally {
|
|
|
|
log.error(msg);
|
|
|
|
DAOUtil.cleanupResources(stmt, rs);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -450,86 +413,84 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Getting application with the id (" + applicationId + ") from the database");
|
|
|
|
log.debug("Getting application with the id (" + applicationId + ") from the database");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Connection conn;
|
|
|
|
String sql = "SELECT "
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
+ "AP_APP.ID AS APP_ID, "
|
|
|
|
ResultSet rs = null;
|
|
|
|
+ "AP_APP.NAME AS APP_NAME, "
|
|
|
|
|
|
|
|
+ "AP_APP.DESCRIPTION AS APP_DESCRIPTION, "
|
|
|
|
|
|
|
|
+ "AP_APP.TYPE AS APP_TYPE, "
|
|
|
|
|
|
|
|
+ "AP_APP.STATUS AS APP_STATUS, "
|
|
|
|
|
|
|
|
+ "AP_APP.SUB_TYPE AS APP_SUB_TYPE, "
|
|
|
|
|
|
|
|
+ "AP_APP.CURRENCY AS APP_CURRENCY, "
|
|
|
|
|
|
|
|
+ "AP_APP.RATING AS APP_RATING, "
|
|
|
|
|
|
|
|
+ "AP_APP.DEVICE_TYPE_ID AS APP_DEVICE_TYPE_ID, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.ID AS RELEASE_ID, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.DESCRIPTION AS RELEASE_DESCRIPTION, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.VERSION AS RELEASE_VERSION, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.UUID AS RELEASE_UUID, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RELEASE_TYPE AS RELEASE_TYPE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.INSTALLER_LOCATION AS AP_RELEASE_STORED_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.ICON_LOCATION AS AP_RELEASE_ICON_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.BANNER_LOCATION AS AP_RELEASE_BANNER_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_1_LOCATION AS AP_RELEASE_SC1, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_2_LOCATION AS AP_RELEASE_SC2, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_3_LOCATION AS AP_RELEASE_SC3, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_HASH_VALUE AS RELEASE_HASH_VALUE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_PRICE AS RELEASE_PRICE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_META_INFO AS RELEASE_META_INFO, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.PACKAGE_NAME AS PACKAGE_NAME, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RATING AS RELEASE_RATING, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT "
|
|
|
|
|
|
|
|
+ "FROM AP_APP "
|
|
|
|
|
|
|
|
+ "INNER JOIN AP_APP_RELEASE ON "
|
|
|
|
|
|
|
|
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID AND "
|
|
|
|
|
|
|
|
+ "AP_APP.TENANT_ID = AP_APP_RELEASE.TENANT_ID "
|
|
|
|
|
|
|
|
+ "WHERE "
|
|
|
|
|
|
|
|
+ "AP_APP.ID =? AND "
|
|
|
|
|
|
|
|
+ "AP_APP.TENANT_ID = ?";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
String sql = "SELECT "
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
+ "AP_APP.ID AS APP_ID, "
|
|
|
|
stmt.setInt(1, applicationId);
|
|
|
|
+ "AP_APP.NAME AS APP_NAME, "
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
+ "AP_APP.DESCRIPTION AS APP_DESCRIPTION, "
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
+ "AP_APP.TYPE AS APP_TYPE, "
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
+ "AP_APP.STATUS AS APP_STATUS, "
|
|
|
|
log.debug("Successfully retrieved basic details of the application with the id "
|
|
|
|
+ "AP_APP.SUB_TYPE AS APP_SUB_TYPE, "
|
|
|
|
+ applicationId);
|
|
|
|
+ "AP_APP.CURRENCY AS APP_CURRENCY, "
|
|
|
|
}
|
|
|
|
+ "AP_APP.RATING AS APP_RATING, "
|
|
|
|
return DAOUtil.loadApplication(rs);
|
|
|
|
+ "AP_APP.DEVICE_TYPE_ID AS APP_DEVICE_TYPE_ID, "
|
|
|
|
}
|
|
|
|
+ "AP_APP_RELEASE.ID AS RELEASE_ID, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.DESCRIPTION AS RELEASE_DESCRIPTION, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.VERSION AS RELEASE_VERSION, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.UUID AS RELEASE_UUID, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RELEASE_TYPE AS RELEASE_TYPE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.INSTALLER_LOCATION AS AP_RELEASE_STORED_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.ICON_LOCATION AS AP_RELEASE_ICON_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.BANNER_LOCATION AS AP_RELEASE_BANNER_LOC, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_1_LOCATION AS AP_RELEASE_SC1, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_2_LOCATION AS AP_RELEASE_SC2, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SC_3_LOCATION AS AP_RELEASE_SC3, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_HASH_VALUE AS RELEASE_HASH_VALUE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_PRICE AS RELEASE_PRICE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.APP_META_INFO AS RELEASE_META_INFO, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.PACKAGE_NAME AS PACKAGE_NAME, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RATING AS RELEASE_RATING, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
|
|
|
|
|
|
|
|
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT "
|
|
|
|
|
|
|
|
+ "FROM AP_APP "
|
|
|
|
|
|
|
|
+ "INNER JOIN AP_APP_RELEASE ON "
|
|
|
|
|
|
|
|
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID AND "
|
|
|
|
|
|
|
|
+ "AP_APP.TENANT_ID = AP_APP_RELEASE.TENANT_ID "
|
|
|
|
|
|
|
|
+ "WHERE "
|
|
|
|
|
|
|
|
+ "AP_APP.ID =? AND "
|
|
|
|
|
|
|
|
+ "AP_APP.TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
stmt.setInt(1, applicationId);
|
|
|
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Successfully retrieved basic details of the application with the id "
|
|
|
|
|
|
|
|
+ applicationId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DAOUtil.loadApplication(rs);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
|
|
|
"Error occurred while getting application details with app id " + applicationId +
|
|
|
|
|
|
|
|
" while executing query.", e);
|
|
|
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e);
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
|
|
String msg = "Error occurred while obtaining the DB connection to get application for application ID: "
|
|
|
|
|
|
|
|
+ applicationId;
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred to get application details with app id " + applicationId + " while executing "
|
|
|
|
|
|
|
|
+ "query. Query: " + sql;
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (UnexpectedServerErrorException e) {
|
|
|
|
} catch (UnexpectedServerErrorException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
|
|
String msg = "Found more than one application for application ID: " + applicationId;
|
|
|
|
} finally {
|
|
|
|
log.error(msg);
|
|
|
|
DAOUtil.cleanupResources(stmt, rs);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean updateApplication(ApplicationDTO applicationDTO, int tenantId)
|
|
|
|
public boolean updateApplication(ApplicationDTO applicationDTO, int tenantId)
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
Connection conn;
|
|
|
|
String sql = "UPDATE AP_APP AP " +
|
|
|
|
|
|
|
|
"SET " +
|
|
|
|
|
|
|
|
"AP.NAME = ?, " +
|
|
|
|
|
|
|
|
"AP.DESCRIPTION = ?, " +
|
|
|
|
|
|
|
|
"AP.SUB_TYPE = ?, " +
|
|
|
|
|
|
|
|
"AP.CURRENCY = ? " +
|
|
|
|
|
|
|
|
"WHERE AP.ID = ? AND AP.TENANT_ID = ?";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
String sql = "UPDATE AP_APP AP " +
|
|
|
|
|
|
|
|
"SET " +
|
|
|
|
|
|
|
|
"AP.NAME = ?, " +
|
|
|
|
|
|
|
|
"AP.DESCRIPTION = ?, " +
|
|
|
|
|
|
|
|
"AP.SUB_TYPE = ?, " +
|
|
|
|
|
|
|
|
"AP.CURRENCY = ? " +
|
|
|
|
|
|
|
|
"WHERE AP.ID = ? AND AP.TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
stmt.setString(1, applicationDTO.getName());
|
|
|
|
stmt.setString(1, applicationDTO.getName());
|
|
|
|
stmt.setString(2, applicationDTO.getDescription());
|
|
|
|
stmt.setString(2, applicationDTO.getDescription());
|
|
|
@ -544,7 +505,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
String msg = "Error occurred when obtaining database connection for updating the application.";
|
|
|
|
String msg = "Error occurred when executing SQL to update an application. Executed query: " + sql;
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -553,16 +514,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateApplicationRating(String uuid, double rating, int tenantId)
|
|
|
|
public void updateApplicationRating(String uuid, double rating, int tenantId)
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
Connection conn;
|
|
|
|
String sql = "UPDATE AP_APP AP " +
|
|
|
|
|
|
|
|
"SET " +
|
|
|
|
|
|
|
|
"AP.RATING = ? " +
|
|
|
|
|
|
|
|
"WHERE " +
|
|
|
|
|
|
|
|
"AP.ID = (SELECT AP_APP_ID FROM AP_APP_RELEASE WHERE UUID = ?) AND " +
|
|
|
|
|
|
|
|
"AP.TENANT_ID = ?";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
String sql = "UPDATE AP_APP AP " +
|
|
|
|
|
|
|
|
"SET " +
|
|
|
|
|
|
|
|
"AP.RATING = ? " +
|
|
|
|
|
|
|
|
"WHERE " +
|
|
|
|
|
|
|
|
"AP.ID = (SELECT AP_APP_ID FROM AP_APP_RELEASE WHERE UUID = ?) AND " +
|
|
|
|
|
|
|
|
"AP.TENANT_ID = ?";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
stmt.setDouble(1, rating);
|
|
|
|
stmt.setDouble(1, rating);
|
|
|
|
stmt.setString(2, uuid);
|
|
|
|
stmt.setString(2, uuid);
|
|
|
@ -583,22 +542,27 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void retireApplication(int appId) throws ApplicationManagementDAOException {
|
|
|
|
public void retireApplication(int appId) throws ApplicationManagementDAOException {
|
|
|
|
Connection conn;
|
|
|
|
String sql = "UPDATE "
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
+ "AP_APP "
|
|
|
|
|
|
|
|
+ "SET STATUS = ? "
|
|
|
|
|
|
|
|
+ "WHERE ID = ? ";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
String sql = "UPDATE AP_APP SET STATUS = ? WHERE ID = ? ";
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)){
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, AppLifecycleState.RETIRED.toString());
|
|
|
|
stmt.setString(1, AppLifecycleState.RETIRED.toString());
|
|
|
|
stmt.setInt(2, appId);
|
|
|
|
stmt.setInt(2, appId);
|
|
|
|
stmt.executeUpdate();
|
|
|
|
stmt.executeUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
|
|
String msg = "Error occurred while obtaining the DB connection to retire application which has application "
|
|
|
|
|
|
|
|
+ "ID: " + appId;
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while deleting the application: ", e);
|
|
|
|
String msg = "Error occurred while executing SQL to retire an application which has application ID "
|
|
|
|
} finally {
|
|
|
|
+ appId;
|
|
|
|
DAOUtil.cleanupResources(stmt, null);
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -607,29 +571,28 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to add tags");
|
|
|
|
log.debug("Request received in DAO Layer to add tags");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
String sql = "INSERT INTO AP_APP_TAG "
|
|
|
|
String sql = "INSERT INTO AP_APP_TAG "
|
|
|
|
+ "(TAG,"
|
|
|
|
+ "(TAG, "
|
|
|
|
+ " TENANT_ID) "
|
|
|
|
+ " TENANT_ID) "
|
|
|
|
+ "VALUES (?, ?)";
|
|
|
|
+ "VALUES (?, ?)";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
for (String tag : tags) {
|
|
|
|
for (String tag : tags) {
|
|
|
|
stmt.setString(1, tag);
|
|
|
|
stmt.setString(1, tag);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.addBatch();
|
|
|
|
stmt.addBatch();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stmt.executeBatch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt.executeBatch();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
String msg = "Error occurred while obtaining the DB connection when adding tags";
|
|
|
|
"Error occurred while obtaining the DB connection when adding tags", e);
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
|
|
|
|
String msg = "SQL Error occurred while adding tags. Executed Query: " + sql;
|
|
|
|
} finally {
|
|
|
|
log.error(msg);
|
|
|
|
DAOUtil.cleanupResources(stmt, null);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -638,72 +601,70 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to get all tags");
|
|
|
|
log.debug("Request received in DAO Layer to get all tags");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Connection conn;
|
|
|
|
String sql = "SELECT "
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
+ "AP_APP_TAG.ID AS ID, "
|
|
|
|
ResultSet rs = null;
|
|
|
|
+ "AP_APP_TAG.TAG AS TAG "
|
|
|
|
|
|
|
|
+ "FROM AP_APP_TAG "
|
|
|
|
|
|
|
|
+ "WHERE TENANT_ID = ?";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<TagDTO> tagEntities = new ArrayList<>();
|
|
|
|
List<TagDTO> tagEntities = new ArrayList<>();
|
|
|
|
String sql = "SELECT "
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
+ "AP_APP_TAG.ID AS ID, "
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
+ "AP_APP_TAG.TAG AS TAG "
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
+ "FROM AP_APP_TAG "
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
+ "WHERE TENANT_ID = ?";
|
|
|
|
while (rs.next()) {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
TagDTO tagDTO = new TagDTO();
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
tagDTO.setId(rs.getInt("ID"));
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
tagDTO.setTagName(rs.getString("TAG"));
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
tagEntities.add(tagDTO);
|
|
|
|
|
|
|
|
}
|
|
|
|
while(rs.next()){
|
|
|
|
return tagEntities;
|
|
|
|
TagDTO tagDTO = new TagDTO();
|
|
|
|
}
|
|
|
|
tagDTO.setId(rs.getInt("ID"));
|
|
|
|
|
|
|
|
tagDTO.setTagName(rs.getString("TAG"));
|
|
|
|
|
|
|
|
tagEntities.add(tagDTO);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tagEntities;
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
String msg = "Error occurred while obtaining the DB connection when getting all tags";
|
|
|
|
"Error occurred while obtaining the DB connection when adding tags", e);
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
|
|
|
|
String msg = "SQL Error occurred while getting all tags";
|
|
|
|
} finally {
|
|
|
|
log.error(msg);
|
|
|
|
DAOUtil.cleanupResources(stmt, rs);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<CategoryDTO> getAllCategories(int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
public List<CategoryDTO> getAllCategories(int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to get all tags");
|
|
|
|
log.debug("Request received in DAO Layer to get all categories.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Connection conn;
|
|
|
|
String sql = "SELECT "
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
+ "AP_APP_CATEGORY.ID AS ID, "
|
|
|
|
ResultSet rs = null;
|
|
|
|
+ "AP_APP_CATEGORY.CATEGORY AS CATEGORY "
|
|
|
|
|
|
|
|
+ "FROM AP_APP_CATEGORY "
|
|
|
|
|
|
|
|
+ "WHERE TENANT_ID = ?";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<CategoryDTO> categories = new ArrayList<>();
|
|
|
|
List<CategoryDTO> categories = new ArrayList<>();
|
|
|
|
String sql = "SELECT "
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
+ "AP_APP_CATEGORY.ID AS ID, "
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
+ "AP_APP_CATEGORY.CATEGORY AS CATEGORY "
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
+ "FROM AP_APP_CATEGORY "
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
+ "WHERE TENANT_ID = ?";
|
|
|
|
while (rs.next()) {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
CategoryDTO category = new CategoryDTO();
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
category.setId(rs.getInt("ID"));
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
category.setCategoryName(rs.getString("CATEGORY"));
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
categories.add(category);
|
|
|
|
|
|
|
|
}
|
|
|
|
while(rs.next()){
|
|
|
|
return categories;
|
|
|
|
CategoryDTO category = new CategoryDTO();
|
|
|
|
}
|
|
|
|
category.setId(rs.getInt("ID"));
|
|
|
|
|
|
|
|
category.setCategoryName(rs.getString("CATEGORY"));
|
|
|
|
|
|
|
|
categories.add(category);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return categories;
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
String msg = "Error occurred while obtaining the DB connection when getting all categories.";
|
|
|
|
"Error occurred while obtaining the DB connection when getting categories", e);
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while getting categories", e);
|
|
|
|
String msg = "SQL Error occurred while getting all categories. Executed query: " + sql;
|
|
|
|
} finally {
|
|
|
|
log.error(msg);
|
|
|
|
DAOUtil.cleanupResources(stmt, rs);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -711,14 +672,15 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
public List<Integer> getCategoryIdsForCategoryNames(List<String> categoryNames, int tenantId)
|
|
|
|
public List<Integer> getCategoryIdsForCategoryNames(List<String> categoryNames, int tenantId)
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to get tag ids for given tag names");
|
|
|
|
log.debug("Request received in DAO Layer to get category ids for given category names");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
int index = 1;
|
|
|
|
int index = 1;
|
|
|
|
List<Integer> tagIds = new ArrayList<>();
|
|
|
|
List<Integer> tagIds = new ArrayList<>();
|
|
|
|
StringJoiner joiner = new StringJoiner(",",
|
|
|
|
StringJoiner joiner = new StringJoiner(",",
|
|
|
|
"SELECT AP_APP_CATEGORY.ID AS ID FROM AP_APP_CATEGORY WHERE AP_APP_CATEGORY.CATEGORY IN (", ") AND TENANT_ID = ?");
|
|
|
|
"SELECT AP_APP_CATEGORY.ID AS ID FROM AP_APP_CATEGORY WHERE AP_APP_CATEGORY.CATEGORY IN (",
|
|
|
|
|
|
|
|
") AND TENANT_ID = ?");
|
|
|
|
categoryNames.stream().map(ignored -> "?").forEach(joiner::add);
|
|
|
|
categoryNames.stream().map(ignored -> "?").forEach(joiner::add);
|
|
|
|
String query = joiner.toString();
|
|
|
|
String query = joiner.toString();
|
|
|
|
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
|
|
|
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
|
|
@ -734,17 +696,21 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tagIds;
|
|
|
|
return tagIds;
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
String msg = "Error occurred while obtaining the DB connection when getting category ids for given "
|
|
|
|
"Error occurred while obtaining the DB connection when getting categories", e);
|
|
|
|
+ "category names";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while getting categories", e);
|
|
|
|
String msg = "SQL Error occurred while getting all categories.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Integer> getDistinctCategoryIdsInCategoryMapping() throws ApplicationManagementDAOException {
|
|
|
|
public List<Integer> getDistinctCategoryIdsInCategoryMapping() throws ApplicationManagementDAOException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to get distinct category ids for given tag names");
|
|
|
|
log.debug("Request received in DAO Layer to get distinct category ids in category mapping.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
@ -759,12 +725,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return distinctCategoryIds;
|
|
|
|
return distinctCategoryIds;
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
String msg = "Error occurred while obtaining the DB connection when getting distinct category ids in "
|
|
|
|
"Error occurred while obtaining the DB connection when getting distinct category ids in tag mapping",
|
|
|
|
+ "category mapping";
|
|
|
|
e);
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
String msg = "SQL Error occurred while getting distinct category ids in category mapping.";
|
|
|
|
"Error occurred while getting distinct category ids in tag mapping", e);
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -773,12 +741,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to get category for given category name.");
|
|
|
|
log.debug("Request received in DAO Layer to get category for given category name.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String sql = "SELECT AP_APP_CATEGORY.ID AS ID "
|
|
|
|
|
|
|
|
+ "FROM AP_APP_CATEGORY "
|
|
|
|
|
|
|
|
+ "WHERE AP_APP_CATEGORY.CATEGORY = ? AND "
|
|
|
|
|
|
|
|
+ "AP_APP_CATEGORY.TENANT_ID = ?";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
String sql = "SELECT AP_APP_CATEGORY.ID AS ID"
|
|
|
|
|
|
|
|
+ " FROM AP_APP_CATEGORY "
|
|
|
|
|
|
|
|
+ "WHERE AP_APP_CATEGORY.CATEGORY = ? AND "
|
|
|
|
|
|
|
|
+ "AP_APP_CATEGORY.TENANT_ID = ?";
|
|
|
|
|
|
|
|
try (PreparedStatement ps = conn.prepareStatement(sql)) {
|
|
|
|
try (PreparedStatement ps = conn.prepareStatement(sql)) {
|
|
|
|
ps.setString(1, categoryName);
|
|
|
|
ps.setString(1, categoryName);
|
|
|
|
ps.setInt(2, tenantId);
|
|
|
|
ps.setInt(2, tenantId);
|
|
|
@ -789,80 +757,81 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
categoryDTO.setCategoryName(categoryName);
|
|
|
|
categoryDTO.setCategoryName(categoryName);
|
|
|
|
return categoryDTO;
|
|
|
|
return categoryDTO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
String msg = "Error occurred while obtaining the DB connection when getting category for given category "
|
|
|
|
"Error occurred while obtaining the DB connection when getting category Id for given category name",
|
|
|
|
+ "name.";
|
|
|
|
e);
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
String msg = "SQL Error occurred while getting category for category name. Executed query " + sql;
|
|
|
|
"SQL Error occurred while getting category Id for category name.", e);
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addCategories(List<String> categories, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
public void addCategories(List<String> categories, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to add tags");
|
|
|
|
log.debug("DAO Request received in DAO Layer to add categories.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
String sql = "INSERT INTO AP_APP_CATEGORY "
|
|
|
|
String sql = "INSERT INTO AP_APP_CATEGORY "
|
|
|
|
+ "(CATEGORY,"
|
|
|
|
+ "(CATEGORY,"
|
|
|
|
+ " TENANT_ID) "
|
|
|
|
+ " TENANT_ID) "
|
|
|
|
+ "VALUES (?, ?)";
|
|
|
|
+ "VALUES (?, ?)";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
for (String category : categories) {
|
|
|
|
for (String category : categories) {
|
|
|
|
stmt.setString(1, category);
|
|
|
|
stmt.setString(1, category);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
stmt.addBatch();
|
|
|
|
stmt.addBatch();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stmt.executeBatch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt.executeBatch();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
String msg = "Error occurred while obtaining the DB connection when adding categories.";
|
|
|
|
"Error occurred while obtaining the DB connection when adding categories.", e);
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while adding categories.", e);
|
|
|
|
String msg = "SQL Error occurred while adding categories. Executed query " + sql;
|
|
|
|
} finally {
|
|
|
|
log.error(msg);
|
|
|
|
DAOUtil.cleanupResources(stmt, null);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addCategoryMapping (List<Integer> categoryIds, int applicationId, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
public void addCategoryMapping(List<Integer> categoryIds, int applicationId, int tenantId)
|
|
|
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to add categories");
|
|
|
|
log.debug("Request received in DAO Layer to add category mappings");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
String sql = "INSERT INTO AP_APP_CATEGORY_MAPPING "
|
|
|
|
String sql = "INSERT INTO AP_APP_CATEGORY_MAPPING "
|
|
|
|
+ "(AP_APP_CATEGORY_ID, "
|
|
|
|
+ "(AP_APP_CATEGORY_ID, "
|
|
|
|
+ "AP_APP_ID, "
|
|
|
|
+ "AP_APP_ID, "
|
|
|
|
+ " TENANT_ID) "
|
|
|
|
+ " TENANT_ID) "
|
|
|
|
+ "VALUES (?, ?, ?)";
|
|
|
|
+ "VALUES (?, ?, ?)";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
for (Integer categoryId : categoryIds) {
|
|
|
|
for (Integer categoryId : categoryIds) {
|
|
|
|
stmt.setInt(1, categoryId);
|
|
|
|
stmt.setInt(1, categoryId);
|
|
|
|
stmt.setInt(2, applicationId);
|
|
|
|
stmt.setInt(2, applicationId);
|
|
|
|
stmt.setInt(3, tenantId);
|
|
|
|
stmt.setInt(3, tenantId);
|
|
|
|
stmt.addBatch();
|
|
|
|
stmt.addBatch();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stmt.executeBatch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt.executeBatch();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
String msg = "Error occurred while obtaining the DB connection when adding data into category mapping.";
|
|
|
|
"Error occurred while obtaining the DB connection when adding data into category mapping.", e);
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while adding data into category mapping.", e);
|
|
|
|
String msg = "SQL Error occurred while adding data into category mapping.";
|
|
|
|
} finally {
|
|
|
|
log.error(msg);
|
|
|
|
DAOUtil.cleanupResources(stmt, null);
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|