MS sql related bug fixes

feature/appm-store/pbac
inoshperera 5 years ago
parent f3d34a0ad6
commit 422e106c36

@ -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();
@ -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 DM_DEVICE_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);

@ -552,7 +552,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
isStatusProvided = true; isStatusProvided = true;
} }
query = query + " LIMIT ?,?"; query = query + " ORDER BY f.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement ps = conn.prepareStatement(query)) { try (PreparedStatement ps = conn.prepareStatement(query)) {

Loading…
Cancel
Save