|
|
|
@ -967,25 +967,31 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> getAppSubscribedUsers(int offsetValue, int limitValue, int appReleaseId,
|
|
|
|
|
int tenantId)
|
|
|
|
|
int tenantId, Boolean uninstalled)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Request received in DAO Layer to get already subscribed users for " +
|
|
|
|
|
"given app release id.");
|
|
|
|
|
log.debug("Request received in DAO Layer to get subscribed/unsubscribed users for the given app release ID.");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
|
List<String> subscribedUsers = new ArrayList<>();
|
|
|
|
|
String sql = "SELECT "
|
|
|
|
|
+ "US.USER_NAME AS USER_NAME "
|
|
|
|
|
+ "FROM AP_USER_SUBSCRIPTION US "
|
|
|
|
|
+ "WHERE "
|
|
|
|
|
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?";
|
|
|
|
|
String sql = "SELECT US.USER_NAME AS USER_NAME " +
|
|
|
|
|
"FROM AP_USER_SUBSCRIPTION US " +
|
|
|
|
|
"WHERE AP_APP_RELEASE_ID = ? " +
|
|
|
|
|
"AND TENANT_ID = ? ";
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
sql += "AND UNSUBSCRIBED = ? ";
|
|
|
|
|
}
|
|
|
|
|
sql += "LIMIT ? OFFSET ?";
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
|
stmt.setInt(1, appReleaseId);
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
stmt.setInt(3, limitValue);
|
|
|
|
|
stmt.setInt(4, offsetValue);
|
|
|
|
|
int index = 1;
|
|
|
|
|
stmt.setInt(index++, appReleaseId);
|
|
|
|
|
stmt.setInt(index++, tenantId);
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
stmt.setBoolean(index++, uninstalled);
|
|
|
|
|
}
|
|
|
|
|
stmt.setInt(index++, limitValue);
|
|
|
|
|
stmt.setInt(index, offsetValue);
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
subscribedUsers.add(rs.getString("USER_NAME"));
|
|
|
|
@ -994,39 +1000,42 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
return subscribedUsers;
|
|
|
|
|
}
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
String msg = "Error occurred while obtaining the DB connection to get already " +
|
|
|
|
|
"subscribed users for given app release id.";
|
|
|
|
|
String msg = "Error occurred while obtaining the DB connection to get subscribed/unsubscribed users for the given app release ID.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
String msg = "SQL Error occurred while getting subscribed users for given app release id.";
|
|
|
|
|
String msg = "SQL Error occurred while getting subscribed/unsubscribed users for the given app release ID.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getSubscribedUserCount(int appReleaseId, int tenantId)
|
|
|
|
|
public int getSubscribedUserCount(int appReleaseId, int tenantId, Boolean uninstalled)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Request received in DAO Layer to get already subscribed users for " +
|
|
|
|
|
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed users for " +
|
|
|
|
|
"given app release id.");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
|
String sql = "SELECT "
|
|
|
|
|
+ "COUNT(US.USER_NAME) AS USER_NAME "
|
|
|
|
|
+ "FROM AP_USER_SUBSCRIPTION US "
|
|
|
|
|
+ "WHERE "
|
|
|
|
|
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
|
|
|
|
|
String sql = "SELECT COUNT(US.USER_NAME) AS USER_COUNT " +
|
|
|
|
|
"FROM AP_USER_SUBSCRIPTION US " +
|
|
|
|
|
"WHERE AP_APP_RELEASE_ID = ? " +
|
|
|
|
|
"AND TENANT_ID = ?";
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
sql += " AND UNSUBSCRIBED = ?";
|
|
|
|
|
}
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
|
stmt.setInt(1, appReleaseId);
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
stmt.setBoolean(3, uninstalled);
|
|
|
|
|
}
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
return rs.getInt("USER_NAME");
|
|
|
|
|
return rs.getInt("USER_COUNT");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
@ -1037,7 +1046,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
String msg = "SQL Error occurred while getting subscribed users for given app release id.";
|
|
|
|
|
String msg = "SQL Error occurred while getting subscribed users count for given app release id.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
@ -1151,10 +1160,10 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> getAppSubscribedRoles(int offsetValue, int limitValue, int appReleaseId,
|
|
|
|
|
int tenantId)
|
|
|
|
|
int tenantId, Boolean uninstalled)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Request received in DAO Layer to get already subscribed roles for " +
|
|
|
|
|
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed roles for " +
|
|
|
|
|
"given app release id.");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
@ -1163,13 +1172,21 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
String sql = "SELECT "
|
|
|
|
|
+ "RS.ROLE_NAME AS ROLE "
|
|
|
|
|
+ "FROM AP_ROLE_SUBSCRIPTION RS "
|
|
|
|
|
+ "WHERE "
|
|
|
|
|
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?";
|
|
|
|
|
+ "WHERE AP_APP_RELEASE_ID = ? "
|
|
|
|
|
+ "AND TENANT_ID = ?";
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
sql += " AND UNSUBSCRIBED = ?";
|
|
|
|
|
}
|
|
|
|
|
sql += " LIMIT ? OFFSET ?";
|
|
|
|
|
try (PreparedStatement ps = conn.prepareStatement(sql)) {
|
|
|
|
|
ps.setInt(1, appReleaseId);
|
|
|
|
|
ps.setInt(2, tenantId);
|
|
|
|
|
ps.setInt(3, limitValue);
|
|
|
|
|
ps.setInt(4, offsetValue);
|
|
|
|
|
int paramIndex = 3;
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
ps.setBoolean(paramIndex++, uninstalled);
|
|
|
|
|
}
|
|
|
|
|
ps.setInt(paramIndex++, limitValue);
|
|
|
|
|
ps.setInt(paramIndex, offsetValue);
|
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
subscribedRoles.add(rs.getString("ROLE"));
|
|
|
|
@ -1190,38 +1207,43 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getSubscribedRoleCount(int appReleaseId, int tenantId)
|
|
|
|
|
public int getSubscribedRoleCount(int appReleaseId, int tenantId, Boolean uninstalled)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Request received in DAO Layer to get already subscribed roles for " +
|
|
|
|
|
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed roles for " +
|
|
|
|
|
"given app release id.");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
|
String sql = "SELECT "
|
|
|
|
|
+ "COUNT(RS.ROLE_NAME) AS ROLE_NAME "
|
|
|
|
|
+ "COUNT(RS.ROLE_NAME) AS ROLE_COUNT "
|
|
|
|
|
+ "FROM AP_ROLE_SUBSCRIPTION RS "
|
|
|
|
|
+ "WHERE "
|
|
|
|
|
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
|
|
|
|
|
+ "WHERE AP_APP_RELEASE_ID = ? "
|
|
|
|
|
+ "AND TENANT_ID = ?";
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
sql += " AND UNSUBSCRIBED = ?";
|
|
|
|
|
}
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
|
stmt.setInt(1, appReleaseId);
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
stmt.setBoolean(3, uninstalled);
|
|
|
|
|
}
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
return rs.getInt("ROLE_NAME");
|
|
|
|
|
}
|
|
|
|
|
return rs.getInt("ROLE_COUNT");
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
String msg = "Error occurred while obtaining the DB connection to get already " +
|
|
|
|
|
"subscribed roles count for given app release id.";
|
|
|
|
|
"subscribed/unsubscribed roles count for given app release id.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
String msg = "SQL Error occurred while getting subscribed roles for given app release id.";
|
|
|
|
|
String msg = "SQL Error occurred while getting subscribed roles count for given app release id.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
@ -1269,25 +1291,31 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId,
|
|
|
|
|
int tenantId)
|
|
|
|
|
int tenantId, Boolean uninstalled)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Request received in DAO Layer to get already subscribed groups for " +
|
|
|
|
|
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed groups for " +
|
|
|
|
|
"given app release id.");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
|
List<String> subscribedGroups = new ArrayList<>();
|
|
|
|
|
String sql = "SELECT "
|
|
|
|
|
+ "GS.GROUP_NAME AS APP_GROUPS "
|
|
|
|
|
+ "FROM AP_GROUP_SUBSCRIPTION GS "
|
|
|
|
|
+ "WHERE "
|
|
|
|
|
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?";
|
|
|
|
|
String sql = "SELECT GS.GROUP_NAME AS APP_GROUPS " +
|
|
|
|
|
"FROM AP_GROUP_SUBSCRIPTION GS " +
|
|
|
|
|
"WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
sql += " AND UNSUBSCRIBED = ?";
|
|
|
|
|
}
|
|
|
|
|
sql += " LIMIT ? OFFSET ?";
|
|
|
|
|
try (PreparedStatement ps = conn.prepareStatement(sql)) {
|
|
|
|
|
ps.setInt(1, appReleaseId);
|
|
|
|
|
ps.setInt(2, tenantId);
|
|
|
|
|
ps.setInt(3, limitValue);
|
|
|
|
|
ps.setInt(4, offsetValue);
|
|
|
|
|
int paramIndex = 1;
|
|
|
|
|
ps.setInt(paramIndex++, appReleaseId);
|
|
|
|
|
ps.setInt(paramIndex++, tenantId);
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
ps.setBoolean(paramIndex++, uninstalled);
|
|
|
|
|
}
|
|
|
|
|
ps.setInt(paramIndex++, limitValue);
|
|
|
|
|
ps.setInt(paramIndex, offsetValue);
|
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
subscribedGroups.add(rs.getString("APP_GROUPS"));
|
|
|
|
@ -1297,11 +1325,11 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
}
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
String msg = "Error occurred while obtaining the DB connection to get already " +
|
|
|
|
|
"subscribed groups for given app release id.";
|
|
|
|
|
"subscribed/unsubscribed groups for given app release id.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
String msg = "SQL Error occurred while getting subscribed groups for given " +
|
|
|
|
|
String msg = "SQL Error occurred while getting subscribed/unsubscribed groups for given " +
|
|
|
|
|
"app release id.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
@ -1309,24 +1337,27 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getSubscribedGroupCount(int appReleaseId, int tenantId)
|
|
|
|
|
public int getSubscribedGroupCount(int appReleaseId, int tenantId, Boolean uninstalled)
|
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Request received in DAO Layer to get already subscribed groups for " +
|
|
|
|
|
log.debug("Request received in DAO Layer to get the count of subscribed groups for " +
|
|
|
|
|
"given app release id.");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
|
String sql = "SELECT "
|
|
|
|
|
+ "COUNT(GS.GROUP_NAME) AS APP_GROUPS_COUNT "
|
|
|
|
|
+ "FROM AP_GROUP_SUBSCRIPTION GS "
|
|
|
|
|
+ "WHERE "
|
|
|
|
|
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
|
|
|
|
|
String sql = "SELECT COUNT(GS.GROUP_NAME) AS APP_GROUPS_COUNT " +
|
|
|
|
|
"FROM AP_GROUP_SUBSCRIPTION GS " +
|
|
|
|
|
"WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
sql += " AND UNSUBSCRIBED = ?";
|
|
|
|
|
}
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
|
stmt.setInt(1, appReleaseId);
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
|
|
|
|
|
if (uninstalled != null) {
|
|
|
|
|
stmt.setBoolean(3, uninstalled);
|
|
|
|
|
}
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
return rs.getInt("APP_GROUPS_COUNT");
|
|
|
|
@ -1335,12 +1366,13 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
String msg = "Error occurred while obtaining the DB connection to get already " +
|
|
|
|
|
"subscribed groups count for given app release id.";
|
|
|
|
|
String msg = "Error occurred while obtaining the DB connection to get the count of " +
|
|
|
|
|
"subscribed groups for given app release id.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
String msg = "SQL Error occurred while getting subscribed groups for given app release id.";
|
|
|
|
|
String msg = "SQL Error occurred while getting the count of subscribed groups for given " +
|
|
|
|
|
"app release id.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementDAOException(msg, e);
|
|
|
|
|
}
|
|
|
|
|