|
|
@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAO
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.*;
|
|
|
|
import java.sql.*;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -43,14 +44,15 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = NotificationManagementDAOFactory.getConnection();
|
|
|
|
conn = NotificationManagementDAOFactory.getConnection();
|
|
|
|
String sql =
|
|
|
|
String sql =
|
|
|
|
"INSERT INTO DM_NOTIFICATION(DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION, TENANT_ID) " +
|
|
|
|
"INSERT INTO DM_NOTIFICATION(DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION, " +
|
|
|
|
"VALUES (?, ?, ?, ?, ?)";
|
|
|
|
"TENANT_ID, LAST_UPDATED_TIMESTAMP) VALUES (?, ?, ?, ?, ?, ?)";
|
|
|
|
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
|
|
|
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
|
|
|
stmt.setInt(1, deviceId);
|
|
|
|
stmt.setInt(1, deviceId);
|
|
|
|
stmt.setInt(2, notification.getOperationId());
|
|
|
|
stmt.setInt(2, notification.getOperationId());
|
|
|
|
stmt.setString(3, notification.getStatus().toString());
|
|
|
|
stmt.setString(3, notification.getStatus().toString());
|
|
|
|
stmt.setString(4, notification.getDescription());
|
|
|
|
stmt.setString(4, notification.getDescription());
|
|
|
|
stmt.setInt(5, tenantId);
|
|
|
|
stmt.setInt(5, tenantId);
|
|
|
|
|
|
|
|
stmt.setTimestamp(6, new Timestamp(new Date().getTime()));
|
|
|
|
stmt.execute();
|
|
|
|
stmt.execute();
|
|
|
|
rs = stmt.getGeneratedKeys();
|
|
|
|
rs = stmt.getGeneratedKeys();
|
|
|
|
if (rs.next()) {
|
|
|
|
if (rs.next()) {
|
|
|
@ -103,13 +105,14 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO {
|
|
|
|
int rows;
|
|
|
|
int rows;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = NotificationManagementDAOFactory.getConnection();
|
|
|
|
conn = NotificationManagementDAOFactory.getConnection();
|
|
|
|
String sql = "UPDATE DM_NOTIFICATION SET OPERATION_ID = ?, STATUS = ?, DESCRIPTION = ? " +
|
|
|
|
String sql = "UPDATE DM_NOTIFICATION SET OPERATION_ID = ?, STATUS = ?, DESCRIPTION = ?, " +
|
|
|
|
"WHERE NOTIFICATION_ID = ?";
|
|
|
|
"LAST_UPDATED_TIMESTAMP = ? WHERE NOTIFICATION_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setInt(1, notification.getOperationId());
|
|
|
|
stmt.setInt(1, notification.getOperationId());
|
|
|
|
stmt.setString(2, notification.getStatus().toString());
|
|
|
|
stmt.setString(2, notification.getStatus().toString());
|
|
|
|
stmt.setString(3, notification.getDescription());
|
|
|
|
stmt.setString(3, notification.getDescription());
|
|
|
|
stmt.setInt(4, notification.getNotificationId());
|
|
|
|
stmt.setTimestamp(4, new Timestamp(new Date().getTime()));
|
|
|
|
|
|
|
|
stmt.setInt(5, notification.getNotificationId());
|
|
|
|
rows = stmt.executeUpdate();
|
|
|
|
rows = stmt.executeUpdate();
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new NotificationManagementException("Error occurred while updating the " +
|
|
|
|
throw new NotificationManagementException("Error occurred while updating the " +
|
|
|
@ -128,10 +131,11 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO {
|
|
|
|
int rows;
|
|
|
|
int rows;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = NotificationManagementDAOFactory.getConnection();
|
|
|
|
conn = NotificationManagementDAOFactory.getConnection();
|
|
|
|
String sql = "UPDATE DM_NOTIFICATION SET STATUS = ? WHERE NOTIFICATION_ID = ?";
|
|
|
|
String sql = "UPDATE DM_NOTIFICATION SET STATUS = ?, LAST_UPDATED_TIMESTAMP = ? WHERE NOTIFICATION_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, status.toString());
|
|
|
|
stmt.setString(1, status.toString());
|
|
|
|
stmt.setInt(2, notificationId);
|
|
|
|
stmt.setTimestamp(2, new Timestamp(new Date().getTime()));
|
|
|
|
|
|
|
|
stmt.setInt(3, notificationId);
|
|
|
|
rows = stmt.executeUpdate();
|
|
|
|
rows = stmt.executeUpdate();
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new NotificationManagementException("Error occurred while updating the status of " +
|
|
|
|
throw new NotificationManagementException("Error occurred while updating the status of " +
|
|
|
@ -150,10 +154,11 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO {
|
|
|
|
int rows;
|
|
|
|
int rows;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = NotificationManagementDAOFactory.getConnection();
|
|
|
|
conn = NotificationManagementDAOFactory.getConnection();
|
|
|
|
String sql = "UPDATE DM_NOTIFICATION SET STATUS = ? WHERE TENANT_ID= ?";
|
|
|
|
String sql = "UPDATE DM_NOTIFICATION SET STATUS = ?, LAST_UPDATED_TIMESTAMP = ? WHERE TENANT_ID= ?";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, status.toString());
|
|
|
|
stmt.setString(1, status.toString());
|
|
|
|
stmt.setInt(2, tenantID);
|
|
|
|
stmt.setTimestamp(2, new Timestamp(new Date().getTime()));
|
|
|
|
|
|
|
|
stmt.setInt(3, tenantID);
|
|
|
|
rows = stmt.executeUpdate();
|
|
|
|
rows = stmt.executeUpdate();
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new NotificationManagementException("Error while trying to clear all " +
|
|
|
|
throw new NotificationManagementException("Error while trying to clear all " +
|
|
|
|