|
|
|
@ -43,7 +43,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(GenericApplicationReleaseDAOImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* To insert the Application Release Details.
|
|
|
|
|
*
|
|
|
|
@ -52,20 +51,18 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease createRelease(ApplicationRelease applicationRelease, int appId, int tenantId) throws
|
|
|
|
|
ApplicationManagementDAOException {
|
|
|
|
|
@Override public ApplicationRelease createRelease(ApplicationRelease applicationRelease, int appId, int tenantId)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
|
|
|
|
|
|
String sql = "INSERT INTO AP_APP_RELEASE (VERSION,TENANT_ID,UUID,RELEASE_TYPE, PACKAGE_NAME, APP_PRICE,"
|
|
|
|
|
+ "STORED_LOCATION, BANNER_LOCATION, SC_1_LOCATION,SC_2_LOCATION,SC_3_LOCATION, APP_HASH_VALUE,"
|
|
|
|
|
+ "SHARED_WITH_ALL_TENANTS, APP_META_INFO,AP_APP_ID) "
|
|
|
|
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
|
|
|
|
|
+ "SHARED_WITH_ALL_TENANTS, APP_META_INFO,AP_APP_ID) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
String generatedColumns[] = {"ID"};
|
|
|
|
|
String generatedColumns[] = { "ID" };
|
|
|
|
|
try {
|
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
|
statement = connection.prepareStatement(sql, generatedColumns);
|
|
|
|
@ -95,7 +92,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
"SQL Exception while trying to release an application by executing the query " + sql, e);
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
"Database Connection Exception while trying to release a new version" , e);
|
|
|
|
|
"Database Connection Exception while trying to release a new version", e);
|
|
|
|
|
} finally {
|
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
|
}
|
|
|
|
@ -111,8 +108,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease getRelease(String applicationName, String applicationType, String versionName,
|
|
|
|
|
@Override public ApplicationRelease getRelease(String applicationName, String applicationType, String versionName,
|
|
|
|
|
String releaseType, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
@ -144,11 +140,10 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
return null;
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Database connection exception while trying to get the "
|
|
|
|
|
+ "release details of the application with " + applicationName + " and version " +
|
|
|
|
|
versionName, e);
|
|
|
|
|
+ "release details of the application with " + applicationName + " and version " + versionName, e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Error while getting release details of the application " +
|
|
|
|
|
applicationName + " and version " + versionName + " , while executing the query " + sql, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
"Error while getting release details of the application " + applicationName + " and version " + versionName + " , while executing the query " + sql, e);
|
|
|
|
|
} finally {
|
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
|
}
|
|
|
|
@ -162,21 +157,21 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease getReleaseByIds(int applicationId, String releaseUuid, int tenantId) throws
|
|
|
|
|
ApplicationManagementDAOException {
|
|
|
|
|
@Override public ApplicationRelease getReleaseByIds(int applicationId, String releaseUuid, int tenantId)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
|
String sql = "SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE, AR.APP_PRICE,"
|
|
|
|
|
+ " AR.STORED_LOCATION, AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, "
|
|
|
|
|
+ "AR.SC_2_LOCATION AS SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.APP_HASH_VALUE AS " +
|
|
|
|
|
"HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO, AR.CREATED_BY, AR.CREATED_AT, AR" +
|
|
|
|
|
".PUBLISHED_BY, AR.PUBLISHED_AT, AR.STARS, AL.CURRENT_STATE, AL.PREVIOUS_STATE, AL.UPDATED_BY, " +
|
|
|
|
|
"AL.UPDATED_AT FROM AP_APP_RELEASE AS AR, AP_APP_LIFECYCLE_STATE AS AL WHERE " +
|
|
|
|
|
"AR.AP_APP_ID = ? AND AR.UUID = ? AND AR.TENANT_ID = ? AND AL.AP_APP_RELEASE_ID=AR.ID AND " +
|
|
|
|
|
"AL.TENANT_ID = AR.TENANT_ID ORDER BY AL.UPDATED_AT DESC;";
|
|
|
|
|
String sql =
|
|
|
|
|
"SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE, AR.APP_PRICE, "
|
|
|
|
|
+ "AR.STORED_LOCATION, AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, "
|
|
|
|
|
+ "AR.SC_2_LOCATION AS SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.PACKAGE_NAME AS "
|
|
|
|
|
+ "PACKAGE_NAME, AR.APP_HASH_VALUE AS HASH_VALUE, AR.SHARED_WITH_ALL_TENANTS AS SHARED, "
|
|
|
|
|
+ "AR.APP_META_INFO AS APP_META_INFO, AR.RATING AS RATING, AL.CURRENT_STATE, AL.PREVIOUS_STATE, "
|
|
|
|
|
+ "AL.UPDATED_BY, AL.UPDATED_AT FROM AP_APP_RELEASE AS AR, AP_APP_LIFECYCLE_STATE AS AL "
|
|
|
|
|
+ "WHERE AR.AP_APP_ID = ? AND AR.UUID = ? AND AR.TENANT_ID = ? AND AL.AP_APP_RELEASE_ID=AR.ID "
|
|
|
|
|
+ "AND AL.TENANT_ID = AR.TENANT_ID ORDER BY AL.UPDATED_AT DESC;";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
connection = this.getDBConnection();
|
|
|
|
@ -192,14 +187,12 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
return null;
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
"Database connection exception while trying to get the release details of the " +
|
|
|
|
|
"application id: " + applicationId + "and UUID of the application release: " +
|
|
|
|
|
releaseUuid, e);
|
|
|
|
|
"Database connection exception while trying to get the release details of the " + "application id: "
|
|
|
|
|
+ applicationId + "and UUID of the application release: " + releaseUuid, e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
"Error while getting release details of the application id: " + applicationId +
|
|
|
|
|
" and theUUID of the application " +
|
|
|
|
|
"release: " + releaseUuid + " , while executing the query " + sql, e);
|
|
|
|
|
"Error while getting release details of the application id: " + applicationId
|
|
|
|
|
+ " and theUUID of the application " + "release: " + releaseUuid + " , while executing the query " + sql, e);
|
|
|
|
|
} finally {
|
|
|
|
|
Util.cleanupResources(statement, resultSet);
|
|
|
|
|
}
|
|
|
|
@ -212,8 +205,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param tenantId Tenant Id
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<ApplicationRelease> getReleases(int applicationId, int tenantId)
|
|
|
|
|
@Override public List<ApplicationRelease> getReleases(int applicationId, int tenantId)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
@ -258,8 +250,8 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param rating given stars for the application release.
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void updateRatingValue(String uuid, double rating, int ratedUsers) throws ApplicationManagementDAOException {
|
|
|
|
|
@Override public void updateRatingValue(String uuid, double rating, int ratedUsers)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
String sql = "UPDATE AP_APP_RELEASE SET RATING = ?,RATED_USERS = ? WHERE UUID = ?;";
|
|
|
|
@ -287,8 +279,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param uuid UUID of the application Release.
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
@Override public Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
@ -301,7 +292,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
statement.setInt(2, tenantId);
|
|
|
|
|
resultSet = statement.executeQuery();
|
|
|
|
|
|
|
|
|
|
if (resultSet.next()){
|
|
|
|
|
if (resultSet.next()) {
|
|
|
|
|
rating = new Rating();
|
|
|
|
|
rating.setRatingValue(resultSet.getDouble("RATING"));
|
|
|
|
|
rating.setNoOfUsers(resultSet.getInt("RATED_USERS"));
|
|
|
|
@ -324,8 +315,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param applicationRelease Application Release the properties of which that need to be inserted.
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease updateRelease(int applicationId, ApplicationRelease applicationRelease, int tenantId)
|
|
|
|
|
@Override public ApplicationRelease updateRelease(int applicationId, ApplicationRelease applicationRelease, int tenantId)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
@ -349,7 +339,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
statement.setString(11, applicationRelease.getAppHashValue());
|
|
|
|
|
statement.setInt(12, applicationRelease.getIsSharedWithAllTenants());
|
|
|
|
|
statement.setString(13, applicationRelease.getMetaData());
|
|
|
|
|
statement.setInt(14,applicationId);
|
|
|
|
|
statement.setInt(14, applicationId);
|
|
|
|
|
statement.setInt(15, tenantId);
|
|
|
|
|
statement.setInt(16, applicationRelease.getId());
|
|
|
|
|
|
|
|
|
@ -373,8 +363,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
* @param version version name of the application release.
|
|
|
|
|
* @throws ApplicationManagementDAOException Application Management DAO Exception.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteRelease(int id, String version) throws ApplicationManagementDAOException {
|
|
|
|
|
@Override public void deleteRelease(int id, String version) throws ApplicationManagementDAOException {
|
|
|
|
|
Connection connection;
|
|
|
|
|
PreparedStatement statement = null;
|
|
|
|
|
String sql = "DELETE FROM AP_APP_RELEASE WHERE ID = ? AND VERSION = ?";
|
|
|
|
@ -396,8 +385,46 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean verifyReleaseExistence(int appId, String uuid, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Verifying application release existence by application id:" + appId
|
|
|
|
|
+ " and application release uuid: " + uuid);
|
|
|
|
|
}
|
|
|
|
|
Connection conn;
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
try {
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
String sql =
|
|
|
|
|
"SELECT AR.ID AS RELEASE_ID FROM AP_APP_RELEASE AS AR WHERE AR.AP_APP_ID = ? AND AR.UUID = ? AND "
|
|
|
|
|
+ "AR.TENANT_ID = ?;";
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
stmt.setInt(1, appId);
|
|
|
|
|
stmt.setString(2, uuid);
|
|
|
|
|
stmt.setInt(3, tenantId);
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Successfully retrieved basic details of the application release with the application ID "
|
|
|
|
|
+ appId + " Application release uuid: " + uuid);
|
|
|
|
|
}
|
|
|
|
|
return rs.next();
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
"Error occurred while getting application release details with app ID: " + appId
|
|
|
|
|
+ " App release uuid: " + uuid + " While executing query ", e);
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
|
|
|
|
|
} finally {
|
|
|
|
|
Util.cleanupResources(stmt, rs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This method is capable to construct {@link ApplicationRelease} and return the object
|
|
|
|
|
*
|
|
|
|
|
* @param resultSet result set obtained from the query executing.
|
|
|
|
|
* @throws SQLException SQL exception while accessing result set data.
|
|
|
|
|
*/
|
|
|
|
@ -418,8 +445,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|
|
|
|
applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED"));
|
|
|
|
|
applicationRelease.setMetaData(resultSet.getString("APP_META_INFO"));
|
|
|
|
|
applicationRelease.setRating(resultSet.getDouble("RATING"));
|
|
|
|
|
|
|
|
|
|
return applicationRelease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|