Merge pull request #1152 from ruwany/master

Fixing https://github.com/wso2/product-iots/issues/1579
4.x.x
Ruwan 7 years ago committed by GitHub
commit b6792f89f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAO
import java.sql.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -41,14 +42,16 @@ public class OracleNotificationDAOImpl extends AbstractNotificationDAOImpl {
int notificationId = -1;
try {
conn = NotificationManagementDAOFactory.getConnection();
String sql = "INSERT INTO DM_NOTIFICATION(DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION, TENANT_ID) "
+ "VALUES (?, ?, ?, ?, ?)";
String sql = "INSERT INTO DM_NOTIFICATION(DEVICE_ID, OPERATION_ID, STATUS, " +
"DESCRIPTION, TENANT_ID, LAST_UPDATED_TIMESTAMP) "
+ "VALUES (?, ?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(sql, new int[] { 1 });
stmt.setInt(1, deviceId);
stmt.setInt(2, notification.getOperationId());
stmt.setString(3, notification.getStatus().toString());
stmt.setString(4, notification.getDescription());
stmt.setInt(5, tenantId);
stmt.setTimestamp(6, new Timestamp(new Date().getTime()));
stmt.execute();
rs = stmt.getGeneratedKeys();
if (rs.next()) {

@ -385,6 +385,7 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
TENANT_ID INTEGER NOT NULL,
STATUS VARCHAR(10) NULL,
DESCRIPTION VARCHAR(1000) NULL,
LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,

@ -385,6 +385,7 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
TENANT_ID INTEGER NOT NULL,
STATUS VARCHAR(10) NULL,
DESCRIPTION VARCHAR(1000) NULL,
LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,

@ -437,6 +437,7 @@ CREATE TABLE DM_NOTIFICATION (
TENANT_ID INTEGER NOT NULL,
STATUS VARCHAR(10) NULL,
DESCRIPTION VARCHAR(1000) NULL,
LAST_UPDATED_TIMESTAMP DATETIME2 NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT FL_DM_NOTIFICATION FOREIGN KEY (DEVICE_ID) REFERENCES
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,

@ -452,6 +452,7 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
TENANT_ID INTEGER NOT NULL,
STATUS VARCHAR(10) NULL,
DESCRIPTION VARCHAR(1000) NULL,
LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,

@ -747,6 +747,7 @@ CREATE TABLE DM_NOTIFICATION (
TENANT_ID NUMBER(10) NOT NULL,
STATUS VARCHAR2(10) NULL,
DESCRIPTION VARCHAR2(1000) NULL,
LAST_UPDATED_TIMESTAMP TIMESTAMP(0) NOT NULL,
CONSTRAINT PK_DM_NOTIFICATION PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT FK_DM_DEVICE_NOTIFICATION FOREIGN KEY (DEVICE_ID) REFERENCES
DM_DEVICE (ID),

@ -395,6 +395,7 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
TENANT_ID INTEGER NOT NULL,
STATUS VARCHAR(10) NULL,
DESCRIPTION VARCHAR(1000) NULL,
LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL,
CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES
DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES

Loading…
Cancel
Save