Index: openacs-4/packages/rules/sql/oracle/rules-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/sql/oracle/Attic/rules-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/sql/oracle/rules-create.sql 3 Dec 2004 18:07:19 -0000 1.1 @@ -0,0 +1,194 @@ +-- create rule object +-- +-- @creation-date Nov 11, 2004 + +--------------------------------------------------------------------- +-- rule_object +--------------------------------------------------------------------- + +begin + + -- create the rule object + + acs_object_type.create_type ( + supertype => 'acs_object', + object_type => 'rule', + pretty_name => 'Rule', + pretty_plural => 'Rules', + table_name => 'rules', + id_column => 'rule_id' + ); +end; +/ +show errors; + +declare + + attr_id acs_attributes.attribute_id%TYPE; +begin + attr_id := acs_attribute.create_attribute ( + object_type => 'rule', + attribute_name => 'rule_name', + pretty_name => 'Name', + pretty_plural => 'Names', + datatype => 'string' + ); + + attr_id := acs_attribute.create_attribute ( + object_type => 'rule', + attribute_name => 'asm_id', + pretty_name => 'Assessment', + pretty_plural => 'Assessments', + datatype => 'integer' + ); + + attr_id := acs_attribute.create_attribute ( + object_type => 'rule', + attribute_name => 'active_p', + pretty_name => 'Active', + pretty_plural => 'Active', + datatype => 'string' + ); +end; +/ +show errors; + +--------------------------------------------------------- +-- Table rules +--------------------------------------------------------- + + +create table rules ( + rule_id integer, + rule_name varchar2(50), + asm_id integer, + active_p varchar2(1), + constraint rules_rule_id_pk primary key (rule_id) , + constraint rules_rule_id_fk foreign key (rule_id) references acs_objects (object_id), + constraint rules_active_p_ck check (active_p in ('y','n')) +); + + +------------------------------------------- +-- Table rules_triggers +------------------------------------------- + + +create table rules_triggers ( + -- primary key + rule_def_id integer + constraint rules_triggers_rule_def_id_pk + primary key, + qs_id integer, + result_id integer, + rule_id integer + constraint rules_triggers_rule_id_fk + references rules + on delete cascade, + active_p varchar2(1) + default 'y' + constraint rules_triggers_active_p_ck + check (active_p in ( + 'y', + 'n' + ) + ) +); + + +------------------------------------------- +-- Table rules_actions +------------------------------------------- + + +create table rules_actions ( + -- primary key + rule_action_id integer + constraint rules_a_rule_a_id_pk + primary key, + action_type varchar2(10), + group_id integer, + rule_id integer + constraint rules_a_rule_id_fk + references rules + on delete cascade, + notify_p varchar2(1) + default 'y' + constraint notify_p_ck + check (notify_p in ( + 'y', + 'n' + ) + ), + active_p varchar2(1) + default 'y' + constraint active_p_ck + check (active_p in ( + 'y', + 'n' + ) + ) +); + + + + +------------------------------------------- +-- Table rule_history_actions +------------------------------------------- + + +create table rule_history_actions ( + -- primary key + rha_id integer + constraint rha_rha_id_pk + primary key, + group_id integer, + rule_action_id integer + constraint rha_rule_act_id_fk + references rules_actions + on delete cascade, + request_date date, + processing_date date, + approved_p varchar2(1) + default 'y' + constraint rha_approved_p_ck + check (approved_p in ( + 'y', + 'n' + ) + ) +); + +-------------------------------------------------------- +-- TRIGGER SEQUENCE FOR PRIMARY KEY +-------------------------------------------------------- + create sequence trigger_seq + minvalue 1 + maxvalue 999999999 + start with 1 + increment by 1 + cache 20; + +-------------------------------------------------------- +-- ACTION SEQUENCE FOR PRIMARY KEY +-------------------------------------------------------- + + create sequence action_seq + minvalue 1 + maxvalue 999999999 + start with 1 + increment by 1 + cache 20; + + +-------------------------------------------------------- +-- RULE HISTORY ACTIONS SEQUENCE FOR PRIMARY KEY +-------------------------------------------------------- + + create sequence rha_seq + minvalue 1 + maxvalue 999999999 + start with 1 + increment by 1 + cache 20; Index: openacs-4/packages/rules/sql/oracle/rules-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/sql/oracle/Attic/rules-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/sql/oracle/rules-drop.sql 3 Dec 2004 18:07:20 -0000 1.1 @@ -0,0 +1,16 @@ +-- +-- The Rules Package +-- +-- + +drop table rule_history_actions; +drop table rules_actions; +drop table rules_triggers; +drop table rules; + +declare begin + acs_object_type.drop_type (object_type => 'rules'); +end; +/ +show errors; + Index: openacs-4/packages/rules/sql/oracle/rules-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/sql/oracle/Attic/rules-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/sql/oracle/rules-package-create.sql 3 Dec 2004 18:07:20 -0000 1.1 @@ -0,0 +1,92 @@ +------------------------------------------------ +-- create package rule +------------------------------------------------ + + +create or replace package rule +as + + function new ( + rule_id in acs_objects.object_id%TYPE default null, + rule_name in rules.rule_name%TYPE default null, + object_type in acs_objects.object_type%TYPE default 'rule', + asm_id in rules.asm_id%TYPE, + active_p in rules.active_p%TYPE default 'y', + context_id in acs_objects.context_id%TYPE default null, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null + ) return rules.rule_id%TYPE; + + procedure del ( + rule_id in rules.rule_id%TYPE + ); +end rule; +/ +show errors; + +create or replace package body rule +as + function new ( + rule_id in acs_objects.object_id%TYPE default null, + rule_name in rules.rule_name%TYPE default null, + object_type in acs_objects.object_type%TYPE default 'rule', + asm_id in rules.asm_id%TYPE, + active_p in rules.active_p%TYPE default 'y', + context_id in acs_objects.context_id%TYPE default null, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null + ) return rules.rule_id%TYPE + is + v_rule_id rules.rule_id%TYPE; + + begin + v_rule_id := acs_object.new ( + object_id => rule_id, + object_type => object_type, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id + ); + + insert into rules + (rule_id,rule_name,asm_id,active_p) + values + (v_rule_id,rule_name,asm_id,active_p); + + return v_rule_id; + end new; + + + + -- body for procedure delete + + procedure del ( + rule_id in rules.rule_id%TYPE + ) + is + begin + delete from rule_history_actions + where rule_id = rule.del.rule_id; + delete from rules_actions + where rule_id = rule.del.rule_id; + delete from rules_triggers + where rule_id = rule.del.rule_id; + delete from rules + where rule_id = rule.del.rule_id; + acs_object.del(rule_id); + end del; + +end rule; +/ +show errors + + + + + + + + Index: openacs-4/packages/rules/sql/oracle/rules-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rules/sql/oracle/Attic/rules-package-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/rules/sql/oracle/rules-package-drop.sql 3 Dec 2004 18:07:20 -0000 1.1 @@ -0,0 +1,4 @@ +-------------------------- +-- drop package rules +------------------------- +drop package rule; \ No newline at end of file