Added Subscriptions, Schedules
This commit is contained in:
parent
86ab7df3fe
commit
5531b942de
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,52 @@
|
||||
prompt --application/shared_components/user_interface/lovs/lov_core_schedules
|
||||
begin
|
||||
-- Manifest
|
||||
-- LOV_CORE_SCHEDULES
|
||||
-- Manifest End
|
||||
wwv_flow_api.component_begin (
|
||||
p_version_yyyy_mm_dd=>'2021.04.15'
|
||||
,p_release=>'21.1.7'
|
||||
,p_default_workspace_id=>9014660246496943
|
||||
,p_default_application_id=>770
|
||||
,p_default_id_offset=>0
|
||||
,p_default_owner=>'CORE'
|
||||
);
|
||||
wwv_flow_api.create_list_of_values(
|
||||
p_id=>wwv_flow_api.id(24119159536460151)
|
||||
,p_lov_name=>'LOV_CORE_SCHEDULES'
|
||||
,p_source_type=>'TABLE'
|
||||
,p_location=>'LOCAL'
|
||||
,p_use_local_sync_table=>false
|
||||
,p_query_table=>'MAIL_SCHEDULES'
|
||||
,p_query_where=>'app_id = app.get_app_id()'
|
||||
,p_return_column_name=>'SCHEDULE_ID'
|
||||
,p_display_column_name=>'SCHEDULE_ID'
|
||||
,p_group_column_name=>'SCHEDULE_GROUP'
|
||||
,p_group_sort_direction=>'ASC'
|
||||
,p_default_sort_column_name=>'SCHEDULE_ID'
|
||||
,p_default_sort_direction=>'ASC'
|
||||
);
|
||||
wwv_flow_api.create_list_of_values_cols(
|
||||
p_id=>wwv_flow_api.id(24119589931466015)
|
||||
,p_query_column_name=>'SCHEDULE_ID'
|
||||
,p_heading=>'Schedule Id'
|
||||
,p_display_sequence=>10
|
||||
,p_data_type=>'VARCHAR2'
|
||||
);
|
||||
wwv_flow_api.create_list_of_values_cols(
|
||||
p_id=>wwv_flow_api.id(24119958623466017)
|
||||
,p_query_column_name=>'SCHEDULE_GROUP'
|
||||
,p_heading=>'Schedule Group'
|
||||
,p_display_sequence=>20
|
||||
,p_data_type=>'VARCHAR2'
|
||||
);
|
||||
wwv_flow_api.create_list_of_values_cols(
|
||||
p_id=>wwv_flow_api.id(24120349566466017)
|
||||
,p_query_column_name=>'DESCRIPTION_'
|
||||
,p_heading=>'Description '
|
||||
,p_display_sequence=>30
|
||||
,p_data_type=>'VARCHAR2'
|
||||
);
|
||||
wwv_flow_api.component_end;
|
||||
end;
|
||||
/
|
||||
@ -31,6 +31,7 @@ prompt --install
|
||||
@@application/shared_components/user_interface/lovs/lov_core_languages.sql
|
||||
@@application/shared_components/user_interface/lovs/lov_core_pages_page_id_page_name.sql
|
||||
@@application/shared_components/user_interface/lovs/lov_core_roles_role_id_role_name.sql
|
||||
@@application/shared_components/user_interface/lovs/lov_core_schedules.sql
|
||||
@@application/shared_components/user_interface/lovs/lov_core_templates.sql
|
||||
@@application/shared_components/user_interface/lovs/lov_core_users_active_user_id_user_id.sql
|
||||
@@application/pages/page_groups.sql
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
--DROP TABLE event_subscriptions PURGE;
|
||||
CREATE TABLE event_subscriptions (
|
||||
app_id NUMBER(4) CONSTRAINT nn_event_subscriptions_app_id NOT NULL,
|
||||
event_id VARCHAR2(30) CONSTRAINT nn_event_subscriptions_event_id NOT NULL,
|
||||
role_id VARCHAR2(30) CONSTRAINT nn_event_subscriptions_role_id NOT NULL,
|
||||
--
|
||||
schedule_month VARCHAR2(128),
|
||||
schedule_day VARCHAR2(128),
|
||||
schedule_weekday VARCHAR2(128),
|
||||
schedule_hour VARCHAR2(128),
|
||||
schedule_minute VARCHAR2(128),
|
||||
schedule_interval VARCHAR2(128),
|
||||
--
|
||||
eval_function VARCHAR2(64),
|
||||
is_active CHAR(1),
|
||||
processed_log_id NUMBER,
|
||||
--
|
||||
updated_by VARCHAR2(30),
|
||||
updated_at DATE,
|
||||
--
|
||||
CONSTRAINT pk_event_subscriptions
|
||||
PRIMARY KEY (app_id, event_id),
|
||||
--
|
||||
CONSTRAINT fk_event_subscriptions_role_id
|
||||
FOREIGN KEY (app_id, role_id)
|
||||
REFERENCES roles (app_id, role_id),
|
||||
--
|
||||
CONSTRAINT ch_event_subscriptions_month
|
||||
CHECK (REGEXP_LIKE(schedule_month, '^(\d+,?\s*)+$') OR schedule_month IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_event_subscriptions_day
|
||||
CHECK (REGEXP_LIKE(schedule_day, '^(\d+,?\s*)+$') OR schedule_day IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_event_subscriptions_weekday
|
||||
CHECK (REGEXP_LIKE(schedule_weekday, '^(\d+,?\s*)+|(\d+[-]\d+)$') OR schedule_weekday IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_event_subscriptions_hour
|
||||
CHECK (REGEXP_LIKE(schedule_hour, '^(\d+,?\s*)+|(\d+[-]\d,?\s*)+$') OR schedule_hour IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_event_subscriptions_minute
|
||||
CHECK (REGEXP_LIKE(schedule_minute, '^(\d+,?\s*)+$') OR schedule_minute IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_event_subscriptions_interval
|
||||
CHECK (REGEXP_LIKE(schedule_interval, '^(\d+)$') OR schedule_interval IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_event_subscriptions_is_active
|
||||
CHECK (is_active = 'Y' OR is_active IS NULL)
|
||||
)
|
||||
STORAGE (BUFFER_POOL KEEP);
|
||||
--
|
||||
COMMENT ON TABLE event_subscriptions IS '[CORE] Subscriptions to events based on user roles';
|
||||
--
|
||||
COMMENT ON COLUMN event_subscriptions.app_id IS 'APEX application ID';
|
||||
COMMENT ON COLUMN event_subscriptions.event_id IS 'Event id';
|
||||
COMMENT ON COLUMN event_subscriptions.role_id IS 'Role id receiving subscribed content';
|
||||
COMMENT ON COLUMN event_subscriptions.schedule_month IS 'Send at specific month, 1..12 for months, separate values with comma';
|
||||
COMMENT ON COLUMN event_subscriptions.schedule_weekday IS 'Send at specific day in a week, 1..7 (MON..SUN), 1-5 possible';
|
||||
COMMENT ON COLUMN event_subscriptions.schedule_day IS 'Send at specific dau of the month, 1..31';
|
||||
COMMENT ON COLUMN event_subscriptions.schedule_hour IS 'Send at specific hour, 00..23, 8-17 is possible';
|
||||
COMMENT ON COLUMN event_subscriptions.schedule_minute IS 'Send at specific minute in an hour, 00..59';
|
||||
COMMENT ON COLUMN event_subscriptions.schedule_interval IS 'Send every 1..30 minutes, schedule_minute is ignored';
|
||||
COMMENT ON COLUMN event_subscriptions.eval_function IS 'Function to evaluate if to really send and to whom';
|
||||
COMMENT ON COLUMN event_subscriptions.is_active IS 'Flag to disable tracking';
|
||||
COMMENT ON COLUMN event_subscriptions.processed_log_id IS 'Last log_events.log_id to mark processed logs';
|
||||
|
||||
53
tables/mail_schedules.sql
Normal file
53
tables/mail_schedules.sql
Normal file
@ -0,0 +1,53 @@
|
||||
--DROP TABLE mail_subscriptions PURGE;
|
||||
--DROP TABLE mail_schedules PURGE;
|
||||
CREATE TABLE mail_schedules (
|
||||
app_id NUMBER(4) CONSTRAINT nn_mail_schedules_app_id NOT NULL,
|
||||
schedule_id VARCHAR2(30) CONSTRAINT nn_mail_schedules_schedule_id NOT NULL,
|
||||
schedule_group VARCHAR2(64),
|
||||
description_ VARCHAR2(256),
|
||||
--
|
||||
schedule_month VARCHAR2(128),
|
||||
schedule_day VARCHAR2(128),
|
||||
schedule_weekday VARCHAR2(128),
|
||||
schedule_hour VARCHAR2(128),
|
||||
schedule_minute VARCHAR2(128),
|
||||
schedule_interval VARCHAR2(128),
|
||||
--
|
||||
updated_by VARCHAR2(30),
|
||||
updated_at DATE,
|
||||
--
|
||||
CONSTRAINT pk_mail_schedules
|
||||
PRIMARY KEY (app_id, schedule_id),
|
||||
--
|
||||
CONSTRAINT ch_mail_schedules_month
|
||||
CHECK (REGEXP_LIKE(schedule_month, '^(\d+,?\s*)+$') OR schedule_month IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_mail_schedules_day
|
||||
CHECK (REGEXP_LIKE(schedule_day, '^(\d+,?\s*)+$') OR schedule_day IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_mail_schedules_weekday
|
||||
CHECK (REGEXP_LIKE(schedule_weekday, '^(\d+,?\s*)+|(\d+[-]\d+)$') OR schedule_weekday IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_mail_schedules_hour
|
||||
CHECK (REGEXP_LIKE(schedule_hour, '^(\d+,?\s*)+|(\d+[-]\d,?\s*)+$') OR schedule_hour IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_mail_schedules_minute
|
||||
CHECK (REGEXP_LIKE(schedule_minute, '^(\d+,?\s*)+$') OR schedule_minute IS NULL),
|
||||
--
|
||||
CONSTRAINT ch_mail_schedules_interval
|
||||
CHECK (REGEXP_LIKE(schedule_interval, '^(\d+)$') OR schedule_interval IS NULL)
|
||||
);
|
||||
--
|
||||
COMMENT ON TABLE mail_schedules IS '[CORE] mail_schedules...';
|
||||
--
|
||||
COMMENT ON COLUMN mail_schedules.app_id IS 'APEX application ID';
|
||||
COMMENT ON COLUMN mail_schedules.schedule_id IS 'Schedule id';
|
||||
COMMENT ON COLUMN mail_schedules.schedule_group IS 'Group for better visibility';
|
||||
COMMENT ON COLUMN mail_schedules.description_ IS 'Description';
|
||||
COMMENT ON COLUMN mail_schedules.schedule_month IS 'Send at specific month, 1..12 for months, separate values with comma';
|
||||
COMMENT ON COLUMN mail_schedules.schedule_weekday IS 'Send at specific day in a week, 1..7 (MON..SUN), 1-5 possible';
|
||||
COMMENT ON COLUMN mail_schedules.schedule_day IS 'Send at specific day of the month, 1..31';
|
||||
COMMENT ON COLUMN mail_schedules.schedule_hour IS 'Send at specific hour, 00..23, 8-17 is possible';
|
||||
COMMENT ON COLUMN mail_schedules.schedule_minute IS 'Send at specific minute in an hour, 00..59';
|
||||
COMMENT ON COLUMN mail_schedules.schedule_interval IS 'Send every 1..30 minutes, schedule_minute is ignored';
|
||||
|
||||
45
tables/mail_subscriptions.sql
Normal file
45
tables/mail_subscriptions.sql
Normal file
@ -0,0 +1,45 @@
|
||||
--DROP TABLE mail_subscriptions PURGE;
|
||||
CREATE TABLE mail_subscriptions (
|
||||
app_id NUMBER(4) CONSTRAINT nn_mail_subscriptions_app_id NOT NULL,
|
||||
event_id VARCHAR2(30) CONSTRAINT nn_mail_subscriptions_event_id NOT NULL,
|
||||
role_id VARCHAR2(30) CONSTRAINT nn_mail_subscriptions_role_id NOT NULL,
|
||||
template_id VARCHAR2(30) CONSTRAINT nn_mail_subscriptions_template_id NOT NULL,
|
||||
schedule_id VARCHAR2(30),
|
||||
eval_function VARCHAR2(64), -- to evaluate on each role user if to send or not
|
||||
--
|
||||
is_active CHAR(1),
|
||||
processed_log_id NUMBER,
|
||||
--
|
||||
updated_by VARCHAR2(30),
|
||||
updated_at DATE,
|
||||
--
|
||||
CONSTRAINT pk_mail_subscriptions
|
||||
PRIMARY KEY (app_id, event_id),
|
||||
--
|
||||
CONSTRAINT fk_mail_subscriptions_role_id
|
||||
FOREIGN KEY (app_id, role_id)
|
||||
REFERENCES roles (app_id, role_id),
|
||||
--
|
||||
CONSTRAINT fk_mail_subscriptions_schedule_id
|
||||
FOREIGN KEY (app_id, schedule_id)
|
||||
REFERENCES mail_schedules (app_id, schedule_id),
|
||||
--
|
||||
--CONSTRAINT fk_mail_subscriptions_template_id
|
||||
-- FOREIGN KEY (app_id, template_id)
|
||||
-- REFERENCES mail_templates (app_id, template_id), -- we dont know the language
|
||||
--
|
||||
CONSTRAINT ch_mail_subscriptions_is_active
|
||||
CHECK (is_active = 'Y' OR is_active IS NULL)
|
||||
);
|
||||
--
|
||||
COMMENT ON TABLE mail_subscriptions IS '[CORE] Subscriptions to events based on user roles';
|
||||
--
|
||||
COMMENT ON COLUMN mail_subscriptions.app_id IS 'APEX application ID';
|
||||
COMMENT ON COLUMN mail_subscriptions.event_id IS 'Event id';
|
||||
COMMENT ON COLUMN mail_subscriptions.role_id IS 'Role id receiving subscribed content';
|
||||
COMMENT ON COLUMN mail_subscriptions.template_id IS 'Template used for notification';
|
||||
COMMENT ON COLUMN mail_subscriptions.schedule_id IS 'Schedule for timing the notification';
|
||||
COMMENT ON COLUMN mail_subscriptions.eval_function IS 'Function to evaluate if to really send notification (and to whom)';
|
||||
COMMENT ON COLUMN mail_subscriptions.is_active IS 'Flag to disable tracking';
|
||||
COMMENT ON COLUMN mail_subscriptions.processed_log_id IS 'Last log_events.log_id to mark processed logs';
|
||||
|
||||
@ -44,7 +44,7 @@ COMPOUND TRIGGER
|
||||
WHERE e.app_id = :OLD.app_id
|
||||
AND e.event_id = :OLD.event_id;
|
||||
--
|
||||
UPDATE event_subscriptions e
|
||||
UPDATE mail_subscriptions e
|
||||
SET e.event_id = :NEW.event_id
|
||||
WHERE e.app_id = :OLD.app_id
|
||||
AND e.event_id = :OLD.event_id;
|
||||
@ -54,7 +54,7 @@ COMPOUND TRIGGER
|
||||
WHERE e.app_id = :OLD.app_id
|
||||
AND e.event_id = :OLD.event_id;
|
||||
--
|
||||
DELETE FROM event_subscriptions e
|
||||
DELETE FROM mail_subscriptions e
|
||||
WHERE e.app_id = :OLD.app_id
|
||||
AND e.event_id = :OLD.event_id;
|
||||
END IF;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user