Index: openacs-4/packages/acs-templating/sql/oracle/demo-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/oracle/demo-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-templating/sql/oracle/demo-create.sql 5 Apr 2001 18:23:38 -0000 1.1 +++ openacs-4/packages/acs-templating/sql/oracle/demo-create.sql 4 Feb 2006 01:54:41 -0000 1.2 @@ -24,3 +24,5 @@ insert into ad_template_sample_users values (4, 'Yoruba', 'Diaz', '12 Magic Ave.', NULL, 'Lariot', 'WY'); + +@@ template-demo-notes-create.sql \ No newline at end of file Index: openacs-4/packages/acs-templating/sql/oracle/demo-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/oracle/demo-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-templating/sql/oracle/demo-drop.sql 5 Apr 2001 18:23:38 -0000 1.1 +++ openacs-4/packages/acs-templating/sql/oracle/demo-drop.sql 4 Feb 2006 01:54:41 -0000 1.2 @@ -6,5 +6,7 @@ -- $Id$ -- +@@ template-demo-notes-drop.sql + drop table ad_template_sample_users; drop sequence ad_template_sample_users_seq; Index: openacs-4/packages/acs-templating/sql/oracle/template-demo-notes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/oracle/template-demo-notes-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/sql/oracle/template-demo-notes-create.sql 4 Feb 2006 01:54:41 -0000 1.1 @@ -0,0 +1,150 @@ +-- +-- packages/notes/sql/notes-create.sql +-- +-- @author rhs@mit.edu +-- @creation-date 2000-10-22 +-- @cvs-id $Id: template-demo-notes-create.sql,v 1.1 2006/02/04 01:54:41 jiml Exp $ +-- + +begin + acs_object_type.create_type ( + supertype => 'acs_object', + object_type => 'template_demo_note', + pretty_name => 'Template Demo Note', + pretty_plural => 'Template Demo Notes', + table_name => 'template_demo_notes', + id_column => 'template_demo_note_id', + name_method => 'template_demo_note.name' + ); +end; +/ +show errors; + +declare + attr_id acs_attributes.attribute_id%TYPE; +begin + attr_id := acs_attribute.create_attribute ( + object_type => 'template_demo_note', + attribute_name => 'title', + pretty_name => 'Title', + pretty_plural => 'Titles', + datatype => 'string' + ); + + attr_id := acs_attribute.create_attribute ( + object_type => 'template_demo_note', + attribute_name => 'body', + pretty_name => 'Body', + pretty_plural => 'Bodies', + datatype => 'string' + ); +end; +/ +show errors; + +create table template_demo_notes ( + template_demo_note_id integer + references acs_objects(object_id) + primary key, + title varchar(255) + not null, + body varchar(4000) +); + +create or replace package template_demo_note +as + function new ( + template_demo_note_id in template_demo_notes.template_demo_note_id%TYPE default null, + title in template_demo_notes.title%TYPE, + body in template_demo_notes.body%TYPE, + object_type in acs_object_types.object_type%TYPE + default 'template_demo_note', + 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, + context_id in acs_objects.context_id%TYPE default null + ) return template_demo_notes.template_demo_note_id%TYPE; + + procedure del ( + template_demo_note_id in template_demo_notes.template_demo_note_id%TYPE + ); + + function name ( + note_id in template_demo_notes.template_demo_note_id%TYPE + ) return template_demo_notes.title%TYPE; +end note; +/ +show errors + +create or replace package body template_demo_note +as + function new ( + template_demo_note_id in template_demo_notes.template_demo_note_id%TYPE default null, + title in template_demo_notes.title%TYPE, + body in template_demo_notes.body%TYPE, + object_type in acs_object_types.object_type%TYPE + default 'note', + 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, + context_id in acs_objects.context_id%TYPE default null + ) return template_demo_notes.template_demo_note_id%TYPE + is + v_template_demo_note_id integer; + begin + v_template_demo_note_id := acs_object.new ( + object_id => template_demo_note_id, + object_type => object_type, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id + ); + + insert into template_demo_notes + (template_demo_note_id, title, body) + values + (v_template_demo_note_id, title, body); + + acs_permission.grant_permission( + object_id => v_template_demo_note_id, + grantee_id => creation_user, + privilege => 'admin' + ); + + return v_template_demo_note_id; + end new; + + procedure del ( + template_demo_note_id in template_demo_notes.template_demo_note_id%TYPE + ) + is + begin + delete from acs_permissions + where object_id = template_demo_note.del.template_demo_note_id; + + delete from template_demo_notes + where template_demo_note_id = template_demo_note.del.template_demo_note_id; + + acs_object.del(template_demo_note_id); + end del; + + function name ( + template_demo_note_id in template_demo_notes.template_demo_note_id%TYPE + ) return template_demo_notes.title%TYPE + is + v_template_demo_note_name template_demo_notes.title%TYPE; + begin + select title into v_template_demo_note_name + from template_demo_notes + where template_demo_note_id = name.template_demo_note_id; + + return v_template_demo_note_name; + end name; +end template_demo_note; +/ +show errors; Index: openacs-4/packages/acs-templating/sql/oracle/template-demo-notes-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/oracle/template-demo-notes-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/sql/oracle/template-demo-notes-drop.sql 4 Feb 2006 01:54:41 -0000 1.1 @@ -0,0 +1,4 @@ +drop package template_demo_note; +drop table template_demo_notes; +execute acs_object_type.drop_type('template_demo_note'); +show errors Index: openacs-4/packages/acs-templating/sql/postgresql/demo-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/postgresql/demo-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-templating/sql/postgresql/demo-create.sql 20 Feb 2002 21:07:13 -0000 1.2 +++ openacs-4/packages/acs-templating/sql/postgresql/demo-create.sql 4 Feb 2006 01:54:41 -0000 1.3 @@ -25,3 +25,6 @@ insert into ad_template_sample_users values (4, 'Yoruba', 'Diaz', '12 Magic Ave.', NULL, 'Lariot', 'WY'); + +\i template-demo-notes-create.sql + Index: openacs-4/packages/acs-templating/sql/postgresql/demo-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/postgresql/demo-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-templating/sql/postgresql/demo-drop.sql 27 Apr 2001 02:27:09 -0000 1.1 +++ openacs-4/packages/acs-templating/sql/postgresql/demo-drop.sql 4 Feb 2006 01:54:41 -0000 1.2 @@ -6,5 +6,7 @@ -- $Id$ -- +\i template-demo-notes-drop.sql + drop table ad_template_sample_users; drop sequence ad_template_sample_users_seq; Index: openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-create.sql 4 Feb 2006 01:54:41 -0000 1.1 @@ -0,0 +1,163 @@ +-- +-- packages/notes/sql/notes-create.sql +-- +-- @author rhs@mit.edu +-- @creation-date 2000-10-22 +-- @cvs-id $Id: template-demo-notes-create.sql,v 1.1 2006/02/04 01:54:41 jiml Exp $ +-- +-- openacs port: vinod kurup vkurup@massmed.org +-- + +create function inline_0 () +returns integer as ' +begin + PERFORM acs_object_type__create_type ( + ''template_demo_note'', -- object_type + ''Template Demo Note'', -- pretty_name + ''Template Demo Notes'', -- pretty_plural + ''acs_object'', -- supertype + ''template_demo_notes'', -- table_name + ''template_demo_note_id'', -- id_column + null, -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + ''template_demo_note.name'' -- name_method + ); + + return 0; +end;' language 'plpgsql'; + +select inline_0 (); + +drop function inline_0 (); + +create function inline_1 () +returns integer as ' +begin + PERFORM acs_attribute__create_attribute ( + ''template_demo_note'', -- object_type + ''title'', -- attribute_name + ''string'', -- datatype + ''Title'', -- pretty_name + ''Titles'', -- pretty_plural + null, -- table_name + null, -- column_name + null, -- default_value + 1, -- min_n_values + 1, -- max_n_values + null, -- sort_order + ''type_specific'', -- storage + ''f'' -- static_p + ); + + PERFORM acs_attribute__create_attribute ( + ''template_demo_note'', -- object_type + ''body'', -- attribute_name + ''string'', -- datatype + ''Body'', -- pretty_name + ''Bodies'', -- pretty_plural + null, -- table_name + null, -- column_name + null, -- default_value + 1, -- min_n_values + 1, -- max_n_values + null, -- sort_order + ''type_specific'', -- storage + ''f'' -- static_p + ); + + return 0; +end;' language 'plpgsql'; + +select inline_1 (); + +drop function inline_1 (); + +create table template_demo_notes ( + template_demo_note_id integer + constraint template_demo_notes_note_id_fk + references acs_objects(object_id) + constraint template_demo_notes_note_id_pk + primary key, + title varchar(255) + constraint template_demo_notes_title_nn + not null, + body text +); + +select define_function_args('template_demo_note__new','template_demo_note_id,title,body,object_type;note,creation_date;now,creation_user,creation_ip,context_id'); + +create function template_demo_note__new (integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer) +returns integer as ' +declare + p_template_demo_note_id alias for $1; -- default null + p_title alias for $2; + p_body alias for $3; + p_object_type alias for $4; -- default ''note'' + p_creation_date alias for $5; -- default now() + p_creation_user alias for $6; -- default null + p_creation_ip alias for $7; -- default null + p_context_id alias for $8; -- default null + v_template_demo_note_id template_demo_notes.template_demo_note_id%TYPE; +begin + v_template_demo_note_id := acs_object__new ( + p_template_demo_note_id, + p_object_type, + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id + ); + + insert into template_demo_notes + (template_demo_note_id, title, body) + values + (v_template_demo_note_id, p_title, p_body); + + PERFORM acs_permission__grant_permission( + v_template_demo_note_id, + p_creation_user, + ''admin'' + ); + + return v_template_demo_note_id; + +end;' language 'plpgsql'; + +select define_function_args('template_demo_note__del','template_demo_note_id'); + +create function template_demo_note__del (integer) +returns integer as ' +declare + p_template_demo_note_id alias for $1; +begin + delete from acs_permissions + where object_id = p_template_demo_note_id; + + delete from template_demo_notes + where template_demo_note_id = p_template_demo_note_id; + + raise NOTICE ''Deleting note...''; + PERFORM acs_object__delete(p_template_demo_note_id); + + return 0; + +end;' language 'plpgsql'; + +create function template_demo_note__name (integer) +returns varchar as ' +declare + p_template_demo_note_id alias for $1; + v_template_demo_note_name template_demo_notes.title%TYPE; +begin + select title into v_template_demo_note_name + from template_demo_notes + where template_demo_note_id = p_template_demo_note_id; + + return v_template_demo_note_name; +end; +' language 'plpgsql'; + + +-- neophytosd +\i notes-sc-create.sql Index: openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-drop.sql 4 Feb 2006 01:54:41 -0000 1.1 @@ -0,0 +1,54 @@ +-- template-demo-notes +-- drop script +-- Vinod Kurup, vkurup@massmed.org +-- + +-- neophytosd +\i template-demo-notes-sc-drop.sql + +--drop functions +drop function template_demo_note__new (integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer); +drop function template_demo_note__del(integer); +drop function template_demo_note__name (integer); + +--drop permissions +delete from acs_permissions where object_id in (select template_demo_note_id from template_demo_notes); + +--drop objects +create function inline_0 () +returns integer as ' +declare + object_rec record; +begin + for object_rec in select object_id from acs_objects where object_type=''template_demo_note'' + loop + perform acs_object__delete( object_rec.object_id ); + end loop; + + return 0; +end;' language 'plpgsql'; + +select inline_0(); +drop function inline_0(); + +--drop table +drop table template_demo_notes; + +--drop attributes +select acs_attribute__drop_attribute ( + 'template_demo_note', + 'TITLE' + ); + +select acs_attribute__drop_attribute ( + 'template_demo_note', + 'BODY' + ); + + +--drop type +select acs_object_type__drop_type( + 'template_demo_note', + 't' + ); + Index: openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-sc-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/postgresql/Attic/template-demo-notes-sc-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-sc-create.sql 4 Feb 2006 01:54:41 -0000 1.1 @@ -0,0 +1,66 @@ +-- +-- packages/template-demo-notes/sql/notes-sc-create.sql +-- +-- +-- This sets up the service contracts that make the text in notes +-- available for indexing by the search package. See documentation +-- on the packages 'search' and 'acs-service-contract'. +-- +-- This notes package has been altered by prepending "template-demo-" +-- to all identifiers, for use by the template demos page. +-- + + +select acs_sc_impl__new( + 'FtsContentProvider', -- impl_contract_name + 'template_demo_note', -- impl_name + 'template_demo_notes' -- impl_owner_name +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'template_demo_note', -- impl_name + 'datasource', -- impl_operation_name + 'template_demo_notes__datasource', -- impl_alias + 'TCL' -- impl_pl +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'template_demo_note', -- impl_name + 'url', -- impl_operation_name + 'template_demo_notes__url', -- impl_alias + 'TCL' -- impl_pl +); + + +create function template_demo_notes__itrg () +returns trigger as ' +begin + perform search_observer__enqueue(new.template_demo_note_id,''INSERT''); + return new; +end;' language 'plpgsql'; + +create function template_demo_notes__dtrg () +returns trigger as ' +begin + perform search_observer__enqueue(old.template_demo_note_id,''DELETE''); + return old; +end;' language 'plpgsql'; + +create function template_demo_notes__utrg () +returns trigger as ' +begin + perform search_observer__enqueue(old.template_demo_note_id,''UPDATE''); + return old; +end;' language 'plpgsql'; + + +create trigger template_demo_notes__itrg after insert on template_demo_notes +for each row execute procedure notes__itrg (); + +create trigger template_demo_notes__dtrg after delete on template_demo_notes +for each row execute procedure notes__dtrg (); + +create trigger template_demo_notes__utrg after update on template_demo_notes +for each row execute procedure notes__utrg (); Index: openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-sc-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/postgresql/Attic/template-demo-notes-sc-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-sc-drop.sql 4 Feb 2006 01:54:41 -0000 1.1 @@ -0,0 +1,18 @@ +select acs_sc_impl__delete( + 'FtsContentProvider', -- impl_contract_name + 'template_demo_note' -- impl_name +); + + + + +drop trigger template_demo_notes__utrg on notes; +drop trigger template_demo_notes__dtrg on notes; +drop trigger template_demo_notes__itrg on notes; + + + +drop function template_demo_notes__utrg (); +drop function template_demo_notes__dtrg (); +drop function template_demo_notes__itrg (); +