|
|
@ -107,13 +107,15 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
public void updateDeviceSubscription(String updateBy, List<Integer> deviceIds,
|
|
|
|
public void updateDeviceSubscription(String updateBy, List<Integer> deviceIds,
|
|
|
|
String action, String actionTriggeredFrom, String installStatus, int releaseId, int tenantId)
|
|
|
|
String action, String actionTriggeredFrom, String installStatus, int releaseId, int tenantId)
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
boolean unsubscribed = false;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String sql = "UPDATE AP_DEVICE_SUBSCRIPTION SET ";
|
|
|
|
String sql = "UPDATE AP_DEVICE_SUBSCRIPTION SET ";
|
|
|
|
|
|
|
|
|
|
|
|
if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
sql += "UNSUBSCRIBED = true, UNSUBSCRIBED_BY = ?, UNSUBSCRIBED_TIMESTAMP = ?, ";
|
|
|
|
sql += "UNSUBSCRIBED = ?, UNSUBSCRIBED_BY = ?, UNSUBSCRIBED_TIMESTAMP = ?, ";
|
|
|
|
|
|
|
|
unsubscribed = true;
|
|
|
|
} else if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
} else if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
sql += "UNSUBSCRIBED = false, SUBSCRIBED_BY = ?, SUBSCRIBED_TIMESTAMP = ?, ";
|
|
|
|
sql += "UNSUBSCRIBED = ?, SUBSCRIBED_BY = ?, SUBSCRIBED_TIMESTAMP = ?, ";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
String msg = "Found invalid action " + action + ". Hence can't construct the query.";
|
|
|
|
String msg = "Found invalid action " + action + ". Hence can't construct the query.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
@ -131,13 +133,14 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
|
|
|
|
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
|
|
|
|
for (Integer deviceId : deviceIds) {
|
|
|
|
for (Integer deviceId : deviceIds) {
|
|
|
|
stmt.setString(1, updateBy);
|
|
|
|
stmt.setBoolean(1, unsubscribed);
|
|
|
|
stmt.setTimestamp(2, timestamp);
|
|
|
|
stmt.setString(2, updateBy);
|
|
|
|
stmt.setString(3, actionTriggeredFrom);
|
|
|
|
stmt.setTimestamp(3, timestamp);
|
|
|
|
stmt.setString(4, installStatus);
|
|
|
|
stmt.setString(4, actionTriggeredFrom);
|
|
|
|
stmt.setInt(5, deviceId);
|
|
|
|
stmt.setString(5, installStatus);
|
|
|
|
stmt.setInt(6, releaseId);
|
|
|
|
stmt.setInt(6, deviceId);
|
|
|
|
stmt.setInt(7, tenantId);
|
|
|
|
stmt.setInt(7, releaseId);
|
|
|
|
|
|
|
|
stmt.setInt(8, tenantId);
|
|
|
|
stmt.addBatch();
|
|
|
|
stmt.addBatch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt.executeBatch();
|
|
|
|
stmt.executeBatch();
|
|
|
@ -433,7 +436,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
int index = 1;
|
|
|
|
int index = 1;
|
|
|
|
List<String> subscribedUsers = new ArrayList<>();
|
|
|
|
List<String> subscribedUsers = new ArrayList<>();
|
|
|
|
StringJoiner joiner = new StringJoiner(",",
|
|
|
|
StringJoiner joiner = new StringJoiner(",",
|
|
|
|
"SELECT US.USER_NAME AS USER "
|
|
|
|
"SELECT US.USER_NAME AS USER_NAME "
|
|
|
|
+ "FROM AP_USER_SUBSCRIPTION US "
|
|
|
|
+ "FROM AP_USER_SUBSCRIPTION US "
|
|
|
|
+ "WHERE US.USER_NAME IN (", ") AND TENANT_ID = ?");
|
|
|
|
+ "WHERE US.USER_NAME IN (", ") AND TENANT_ID = ?");
|
|
|
|
users.stream().map(ignored -> "?").forEach(joiner::add);
|
|
|
|
users.stream().map(ignored -> "?").forEach(joiner::add);
|
|
|
@ -445,7 +448,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
ps.setInt(index, tenantId);
|
|
|
|
ps.setInt(index, tenantId);
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
subscribedUsers.add(rs.getString("USER"));
|
|
|
|
subscribedUsers.add(rs.getString("USER_NAME"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -513,7 +516,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
int index = 1;
|
|
|
|
int index = 1;
|
|
|
|
List<String> subscribedUsers = new ArrayList<>();
|
|
|
|
List<String> subscribedUsers = new ArrayList<>();
|
|
|
|
StringJoiner joiner = new StringJoiner(",",
|
|
|
|
StringJoiner joiner = new StringJoiner(",",
|
|
|
|
"SELECT GS.GROUP_NAME AS GROUP "
|
|
|
|
"SELECT GS.GROUP_NAME AS GROUP_NAME "
|
|
|
|
+ "FROM AP_GROUP_SUBSCRIPTION GS "
|
|
|
|
+ "FROM AP_GROUP_SUBSCRIPTION GS "
|
|
|
|
+ "WHERE GS.GROUP_NAME IN (", ") AND TENANT_ID = ?");
|
|
|
|
+ "WHERE GS.GROUP_NAME IN (", ") AND TENANT_ID = ?");
|
|
|
|
groups.stream().map(ignored -> "?").forEach(joiner::add);
|
|
|
|
groups.stream().map(ignored -> "?").forEach(joiner::add);
|
|
|
@ -525,7 +528,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
ps.setInt(index, tenantId);
|
|
|
|
ps.setInt(index, tenantId);
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
subscribedUsers.add(rs.getString("GROUP"));
|
|
|
|
subscribedUsers.add(rs.getString("GROUP_NAME"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -554,7 +557,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
int index = 1;
|
|
|
|
int index = 1;
|
|
|
|
List<Integer> subscribedDevices = new ArrayList<>();
|
|
|
|
List<Integer> subscribedDevices = new ArrayList<>();
|
|
|
|
StringJoiner joiner = new StringJoiner(",",
|
|
|
|
StringJoiner joiner = new StringJoiner(",",
|
|
|
|
"SELECT DS.ID "
|
|
|
|
"SELECT DS.ID AS DEVICE_SUBSCRIPTION_ID "
|
|
|
|
+ "FROM AP_DEVICE_SUBSCRIPTION DS "
|
|
|
|
+ "FROM AP_DEVICE_SUBSCRIPTION DS "
|
|
|
|
+ "WHERE DS.DM_DEVICE_ID IN (", ") AND AP_APP_RELEASE_ID = ? AND TENANT_ID = ?");
|
|
|
|
+ "WHERE DS.DM_DEVICE_ID IN (", ") AND AP_APP_RELEASE_ID = ? AND TENANT_ID = ?");
|
|
|
|
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
|
|
|
|
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
|
|
|
@ -567,7 +570,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
ps.setInt(index, tenantId);
|
|
|
|
ps.setInt(index, tenantId);
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|
try (ResultSet rs = ps.executeQuery()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
subscribedDevices.add(rs.getInt("DM_DEVICE_ID"));
|
|
|
|
subscribedDevices.add(rs.getInt("DEVICE_SUBSCRIPTION_ID"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -589,6 +592,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
String subType, String action) throws ApplicationManagementDAOException {
|
|
|
|
String subType, String action) throws ApplicationManagementDAOException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
|
|
|
|
boolean isUnsubscribed = false;
|
|
|
|
String sql = "UPDATE ";
|
|
|
|
String sql = "UPDATE ";
|
|
|
|
if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) {
|
|
|
|
if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) {
|
|
|
|
sql += "AP_USER_SUBSCRIPTION SET ";
|
|
|
|
sql += "AP_USER_SUBSCRIPTION SET ";
|
|
|
@ -599,9 +603,10 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
sql += "UNSUBSCRIBED = true, UNSUBSCRIBED_BY = ?, UNSUBSCRIBED_TIMESTAMP = ? ";
|
|
|
|
sql += "UNSUBSCRIBED = ?, UNSUBSCRIBED_BY = ?, UNSUBSCRIBED_TIMESTAMP = ? ";
|
|
|
|
|
|
|
|
isUnsubscribed = true;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
sql += "UNSUBSCRIBED = false, SUBSCRIBED_BY = ?, SUBSCRIBED_TIMESTAMP = ? ";
|
|
|
|
sql += "UNSUBSCRIBED = ?, SUBSCRIBED_BY = ?, SUBSCRIBED_TIMESTAMP = ? ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) {
|
|
|
|
if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) {
|
|
|
@ -618,11 +623,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
|
|
|
|
Timestamp timestamp = new Timestamp(calendar.getTime().getTime());
|
|
|
|
for (String username : paramList) {
|
|
|
|
for (String username : paramList) {
|
|
|
|
stmt.setString(1, updateBy);
|
|
|
|
stmt.setBoolean(1, isUnsubscribed);
|
|
|
|
stmt.setTimestamp(2, timestamp);
|
|
|
|
stmt.setString(2, updateBy);
|
|
|
|
stmt.setString(3, username);
|
|
|
|
stmt.setTimestamp(3, timestamp);
|
|
|
|
stmt.setInt(4, releaseId);
|
|
|
|
stmt.setString(4, username);
|
|
|
|
stmt.setInt(5, tenantId);
|
|
|
|
stmt.setInt(5, releaseId);
|
|
|
|
|
|
|
|
stmt.setInt(6, tenantId);
|
|
|
|
stmt.addBatch();
|
|
|
|
stmt.addBatch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt.executeBatch();
|
|
|
|
stmt.executeBatch();
|
|
|
@ -752,12 +758,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean updateScheduledSubscription(int id, LocalDateTime scheduledAt, String scheduledBy)
|
|
|
|
public boolean updateScheduledSubscription(int id, LocalDateTime scheduledAt, String scheduledBy)
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION AP "
|
|
|
|
String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION "
|
|
|
|
+ "SET "
|
|
|
|
+ "SET "
|
|
|
|
+ "AP.SCHEDULED_AT = ?, "
|
|
|
|
+ "SCHEDULED_AT = ?, "
|
|
|
|
+ "AP.SCHEDULED_BY = ?, "
|
|
|
|
+ "SCHEDULED_BY = ?, "
|
|
|
|
+ "AP.SCHEDULED_TIMESTAMP = ? "
|
|
|
|
+ "SCHEDULED_TIMESTAMP = ? "
|
|
|
|
+ "WHERE AP.ID = ?";
|
|
|
|
+ "WHERE ID = ?";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
@ -783,9 +789,9 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean deleteScheduledSubscription(List<Integer> subscriptionIdList) throws ApplicationManagementDAOException {
|
|
|
|
public boolean deleteScheduledSubscription(List<Integer> subscriptionIdList) throws ApplicationManagementDAOException {
|
|
|
|
String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION AP "
|
|
|
|
String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION "
|
|
|
|
+ "SET AP.DELETED = ? "
|
|
|
|
+ "SET DELETED = ? "
|
|
|
|
+ "WHERE AP.ID = ?";
|
|
|
|
+ "WHERE ID = ?";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
@ -813,9 +819,9 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean updateScheduledSubscriptionStatus(int id, ExecutionStatus status)
|
|
|
|
public boolean updateScheduledSubscriptionStatus(int id, ExecutionStatus status)
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
throws ApplicationManagementDAOException {
|
|
|
|
String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION AP "
|
|
|
|
String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION "
|
|
|
|
+ "SET AP.STATUS = ? "
|
|
|
|
+ "SET STATUS = ? "
|
|
|
|
+ "WHERE AP.ID = ?";
|
|
|
|
+ "WHERE ID = ?";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
|
|
@ -847,7 +853,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
Connection conn = this.getDBConnection();
|
|
|
|
List<String> subscribedUsers = new ArrayList<>();
|
|
|
|
List<String> subscribedUsers = new ArrayList<>();
|
|
|
|
String sql = "SELECT "
|
|
|
|
String sql = "SELECT "
|
|
|
|
+ "US.USER_NAME AS USER "
|
|
|
|
+ "US.USER_NAME AS USER_NAME "
|
|
|
|
+ "FROM AP_USER_SUBSCRIPTION US "
|
|
|
|
+ "FROM AP_USER_SUBSCRIPTION US "
|
|
|
|
+ "WHERE "
|
|
|
|
+ "WHERE "
|
|
|
|
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?";
|
|
|
|
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?";
|
|
|
@ -858,7 +864,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
stmt.setInt(4, offsetValue);
|
|
|
|
stmt.setInt(4, offsetValue);
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
subscribedUsers.add(rs.getString("USER"));
|
|
|
|
subscribedUsers.add(rs.getString("USER_NAME"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return subscribedUsers;
|
|
|
|
return subscribedUsers;
|
|
|
|