Fixed EMM-1476.

revert-70aa11f8
harshanl 8 years ago
parent 41fc6e84e4
commit 35ea88b9de

@ -35,7 +35,7 @@ import java.util.List;
/** /**
* Implementation of NotificationDAO which includes the methods to do CRUD operations on notification. * Implementation of NotificationDAO which includes the methods to do CRUD operations on notification.
*/ */
public class NotificationDAOImpl implements NotificationDAO { public abstract class NotificationDAOImpl implements NotificationDAO {
@Override @Override
public int addNotification(int deviceId, int tenantId, public int addNotification(int deviceId, int tenantId,
@ -176,45 +176,6 @@ public class NotificationDAOImpl implements NotificationDAO {
return notifications; return notifications;
} }
@Override
public List<Notification> getAllNotifications(PaginationRequest request, int tenantId) throws NotificationManagementException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
List<Notification> notifications = null;
try {
conn = NotificationManagementDAOFactory.getConnection();
String sql =
"SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," +
" d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " +
"NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?";
sql = sql + " LIMIT ?,?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, tenantId);
stmt.setInt(2, tenantId);
int paramIdx = 3;
stmt.setInt(paramIdx++, request.getStartIndex());
stmt.setInt(paramIdx, request.getRowCount());
rs = stmt.executeQuery();
notifications = new ArrayList<>();
while (rs.next()) {
notifications.add(this.getNotification(rs));
}
} catch (SQLException e) {
throw new NotificationManagementException(
"Error occurred while retrieving information of all notifications", e);
} finally {
NotificationDAOUtil.cleanupResources(stmt, rs);
}
return notifications;
}
@Override @Override
public int getNotificationCount(int tenantId) throws NotificationManagementException { public int getNotificationCount(int tenantId) throws NotificationManagementException {
int notificationCount = 0; int notificationCount = 0;

@ -2,7 +2,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE (
ID BIGSERIAL PRIMARY KEY, ID BIGSERIAL PRIMARY KEY,
NAME VARCHAR(300) DEFAULT NULL, NAME VARCHAR(300) DEFAULT NULL,
PROVIDER_TENANT_ID INTEGER DEFAULT 0, PROVIDER_TENANT_ID INTEGER DEFAULT 0,
SHARED_WITH_ALL_TENANTS BOOLEAN NOT NULL DEFAULT FALSE SHARED_WITH_ALL_TENANTS BOOLEAN NOT NULL DEFAULT FALSE,
UNIQUE(NAME)
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE ( CREATE TABLE IF NOT EXISTS DM_DEVICE (
@ -272,7 +273,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT (
ID BIGSERIAL NOT NULL PRIMARY KEY, ID BIGSERIAL NOT NULL PRIMARY KEY,
POLICY_ID INTEGER NOT NULL, POLICY_ID INTEGER NOT NULL,
DEVICE_TYPE VARCHAR(300) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL,
TENANT_ID INTEGER NOT NULL TENANT_ID INTEGER NOT NULL
); );
@ -289,18 +290,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
ID BIGSERIAL NOT NULL PRIMARY KEY, ID BIGSERIAL NOT NULL PRIMARY KEY,
DEVICE_GROUP_ID INT NOT NULL, DEVICE_GROUP_ID INT NOT NULL,
POLICY_ID INT NOT NULL, POLICY_ID INT NOT NULL,
TENANT_ID INT NOT NULL, TENANT_ID INT NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_DM_DEVICE_GROUP_POLICY
FOREIGN KEY (DEVICE_GROUP_ID)
REFERENCES DM_GROUP (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY
FOREIGN KEY (POLICY_ID) FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID) REFERENCES DM_POLICY (ID)
@ -350,6 +344,52 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING (
-- POLICY RELATED TABLES FINISHED -- -- POLICY RELATED TABLES FINISHED --
-- DEVICE GROUP TABLES --
CREATE TABLE IF NOT EXISTS DM_GROUP (
ID BIGSERIAL NOT NULL PRIMARY KEY,
GROUP_NAME VARCHAR(100) DEFAULT NULL,
DESCRIPTION BYTEA DEFAULT NULL,
DATE_OF_CREATE INTEGER DEFAULT NULL,
DATE_OF_LAST_UPDATE INTEGER DEFAULT NULL,
OWNER VARCHAR(45) DEFAULT NULL,
TENANT_ID INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP (
ID BIGSERIAL NOT NULL PRIMARY KEY,
DEVICE_ID INTEGER DEFAULT NULL,
GROUP_ID INTEGER DEFAULT NULL,
TENANT_ID INTEGER DEFAULT 0,
CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_DEVICE2 FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID)
REFERENCES DM_GROUP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
-- END OF DEVICE GROUP TABLES --
-- POLICY AND DEVICE GROUP MAPPING --
CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY (
ID BIGSERIAL NOT NULL PRIMARY KEY,
DEVICE_GROUP_ID INTEGER NOT NULL,
POLICY_ID INTEGER NOT NULL,
TENANT_ID INTEGER NOT NULL,
CONSTRAINT FK_DM_DEVICE_GROUP_POLICY
FOREIGN KEY (DEVICE_GROUP_ID)
REFERENCES DM_GROUP (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY
FOREIGN KEY (POLICY_ID)
REFERENCES DM_POLICY (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
-- END OF POLICY AND DEVICE GROUP MAPPING --
-- NOTIFICATION TABLE -- -- NOTIFICATION TABLE --
CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
NOTIFICATION_ID BIGSERIAL NOT NULL PRIMARY KEY, NOTIFICATION_ID BIGSERIAL NOT NULL PRIMARY KEY,
@ -420,7 +460,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
CPU_USAGE DECIMAL(5) NULL, CPU_USAGE DECIMAL(5) NULL,
TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL,
AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL,
PLUGGED_IN INT NULL, PLUGGED_IN BOOLEAN NOT NULL DEFAULT FALSE,
UPDATE_TIMESTAMP BIGINT NOT NULL, UPDATE_TIMESTAMP BIGINT NOT NULL,
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
FOREIGN KEY (DEVICE_ID) FOREIGN KEY (DEVICE_ID)

Loading…
Cancel
Save