Skip to content

Commit

Permalink
Adding Event creation, polling and subscription implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashi1993 committed Oct 27, 2024
1 parent 1053789 commit b74b5f0
Show file tree
Hide file tree
Showing 47 changed files with 4,925 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-- Since the database systems does not support adding default unix time to the database columns, the default data
-- storing is handled within the database querieS.

CREATE TABLE OB_NOTIFICATION (
CREATE TABLE FS_NOTIFICATION (
NOTIFICATION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
RESOURCE_ID varchar(255) NOT NULL,
Expand All @@ -30,24 +30,24 @@ CREATE TABLE OB_NOTIFICATION (
PRIMARY KEY (NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_EVENT (
CREATE TABLE FS_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)
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_ERROR (
CREATE TABLE FS_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)
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
CREATE TABLE FS_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
Expand All @@ -58,9 +58,9 @@ CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
PRIMARY KEY (SUBSCRIPTION_ID)
);

CREATE TABLE OB_NOTIFICATION_SUBSCRIBED_EVENTS (
CREATE TABLE FS_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)
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES FS_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

-- For event notifications feature run the following queries against the openbank_openbankingdb--

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION (
NOTIFICATION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
RESOURCE_ID varchar(255) NOT NULL,
Expand All @@ -33,26 +33,26 @@ CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_EVENT (
CREATE TABLE IF NOT EXISTS FS_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)
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_ERROR (
CREATE TABLE IF NOT EXISTS FS_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)
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
Expand All @@ -64,10 +64,10 @@ CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
)
ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIBED_EVENTS (
CREATE TABLE IF NOT EXISTS FS_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)
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES FS_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
)
ENGINE=InnoDB;
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
-- All the data related to time are stored in unix time stamp and therefore, the data types for the time related data
-- are represented in BIGINT.
-- Since the database systems does not support adding default unix time to the database columns, the default data
-- storing is handled within the database querieS.
-- storing is handled within the database queries.

CREATE TABLE OB_NOTIFICATION (
CREATE TABLE FS_NOTIFICATION (
NOTIFICATION_ID varchar2(36) NOT NULL,
CLIENT_ID varchar2(255) NOT NULL,
RESOURCE_ID varchar2(255) NOT NULL,
Expand All @@ -30,34 +30,34 @@ CREATE TABLE OB_NOTIFICATION (
PRIMARY KEY (NOTIFICATION_ID)
);

CREATE TABLE OB_NOTIFICATION_EVENT (
CREATE TABLE FS_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)
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
);

-- Generate ID using sequence and trigger
CREATE SEQUENCE OB_NOTIFICATION_EVENT_seq START WITH 1 INCREMENT BY 1;
CREATE SEQUENCE FS_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
CREATE OR REPLACE TRIGGER FS_NOTIFICATION_EVENT_seq_tr
BEFORE INSERT ON FS_NOTIFICATION_EVENT FOR EACH ROW
WHEN (NEW.EVENT_ID IS NULL)
BEGIN
SELECT OB_NOTIFICATION_EVENT_seq.NEXTVAL INTO :NEW.EVENT_ID FROM DUAL;
SELECT FS_NOTIFICATION_EVENT_seq.NEXTVAL INTO :NEW.EVENT_ID FROM DUAL;
END;

CREATE TABLE OB_NOTIFICATION_ERROR (
CREATE TABLE FS_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)
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
)

CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
CREATE TABLE FS_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
Expand All @@ -68,9 +68,9 @@ CREATE TABLE OB_NOTIFICATION_SUBSCRIPTION (
PRIMARY KEY (SUBSCRIPTION_ID)
);

CREATE TABLE OB_NOTIFICATION_SUBSCRIBED_EVENTS (
CREATE TABLE FS_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)
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES FS_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

-- For event notifications feature run the following queries against the openbank_openbankingdb--

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION (
NOTIFICATION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
RESOURCE_ID varchar(255) NOT NULL,
Expand All @@ -32,23 +32,23 @@ CREATE TABLE IF NOT EXISTS OB_NOTIFICATION (
PRIMARY KEY (NOTIFICATION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_EVENT (
CREATE TABLE IF NOT EXISTS FS_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)
CONSTRAINT FK_NotificationEvent FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_ERROR (
CREATE TABLE IF NOT EXISTS FS_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)
CONSTRAINT FK_NotificationError FOREIGN KEY (NOTIFICATION_ID) REFERENCES FS_NOTIFICATION(NOTIFICATION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
CREATE TABLE IF NOT EXISTS FS_NOTIFICATION_SUBSCRIPTION (
SUBSCRIPTION_ID varchar(36) NOT NULL,
CLIENT_ID varchar(255) NOT NULL,
REQUEST JSON NOT NULL,
Expand All @@ -59,9 +59,9 @@ CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIPTION (
PRIMARY KEY (SUBSCRIPTION_ID)
);

CREATE TABLE IF NOT EXISTS OB_NOTIFICATION_SUBSCRIBED_EVENTS (
CREATE TABLE IF NOT EXISTS FS_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)
CONSTRAINT FK_NotificationSubEvents FOREIGN KEY (SUBSCRIPTION_ID) REFERENCES FS_NOTIFICATION_SUBSCRIPTION(SUBSCRIPTION_ID)
);
Loading

0 comments on commit b74b5f0

Please sign in to comment.