Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issues in Event Notification Implementation #33

Merged
merged 6 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
CREATE TABLE OB_NOTIFICATION (
ChinthakaJ98 marked this conversation as resolved.
Show resolved Hide resolved
NOTIFICATION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
RESOURCE_ID varchar(255) NOT NULL,
STATUS varchar(10) NOT NULL,
UPDATED_TIMESTAMP DATETIME2(0) DEFAULT GETDATE(),
PRIMARY KEY (NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_EVENT (
EVENT_ID int NOT NULL IDENTITY,
NOTIFICATION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(200) NOT NULL,
EVENT_INFO varchar(1000) NOT NULL,
PRIMARY KEY (EVENT_ID),
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_ERROR (
NOTIFICATION_ID varchar(36) NOT NULL,
ERROR_CODE varchar(255) NOT NULL,
DESCRIPTION varchar(255) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
CALLBACK_URL varchar(255),
TIMESTAMP BIGINT NOT NULL,
SPEC_VERSION varchar(255),
STATUS varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID)
);

CREATE TABLE OB_NOTIFICATION_SUBSCRIBED_EVENTS (
SUBSCRIPTION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-- For event notifications feature run the following queries against the openbank_openbankingdb--

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
NOTIFICATION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
RESOURCE_ID varchar(255) NOT NULL,
STATUS varchar(10) NOT NULL,
UPDATED_TIMESTAMP TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (NOTIFICATION_ID)
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_EVENT (
EVENT_ID int(11) NOT NULL AUTO_INCREMENT,
NOTIFICATION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(200) NOT NULL,
EVENT_INFO varchar(1000) NOT NULL,
PRIMARY KEY (EVENT_ID),
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_ERROR (
NOTIFICATION_ID varchar(36) NOT NULL,
ERROR_CODE varchar(255) NOT NULL,
DESCRIPTION varchar(255) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
CALLBACK_URL varchar(255),
TIMESTAMP BIGINT NOT NULL,
SPEC_VERSION varchar(255),
STATUS varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID)
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIBED_EVENTS (
SUBSCRIPTION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
)
ENGINE=InnoDB;
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
CREATE TABLE OB_NOTIFICATION (
NOTIFICATION_ID varchar2(36) NOT NULL,
CLIENT_ID varchar2(255) NOT NULL,
RESOURCE_ID varchar2(255) NOT NULL,
STATUS varchar2(10) NOT NULL,
UPDATED_TIMESTAMP TIMESTAMP(0) DEFAULT SYSTIMESTAMP,
PRIMARY KEY (NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_EVENT (
EVENT_ID number(10) NOT NULL,
NOTIFICATION_ID varchar2(36) NOT NULL,
EVENT_TYPE varchar2(200) NOT NULL,
EVENT_INFO varchar2(1000) NOT NULL,
PRIMARY KEY (EVENT_ID),
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
);

-- Generate ID using sequence and trigger
CREATE SEQUENCE OB_NOTIFICATION_EVENT_seq START WITH 1 INCREMENT BY 1;

CREATE OR REPLACE TRIGGER OB_NOTIFICATION_EVENT_seq_tr
BEFORE INSERT ON OB_NOTIFICATION_EVENT FOR EACH ROW
WHEN (NEW.EVENT_ID IS NULL)
BEGIN
SELECT OB_NOTIFICATION_EVENT_seq.NEXTVAL INTO :NEW.EVENT_ID FROM DUAL;
END;

Ashi1993 marked this conversation as resolved.
Show resolved Hide resolved

CREATE TABLE OB_NOTIFICATION_ERROR (
NOTIFICATION_ID varchar2(36) NOT NULL,
ERROR_CODE varchar2(255) NOT NULL,
DESCRIPTION varchar2(255) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
)

CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
CALLBACK_URL varchar(255),
TIMESTAMP BIGINT NOT NULL,
SPEC_VERSION varchar(255),
STATUS varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID)
);

CREATE TABLE OB_NOTIFICATION_SUBSCRIBED_EVENTS (
SUBSCRIPTION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
);


Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- For event notifications feature run the following queries against the openbank_openbankingdb--

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
NOTIFICATION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
RESOURCE_ID varchar(255) NOT NULL,
STATUS varchar(10) NOT NULL,
UPDATED_TIMESTAMP TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (NOTIFICATION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_EVENT (
EVENT_ID SERIAL PRIMARY KEY,
NOTIFICATION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(200) NOT NULL,
EVENT_INFO varchar(1000) NOT NULL,
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_ERROR (
NOTIFICATION_ID varchar(36) NOT NULL,
ERROR_CODE varchar(255) NOT NULL,
DESCRIPTION varchar(255) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID),
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES OB_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
CALLBACK_URL varchar(255),
TIMESTAMP BIGINT NOT NULL,
SPEC_VERSION varchar(255),
STATUS varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIBED_EVENTS (
SUBSCRIPTION_ID varchar(36) NOT NULL,
EVENT_TYPE varchar(255) NOT NULL,
PRIMARY KEY (SUBSCRIPTION_ID, EVENT_TYPE),
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES OB_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
);
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,5 @@ public class EventNotificationConstants {
public static final String EVENT_SUBSCRIPTION_NOT_FOUND = "Event subscription not found.";
public static final String EVENT_SUBSCRIPTIONS_NOT_FOUND = "Event subscriptions not found for the given client id.";
public static final String ERROR_HANDLING_EVENT_SUBSCRIPTION = "Error occurred while handling the event " +
"subscription request";
"subscription request";
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,68 +35,70 @@ public interface AggregatedPollingDAO {
* This method is to update the notification status by ID, allowed values are.
* OPEN,ACK and ERR
*
* @param notificationId
* @param notificationStatus
* @return
* @param notificationId Notification ID to update
* @param notificationStatus Notification status to update
* @return Update is success or not
* @throws OBEventNotificationException
*/
Boolean updateNotificationStatusById(String notificationId, String notificationStatus)
throws OBEventNotificationException;

/**
* This method is to store event notifications in the OB_NOTIFICATION table.
* @param notificationError
* @return
* This method is to store event notifications error details in the OB_NOTIFICATION table.
*
* @param notificationError Notification error details
* @return Stored event notifications error details
* @throws OBEventNotificationException
*/
Map<String, NotificationError> storeErrorNotification(NotificationError notificationError)
throws OBEventNotificationException;

/**
* This method is to retrieve given number of notifications in the OB_NOTIFICATION table by client and status.
* @param clientId
* @param status
* @param max
* @return
*
* @param clientId Client ID to retrieve notifications
* @param status Notification status to retrieve
* @param max Maximum number of notifications to retrieve
* @return List of notifications by client and status
* @throws OBEventNotificationException
*/
List<NotificationDTO> getNotificationsByClientIdAndStatus(String clientId, String
status, int max) throws OBEventNotificationException;

/**
* This method is to retrieve notifications by NotificationID.
* @param notificationId
*
* @return
* @param notificationId Notification ID to retrieve
* @return List of notifications by notification ID
* @throws OBEventNotificationException
*/
List<NotificationEvent> getEventsByNotificationID(String notificationId) throws OBEventNotificationException;

/**
* This method is to retrieve notifications in the OB_NOTIFICATION table by status.
* @param status
*
* @return List<NotificationDTO>
* @param status Notification status to retrieve
* @return List of notifications by status
* @throws OBEventNotificationException
*/
List<NotificationDTO> getNotificationsByStatus(String status) throws OBEventNotificationException;

/**
* This method is to retrieve notificationsCount by ClientId and Status.
* @param clientId
* @param eventStatus
*
* @return
* @param clientId Client ID to retrieve notifications
* @param eventStatus Notification status to retrieve
* @return List of notifications by status and client id
* @throws OBEventNotificationException
*/
int getNotificationCountByClientIdAndStatus(String clientId, String eventStatus)
throws OBEventNotificationException;

/**
* This method is to retrieve the notification status.
* @param notificationId
*
* @return
* @param notificationId Notification ID to retrieve
* @return Notification status by notification ID
* @throws OBEventNotificationException
*/
boolean getNotificationStatus(String notificationId) throws OBEventNotificationException;
Expand Down
Loading
Loading