Index: openacs-4/packages/acs-authentication/tcl/authority-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/authority-procs.tcl,v diff -u -N -r1.22 -r1.23 --- openacs-4/packages/acs-authentication/tcl/authority-procs.tcl 4 Mar 2004 14:52:35 -0000 1.22 +++ openacs-4/packages/acs-authentication/tcl/authority-procs.tcl 12 Mar 2004 18:48:45 -0000 1.23 @@ -265,6 +265,12 @@ get_flush -authority_id $authority_id get_id_flush -short_name $old_short_name + + # check if we need to update the object title + set new_short_name [get_element -authority_id $authority_id -element short_name] + if {![string equal $old_short_name $new_short_name]} { + db_dml update_object_title {} + } } ad_proc -public auth::authority::delete { Index: openacs-4/packages/acs-authentication/tcl/authority-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/authority-procs.xql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/acs-authentication/tcl/authority-procs.xql 4 Mar 2004 14:52:35 -0000 1.5 +++ openacs-4/packages/acs-authentication/tcl/authority-procs.xql 12 Mar 2004 18:48:45 -0000 1.6 @@ -2,6 +2,14 @@ + + + update acs_objects + set title = :new_short_name + where object_id = :authority_id + + + select pretty_name, authority_id Index: openacs-4/packages/acs-content-repository/sql/oracle/content-extlink.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-extlink.sql,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/acs-content-repository/sql/oracle/content-extlink.sql 4 Mar 2004 14:52:35 -0000 1.8 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-extlink.sql 12 Mar 2004 18:48:46 -0000 1.9 @@ -24,10 +24,12 @@ default sysdate, creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE ) return cr_extlinks.extlink_id%TYPE is v_extlink_id cr_extlinks.extlink_id%TYPE; + v_package_id acs_objects.package_id%TYPE; v_label cr_extlinks.label%TYPE; v_name cr_items.name%TYPE; @@ -46,9 +48,16 @@ v_name := name; end if; + if package_id is null then + v_package_id := acs_object.package_id(new.parent_id); + else + v_package_id := package_id; + end if; + v_extlink_id := content_item.new( item_id => content_extlink.new.extlink_id, - name => v_name, + name => v_name, + package_id => v_package_id, content_type => 'content_extlink', creation_date => content_extlink.new.creation_date, creation_user => content_extlink.new.creation_user, @@ -62,6 +71,10 @@ (v_extlink_id, content_extlink.new.url, v_label, content_extlink.new.description); + update acs_objects + set title = v_label + where object_id = v_extlink_id; + return v_extlink_id; end new; Index: openacs-4/packages/acs-content-repository/sql/oracle/content-folder.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-folder.sql,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/acs-content-repository/sql/oracle/content-folder.sql 4 Mar 2004 14:52:35 -0000 1.8 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-folder.sql 12 Mar 2004 18:48:46 -0000 1.9 @@ -22,10 +22,12 @@ folder_id in cr_folders.folder_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 + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE default null, ) return cr_folders.folder_id%TYPE is v_folder_id cr_folders.folder_id%TYPE; v_context_id acs_objects.context_id%TYPE; + v_package_id acs_objects.package_id%TYPE; begin -- set the context_id @@ -43,6 +45,12 @@ 'This folder does not allow subfolders to be created'); else + v_package_id := package_id; + + if parent_id is not null and package_id is null then + v_package_id := acs_object.package_id(content_item.get_root_folder(parent_id)); + end if; + v_folder_id := content_item.new( item_id => folder_id, name => name, @@ -52,15 +60,21 @@ creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - parent_id => parent_id + parent_id => parent_id, + package_id => v_package_id ); insert into cr_folders ( - folder_id, label, description + folder_id, label, description, package_id ) values ( - v_folder_id, label, description + v_folder_id, label, description, v_package_id ); + -- set the correct object title + update acs_objects + set title = new.label + where object_id = v_folder_id; + -- inherit the attributes of the parent folder if content_folder.new.parent_id is not null then @@ -163,6 +177,12 @@ content_item.rename(folder_id, name); end if; + if label is not null then + update acs_objects + set title = rename.label + where object_id = rename.folder_id; + end if; + if label is not null and description is not null then update cr_folders Index: openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql 4 Mar 2004 14:52:35 -0000 1.9 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql 12 Mar 2004 18:48:46 -0000 1.10 @@ -112,7 +112,8 @@ height in images.height%TYPE default null, width in images.width%TYPE default null, file_size in cr_revisions.content_length%TYPE default null, - storage_type in cr_items.storage_type%TYPE default 'file' + storage_type in cr_items.storage_type%TYPE default 'file', + package_id in acs_objects.package_id%TYPE ) return cr_items.item_id%TYPE; function new_revision ( @@ -131,7 +132,8 @@ filename in cr_revisions.filename%TYPE default null, height in images.height%TYPE default null, width in images.width%TYPE default null, - file_size in cr_revisions.content_length%TYPE default null + file_size in cr_revisions.content_length%TYPE default null, + package_id in acs_objects.package_id%TYPE ) return cr_revisions.revision_id%TYPE; --/** @@ -182,17 +184,26 @@ height in images.height%TYPE default null, width in images.width%TYPE default null, file_size in cr_revisions.content_length%TYPE default null, - storage_type in cr_items.storage_type%TYPE default 'file' + storage_type in cr_items.storage_type%TYPE default 'file', + package_id in acs_objects.package_id%TYPE ) return cr_items.item_id%TYPE is v_item_id cr_items.item_id%TYPE; v_revision_id cr_revisions.revision_id%TYPE; + v_package_id acs_objects.package_id%TYPE; begin + if package_id is null then + v_package_id := acs_object.package_id(new.parent_id); + else + v_package_id := package_id; + end if; + v_item_id := content_item.new ( name => name, item_id => item_id, parent_id => parent_id, + package_id => v_package_id, relation_tag => relation_tag, content_type => content_type, creation_date => creation_date, @@ -208,6 +219,7 @@ description => description, item_id => v_item_id, revision_id => revision_id, + package_id => v_package_id, publish_date => publish_date, mime_type => mime_type, nls_language => nls_language, @@ -257,17 +269,26 @@ filename in cr_revisions.filename%TYPE default null, height in images.height%TYPE default null, width in images.width%TYPE default null, - file_size in cr_revisions.content_length%TYPE default null + file_size in cr_revisions.content_length%TYPE default null, + package_id in acs_objects.package_id%TYPE ) return cr_revisions.revision_id%TYPE is v_revision_id cr_revisions.revision_id%TYPE; + v_package_id acs_objects.package_id%TYPE; begin + if package_id is null then + v_package_id := acs_object.package_id(new_revision.item_id); + else + v_package_id := package_id; + end if; + v_revision_id := content_revision.new ( title => title, description => description, item_id => item_id, revision_id => revision_id, + package_id => v_package_id, publish_date => publish_date, mime_type => mime_type, nls_language => nls_language, Index: openacs-4/packages/acs-content-repository/sql/oracle/content-item.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-item.sql,v diff -u -N -r1.20 -r1.21 --- openacs-4/packages/acs-content-repository/sql/oracle/content-item.sql 4 Mar 2004 14:52:35 -0000 1.20 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-item.sql 12 Mar 2004 18:48:46 -0000 1.21 @@ -74,7 +74,9 @@ data in cr_revisions.content%TYPE default null, relation_tag in cr_child_rels.relation_tag%TYPE default null, is_live in char default 'f', - storage_type in cr_items.storage_type%TYPE default 'lob' + storage_type in cr_items.storage_type%TYPE default 'lob', + package_id in acs_objects.package_id%TYPE default null + ) return cr_items.item_id%TYPE is v_parent_id cr_items.parent_id%TYPE; @@ -84,6 +86,7 @@ v_title cr_revisions.title%TYPE; v_rel_id acs_objects.object_id%TYPE; v_rel_tag cr_child_rels.relation_tag%TYPE; + v_package_id acs_objects.package_id%TYPE; v_context_id acs_objects.context_id%TYPE; v_storage_type cr_items.storage_type%TYPE; begin @@ -108,6 +111,12 @@ v_parent_id := parent_id; end if; + if package_id is null then + v_package_id := acs_object.package_id(content_item.get_root_folder(v_parent_id)); + else + v_package_id := package_id; + end if; + -- Determine context_id if context_id is null then v_context_id := v_parent_id; @@ -166,7 +175,9 @@ v_item_id := acs_object.new( object_id => content_item.new.item_id, - object_type => content_item.new.item_subtype, + object_type => content_item.new.item_subtype, + title => content_item.new.name, + package_id => v_package_id, context_id => v_context_id, creation_date => content_item.new.creation_date, creation_user => content_item.new.creation_user, @@ -193,6 +204,8 @@ v_rel_id := acs_object.new( object_type => 'cr_item_child_rel', + title => v_rel_tag || ': ' || v_parent_id || ' - ' || v_item_id, + package_id => v_package_id, context_id => v_parent_id ); @@ -220,6 +233,7 @@ v_revision_id := content_revision.new( item_id => v_item_id, title => v_title, + package_id => v_package_id, description => content_item.new.description, data => content_item.new.data, mime_type => content_item.new.mime_type, @@ -235,6 +249,7 @@ v_revision_id := content_revision.new( item_id => v_item_id, title => v_title, + package_id => v_package_id, description => content_item.new.description, text => content_item.new.text, mime_type => content_item.new.mime_type, @@ -634,6 +649,10 @@ update cr_items set name = rename.name where item_id = rename.item_id; + + update acs_objects + set title = rename.name + where object_id = rename.item_id; else close exists_cur; if exists_id <> rename.item_id then @@ -1233,6 +1252,12 @@ where item_id = move.item_id; end if; + if name is not null then + update acs_objects + set title = move.name + where object_id = move.item_id; + end if; + end if; end move; @@ -1584,6 +1609,7 @@ v_rel_id integer; v_exists integer; v_order_n cr_item_rels.order_n%TYPE; + v_package_id acs_objects.package_id%TYPE; begin -- check the relationship is valid @@ -1622,6 +1648,7 @@ v_exists := 0; end; + v_package_id := acs_object.package_id(relate.item_id); -- if order_n is null, use rel_id (the order the item was related) if relate.order_n is null then @@ -1636,6 +1663,8 @@ --dbms_output.put_line( 'creating new relationship...'); v_rel_id := acs_object.new( object_type => relation_type, + title => relation_tag || ': ' || relate.item_id || ' - ' || relate.object_id, + package_id => v_package_id, context_id => item_id ); insert into cr_item_rels ( @@ -1652,6 +1681,10 @@ order_n = v_order_n where rel_id = v_rel_id; + + update acs_objects set + title = relate.relation_tag || ': ' || relate.item_id || ' - ' || relate.object_id + where object_id = v_rel_id; end if; end if; Index: openacs-4/packages/acs-content-repository/sql/oracle/content-keyword.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-keyword.sql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/acs-content-repository/sql/oracle/content-keyword.sql 4 Mar 2004 14:52:35 -0000 1.4 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-keyword.sql 12 Mar 2004 18:48:46 -0000 1.5 @@ -49,6 +49,10 @@ where keyword_id = set_heading.keyword_id; + update acs_objects + set title = set_heading.heading + where object_id = set_heading.keyword_id; + end set_heading; procedure set_description ( @@ -100,15 +104,25 @@ creation_user in acs_objects.creation_user%TYPE default null, creation_ip in acs_objects.creation_ip%TYPE default null, - object_type in acs_object_types.object_type%TYPE default 'content_keyword' + object_type in acs_object_types.object_type%TYPE default 'content_keyword', + package_id in acs_objects.package_id%TYPE ) return cr_keywords.keyword_id%TYPE is v_id integer; + v_package_id acs_objects.package_id%TYPE; begin + if package_id is null then + v_package_id := acs_object.package_id(new.parent_id); + else + v_package_id := package_id; + end if; + v_id := acs_object.new (object_id => keyword_id, context_id => parent_id, object_type => object_type, + title => heading, + package_id => v_package_id, creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip); Index: openacs-4/packages/acs-content-repository/sql/oracle/content-revision.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-revision.sql,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/acs-content-repository/sql/oracle/content-revision.sql 4 Mar 2004 14:52:35 -0000 1.10 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-revision.sql 12 Mar 2004 18:48:46 -0000 1.11 @@ -25,20 +25,30 @@ 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, - filename in cr_revisions.filename%TYPE default null + filename in cr_revisions.filename%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return cr_revisions.revision_id%TYPE is v_revision_id integer; + v_package_id acs_objects.package_id%TYPE; v_content_type acs_object_types.object_type%TYPE; begin v_content_type := content_item.get_content_type(item_id); + if package_id is null then + v_package_id := acs_object.package_id(item_id); + else + v_package_id := package_id; + end if; + v_revision_id := acs_object.new( object_id => revision_id, - object_type => v_content_type, + object_type => v_content_type, + title => title, + package_id => v_package_id, creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, @@ -68,7 +78,8 @@ revision_id in cr_revisions.revision_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 + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return cr_revisions.revision_id%TYPE is v_revision_id integer; @@ -89,7 +100,8 @@ revision_id => revision_id, creation_date => creation_date, creation_user => creation_user, - creation_ip => creation_ip + creation_ip => creation_ip, + package_id => package_id ); select @@ -193,11 +205,13 @@ insert into acs_objects ( object_id, object_type, context_id, security_inherit_p, creation_user, creation_date, creation_ip, - last_modified, modifying_user, modifying_ip + last_modified, modifying_user, modifying_ip, + title, package_id ) ( select v_copy_id, object_type, v_target_item_id, security_inherit_p, copy.creation_user, sysdate, copy.creation_ip, - sysdate, copy.creation_user, copy.creation_ip from + sysdate, copy.creation_user, copy.creation_ip, + title, package_id from acs_objects where object_id = copy.revision_id ); Index: openacs-4/packages/acs-content-repository/sql/oracle/content-symlink.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-symlink.sql,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/acs-content-repository/sql/oracle/content-symlink.sql 4 Mar 2004 14:52:35 -0000 1.7 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-symlink.sql 12 Mar 2004 18:48:46 -0000 1.8 @@ -21,9 +21,11 @@ symlink_id in cr_symlinks.symlink_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 + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE ) return cr_symlinks.symlink_id%TYPE is v_symlink_id cr_symlinks.symlink_id%TYPE; + v_package_id acs_objects.package_id%TYPE; v_name cr_items.name%TYPE; v_label cr_symlinks.label%TYPE; begin @@ -85,9 +87,16 @@ v_label := content_symlink.new.label; end if; + if package_id is null then + v_package_id := acs_object.package_id(new.parent_id); + else + v_package_id := package_id; + end if; + v_symlink_id := content_item.new( item_id => content_symlink.new.symlink_id, - name => v_name, + name => v_name, + package_id => v_package_id, content_type => 'content_symlink', creation_date => content_symlink.new.creation_date, creation_user => content_symlink.new.creation_user, @@ -100,6 +109,10 @@ values (v_symlink_id, content_symlink.new.target_id, v_label); + update acs_objects + set title = v_label + where object_id = v_symlink_id; + return v_symlink_id; end new; Index: openacs-4/packages/acs-content-repository/sql/oracle/content-template.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-template.sql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/acs-content-repository/sql/oracle/content-template.sql 4 Mar 2004 14:52:35 -0000 1.5 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-template.sql 12 Mar 2004 18:48:46 -0000 1.6 @@ -30,12 +30,14 @@ default sysdate, creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE ) return cr_templates.template_id%TYPE is v_template_id cr_templates.template_id%TYPE; v_parent_id cr_items.parent_id%TYPE; + v_package_id acs_objects.package_id%TYPE; begin @@ -53,11 +55,18 @@ 'This folder does not allow templates to be created'); else + if package_id is null then + v_package_id := acs_object.package_id(v_parent_id); + else + v_package_id := package_id; + end if; + v_template_id := content_item.new ( item_id => content_template.new.template_id, name => content_template.new.name, text => content_template.new.text, parent_id => v_parent_id, + package_id => v_package_id, content_type => 'content_template', is_live => content_template.new.is_live, creation_date => content_template.new.creation_date, Index: openacs-4/packages/acs-content-repository/sql/oracle/packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/packages-create.sql,v diff -u -N -r1.17 -r1.18 --- openacs-4/packages/acs-content-repository/sql/oracle/packages-create.sql 4 Mar 2004 14:52:35 -0000 1.17 +++ openacs-4/packages/acs-content-repository/sql/oracle/packages-create.sql 12 Mar 2004 18:48:46 -0000 1.18 @@ -375,7 +375,8 @@ data in cr_revisions.content%TYPE default null, relation_tag in cr_child_rels.relation_tag%TYPE default null, is_live in char default 'f', - storage_type in cr_items.storage_type%TYPE default 'lob' + storage_type in cr_items.storage_type%TYPE default 'lob', + package_id in acs_objects.package_id%TYPE default null ) return cr_items.item_id%TYPE; @@ -841,7 +842,8 @@ creation_user in acs_objects.creation_user%TYPE default null, creation_ip in acs_objects.creation_ip%TYPE default null, - filename in cr_revisions.filename%TYPE default null + filename in cr_revisions.filename%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return cr_revisions.revision_id%TYPE; function new ( @@ -855,7 +857,8 @@ revision_id in cr_revisions.revision_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 + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return cr_revisions.revision_id%TYPE; function copy ( @@ -1031,7 +1034,8 @@ default sysdate, creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE ) return cr_symlinks.symlink_id%TYPE; @@ -1130,7 +1134,8 @@ default sysdate, creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE ) return cr_extlinks.extlink_id%TYPE; @@ -1180,6 +1185,7 @@ -- @param creation_date As in acs_object.new -- @param creation_ip As in acs_object.new -- @param creation_user As in acs_object.new + -- @param package_id The package id. -- @return The id of the newly created folder -- @see {acs_object.new}, {content_item.new} --*/ @@ -1191,7 +1197,8 @@ folder_id in cr_folders.folder_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 + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return cr_folders.folder_id%TYPE; procedure del ( @@ -1415,7 +1422,8 @@ default sysdate, creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE ) return cr_templates.template_id%TYPE; procedure del ( @@ -1487,7 +1495,8 @@ creation_user in acs_objects.creation_user%TYPE default null, creation_ip in acs_objects.creation_ip%TYPE default null, - object_type in acs_object_types.object_type%TYPE default 'content_keyword' + object_type in acs_object_types.object_type%TYPE default 'content_keyword', + package_id in acs_objects.package_id%TYPE ) return cr_keywords.keyword_id%TYPE; procedure del ( Index: openacs-4/packages/acs-content-repository/sql/oracle/upgrade/upgrade-5.1.0d2-5.1.0d3.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/upgrade/upgrade-5.1.0d2-5.1.0d3.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/oracle/upgrade/upgrade-5.1.0d2-5.1.0d3.sql 12 Mar 2004 18:48:47 -0000 1.3 @@ -0,0 +1,382 @@ +update acs_objects +set title = (select label + from cr_folders + where folder_id = object_id), +package_id = (select package_id + from apm_packages + where package_key = 'acs-content-repository') +where object_type = 'content_folder' +and object_id < 0; + +update acs_objects +set title = (select label + from cr_folders + where folder_id = object_id), +package_id = (select nvl(package_id, acs_object.package_id(content_item.get_root_folder(folder_id))) + from cr_folders + where folder_id = object_id) +where object_type = 'content_folder' +and object_id > 0; + +update acs_objects +set title = (select name + from cr_items + where item_id = object_id), +package_id = acs_object.package_id(content_item.get_root_folder(object_id)) +where object_type = 'content_item'; + +update acs_objects +set title = (select title + from cr_revisions + where revision_id = object_id), +package_id = (select acs_object.package_id(item_id) + from cr_revisions + where revision_id = object_id) +where object_type in ('content_revision', 'image'); + +update acs_objects +set title = (select label + from cr_symlinks + where symlink_id = object_id), +package_id = (select acs_object.package_id(target_id) + from cr_symlinks + where symlink_id = object_id) +where object_type = 'content_symlink'; + +update acs_objects +set title = (select label + from cr_extlinks + where extlink_id = object_id), +package_id = (select acs_object.package_id(parent_id) + from cr_items + where item_id = object_id) +where object_type = 'content_extlink'; + +update acs_objects +set title = (select heading + from cr_keywords + where keyword_id = object_id), +package_id = (select package_id + from apm_packages + where package_key = 'acs-content-repository') +where object_type = 'content_keyword'; + +update acs_objects +set title = (select name + from cr_items + where item_id = object_id), +package_id = (select acs_object.package_id(parent_id) + from cr_items + where item_id = object_id) +where object_type = 'content_template'; + +update acs_objects +set title = (select relation_tag || ': ' || item_id || ' - ' || related_object_id + from cr_item_rels + where rel_id = object_id), +package_id = (select acs_object.package_id(item_id) + from cr_item_rels + where rel_id = object_id) +where object_type = 'cr_item_rel'; + +update acs_objects +set title = (select relation_tag || ': ' || parent_id || ' - ' || child_id + from cr_child_rels + where rel_id = object_id), +package_id = (select acs_object.package_id(parent_id) + from cr_child_rels + where rel_id = object_id) +where object_type = 'cr_item_child_rel'; + +@@ ../packages-create.sql +@@ ../content-item.sql +@@ ../content-revision.sql +@@ ../content-folder.sql +@@ ../content-template.sql +@@ ../content-symlink.sql +@@ ../content-extlink.sql +@@ ../content-keyword.sql + + +create or replace package image +as + --/** + -- Creates a new image + -- Binary file stored in file-system + --*/ + function new ( + name in cr_items.name%TYPE, + parent_id in cr_items.parent_id%TYPE default null, + item_id in acs_objects.object_id%TYPE default null, + revision_id in acs_objects.object_id%TYPE default null, + content_type in acs_object_types.object_type%TYPE default 'image', + 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, + locale in cr_items.locale%TYPE default null, + context_id in acs_objects.context_id%TYPE default null, + title in cr_revisions.title%TYPE default null, + description in cr_revisions.description%TYPE default null, + mime_type in cr_revisions.mime_type%TYPE default null, + nls_language in cr_revisions.nls_language%TYPE default null, + relation_tag in cr_child_rels.relation_tag%TYPE default null, + is_live in char default 'f', + publish_date in cr_revisions.publish_date%TYPE default sysdate, + data in cr_revisions.content%TYPE default null, + filename in cr_revisions.filename%TYPE default null, + height in images.height%TYPE default null, + width in images.width%TYPE default null, + file_size in cr_revisions.content_length%TYPE default null, + storage_type in cr_items.storage_type%TYPE default 'file', + package_id in acs_objects.package_id%TYPE + ) return cr_items.item_id%TYPE; + + function new_revision ( + item_id in acs_objects.object_id%TYPE default null, + revision_id in acs_objects.object_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, + title in cr_revisions.title%TYPE default null, + description in cr_revisions.description%TYPE default null, + mime_type in cr_revisions.mime_type%TYPE default null, + nls_language in cr_revisions.nls_language%TYPE default null, + is_live in char default 'f', + publish_date in cr_revisions.publish_date%TYPE default sysdate, + data in cr_revisions.content%TYPE default null, + filename in cr_revisions.filename%TYPE default null, + height in images.height%TYPE default null, + width in images.width%TYPE default null, + file_size in cr_revisions.content_length%TYPE default null, + package_id in acs_objects.package_id%TYPE + ) return cr_revisions.revision_id%TYPE; + + --/** + -- Deletes a single revision of image + -- Schedules binary file for deletion. + -- File delete sweep checks to see if no other images are using binary prior to deleting + --*/ + procedure delete_revision ( + revision_id in cr_revisions.revision_id%TYPE + ); + + --/** + -- Deletes a image and all revisions + -- Schedules binary files for deletion. + -- + -- Be careful, cannot be undone (easily) + --*/ + procedure del ( + item_id in cr_items.item_id%TYPE + ); + +end image; +/ +show errors; + +create or replace package body image +as + function new ( + name in cr_items.name%TYPE, + parent_id in cr_items.parent_id%TYPE default null, + item_id in acs_objects.object_id%TYPE default null, + revision_id in acs_objects.object_id%TYPE default null, + content_type in acs_object_types.object_type%TYPE default 'image', + 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, + locale in cr_items.locale%TYPE default null, + context_id in acs_objects.context_id%TYPE default null, + title in cr_revisions.title%TYPE default null, + description in cr_revisions.description%TYPE default null, + mime_type in cr_revisions.mime_type%TYPE default null, + nls_language in cr_revisions.nls_language%TYPE default null, + relation_tag in cr_child_rels.relation_tag%TYPE default null, + is_live in char default 'f', + publish_date in cr_revisions.publish_date%TYPE default sysdate, + data in cr_revisions.content%TYPE default null, + filename in cr_revisions.filename%TYPE default null, + height in images.height%TYPE default null, + width in images.width%TYPE default null, + file_size in cr_revisions.content_length%TYPE default null, + storage_type in cr_items.storage_type%TYPE default 'file', + package_id in acs_objects.package_id%TYPE + ) return cr_items.item_id%TYPE + is + v_item_id cr_items.item_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; + v_package_id acs_objects.package_id%TYPE; + begin + + if package_id is null then + v_package_id := acs_object.package_id(new.parent_id); + else + v_package_id := package_id; + end if; + + v_item_id := content_item.new ( + name => name, + item_id => item_id, + parent_id => parent_id, + package_id => v_package_id, + relation_tag => relation_tag, + content_type => content_type, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + locale => locale, + context_id => context_id, + storage_type => storage_type + ); + + v_revision_id := content_revision.new ( + title => title, + description => description, + item_id => v_item_id, + revision_id => revision_id, + package_id => v_package_id, + publish_date => publish_date, + mime_type => mime_type, + nls_language => nls_language, + data => data, + filename => filename, + creation_date => sysdate, + creation_user => creation_user, + creation_ip => creation_ip + ); + + insert into images + (image_id, height, width) + values + (v_revision_id, height, width); + + -- update revision with image file info + update cr_revisions + set content_length = file_size + where revision_id = v_revision_id; + + -- is_live => 't' not used as part of content_item.new + -- because content_item.new does not let developer specify revision_id, + -- revision_id is determined in advance + + if is_live = 't' then + content_item.set_live_revision ( + revision_id => v_revision_id + ); + end if; + + return v_item_id; + end new; + + function new_revision ( + item_id in acs_objects.object_id%TYPE default null, + revision_id in acs_objects.object_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, + title in cr_revisions.title%TYPE default null, + description in cr_revisions.description%TYPE default null, + mime_type in cr_revisions.mime_type%TYPE default null, + nls_language in cr_revisions.nls_language%TYPE default null, + is_live in char default 'f', + publish_date in cr_revisions.publish_date%TYPE default sysdate, + data in cr_revisions.content%TYPE default null, + filename in cr_revisions.filename%TYPE default null, + height in images.height%TYPE default null, + width in images.width%TYPE default null, + file_size in cr_revisions.content_length%TYPE default null, + package_id in acs_objects.package_id%TYPE + ) return cr_revisions.revision_id%TYPE + is + v_revision_id cr_revisions.revision_id%TYPE; + v_package_id acs_objects.package_id%TYPE; + + begin + if package_id is null then + v_package_id := acs_object.package_id(new_revision.item_id); + else + v_package_id := package_id; + end if; + + v_revision_id := content_revision.new ( + title => title, + description => description, + item_id => item_id, + revision_id => revision_id, + package_id => v_package_id, + publish_date => publish_date, + mime_type => mime_type, + nls_language => nls_language, + data => data, + filename => filename, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip + ); + + insert into images + (image_id, height, width) + values + (v_revision_id, height, width); + + -- update revision with image file info + update cr_revisions + set content_length = file_size + where revision_id = v_revision_id; + + -- is_live => 't' not used as part of content_item.new + -- because content_item.new does not let developer specify revision_id, + -- revision_id is determined in advance + + if is_live = 't' then + content_item.set_live_revision ( + revision_id => v_revision_id + ); + end if; + + return v_revision_id; + end new_revision; + + procedure delete_revision ( + revision_id in cr_revisions.revision_id%TYPE + ) + is + v_content cr_files_to_delete.path%TYPE default null; + begin + content_revision.del ( + revision_id => revision_id + ); + end delete_revision; + + procedure del ( + item_id in cr_items.item_id%TYPE + ) + is + + cursor image_revision_cur is + select + revision_id + from + cr_revisions + where + item_id = image.del.item_id + order by revision_id asc; + + -- order by used in cursur so latest revision will be deleted last + -- save resetting latest revision multiple times during delete process + + begin + for v_revision_val in image_revision_cur loop + image.delete_revision ( + revision_id => v_revision_val.revision_id + ); + end loop; + + content_item.del ( + item_id => item_id + ); + end del; + +end image; +/ +show errors; Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-extlink.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-extlink.sql,v diff -u -N -r1.15 -r1.16 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-extlink.sql 4 Mar 2004 14:52:36 -0000 1.15 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-extlink.sql 12 Mar 2004 18:48:47 -0000 1.16 @@ -12,7 +12,7 @@ select define_function_args('content_extlink__new','name,url,label,description,parent_id,extlink_id,creation_date;now,creation_user,creation_ip'); -create or replace function content_extlink__new (varchar,varchar,varchar,varchar,integer,integer,timestamptz,integer,varchar) +create or replace function content_extlink__new (varchar,varchar,varchar,varchar,integer,integer,timestamptz,integer,varchar,integer) returns integer as ' declare new__name alias for $1; -- default null @@ -24,7 +24,9 @@ new__creation_date alias for $7; -- default now() new__creation_user alias for $8; -- default null new__creation_ip alias for $9; -- default null + new__package_id alias for $10; -- default null v_extlink_id cr_extlinks.extlink_id%TYPE; + v_package_id acs_objects.package_id%TYPE; v_label cr_extlinks.label%TYPE; v_name cr_items.name%TYPE; begin @@ -42,6 +44,12 @@ v_name := new__name; end if; + if new__package_id is null then + v_package_id := acs_object__package_id(new__parent_id); + else + v_package_id := new__package_id; + end if; + v_extlink_id := content_item__new( v_name, new__parent_id, @@ -58,18 +66,50 @@ ''text/plain'', null, null, - ''text'' + ''text'', + v_package_id ); insert into cr_extlinks (extlink_id, url, label, description) values (v_extlink_id, new__url, v_label, new__description); + update acs_objects + set title = v_label + where object_id = v_extlink_id; + return v_extlink_id; end;' language 'plpgsql'; +create or replace function content_extlink__new (varchar,varchar,varchar,varchar,integer,integer,timestamptz,integer,varchar) +returns integer as ' +declare + new__name alias for $1; -- default null + new__url alias for $2; + new__label alias for $3; -- default null + new__description alias for $4; -- default null + new__parent_id alias for $5; + new__extlink_id alias for $6; -- default null + new__creation_date alias for $7; -- default now() + new__creation_user alias for $8; -- default null + new__creation_ip alias for $9; -- default null +begin + return content_extlink__new(new__name, + new__url, + new__label, + new__description, + new__parent_id, + new__extlink_id, + new__creation_date, + new__creation_user, + new__creation_ip, + null + ); + +end;' language 'plpgsql'; + create or replace function content_extlink__delete (integer) returns integer as ' declare @@ -186,7 +226,8 @@ null, current_timestamp, copy__creation_user, - copy__creation_ip + copy__creation_ip, + null ); end if; Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql,v diff -u -N -r1.33 -r1.34 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql 4 Mar 2004 14:52:36 -0000 1.33 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql 12 Mar 2004 18:48:47 -0000 1.34 @@ -12,6 +12,29 @@ -- create or replace package body content_folder +create or replace function content_folder__new(varchar,varchar,varchar,integer,integer) +returns integer as ' +declare + new__name alias for $1; + new__label alias for $2; + new__description alias for $3; -- default null + new__parent_id alias for $4; -- default null + new__package_id alias for $5; -- default null +begin + return content_folder__new(new__name, + new__label, + new__description, + new__parent_id, + null, + null, + now(), + null, + null, + new__package_id + ); + +end;' language 'plpgsql'; + create or replace function content_folder__new(varchar,varchar,varchar,integer) returns integer as ' declare @@ -28,10 +51,12 @@ null, now(), null, + null, null ); end;' language 'plpgsql'; + -- function new create or replace function content_folder__new (varchar,varchar,varchar,integer,integer,integer,timestamptz,integer,varchar) returns integer as ' @@ -45,8 +70,38 @@ new__creation_date alias for $7; -- default now() new__creation_user alias for $8; -- default null new__creation_ip alias for $9; -- default null +begin + return content_folder__new(new__name, + new__label, + new__description, + new__parent_id, + new__content_id, + new__folder_id, + new__creation_date, + new__creation_user, + new__creation_ip, + null + ); + +end;' language 'plpgsql'; + +-- function new +create or replace function content_folder__new (varchar,varchar,varchar,integer,integer,integer,timestamptz,integer,varchar,integer) +returns integer as ' +declare + new__name alias for $1; + new__label alias for $2; + new__description alias for $3; -- default null + new__parent_id alias for $4; -- default null + new__context_id alias for $5; -- default null + new__folder_id alias for $6; -- default null + new__creation_date alias for $7; -- default now() + new__creation_user alias for $8; -- default null + new__creation_ip alias for $9; -- default null + new__package_id alias for $10; -- default null v_folder_id cr_folders.folder_id%TYPE; v_context_id acs_objects.context_id%TYPE; + v_package_id acs_objects.package_id%TYPE; begin -- set the context_id @@ -65,6 +120,12 @@ else + v_package_id := new__package_id; + + if new__parent_id is not null and new__package_id is null then + v_package_id := acs_object__package_id(content_item__get_root_folder(new__parent_id)); + end if; + v_folder_id := content_item__new( new__name, new__parent_id, @@ -81,15 +142,21 @@ ''text/plain'', null, null, - ''text'' + ''text'', + v_package_id ); insert into cr_folders ( - folder_id, label, description + folder_id, label, description, package_id ) values ( - v_folder_id, new__label, new__description + v_folder_id, new__label, new__description, v_package_id ); + -- set the correct object title + update acs_objects + set title = new__label + where object_id = v_folder_id; + -- inherit the attributes of the parent folder if new__parent_id is not null then @@ -117,7 +184,7 @@ select define_function_args('content_folder__new','name,label,description,parent_id,context_id,folder_id,creation_date;now,creation_user,creation_ip,security_inherit_p;t'); -create or replace function content_folder__new (varchar,varchar,varchar,integer,integer,integer,timestamptz,integer,varchar, boolean) +create or replace function content_folder__new (varchar,varchar,varchar,integer,integer,integer,timestamptz,integer,varchar,boolean,integer) returns integer as ' declare new__name alias for $1; @@ -130,6 +197,8 @@ new__creation_user alias for $8; -- default null new__creation_ip alias for $9; -- default null new__security_inherit_p alias for $10; -- default true + new__package_id alias for $11; -- default null + v_package_id acs_objects.package_id%TYPE; v_folder_id cr_folders.folder_id%TYPE; v_context_id acs_objects.context_id%TYPE; begin @@ -150,6 +219,12 @@ else + v_package_id := new__package_id; + + if new__parent_id is not null and new__package_id is null then + v_package_id := acs_object__package_id(content_item__get_root_folder(new__parent_id)); + end if; + v_folder_id := content_item__new( new__folder_id, new__name, @@ -166,14 +241,21 @@ new__security_inherit_p, ''CR_FILES'', ''content_folder'', - ''content_folder''); + ''content_folder'', + v_package_id + ); insert into cr_folders ( - folder_id, label, description + folder_id, label, description, package_id ) values ( - v_folder_id, new__label, new__description + v_folder_id, new__label, new__description, v_package_id ); + -- set the correct object title + update acs_objects + set title = new__label + where object_id = v_folder_id; + -- inherit the attributes of the parent folder if new__parent_id is not null then @@ -198,6 +280,35 @@ return null; end;' language 'plpgsql'; +create or replace function content_folder__new (varchar,varchar,varchar,integer,integer,integer,timestamptz,integer,varchar,boolean) +returns integer as ' +declare + new__name alias for $1; + new__label alias for $2; + new__description alias for $3; -- default null + new__parent_id alias for $4; -- default null + new__context_id alias for $5; -- default null + new__folder_id alias for $6; -- default null + new__creation_date alias for $7; -- default now() + new__creation_user alias for $8; -- default null + new__creation_ip alias for $9; -- default null + new__security_inherit_p alias for $10; -- default true +begin + return content_folder__new(new__name, + new__label, + new__description, + new__parent_id, + new__content_id, + new__folder_id, + new__creation_date, + new__creation_user, + new__creation_ip, + new__security_inherit_p, + null + ); + +end;' language 'plpgsql'; + -- procedure delete create or replace function content_folder__delete (integer, boolean) @@ -294,6 +405,12 @@ PERFORM content_item__rename(rename__folder_id, rename__name); end if; + if rename__label is not null and rename_label != '''' then + update acs_objects + set title = rename__label + where object_id = rename__folder_id; + end if; + if rename__label is not null and rename__label != '''' and rename__description is not null and rename__description != '''' then @@ -414,7 +531,7 @@ return v_new_folder_id; end;' language 'plpgsql'; -create function content_folder__copy (integer,integer,integer,varchar,varchar) +create or replace function content_folder__copy (integer,integer,integer,varchar,varchar) returns integer as ' declare copy__folder_id alias for $1; @@ -483,7 +600,8 @@ null, now(), copy__creation_user, - copy__creation_ip + copy__creation_ip, + null ); -- copy attributes of original folder @@ -513,7 +631,8 @@ v_folder_contents_val.item_id, v_new_folder_id, copy__creation_user, - copy__creation_ip + copy__creation_ip, + null ); end loop; Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql,v diff -u -N -r1.14 -r1.15 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql 4 Mar 2004 14:52:36 -0000 1.14 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql 12 Mar 2004 18:48:47 -0000 1.15 @@ -109,7 +109,7 @@ -- than the standard package_instantiate_object. So we don't bother calling define_function_args -- here. -create function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,boolean,timestamptz,varchar,integer,integer,integer +create function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,boolean,timestamptz,varchar,integer,integer,integer,integer ) returns integer as ' declare new__name alias for $1; @@ -128,17 +128,25 @@ new__file_size alias for $14; new__height alias for $15; new__width alias for $16; + new__package_id alias for $17; -- default null new__locale varchar default null; new__nls_language varchar default null; new__creation_date timestamptz default current_timestamp; new__context_id integer; v_item_id cr_items.item_id%TYPE; + v_package_id acs_objects.package_id%TYPE; v_revision_id cr_revisions.revision_id%TYPE; begin new__context_id := new__parent_id; + if p_package_id is null then + v_package_id := acs_object__package_id(new__parent_id); + else + v_package_id := new__package_id; + end if; + v_item_id := content_item__new ( new__name, new__parent_id, @@ -155,7 +163,8 @@ new__mime_type, new__nls_language, null, - ''file'' -- storage_type + ''file'' -- storage_type, + v_package_id ); -- update cr_child_rels to have the correct relation_tag @@ -176,7 +185,8 @@ new__revision_id, new__creation_date, new__creation_user, - new__creation_ip + new__creation_ip, + v_package_id ); insert into images @@ -201,10 +211,50 @@ return v_item_id; end; ' language 'plpgsql'; +create function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,boolean,timestamptz,varchar,integer,integer,integer + ) returns integer as ' + declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__item_id alias for $3; -- default null + new__revision_id alias for $4; -- default null + new__mime_type alias for $5; -- default jpeg + new__creation_user alias for $6; -- default null + new__creation_ip alias for $7; -- default null + new__relation_tag alias for $8; -- default null + new__title alias for $9; -- default null + new__description alias for $10; -- default null + new__is_live alias for $11; -- default f + new__publish_date alias for $12; -- default now() + new__path alias for $13; + new__file_size alias for $14; + new__height alias for $15; + new__width alias for $16; + begin + return image__new(new__name, + new__parent_id, + new__item_id, + new__revision_id, + new__mime_type, + new__creation_user, + new__creation_ip, + new__relation_tag, + new__title, + new__description, + new__is_live, + new__publish_date, + new__path, + new__file_size, + new__height, + new__width, + null + ); +end; ' language 'plpgsql'; + -- DRB's version create function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,varchar, - varchar,timestamptz,integer, integer) returns integer as ' + varchar,timestamptz,integer, integer, integer) returns integer as ' declare p_name alias for $1; p_parent_id alias for $2; -- default null @@ -221,15 +271,23 @@ p_publish_date alias for $13; p_height alias for $14; p_width alias for $15; + p_package_id alias for $16; -- default null v_item_id cr_items.item_id%TYPE; v_revision_id cr_revisions.revision_id%TYPE; + v_package_id acs_objects.package_id%TYPE; begin if content_item__is_subclass(p_content_type, ''image'') = ''f'' then raise EXCEPTION ''-20000: image__new can only be called for an image type''; end if; + if p_package_id is null then + v_package_id := acs_object__package_id(p_parent_id); + else + v_package_id := p_package_id; + end if; + v_item_id := content_item__new ( p_name, p_parent_id, @@ -246,7 +304,8 @@ null, null, null, - p_storage_type + p_storage_type, + v_package_id ); -- We will let the caller fill in the LOB data or file path. @@ -262,7 +321,8 @@ p_revision_id, current_timestamp, p_creation_user, - p_creation_ip + p_creation_ip, + v_package_id ); insert into images @@ -273,9 +333,47 @@ return v_item_id; end; ' language 'plpgsql'; +create function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,varchar, + varchar,timestamptz,integer, integer) returns integer as ' + declare + p_name alias for $1; + p_parent_id alias for $2; -- default null + p_item_id alias for $3; -- default null + p_revision_id alias for $4; -- default null + p_mime_type alias for $5; -- default jpeg + p_creation_user alias for $6; -- default null + p_creation_ip alias for $7; -- default null + p_title alias for $8; -- default null + p_description alias for $9; -- default null + p_storage_type alias for $10; + p_content_type alias for $11; + p_nls_language alias for $12; + p_publish_date alias for $13; + p_height alias for $14; + p_width alias for $15; + begin + return image__new(p_name, + p_parent_id, + p_item_id, + p_revision_id, + p_mime_type, + p_creation_user, + p_creation_ip, + p_title, + p_description, + p_storage_type, + p_content_type, + p_nls_language, + p_publish_date, + p_height, + p_width, + null + ); +end; ' language 'plpgsql'; + create or replace function image__new_revision(integer, integer, varchar, varchar, timestamptz, varchar, varchar, - integer, varchar, integer, integer) returns integer as ' + integer, varchar, integer, integer, integer) returns integer as ' declare p_item_id alias for $1; p_revision_id alias for $2; @@ -288,10 +386,18 @@ p_creation_ip alias for $9; p_height alias for $10; p_width alias for $11; + p_package_id alias for $12; v_revision_id integer; + v_package_id acs_objects.package_id%TYPE; begin -- We will let the caller fill in the LOB data or file path. + if p_package_id is null then + v_package_id := acs_object__package_id(p_item_id); + else + v_package_id := p_package_id; + end if; + v_revision_id := content_revision__new ( p_title, p_description, @@ -303,7 +409,8 @@ p_revision_id, current_timestamp, p_creation_user, - p_creation_ip + p_creation_ip, + p_package_id ); insert into images @@ -314,6 +421,39 @@ return v_revision_id; end;' language 'plpgsql'; +create or replace function image__new_revision(integer,integer,varchar,varchar,timestamptz,varchar,varchar, + integer,varchar,integer,integer) returns integer as ' +declare + p_item_id alias for $1; + p_revision_id alias for $2; + p_title alias for $3; + p_description alias for $4; + p_publish_date alias for $5; + p_mime_type alias for $6; + p_nls_language alias for $7; + p_creation_user alias for $8; + p_creation_ip alias for $9; + p_height alias for $10; + p_width alias for $11; + v_revision_id integer; +begin + return image__new_revision(p_item_id, + p_revision_id, + p_title, + p_description, + p_publish_date, + p_mime_type, + p_nls_language, + p_creation_user, + p_creation_ip, + p_height, + p_width, + p_revision_id, + null + ); + +end;' language 'plpgsql'; + create function image__delete (integer) returns integer as ' declare Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql,v diff -u -N -r1.50 -r1.51 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql 4 Mar 2004 14:52:36 -0000 1.50 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql 12 Mar 2004 18:48:47 -0000 1.51 @@ -10,7 +10,7 @@ -- License. Full text of the license is available from the GNU Project: -- http://www.fsf.org/copyleft/gpl.html -create view content_item_globals as +create or replace view content_item_globals as select -100 as c_root_folder_id; create or replace function content_item__get_root_folder (integer) @@ -64,7 +64,8 @@ cr_revisions.content%TYPE, cr_child_rels.relation_tag%TYPE, boolean, - cr_items.storage_type%TYPE + cr_items.storage_type%TYPE, + acs_objects.package_id%TYPE ) returns integer as ' declare new__name alias for $1; @@ -86,6 +87,7 @@ new__relation_tag alias for $17; new__is_live alias for $18; new__storage_type alias for $19; + new__package_id alias for $20; v_parent_id cr_items.parent_id%TYPE; v_parent_type acs_objects.object_type%TYPE; v_item_id cr_items.item_id%TYPE; @@ -94,6 +96,7 @@ v_rel_id acs_objects.object_id%TYPE; v_rel_tag cr_child_rels.relation_tag%TYPE; v_context_id acs_objects.context_id%TYPE; + v_package_id acs_objects.package_id%TYPE; v_storage_type cr_items.storage_type%TYPE; begin @@ -113,6 +116,12 @@ v_context_id := new__context_id; end if; + if new__package_id is null then + v_package_id := acs_object__package_id(content_item__get_root_folder(v_parent_id)); + else + v_package_id := new__package_id; + end if; + if v_parent_id = 0 or content_folder__is_folder(v_parent_id) = ''t'' then @@ -155,7 +164,10 @@ new__creation_date, new__creation_user, new__creation_ip, - v_context_id + v_context_id, + ''t'', + new__name, + v_package_id ); @@ -175,7 +187,10 @@ now(), null, null, - v_parent_id + v_parent_id, + ''t'', + v_rel_tag || '': '' || v_parent_id || '' - '' || v_item_id, + v_package_id ); insert into cr_child_rels ( @@ -208,7 +223,8 @@ null, new__creation_date, new__creation_user, - new__creation_ip + new__creation_ip, + v_package_id ); elsif new__text is not null or new__title is not null then @@ -224,7 +240,8 @@ null, new__creation_date, new__creation_user, - new__creation_ip + new__creation_ip, + v_package_id ); end if; @@ -238,8 +255,61 @@ end;' language 'plpgsql'; +create or replace function content_item__new ( + cr_items.name%TYPE, + cr_items.parent_id%TYPE, + acs_objects.object_id%TYPE, + cr_items.locale%TYPE, + acs_objects.creation_date%TYPE, + acs_objects.creation_user%TYPE, + acs_objects.context_id%TYPE, + acs_objects.creation_ip%TYPE, + acs_object_types.object_type%TYPE, + acs_object_types.object_type%TYPE, + cr_revisions.title%TYPE, + cr_revisions.description%TYPE, + cr_revisions.mime_type%TYPE, + cr_revisions.nls_language%TYPE, + varchar, + cr_revisions.content%TYPE, + cr_child_rels.relation_tag%TYPE, + boolean, + cr_items.storage_type%TYPE +) returns integer as ' +declare + new__name alias for $1; + new__parent_id alias for $2; + new__item_id alias for $3; + new__locale alias for $4; + new__creation_date alias for $5; + new__creation_user alias for $6; + new__context_id alias for $7; + new__creation_ip alias for $8; + new__item_subtype alias for $9; + new__content_type alias for $10; + new__title alias for $11; + new__description alias for $12; + new__mime_type alias for $13; + new__nls_language alias for $14; + new__text alias for $15; + new__data alias for $16; + new__relation_tag alias for $17; + new__is_live alias for $18; + new__storage_type alias for $19; + v_item_id cr_items.item_id%TYPE; +begin + v_item_id := content_item__new (new__name, new__parent_id, new__item_id, new__locale, + new__creation_date, new__creation_user, new__context_id, new__creation_ip, + new__item_subtype, new__content_type, new__title, new__description, + new__mime_type, new__nls_language, new__text, new__data, new__relation_tag, + new__is_live, new__storage_type, null); + + return v_item_id; + +end;' language 'plpgsql'; + -- -create or replace function content_item__new (varchar,integer,integer,varchar,timestamptz,integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar) +create or replace function content_item__new (varchar,integer,integer,varchar,timestamptz,integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,integer) returns integer as ' declare new__name alias for $1; @@ -258,6 +328,7 @@ new__nls_language alias for $14; -- default null new__text alias for $15; -- default null new__storage_type alias for $16; -- check in (''text'',''file'') + new__package_id alias for $17; -- default null new__relation_tag varchar default null; new__is_live boolean default ''f''; @@ -269,6 +340,7 @@ v_rel_id acs_objects.object_id%TYPE; v_rel_tag cr_child_rels.relation_tag%TYPE; v_context_id acs_objects.context_id%TYPE; + v_package_id acs_objects.package_id%TYPE; begin -- place the item in the context of the pages folder if no @@ -287,6 +359,12 @@ v_context_id := new__context_id; end if; + if new__package_id is null then + v_package_id := acs_object__package_id(content_item__get_root_folder(v_parent_id)); + else + v_package_id := new__package_id; + end if; + if v_parent_id = 0 or content_folder__is_folder(v_parent_id) = ''t'' then @@ -322,7 +400,10 @@ new__creation_date, new__creation_user, new__creation_ip, - v_context_id + v_context_id, + ''t'', + new__name, + v_package_id ); insert into cr_items ( @@ -336,22 +417,25 @@ content_folder__is_folder(v_parent_id) = ''f'' and content_item__is_valid_child(v_parent_id, new__content_type) = ''t'' then + if new__relation_tag is null then + v_rel_tag := content_item__get_content_type(v_parent_id) + || ''-'' || new__content_type; + else + v_rel_tag := new__relation_tag; + end if; + v_rel_id := acs_object__new( null, ''cr_item_child_rel'', now(), null, null, - v_parent_id + v_parent_id, + ''t'', + v_rel_tag || '': '' || v_parent_id || '' - '' || v_item_id, + v_package_id ); - if new__relation_tag is null then - v_rel_tag := content_item__get_content_type(v_parent_id) - || ''-'' || new__content_type; - else - v_rel_tag := new__relation_tag; - end if; - insert into cr_child_rels ( rel_id, parent_id, child_id, relation_tag, order_n ) values ( @@ -381,7 +465,8 @@ null, new__creation_date, new__creation_user, - new__creation_ip + new__creation_ip, + v_package_id ); end if; @@ -395,7 +480,7 @@ end;' language 'plpgsql'; -create or replace function content_item__new (varchar,integer,integer,varchar,timestamptz,integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,varchar,integer) +create or replace function content_item__new (varchar,integer,integer,varchar,timestamptz,integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar) returns integer as ' declare new__name alias for $1; @@ -412,8 +497,39 @@ new__description alias for $12; -- default null new__mime_type alias for $13; -- default ''text/plain'' new__nls_language alias for $14; -- default null + new__text alias for $15; -- default null + new__storage_type alias for $16; -- check in (''text'',''file'') + v_item_id cr_items.item_id%TYPE; +begin + v_item_id := content_item__new (new__name, new__parent_id, new__item_id, new__locale, + new__creation_date, new__creation_user, new__context_id, new__creation_ip, + new__item_subtype, new__content_type, new__title, new__description, + new__mime_type, new__nls_language, new__text, new__storage_type, null); + + return v_item_id; + +end;' language 'plpgsql'; + +create or replace function content_item__new (varchar,integer,integer,varchar,timestamptz,integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,varchar,integer,integer) +returns integer as ' +declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__item_id alias for $3; -- default null + new__locale alias for $4; -- default null + new__creation_date alias for $5; -- default now() + new__creation_user alias for $6; -- default null + new__context_id alias for $7; -- default null + new__creation_ip alias for $8; -- default null + new__item_subtype alias for $9; -- default ''content_item'' + new__content_type alias for $10; -- default ''content_revision'' + new__title alias for $11; -- default null + new__description alias for $12; -- default null + new__mime_type alias for $13; -- default ''text/plain'' + new__nls_language alias for $14; -- default null -- changed to integer for blob_id new__data alias for $15; -- default null + new__package_id alias for $16; -- default null new__relation_tag varchar default null; new__is_live boolean default ''f''; @@ -425,6 +541,7 @@ v_rel_id acs_objects.object_id%TYPE; v_rel_tag cr_child_rels.relation_tag%TYPE; v_context_id acs_objects.context_id%TYPE; + v_package_id acs_objects.package_id%TYPE; begin -- place the item in the context of the pages folder if no @@ -443,6 +560,12 @@ v_context_id := new__context_id; end if; + if new__package_id is null then + v_package_id := acs_object__package_id(content_item__get_root_folder(v_parent_id)); + else + v_package_id := new__package_id; + end if; + if v_parent_id = 0 or content_folder__is_folder(v_parent_id) = ''t'' then @@ -478,7 +601,10 @@ new__creation_date, new__creation_user, new__creation_ip, - v_context_id + v_context_id, + ''t'', + new__name, + v_package_id ); insert into cr_items ( @@ -492,22 +618,25 @@ content_folder__is_folder(v_parent_id) = ''f'' and content_item__is_valid_child(v_parent_id, new__content_type) = ''t'' then + if new__relation_tag is null or new__relation_tag = '''' then + v_rel_tag := content_item__get_content_type(v_parent_id) + || ''-'' || new__content_type; + else + v_rel_tag := new__relation_tag; + end if; + v_rel_id := acs_object__new( null, ''cr_item_child_rel'', now(), null, null, v_parent_id + ''t'', + v_rel_tag || '': '' || v_parent_id || '' - '' || v_item_id, + v_package_id ); - if new__relation_tag is null or new__relation_tag = '''' then - v_rel_tag := content_item__get_content_type(v_parent_id) - || ''-'' || new__content_type; - else - v_rel_tag := new__relation_tag; - end if; - insert into cr_child_rels ( rel_id, parent_id, child_id, relation_tag, order_n ) values ( @@ -540,7 +669,8 @@ null, new__creation_date, new__creation_user, - new__creation_ip + new__creation_ip, + v_package_id ); end if; @@ -554,14 +684,45 @@ end;' language 'plpgsql'; -create or replace function content_item__new(varchar,integer,varchar,text,text) +create or replace function content_item__new (varchar,integer,integer,varchar,timestamptz,integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,varchar,integer) returns integer as ' declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__item_id alias for $3; -- default null + new__locale alias for $4; -- default null + new__creation_date alias for $5; -- default now() + new__creation_user alias for $6; -- default null + new__context_id alias for $7; -- default null + new__creation_ip alias for $8; -- default null + new__item_subtype alias for $9; -- default ''content_item'' + new__content_type alias for $10; -- default ''content_revision'' + new__title alias for $11; -- default null + new__description alias for $12; -- default null + new__mime_type alias for $13; -- default ''text/plain'' + new__nls_language alias for $14; -- default null +-- changed to integer for blob_id + new__data alias for $15; -- default null + v_item_id cr_items.item_id%TYPE; +begin + v_item_id := content_item__new (new__name, new__parent_id, new__item_id, new__locale, + new__creation_date, new__creation_user, new__context_id, new__creation_ip, + new__item_subtype, new__content_type, new__title, new__description, + new__mime_type, new__nls_language, new__data, null); + + return v_item_id; + +end;' language 'plpgsql'; + +create or replace function content_item__new(varchar,integer,varchar,text,text,integer) +returns integer as ' +declare new__name alias for $1; new__parent_id alias for $2; -- default null new__title alias for $3; -- default null new__description alias for $4; -- default null new__text alias for $5; -- default null + new__package_id alias for $6; -- default null begin return content_item__new(new__name, new__parent_id, @@ -578,27 +739,47 @@ ''text/plain'', null, new__text, - ''text'' + ''text'', + new__package_id ); end;' language 'plpgsql'; +create or replace function content_item__new(varchar,integer,varchar,text,text) +returns integer as ' +declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__title alias for $3; -- default null + new__description alias for $4; -- default null + new__text alias for $5; -- default null +begin + return content_item__new(new__name, new__parent_id, new__title, new__description, + new__text, null); + +end;' language 'plpgsql'; + +create or replace function content_item__new(varchar,integer,integer) returns integer as ' +declare + new__name alias for $1; + new__parent_id alias for $2; + new__package_id alias for $3; +begin + return content_item__new(new__name, new__parent_id, null, null, null, new__package_id); +end;' language 'plpgsql'; + create or replace function content_item__new(varchar,integer) returns integer as ' declare new__name alias for $1; new__parent_id alias for $2; begin - return content_item__new(new__name, - new__parent_id, - null, - null, - null); + return content_item__new(new__name, new__parent_id, null, null, null, null); + end;' language 'plpgsql'; -- function new -- sets security_inherit_p to FALSE -DaveB -create or replace function content_item__new ( integer, varchar, integer, varchar, timestamptz, integer, integer, varchar, boolean, varchar, text, varchar, boolean, varchar,varchar,varchar) - +create or replace function content_item__new ( integer, varchar, integer, varchar, timestamptz, integer, integer, varchar, boolean, varchar, text, varchar, boolean, varchar,varchar,varchar,integer) returns integer as ' declare new__item_id alias for $1; --default null @@ -617,6 +798,7 @@ new__storage_area_key alias for $14; -- default ''CR_FILES'' new__item_subtype alias for $15; new__content_type alias for $16; + new__package_id alias for $17; -- default null new__description varchar default null; new__relation_tag varchar default null; new__nls_language varchar default null; @@ -628,6 +810,7 @@ v_rel_id acs_objects.object_id%TYPE; v_rel_tag cr_child_rels.relation_tag%TYPE; v_context_id acs_objects.context_id%TYPE; + v_package_id acs_objects.package_id%TYPE; begin -- place the item in the context of the pages folder if no @@ -646,6 +829,12 @@ v_context_id := new__context_id; end if; + if new__package_id is null then + v_package_id := acs_object__package_id(content_item__get_root_folder(v_parent_id)); + else + v_package_id := new__package_id; + end if; + if v_parent_id = 0 or content_folder__is_folder(v_parent_id) = ''t'' then @@ -683,7 +872,9 @@ new__creation_user, new__creation_ip, v_context_id, - new__security_inherit_p + new__security_inherit_p, + new__name, + v_package_id ); insert into cr_items ( @@ -698,23 +889,25 @@ content_folder__is_folder(v_parent_id) = ''f'' and content_item__is_valid_child(v_parent_id, new__content_type) = ''t'' then + if new__relation_tag is null then + v_rel_tag := content_item__get_content_type(v_parent_id) + || ''-'' || new__content_type; + else + v_rel_tag := new__relation_tag; + end if; + v_rel_id := acs_object__new( null, ''cr_item_child_rel'', new__creation_date, null, null, v_parent_id, - ''f'' + ''f'', + v_rel_tag || '': '' || v_parent_id || '' - '' || v_item_id, + v_package_id ); - if new__relation_tag is null then - v_rel_tag := content_item__get_content_type(v_parent_id) - || ''-'' || new__content_type; - else - v_rel_tag := new__relation_tag; - end if; - insert into cr_child_rels ( rel_id, parent_id, child_id, relation_tag, order_n ) values ( @@ -744,7 +937,8 @@ null, new__creation_date, new__creation_user, - new__creation_ip + new__creation_ip, + v_package_id ); end if; @@ -758,6 +952,37 @@ end;' language 'plpgsql'; +create or replace function content_item__new ( integer, varchar, integer, varchar, timestamptz, integer, integer, varchar, boolean, varchar, text, varchar, boolean, varchar,varchar,varchar) +returns integer as ' +declare + new__item_id alias for $1; --default null + new__name alias for $2; + new__parent_id alias for $3; -- default null + new__title alias for $4; -- default null + new__creation_date alias for $5; -- default now() + new__creation_user alias for $6; -- default null + new__context_id alias for $7; -- default null + new__creation_ip alias for $8; -- default null + new__is_live alias for $9; -- default ''f'' + new__mime_type alias for $10; + new__text alias for $11; -- default null + new__storage_type alias for $12; -- check in (''text'', ''file'') + new__security_inherit_p alias for $13; -- default ''t'' + new__storage_area_key alias for $14; -- default ''CR_FILES'' + new__item_subtype alias for $15; + new__content_type alias for $16; + v_item_id cr_items.item_id%TYPE; +begin + v_item_id := content_item__new (new__item_id, new__name, new__parent_id, new__title, + new__creation_date, new__creation_user, new__context_id, new__creation_ip, + new__is_live, new__mime_type, new__text, new__storage_type, + new__security_inherit_p, new__storage_area_key, new__item_subtype, + new__content_type, null); + + return v_item_id; + +end;' language 'plpgsql'; + create or replace function content_item__is_published (integer) returns boolean as ' declare @@ -1169,6 +1394,10 @@ update cr_items set name = rename__name where item_id = rename__item_id; + + update acs_objects + set title = rename__name + where object_id = rename__item_id; else if exists_id != rename__item_id then raise EXCEPTION ''-20000: An item with the name % already exists in this directory.'', rename__name; @@ -2044,8 +2273,14 @@ where item_id = move__item_id; end if; - end if; end if; + if move__name is not null then + update acs_objects + set title = move__name + where object_id = move__item_id; + end if; + end if; + return 0; end;' language 'plpgsql'; @@ -2413,6 +2648,7 @@ v_object_type acs_objects.object_type%TYPE; v_is_valid integer; v_rel_id integer; + v_package_id integer; v_exists integer; v_order_n cr_item_rels.order_n%TYPE; begin @@ -2453,6 +2689,8 @@ v_exists := 0; end if; + v_package_id := acs_object__package_id(relate__item_id); + -- if order_n is null, use rel_id (the order the item was related) if relate__order_n is null then v_order_n := v_rel_id; @@ -2470,8 +2708,12 @@ now(), null, null, - relate__item_id + relate__item_id, + ''t'', + relate__relation_tag || '': '' || relate__item_id || '' - '' || relate__object_id, + v_package_id ); + insert into cr_item_rels ( rel_id, item_id, related_object_id, order_n, relation_tag ) values ( @@ -2487,6 +2729,10 @@ order_n = v_order_n where rel_id = v_rel_id; + + update acs_objects set + title = relate__relation_tag || '': '' || relate__item_id || '' - '' || relate__object_id + where object_id = v_rel_id; end if; end if; Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-keyword.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-keyword.sql,v diff -u -N -r1.20 -r1.21 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-keyword.sql 4 Mar 2004 14:52:36 -0000 1.20 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-keyword.sql 12 Mar 2004 18:48:47 -0000 1.21 @@ -52,6 +52,10 @@ where keyword_id = set_heading__keyword_id; + update acs_objects + set title = set_heading__heading + where object_id = set_heading__keyword_id; + return 0; end;' language 'plpgsql'; @@ -94,7 +98,7 @@ select define_function_args('content_keyword__new','heading,description,parent_id,keyword_id,creation_date;now,creation_user,creation_ip,object_type;content_keyword'); -create or replace function content_keyword__new (varchar,varchar,integer,integer,timestamptz,integer,varchar,varchar) +create or replace function content_keyword__new (varchar,varchar,integer,integer,timestamptz,integer,varchar,varchar,integer) returns integer as ' declare new__heading alias for $1; @@ -105,15 +109,26 @@ new__creation_user alias for $6; -- default null new__creation_ip alias for $7; -- default null new__object_type alias for $8; -- default ''content_keyword'' + new__package_id alias for $9; -- default null v_id integer; + v_package_id acs_objects.package_id%TYPE; begin + if new__package_id is null then + v_package_id := acs_object__package_id(new__parent_id); + else + v_package_id := new__package_id; + end if; + v_id := acs_object__new (new__keyword_id, new__object_type, new__creation_date, new__creation_user, new__creation_ip, - new__parent_id + new__parent_id, + ''t'', + new__heading, + v_package_id ); insert into cr_keywords @@ -125,7 +140,31 @@ end;' language 'plpgsql'; +create or replace function content_keyword__new (varchar,varchar,integer,integer,timestamptz,integer,varchar,varchar) +returns integer as ' +declare + new__heading alias for $1; + new__description alias for $2; -- default null + new__parent_id alias for $3; -- default null + new__keyword_id alias for $4; -- default null + new__creation_date alias for $5; -- default now() + new__creation_user alias for $6; -- default null + new__creation_ip alias for $7; -- default null + new__object_type alias for $8; -- default ''content_keyword'' +begin + return content_keyword__new(new__heading, + new__description, + new__parent_id, + new__keyword_id, + new__creation_date, + new__creation_user, + new__creation_ip, + new__object_type, + null + ); +end;' language 'plpgsql'; + -- procedure delete create or replace function content_keyword__delete (integer) returns integer as ' Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql,v diff -u -N -r1.35 -r1.36 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql 4 Mar 2004 14:52:36 -0000 1.35 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql 12 Mar 2004 18:48:47 -0000 1.36 @@ -19,7 +19,7 @@ -- than the standard package_instantiate_object. So we don't bother calling define_function_args -- here. -create or replace function content_revision__new (varchar,varchar,timestamptz,varchar,varchar,integer,integer,integer,timestamptz,integer,varchar) +create or replace function content_revision__new (varchar,varchar,timestamptz,varchar,varchar,integer,integer,integer,timestamptz,integer,varchar,integer) returns integer as ' declare new__title alias for $1; @@ -34,19 +34,30 @@ new__creation_date alias for $9; -- default now() new__creation_user alias for $10; -- default null new__creation_ip alias for $11; -- default null + new__package_id alias for $12; -- default null v_revision_id integer; + v_package_id acs_objects.package_id%TYPE; v_content_type acs_object_types.object_type%TYPE; begin v_content_type := content_item__get_content_type(new__item_id); + if new__package_id is null then + v_package_id := acs_object__package_id(new__item_id); + else + v_package_id := new__package_id; + end if; + v_revision_id := acs_object__new( new__revision_id, v_content_type, new__creation_date, new__creation_user, new__creation_ip, - new__item_id + new__item_id, + ''t'', + new__title, + v_package_id ); -- binary data is stored in cr_revisions using Dons lob hack. @@ -71,6 +82,64 @@ end;' language 'plpgsql'; +create or replace function content_revision__new (varchar,varchar,timestamptz,varchar,varchar,integer,integer,integer,timestamptz,integer,varchar) +returns integer as ' +declare + new__title alias for $1; + new__description alias for $2; -- default null + new__publish_date alias for $3; -- default now() + new__mime_type alias for $4; -- default ''text/plain'' + new__nls_language alias for $5; -- default null + -- lob id + new__data alias for $6; + new__item_id alias for $7; + new__revision_id alias for $8; -- default null + new__creation_date alias for $9; -- default now() + new__creation_user alias for $10; -- default null + new__creation_ip alias for $11; -- default null +begin + return content_revision__new(new__title, + new__description, + new__publish_date, + new__mime_type, + new__nls_language, + new__data, + new__item_id, + new__revision_id, + new__creation_date, + new__creation_user, + new__creation_ip, + null + ); +end;' language 'plpgsql'; + +create or replace function content_revision__new(varchar,varchar,timestamptz,varchar,text,integer,integer) returns integer as ' +declare + new__title alias for $1; + new__description alias for $2; -- default null + new__publish_date alias for $3; -- default now() + new__mime_type alias for $4; -- default ''text/plain'' + new__text alias for $5; -- default '' '' + new__item_id alias for $6; + new__package_id alias for $7; -- default null +begin + return content_revision__new(new__title, + new__description, + new__publish_date, + new__mime_type, + null, + new__text, + new__item_id, + null, + now(), + null, + null, + null, + new__package_id + ); + +end;' language 'plpgsql'; + create or replace function content_revision__new(varchar,varchar,timestamptz,varchar,text,integer) returns integer as ' declare new__title alias for $1; @@ -90,6 +159,8 @@ null, now(), null, + null, + null, null ); @@ -121,11 +192,11 @@ new__creation_date, new__creation_user, new__creation_ip, + null, null ); end;' language 'plpgsql'; --- function new create or replace function content_revision__new (varchar,varchar,timestamptz,varchar,varchar,text,integer,integer,timestamptz,integer,varchar,integer) returns integer as ' declare @@ -141,21 +212,65 @@ new__creation_user alias for $10; -- default null new__creation_ip alias for $11; -- default null new__content_length alias for $12; -- default null +begin + return content_revision__new(new__title, + new__description, + new__publish_date, + new__mime_type, + new__nls_language, + new__text, + new__item_id, + new__revision_id, + new__creation_date, + new__creation_user, + new__creation_ip, + new__content_length, + null + ); +end;' language 'plpgsql'; + +-- function new +create or replace function content_revision__new (varchar,varchar,timestamptz,varchar,varchar,text,integer,integer,timestamptz,integer,varchar,integer,integer) +returns integer as ' +declare + new__title alias for $1; + new__description alias for $2; -- default null + new__publish_date alias for $3; -- default now() + new__mime_type alias for $4; -- default ''text/plain'' + new__nls_language alias for $5; -- default null + new__text alias for $6; -- default '' '' + new__item_id alias for $7; + new__revision_id alias for $8; -- default null + new__creation_date alias for $9; -- default now() + new__creation_user alias for $10; -- default null + new__creation_ip alias for $11; -- default null + new__content_length alias for $12; -- default null + new__package_id alias for $13; -- default null v_revision_id integer; + v_package_id acs_objects.package_id%TYPE; v_content_type acs_object_types.object_type%TYPE; v_storage_type cr_items.storage_type%TYPE; v_length cr_revisions.content_length%TYPE; begin v_content_type := content_item__get_content_type(new__item_id); + if new__package_id is null then + v_package_id := acs_object__package_id(new__item_id); + else + v_package_id := new__package_id; + end if; + v_revision_id := acs_object__new( new__revision_id, v_content_type, new__creation_date, new__creation_user, new__creation_ip, - new__item_id + new__item_id, + ''t'', + v_package_id, + new__title ); select storage_type into v_storage_type @@ -266,7 +381,9 @@ copy__creation_ip as creation_ip, now() as last_modified, copy__creation_user as modifying_user, - copy__creation_ip as modifying_ip + copy__creation_ip as modifying_ip, + title, + package_id from acs_objects where Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-symlink.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-symlink.sql,v diff -u -N -r1.17 -r1.18 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-symlink.sql 4 Mar 2004 14:52:36 -0000 1.17 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-symlink.sql 12 Mar 2004 18:48:47 -0000 1.18 @@ -14,7 +14,7 @@ select define_function_args('content_symlink__new','name,label,target_id,parent_id,symlink_id,creation_date;now,creation_user,creation_ip'); -create or replace function content_symlink__new (varchar,varchar,integer,integer,integer,timestamptz,integer,varchar) +create or replace function content_symlink__new (varchar,varchar,integer,integer,integer,timestamptz,integer,varchar,integer) returns integer as ' declare new__name alias for $1; -- default null @@ -25,7 +25,9 @@ new__creation_date alias for $6; -- default now() new__creation_user alias for $7; -- default null new__creation_ip alias for $8; -- default null + new__package_id alias for $9; -- default null v_symlink_id cr_symlinks.symlink_id%TYPE; + v_package_id acs_objects.package_id%TYPE; v_name cr_items.name%TYPE; v_label cr_symlinks.label%TYPE; v_ctype varchar; @@ -80,6 +82,12 @@ v_label := new__label; end if; + if new__package_id is null then + v_package_id := acs_object__package_id(new__parent_id); + else + v_package_id := new__package_id; + end if; + v_symlink_id := content_item__new( v_name, new__parent_id, @@ -96,19 +104,49 @@ ''text/plain'', null, null, - ''text'' + ''text'', + v_package_id ); insert into cr_symlinks (symlink_id, target_id, label) values (v_symlink_id, new__target_id, v_label); + update acs_objects + set title = v_label + where object_id = v_symlink_id; + return v_symlink_id; end;' language 'plpgsql'; +create or replace function content_symlink__new (varchar,varchar,integer,integer,integer,timestamptz,integer,varchar) +returns integer as ' +declare + new__name alias for $1; -- default null + new__label alias for $2; -- default null + new__target_id alias for $3; + new__parent_id alias for $4; + new__symlink_id alias for $5; -- default null + new__creation_date alias for $6; -- default now() + new__creation_user alias for $7; -- default null + new__creation_ip alias for $8; -- default null +begin + return content_extlink__new(new__name, + new__label, + new__target_id, + new__parent_id, + new__symlink_id, + new__creation_date, + new__creation_user, + new__creation_ip, + null + ); + +end;' language 'plpgsql'; + -- procedure delete create or replace function content_symlink__delete (integer) returns integer as ' @@ -205,7 +243,8 @@ null, now(), copy__creation_user, - copy__creation_ip + copy__creation_ip, + null ); @@ -217,7 +256,7 @@ return v_symlink_id; end;' language 'plpgsql'; -create function content_symlink__copy ( +create or replace function content_symlink__copy ( integer, integer, integer, Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql,v diff -u -N -r1.14 -r1.15 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql 4 Mar 2004 14:52:36 -0000 1.14 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql 12 Mar 2004 18:48:47 -0000 1.15 @@ -29,16 +29,38 @@ null, now(), null, + null, null ); end;' language 'plpgsql'; +create or replace function content_template__new (varchar,integer,integer,timestamptz,integer,varchar) +returns integer as ' +declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__template_id alias for $3; -- default null + new__creation_date alias for $4; -- default now() + new__creation_user alias for $5; -- default null + new__creation_ip alias for $6; -- default null +begin + return content_template__new(new__name, + new__parent_id, + new__template_id, + new__creation_date, + new__creation_user, + new__creation_ip, + null + ); + +end;' language 'plpgsql'; + -- function new select define_function_args('content_template__new','name,parent_id,template_id,creation_date,creation_user,creation_ip'); -create or replace function content_template__new (varchar,integer,integer,timestamptz,integer,varchar) +create or replace function content_template__new (varchar,integer,integer,timestamptz,integer,varchar,integer) returns integer as ' declare new__name alias for $1; @@ -47,7 +69,9 @@ new__creation_date alias for $4; -- default now() new__creation_user alias for $5; -- default null new__creation_ip alias for $6; -- default null + new__package_id alias for $7; -- default null v_template_id cr_templates.template_id%TYPE; + v_package_id acs_objects.package_id%TYPE; v_parent_id cr_items.parent_id%TYPE; begin @@ -64,6 +88,12 @@ raise EXCEPTION ''-20000: This folder does not allow templates to be created''; else + if new__package_id is null then + v_package_id := acs_object__package_id(v_parent_id); + else + v_package_id := new__package_id; + end if; + v_template_id := content_item__new ( new__name, v_parent_id, @@ -80,7 +110,8 @@ ''text/plain'', null, null, - ''text'' + ''text'', + v_package_id ); insert into cr_templates ( @@ -96,6 +127,27 @@ end;' language 'plpgsql'; +create or replace function content_template__new(varchar,text,bool,integer) returns integer as ' +declare + new__name alias for $1; + new__text alias for $2; + new__is_live alias for $3; + new__package_id alias for $4; -- default null +begin + return content_template__new(new__name, + null, + null, + now(), + null, + null, + new__text, + new__is_live, + new__package_id + ); + +end;' language 'plpgsql'; + + create or replace function content_template__new(varchar,text,bool) returns integer as ' declare new__name alias for $1; @@ -109,7 +161,8 @@ null, null, new__text, - new__is_live + new__is_live, + null ); end;' language 'plpgsql'; @@ -126,7 +179,35 @@ new__creation_ip alias for $6; -- default null new__text alias for $7; -- default null new__is_live alias for $8; -- default ''f'' +begin + return content_template__new(new__name, + new__parent_id, + new__template_id, + new__creation_date, + new__creation_user, + new__creation_ip, + new__text, + new__is_live, + null + ); + +end;' language 'plpgsql'; + + +create or replace function content_template__new (varchar,integer,integer,timestamptz,integer,varchar,text,bool,integer) +returns integer as ' +declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__template_id alias for $3; -- default null + new__creation_date alias for $4; -- default now() + new__creation_user alias for $5; -- default null + new__creation_ip alias for $6; -- default null + new__text alias for $7; -- default null + new__is_live alias for $8; -- default ''f'' + new__package_id alias for $7; -- default null v_template_id cr_templates.template_id%TYPE; + v_package_id acs_objects.package_id%TYPE; v_parent_id cr_items.parent_id%TYPE; begin @@ -143,6 +224,12 @@ raise EXCEPTION ''-20000: This folder does not allow templates to be created''; else + if new__package_id is null then + v_package_id := acs_object__package_id(v_parent_id); + else + v_package_id := new__package_id; + end if; + v_template_id := content_item__new ( new__template_id, -- new__item_id new__name, -- new__name @@ -159,7 +246,8 @@ ''t'', -- new__security_inherit_p ''CR_FILES'', -- new__storage_area_key ''content_item'', -- new__item_subtype - ''content_template'' -- new__content_type + ''content_template'', -- new__content_type + v_package_id -- new__package_id ); insert into cr_templates ( Index: openacs-4/packages/acs-content-repository/sql/postgresql/upgrade/upgrade-5.1.0d2-5.1.0d3.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/upgrade/upgrade-5.1.0d2-5.1.0d3.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/upgrade/upgrade-5.1.0d2-5.1.0d3.sql 12 Mar 2004 18:48:47 -0000 1.3 @@ -0,0 +1,440 @@ +update acs_objects +set title = (select label + from cr_folders + where folder_id = object_id), +package_id = (select package_id + from apm_packages + where package_key = 'acs-content-repository') +where object_type = 'content_folder' +and object_id < 0; + +update acs_objects +set title = (select label + from cr_folders + where folder_id = object_id), +package_id = (select coalesce(package_id, acs_object__package_id(content_item__get_root_folder(folder_id))) + from cr_folders + where folder_id = object_id) +where object_type = 'content_folder' +and object_id > 0; + +update acs_objects +set title = (select name + from cr_items + where item_id = object_id), +package_id = acs_object__package_id(content_item__get_root_folder(object_id)) +where object_type = 'content_item'; + +update acs_objects +set title = (select title + from cr_revisions + where revision_id = object_id), +package_id = (select acs_object__package_id(item_id) + from cr_revisions + where revision_id = object_id) +where object_type in ('content_revision', 'image'); + +update acs_objects +set title = (select label + from cr_symlinks + where symlink_id = object_id), +package_id = (select acs_object__package_id(target_id) + from cr_symlinks + where symlink_id = object_id) +where object_type = 'content_symlink'; + +update acs_objects +set title = (select label + from cr_extlinks + where extlink_id = object_id), +package_id = (select acs_object__package_id(parent_id) + from cr_items + where item_id = object_id) +where object_type = 'content_extlink'; + +update acs_objects +set title = (select heading + from cr_keywords + where keyword_id = object_id) +where object_type = 'content_keyword'; + +update acs_objects +set title = (select name + from cr_items + where item_id = object_id), +package_id = (select acs_object__package_id(parent_id) + from cr_items + where item_id = object_id) +where object_type = 'content_template'; + +update acs_objects +set title = (select relation_tag || ': ' || item_id || ' - ' || related_object_id + from cr_item_rels + where rel_id = object_id), +package_id = (select acs_object__package_id(item_id) + from cr_item_rels + where rel_id = object_id) +where object_type = 'cr_item_rel'; + +update acs_objects +set title = (select relation_tag || ': ' || parent_id || ' - ' || child_id + from cr_child_rels + where rel_id = object_id), +package_id = (select acs_object__package_id(parent_id) + from cr_child_rels + where rel_id = object_id) +where object_type = 'cr_item_child_rel'; + +\i ../content-item.sql +\i ../content-revision.sql +\i ../content-folder.sql +\i ../content-template.sql +\i ../content-symlink.sql +\i ../content-extlink.sql +\i ../content-keyword.sql + + +create function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,boolean,timestamptz,varchar,integer,integer,integer,integer + ) returns integer as ' + declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__item_id alias for $3; -- default null + new__revision_id alias for $4; -- default null + new__mime_type alias for $5; -- default jpeg + new__creation_user alias for $6; -- default null + new__creation_ip alias for $7; -- default null + new__relation_tag alias for $8; -- default null + new__title alias for $9; -- default null + new__description alias for $10; -- default null + new__is_live alias for $11; -- default f + new__publish_date alias for $12; -- default now() + new__path alias for $13; + new__file_size alias for $14; + new__height alias for $15; + new__width alias for $16; + new__package_id alias for $17; -- default null + + new__locale varchar default null; + new__nls_language varchar default null; + new__creation_date timestamptz default current_timestamp; + new__context_id integer; + + v_item_id cr_items.item_id%TYPE; + v_package_id acs_objects.package_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; + begin + new__context_id := new__parent_id; + + if p_package_id is null then + v_package_id := acs_object__package_id(new__parent_id); + else + v_package_id := new__package_id; + end if; + + v_item_id := content_item__new ( + new__name, + new__parent_id, + new__item_id, + new__locale, + new__creation_date, + new__creation_user, + new__context_id, + new__creation_ip, + ''content_item'', + ''image'', + null, + new__description, + new__mime_type, + new__nls_language, + null, + ''file'' -- storage_type, + v_package_id + ); + + -- update cr_child_rels to have the correct relation_tag + update cr_child_rels + set relation_tag = new__relation_tag + where parent_id = new__parent_id + and child_id = new__item_id + and relation_tag = content_item__get_content_type(new__parent_id) || ''-'' || ''image''; + + v_revision_id := content_revision__new ( + new__title, + new__description, + new__publish_date, + new__mime_type, + new__nls_language, + null, + v_item_id, + new__revision_id, + new__creation_date, + new__creation_user, + new__creation_ip, + v_package_id + ); + + insert into images + (image_id, height, width) + values + (v_revision_id, new__height, new__width); + + -- update revision with image file info + update cr_revisions + set content_length = new__file_size, + content = new__path + where revision_id = v_revision_id; + + -- is_live => ''t'' not used as part of content_item.new + -- because content_item.new does not let developer specify revision_id, + -- revision_id is determined in advance + + if new__is_live = ''t'' then + PERFORM content_item__set_live_revision (v_revision_id); + end if; + + return v_item_id; +end; ' language 'plpgsql'; + +create or replace function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,boolean,timestamptz,varchar,integer,integer,integer + ) returns integer as ' + declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__item_id alias for $3; -- default null + new__revision_id alias for $4; -- default null + new__mime_type alias for $5; -- default jpeg + new__creation_user alias for $6; -- default null + new__creation_ip alias for $7; -- default null + new__relation_tag alias for $8; -- default null + new__title alias for $9; -- default null + new__description alias for $10; -- default null + new__is_live alias for $11; -- default f + new__publish_date alias for $12; -- default now() + new__path alias for $13; + new__file_size alias for $14; + new__height alias for $15; + new__width alias for $16; + begin + return image__new(new__name, + new__parent_id, + new__item_id, + new__revision_id, + new__mime_type, + new__creation_user, + new__creation_ip, + new__relation_tag, + new__title, + new__description, + new__is_live, + new__publish_date, + new__path, + new__file_size, + new__height, + new__width, + null + ); +end; ' language 'plpgsql'; + +-- DRB's version + +create function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,varchar, + varchar,timestamptz,integer, integer, integer) returns integer as ' + declare + p_name alias for $1; + p_parent_id alias for $2; -- default null + p_item_id alias for $3; -- default null + p_revision_id alias for $4; -- default null + p_mime_type alias for $5; -- default jpeg + p_creation_user alias for $6; -- default null + p_creation_ip alias for $7; -- default null + p_title alias for $8; -- default null + p_description alias for $9; -- default null + p_storage_type alias for $10; + p_content_type alias for $11; + p_nls_language alias for $12; + p_publish_date alias for $13; + p_height alias for $14; + p_width alias for $15; + p_package_id alias for $16; -- default null + + v_item_id cr_items.item_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; + v_package_id acs_objects.package_id%TYPE; + begin + + if content_item__is_subclass(p_content_type, ''image'') = ''f'' then + raise EXCEPTION ''-20000: image__new can only be called for an image type''; + end if; + + if p_package_id is null then + v_package_id := acs_object__package_id(p_parent_id); + else + v_package_id := p_package_id; + end if; + + v_item_id := content_item__new ( + p_name, + p_parent_id, + p_item_id, + null, + current_timestamp, + p_creation_user, + p_parent_id, + p_creation_ip, + ''content_item'', + p_content_type, + null, + null, + null, + null, + null, + p_storage_type, + v_package_id + ); + + -- We will let the caller fill in the LOB data or file path. + + v_revision_id := content_revision__new ( + p_title, + p_description, + p_publish_date, + p_mime_type, + p_nls_language, + null, + v_item_id, + p_revision_id, + current_timestamp, + p_creation_user, + p_creation_ip, + v_package_id + ); + + insert into images + (image_id, height, width) + values + (v_revision_id, p_height, p_width); + + return v_item_id; +end; ' language 'plpgsql'; + +create or replace function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,varchar, + varchar,timestamptz,integer, integer) returns integer as ' + declare + p_name alias for $1; + p_parent_id alias for $2; -- default null + p_item_id alias for $3; -- default null + p_revision_id alias for $4; -- default null + p_mime_type alias for $5; -- default jpeg + p_creation_user alias for $6; -- default null + p_creation_ip alias for $7; -- default null + p_title alias for $8; -- default null + p_description alias for $9; -- default null + p_storage_type alias for $10; + p_content_type alias for $11; + p_nls_language alias for $12; + p_publish_date alias for $13; + p_height alias for $14; + p_width alias for $15; + begin + return image__new(p_name, + p_parent_id, + p_item_id, + p_revision_id, + p_mime_type, + p_creation_user, + p_creation_ip, + p_title, + p_description, + p_storage_type, + p_content_type, + p_nls_language, + p_publish_date, + p_height, + p_width, + null + ); +end; ' language 'plpgsql'; + + +create or replace function image__new_revision(integer, integer, varchar, varchar, timestamptz, varchar, varchar, + integer, varchar, integer, integer, integer) returns integer as ' +declare + p_item_id alias for $1; + p_revision_id alias for $2; + p_title alias for $3; + p_description alias for $4; + p_publish_date alias for $5; + p_mime_type alias for $6; + p_nls_language alias for $7; + p_creation_user alias for $8; + p_creation_ip alias for $9; + p_height alias for $10; + p_width alias for $11; + p_package_id alias for $12; + v_revision_id integer; + v_package_id acs_objects.package_id%TYPE; +begin + -- We will let the caller fill in the LOB data or file path. + + if p_package_id is null then + v_package_id := acs_object__package_id(p_item_id); + else + v_package_id := p_package_id; + end if; + + v_revision_id := content_revision__new ( + p_title, + p_description, + p_publish_date, + p_mime_type, + p_nls_language, + null, + p_item_id, + p_revision_id, + current_timestamp, + p_creation_user, + p_creation_ip, + p_package_id + ); + + insert into images + (image_id, height, width) + values + (v_revision_id, p_height, p_width); + + return v_revision_id; +end;' language 'plpgsql'; + +create or replace function image__new_revision(integer,integer,varchar,varchar,timestamptz,varchar,varchar, + integer,varchar,integer,integer) returns integer as ' +declare + p_item_id alias for $1; + p_revision_id alias for $2; + p_title alias for $3; + p_description alias for $4; + p_publish_date alias for $5; + p_mime_type alias for $6; + p_nls_language alias for $7; + p_creation_user alias for $8; + p_creation_ip alias for $9; + p_height alias for $10; + p_width alias for $11; + v_revision_id integer; +begin + return image__new_revision(p_item_id, + p_revision_id, + p_title, + p_description, + p_publish_date, + p_mime_type, + p_nls_language, + p_creation_user, + p_creation_ip, + p_height, + p_width, + p_revision_id, + null + ); + +end;' language 'plpgsql'; Index: openacs-4/packages/acs-content-repository/tcl/extlink-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/extlink-procs-oracle.xql,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/acs-content-repository/tcl/extlink-procs-oracle.xql 4 Mar 2004 14:52:37 -0000 1.8 +++ openacs-4/packages/acs-content-repository/tcl/extlink-procs-oracle.xql 12 Mar 2004 18:48:48 -0000 1.9 @@ -14,7 +14,8 @@ parent_id => :parent_id, extlink_id => :extlink_id, creation_user => :creation_user, - creation_ip => :creation_ip + creation_ip => :creation_ip, + package_id => :package_id ); end; @@ -27,7 +28,8 @@ update acs_objects set last_modified = sysdate, modifying_user = :modifying_user, - modifying_ip = :modifying_ip + modifying_ip = :modifying_ip, + title = :label where object_id = :extlink_id Index: openacs-4/packages/acs-content-repository/tcl/extlink-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/extlink-procs-postgresql.xql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/acs-content-repository/tcl/extlink-procs-postgresql.xql 4 Mar 2004 14:52:37 -0000 1.4 +++ openacs-4/packages/acs-content-repository/tcl/extlink-procs-postgresql.xql 12 Mar 2004 18:48:48 -0000 1.5 @@ -14,7 +14,8 @@ :extlink_id, current_timestamp, :creation_user, - :creation_ip + :creation_ip, + :package_id ); @@ -26,7 +27,8 @@ update acs_objects set last_modified = current_timestamp, modifying_user = :modifying_user, - modifying_ip = :modifying_ip + modifying_ip = :modifying_ip, + title = :label where object_id = :extlink_id Index: openacs-4/packages/acs-content-repository/tcl/extlink-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/extlink-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/acs-content-repository/tcl/extlink-procs.tcl 4 Mar 2004 14:52:37 -0000 1.5 +++ openacs-4/packages/acs-content-repository/tcl/extlink-procs.tcl 12 Mar 2004 18:48:48 -0000 1.6 @@ -16,6 +16,7 @@ {-name ""} {-label ""} {-description ""} + {-package_id ""} } { Create a new external link. @@ -26,12 +27,17 @@ @name Name to assign the object (defaults to "link extlink_id") @label Label for the extlink (defaults to the URL) @description An extended description of the link (defaults to NULL) + @package_id Package Id of the package that created the link } { set creation_user [ad_conn user_id] set creation_ip [ad_conn peeraddr] + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + return [db_exec_plsql extlink_new {}] } Index: openacs-4/packages/acs-content-repository/tcl/keyword-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/keyword-procs-oracle.xql,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/acs-content-repository/tcl/keyword-procs-oracle.xql 4 Mar 2004 14:52:37 -0000 1.7 +++ openacs-4/packages/acs-content-repository/tcl/keyword-procs-oracle.xql 12 Mar 2004 18:48:48 -0000 1.8 @@ -14,7 +14,8 @@ sysdate(), :user_id, :creation_ip, - :object_type + :object_type, + :package_id ); end; Index: openacs-4/packages/acs-content-repository/tcl/keyword-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/keyword-procs-postgresql.xql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-content-repository/tcl/keyword-procs-postgresql.xql 4 Mar 2004 14:52:37 -0000 1.6 +++ openacs-4/packages/acs-content-repository/tcl/keyword-procs-postgresql.xql 12 Mar 2004 18:48:48 -0000 1.7 @@ -12,7 +12,8 @@ current_timestamp, :user_id, :creation_ip, - :object_type + :object_type, + :package_id ) Index: openacs-4/packages/acs-content-repository/tcl/keyword-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/keyword-procs.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-content-repository/tcl/keyword-procs.tcl 4 Mar 2004 14:52:37 -0000 1.6 +++ openacs-4/packages/acs-content-repository/tcl/keyword-procs.tcl 12 Mar 2004 18:48:48 -0000 1.7 @@ -16,12 +16,17 @@ {-parent_id ""} {-keyword_id ""} {-object_type "content_keyword"} + {-package_id ""} } { Create a new keyword } { set user_id [ad_conn user_id] set creation_ip [ad_conn peeraddr] + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + set keyword_id [db_exec_plsql content_keyword_new {}] return $keyword_id Index: openacs-4/packages/acs-content-repository/tcl/revision-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/revision-procs-oracle.xql,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/acs-content-repository/tcl/revision-procs-oracle.xql 4 Mar 2004 14:52:37 -0000 1.8 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs-oracle.xql 12 Mar 2004 18:48:48 -0000 1.9 @@ -63,7 +63,8 @@ content_type => :image_type, storage_type => :storage_type, height => :original_height, - width => :original_width + width => :original_width, + package_id => :package_id ); end; @@ -81,7 +82,8 @@ creation_user => :creation_user, creation_ip => :creation_ip, height => :original_height, - width => :original_width + width => :original_width, + package_id => :package_id ); end; @@ -98,7 +100,8 @@ creation_user => :creation_user, creation_ip => :creation_ip, content_type => :other_type, - storage_type => :storage_type + storage_type => :storage_type, + package_id => :package_id ); end; @@ -114,7 +117,8 @@ item_id => :item_id, revision_id => :revision_id, creation_user => :creation_user, - creation_ip => :creation_ip + creation_ip => :creation_ip, + package_id => :package_id ); end; Index: openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql 4 Mar 2004 14:52:37 -0000 1.8 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql 12 Mar 2004 18:48:48 -0000 1.9 @@ -61,7 +61,8 @@ /* nls_language => */ null, /* publish_date => */ current_timestamp, /* height => */ :original_height, - /* width => */ :original_width + /* width => */ :original_width, + /* package_id => */ :package_id ); @@ -79,7 +80,8 @@ /* creation_user => */ :creation_user, /* creation_ip => */ :creation_ip, /* height => */ :original_height, - /* width => */ :original_width + /* width => */ :original_width, + /* package_id => */ :package_id ); @@ -102,7 +104,8 @@ /* mime_type => */ null, /* nls_language => */ null, /* text => */ null, - /* storage_type => */ :storage_type + /* storage_type => */ :storage_type, + /* package_id => */ :package_id ); @@ -120,7 +123,8 @@ /* revision_id => */ :revision_id, /* creation_date => */ current_timestamp, /* creation_user => */ :creation_user, - /* creation_ip => */ :creation_ip + /* creation_ip => */ :creation_ip, + /* package_id => */ :package_id ); Index: openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl,v diff -u -N -r1.12 -r1.13 --- openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl 4 Mar 2004 14:52:37 -0000 1.12 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl 12 Mar 2004 18:48:48 -0000 1.13 @@ -88,6 +88,7 @@ {-other_type "content_revision"} {-title ""} {-description ""} + {-package_id ""} -item_id parent_id tmp_filename @@ -107,6 +108,7 @@ @param other_type The type of content item to create for a non-image file @param title The title given the new revision @param description The description of the new revision + @param package_id Package Id of the package that created the item @param item_id If present, make a new revision of this item, otherwise, make a new item @param parent_id The parent of the content item we create @@ -147,6 +149,10 @@ set mime_type "application/octet-stream" } + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + set old_item_p [info exists item_id] if { !$old_item_p } { set item_id [db_nextval acs_object_id_seq] Index: openacs-4/packages/acs-content-repository/tcl/symlink-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/symlink-procs-oracle.xql,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/tcl/symlink-procs-oracle.xql 4 Mar 2004 14:52:37 -0000 1.3 +++ openacs-4/packages/acs-content-repository/tcl/symlink-procs-oracle.xql 12 Mar 2004 18:48:48 -0000 1.4 @@ -13,7 +13,8 @@ parent_id => :parent_id, symlink_id => :symlink_id, creation_user => :creation_user, - creation_ip => :creation_ip + creation_ip => :creation_ip, + package_id => :package_id ); end; @@ -26,7 +27,8 @@ update acs_objects set last_modified = sysdate, modifying_user = :modifying_user, - modifying_ip = :modifying_ip + modifying_ip = :modifying_ip, + title = :label where object_id = :symlink_id Index: openacs-4/packages/acs-content-repository/tcl/symlink-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/symlink-procs-postgresql.xql,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/tcl/symlink-procs-postgresql.xql 4 Mar 2004 14:52:37 -0000 1.3 +++ openacs-4/packages/acs-content-repository/tcl/symlink-procs-postgresql.xql 12 Mar 2004 18:48:48 -0000 1.4 @@ -13,7 +13,8 @@ :symlink_id, current_timestamp, :creation_user, - :creation_ip + :creation_ip, + :package_id ); @@ -25,7 +26,8 @@ update acs_objects set last_modified = current_timestamp, modifying_user = :modifying_user, - modifying_ip = :modifying_ip + modifying_ip = :modifying_ip, + title = :label where object_id = :symlink_id Index: openacs-4/packages/acs-content-repository/tcl/symlink-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/Attic/symlink-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/tcl/symlink-procs.tcl 4 Mar 2004 14:52:37 -0000 1.3 +++ openacs-4/packages/acs-content-repository/tcl/symlink-procs.tcl 12 Mar 2004 18:48:48 -0000 1.4 @@ -15,6 +15,7 @@ -parent_id:required {-name ""} {-label ""} + {-package_id ""} } { Create a new internal link. @@ -25,12 +26,17 @@ @name Name to assign the object (defaults to the name of the target item) @label Label for the symlink (defaults to the URL) @description An extended description of the link (defaults to NULL) + @package_id Package Id of the package that created the link } { set creation_user [ad_conn user_id] set creation_ip [ad_conn peeraddr] + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + return [db_exec_plsql symlink_new {}] } Index: openacs-4/packages/acs-events/sql/oracle/acs-events-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-events/sql/oracle/acs-events-create.sql,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/acs-events/sql/oracle/acs-events-create.sql 4 Mar 2004 14:52:38 -0000 1.7 +++ openacs-4/packages/acs-events/sql/oracle/acs-events-create.sql 12 Mar 2004 18:48:48 -0000 1.8 @@ -587,6 +587,7 @@ new_event_id := acs_object.new( object_id => event_id, object_type => object_type, + title => name, creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, Index: openacs-4/packages/acs-events/sql/oracle/activity-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-events/sql/oracle/activity-create.sql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/acs-events/sql/oracle/activity-create.sql 4 Mar 2004 14:52:38 -0000 1.5 +++ openacs-4/packages/acs-events/sql/oracle/activity-create.sql 12 Mar 2004 18:48:48 -0000 1.6 @@ -200,6 +200,7 @@ new_activity_id := acs_object.new( object_id => activity_id, object_type => object_type, + title => name, creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, @@ -265,6 +266,10 @@ html_p = nvl(edit.html_p, html_p), status_summary = nvl(edit.status_summary, status_summary) where activity_id = edit.activity_id; + + update acs_objects + set title = nvl(edit.name, title) + where object_id = edit.activity_id; end edit; procedure object_map ( Index: openacs-4/packages/acs-events/sql/oracle/upgrade/upgrade-0.4d-0.4d1.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-events/sql/oracle/upgrade/upgrade-0.4d-0.4d1.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-events/sql/oracle/upgrade/upgrade-0.4d-0.4d1.sql 12 Mar 2004 18:48:48 -0000 1.3 @@ -0,0 +1,631 @@ +update acs_objects +set title = (select name + from acs_events + where event_id = object_id) +where object_type = 'acs_event'; + +update acs_objects +set title = (select name + from acs_activities + where activity_id = object_id) +where object_type = 'acs_activity'; + +create or replace package body acs_event +as + function new ( + event_id in acs_events.event_id%TYPE default null, + name in acs_events.name%TYPE default null, + description in acs_events.description%TYPE default null, + html_p in acs_events.html_p%TYPE default null, + status_summary in acs_events.status_summary%TYPE default null, + timespan_id in acs_events.timespan_id%TYPE default null, + activity_id in acs_events.activity_id%TYPE default null, + recurrence_id in acs_events.recurrence_id%TYPE default null, + object_type in acs_object_types.object_type%TYPE default 'acs_event', + 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 acs_events.event_id%TYPE + is + new_event_id acs_events.event_id%TYPE; + begin + new_event_id := acs_object.new( + object_id => event_id, + object_type => object_type, + title => name, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id + ); + + insert into acs_events + (event_id, name, description, html_p, status_summary, activity_id, timespan_id, recurrence_id) + values + (new_event_id, name, description, html_p, status_summary, activity_id, timespan_id, recurrence_id); + + return new_event_id; + end new; + + procedure del ( + event_id in acs_events.event_id%TYPE + ) + is + recurrence_id acs_events.recurrence_id%TYPE; + begin + select recurrence_id into recurrence_id + from acs_events + where event_id = acs_event.del.event_id; + + -- acs_events and acs_event_party_map deleted via on delete cascade + acs_object.del(event_id); + + -- Check for no more instances and delete recurrence if exists + if instances_exist_p(recurrence_id) = 'f' then + recurrence.del(recurrence_id); + end if; + end del; + + procedure delete_all ( + event_id in acs_events.event_id%TYPE + ) + is + recurrence_id acs_events.recurrence_id%TYPE; + begin + + select recurrence_id into recurrence_id + from acs_events + where event_id = delete_all.event_id; + + delete_all_recurrences(recurrence_id); + end delete_all; + + procedure delete_all_recurrences ( + recurrence_id in recurrences.recurrence_id%TYPE default null + ) + is + cursor event_id_cursor is + select event_id + from acs_events + where recurrence_id = delete_all_recurrences.recurrence_id; + event_id event_id_cursor%ROWTYPE; + begin + if recurrence_id is not null then + for event_id in event_id_cursor loop + acs_event.del(event_id.event_id); + end loop; + end if; + end delete_all_recurrences; + + -- Equivalent functionality to get_name and get_description provided by + -- acs_event_activity view + + function get_name ( + event_id in acs_events.event_id%TYPE + ) return acs_events.name%TYPE + is + name acs_events.name%TYPE; + begin + select nvl(e.name, a.name) into name + from acs_events e, + acs_activities a + where event_id = get_name.event_id + and e.activity_id = a.activity_id(+); + + return name; + end get_name; + + function get_description ( + event_id in acs_events.event_id%TYPE + ) return acs_events.description%TYPE + is + description acs_events.description%TYPE; + begin + select nvl(e.description, a.description) into description + from acs_events e, acs_activities a + where event_id = get_description.event_id + and e.activity_id = a.activity_id(+); + + return description; + end get_description; + + function get_html_p ( + event_id in acs_events.event_id%TYPE + ) return acs_events.html_p%TYPE + is + html_p acs_events.html_p%TYPE; + begin + select nvl(e.html_p, a.html_p) into html_p + from acs_events e, acs_activities a + where event_id = get_html_p.event_id + and e.activity_id = a.activity_id(+); + + return html_p; + end get_html_p; + + function get_status_summary ( + event_id in acs_events.event_id%TYPE + ) return acs_events.status_summary%TYPE + is + status_summary acs_events.status_summary%TYPE; + begin + select nvl(e.status_summary, a.status_summary) into status_summary + from acs_events e, acs_activities a + where event_id = get_status_summary.event_id + and e.activity_id = a.activity_id(+); + + return status_summary; + end get_status_summary; + + procedure timespan_set ( + event_id in acs_events.event_id%TYPE, + timespan_id in timespans.timespan_id%TYPE + ) + is + begin + update acs_events + set timespan_id = timespan_set.timespan_id + where event_id = timespan_set.event_id; + end timespan_set; + + procedure recurrence_timespan_edit ( + event_id in acs_events.event_id%TYPE, + start_date in time_intervals.start_date%TYPE, + end_date in time_intervals.end_date%TYPE + ) + is + v_timespan timespans%ROWTYPE; + v_one_start_date time_intervals.start_date%TYPE; + v_one_end_date time_intervals.end_date%TYPE; + begin + -- get the initial offsets + select start_date, end_date into v_one_start_date, v_one_end_date + from time_intervals, timespans, acs_events + where time_intervals.interval_id = timespans.interval_id and + timespans.timespan_id = acs_events.timespan_id and + event_id= recurrence_timespan_edit.event_id; + + for v_timespan in + (select * from time_intervals where interval_id in (select interval_id from timespans where timespan_id in (select timespan_id from acs_events where recurrence_id = (select recurrence_id from acs_events where event_id = recurrence_timespan_edit.event_id)))) + LOOP + time_interval.edit(v_timespan.interval_id, v_timespan.start_date + (start_date - v_one_start_date), v_timespan.end_date + (end_date - v_one_end_date)); + END LOOP; + end recurrence_timespan_edit; + + procedure activity_set ( + event_id in acs_events.event_id%TYPE, + activity_id in acs_activities.activity_id%TYPE + ) + as + begin + update acs_events + set activity_id = activity_set.activity_id + where event_id = activity_set.event_id; + end activity_set; + + procedure party_map ( + event_id in acs_events.event_id%TYPE, + party_id in parties.party_id%TYPE + ) + is + begin + insert into acs_event_party_map + (event_id, party_id) + values + (event_id, party_id); + end party_map; + + procedure party_unmap ( + event_id in acs_events.event_id%TYPE, + party_id in parties.party_id%TYPE + ) + is + begin + delete from acs_event_party_map + where event_id = party_unmap.event_id + and party_id = party_unmap.party_id; + end party_unmap; + + function recurs_p ( + event_id in acs_events.event_id%TYPE + ) return char + is + result char; + begin + select decode(recurrence_id, null, 'f', 't') into result + from acs_events + where event_id = recurs_p.event_id; + + return result; + end recurs_p; + + function instances_exist_p ( + recurrence_id in acs_events.recurrence_id%TYPE + ) return char + is + result char; + begin + -- Only need to check if any rows exist. + select count(*) into result + from dual + where exists (select recurrence_id + from acs_events + where recurrence_id = instances_exist_p.recurrence_id); + + if result = 0 then + return 'f'; + else + return 't'; + end if; + end instances_exist_p; + + -- This function is used internally by insert_instances + function get_value ( + parameter_name in apm_parameters.parameter_name%TYPE + ) return apm_parameter_values.attr_value%TYPE + is + package_id apm_packages.package_id%TYPE; + begin + select package_id into package_id + from apm_packages + where package_key = 'acs-events'; + + return apm.get_value(package_id, parameter_name); + end get_value; + + -- This function is used internally by insert_instances + function new_instance ( + event_id in acs_events.event_id%TYPE, + date_offset in integer + ) return acs_events.event_id%TYPE + is + event acs_events%ROWTYPE; + object acs_objects%ROWTYPE; + new_event_id acs_events.event_id%TYPE; + new_timespan_id acs_events.timespan_id%TYPE; + begin + select * into event + from acs_events + where event_id = new_instance.event_id; + + select * into object + from acs_objects + where object_id = event_id; + + new_timespan_id := timespan.copy(event.timespan_id, date_offset); + + new_event_id := new( + name => event.name, + description => event.description, + html_p => event.html_p, + status_summary => event.status_summary, + timespan_id => new_timespan_id, + activity_id => event.activity_id, + recurrence_id => event.recurrence_id, + creation_user => object.creation_user, + creation_ip => object.creation_ip, + context_id => object.context_id + ); + + return new_event_id; + end new_instance; + + procedure insert_instances ( + event_id in acs_events.event_id%TYPE, + cutoff_date in date default null + ) + is + event acs_events%ROWTYPE; + recurrence recurrences%ROWTYPE; + new_event_id acs_events.event_id%TYPE; + interval_name recurrence_interval_types.interval_name%TYPE; + n_intervals recurrence.every_nth_interval%TYPE; + days_of_week recurrence.days_of_week%TYPE; + last_date_done date; + stop_date date; + start_date date; + event_date date; + diff integer; + current_date date; + v_last_day date; + week_date date; + instance_count integer; + days_length integer; + days_index integer; + day_num integer; + begin + select * into event + from acs_events + where event_id = insert_instances.event_id; + + select * into recurrence + from recurrences + where recurrence_id = event.recurrence_id; + + -- Set cutoff date + -- EventFutureLimit is in years. + if cutoff_date is null then + stop_date := add_months(sysdate, 12 * get_value('EventFutureLimit')); + else + stop_date := cutoff_date; + end if; + + -- Events only populated until max(cutoff_date, recur_until) + -- If recur_until null, then defaults to cutoff_date + if recurrence.recur_until < stop_date then + stop_date := recurrence.recur_until; + end if; + + -- Figure out the date to start from + select trunc(min(start_date)) + into event_date + from acs_events_dates + where event_id = insert_instances.event_id; + + if recurrence.db_populated_until is null then + start_date := event_date; + else + start_date := recurrence.db_populated_until; + end if; + + current_date := start_date; + last_date_done := start_date; + n_intervals := recurrence.every_nth_interval; + + -- Case off of the interval_name to make code easier to read + select interval_name into interval_name + from recurrences r, + recurrence_interval_types t + where recurrence_id = recurrence.recurrence_id + and r.interval_type = t.interval_type; + + -- Week has to be handled specially. + -- Start with the beginning of the week containing the start date. + + if interval_name = 'week' then + current_date := NEXT_DAY(current_date - 7, 'SUNDAY'); + days_of_week := recurrence.days_of_week; + days_length := LENGTH(days_of_week); + end if; + + -- Check count to prevent runaway in case of error + instance_count := 0; + while instance_count < 10000 and (trunc(last_date_done) <= trunc(stop_date)) + loop + instance_count := instance_count + 1; + + -- Calculate next date based on interval type + if interval_name = 'day' then + current_date := current_date + n_intervals; + elsif interval_name = 'month_by_date' then + current_date := ADD_MONTHS(current_date, n_intervals); + elsif interval_name = 'month_by_day' then + -- Find last day of month before correct month + v_last_day := ADD_MONTHS(LAST_DAY(current_date), n_intervals - 1); + -- Find correct week and go to correct day of week + current_date := NEXT_DAY(v_last_day + (7 * (to_char(current_date, 'W') - 1)), + to_char(current_date, 'DAY')); + elsif interval_name = 'last_of_month' then + -- Find last day of correct month + v_last_day := LAST_DAY(ADD_MONTHS(current_date, n_intervals)); + -- Back up one week and find correct day of week + current_date := NEXT_DAY(v_last_day - 7, to_char(current_date, 'DAY')); + elsif interval_name = 'year' then + current_date := ADD_MONTHS(current_date, 12 * n_intervals); + -- Deal with custom function + elsif interval_name = 'custom' then + execute immediate 'current_date := ' || + recurrence.custom_func || '(' || current_date || ', ' || n_intervals || ');'; + end if; + + -- Check to make sure we're not going past Trunc because dates aren't integral + exit when trunc(current_date) > trunc(stop_date); + + -- Have to handle week specially + if interval_name = 'week' then + -- loop over days_of_week extracting each day number + -- add day number and insert + days_index := 1; + week_date := current_date; + while days_index <= days_length loop + day_num := SUBSTR(days_of_week, days_index, 1); + week_date := current_date + day_num; + if trunc(week_date) > trunc(start_date) and trunc(week_date) <= trunc(stop_date) then + -- This is where we add the event + new_event_id := new_instance( + event_id, + trunc(week_date) - trunc(event_date) + ); + last_date_done := week_date; + elsif trunc(week_date) > trunc(stop_date) then + -- Gone too far + exit; + end if; + days_index := days_index + 2; + end loop; + + -- Now move to next week with repeats. + current_date := current_date + 7 * n_intervals; + else + -- All other interval types + -- This is where we add the event + new_event_id := new_instance( + event_id, + trunc(current_date) - trunc(event_date) + ); + last_date_done := current_date; + end if; + end loop; + + update recurrences + set db_populated_until = last_date_done + where recurrence_id = recurrence.recurrence_id; + + end insert_instances; + + + procedure shift ( + event_id in acs_events.event_id%TYPE default null, + start_offset in number default 0, + end_offset in number default 0 + ) + is + begin + update acs_events_dates + set start_date = start_date + start_offset, + end_date = end_date + end_offset + where event_id = shift.event_id; + end shift; + + procedure shift_all ( + event_id in acs_events.event_id%TYPE default null, + start_offset in number default 0, + end_offset in number default 0 + ) + is + begin + update acs_events_dates + set start_date = start_date + start_offset, + end_date = end_date + end_offset + where recurrence_id = (select recurrence_id + from acs_events + where event_id = shift_all.event_id); + end shift_all; + + procedure shift_all ( + recurrence_id in recurrences.recurrence_id%TYPE default null, + start_offset in number default 0, + end_offset in number default 0 + ) + is + begin + update acs_events_dates + set start_date = start_date + start_offset, + end_date = end_date + end_offset + where recurrence_id = shift_all.recurrence_id; + end shift_all; + +end acs_event; +/ +show errors + + +create or replace package body acs_activity +as + function new ( + activity_id in acs_activities.activity_id%TYPE default null, + name in acs_activities.name%TYPE, + description in acs_activities.description%TYPE default null, + html_p in acs_activities.html_p%TYPE default 'f', + status_summary in acs_activities.status_summary%TYPE default null, + object_type in acs_object_types.object_type%TYPE default 'acs_activity', + 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 acs_activities.activity_id%TYPE + is + new_activity_id acs_activities.activity_id%TYPE; + begin + new_activity_id := acs_object.new( + object_id => activity_id, + object_type => object_type, + title => name, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id + ); + + insert into acs_activities + (activity_id, name, description, html_p, status_summary) + values + (new_activity_id, name, description, html_p, status_summary); + + return new_activity_id; + end new; + + + function name ( + -- name method + -- @author gjin@arsdigita.com + -- @param activity_id + -- + activity_id in acs_activities.activity_id%TYPE + + ) return acs_activities.name%TYPE + + is + new_activity_name acs_activities.name%TYPE; + + begin + select name + into new_activity_name + from acs_activities + where activity_id = name.activity_id; + + return new_activity_name; + end; + + + procedure del ( + activity_id in acs_activities.activity_id%TYPE + ) + is + begin + -- Cascade will cause delete from acs_activities + -- and acs_activity_object_map + + acs_object.del(activity_id); + end del; + + -- NOTE: can't use update + + procedure edit ( + activity_id in acs_activities.activity_id%TYPE, + name in acs_activities.name%TYPE default null, + description in acs_activities.description%TYPE default null, + html_p in acs_activities.html_p%TYPE default null, + status_summary in acs_activities.status_summary%TYPE default null + ) + is + begin + update acs_activities + set name = nvl(edit.name, name), + description = nvl(edit.description, description), + html_p = nvl(edit.html_p, html_p), + status_summary = nvl(edit.status_summary, status_summary) + where activity_id = edit.activity_id; + + update acs_objects + set title = nvl(edit.name, title) + where object_id = edit.activity_id; + end edit; + + procedure object_map ( + activity_id in acs_activities.activity_id%TYPE, + object_id in acs_objects.object_id%TYPE + ) + is + begin + insert into acs_activity_object_map + (activity_id, object_id) + values + (activity_id, object_id); + end object_map; + + procedure object_unmap ( + activity_id in acs_activities.activity_id%TYPE, + object_id in acs_objects.object_id%TYPE + ) + is + begin + delete from acs_activity_object_map + where activity_id = object_unmap.activity_id + and object_id = object_unmap.object_id; + end object_unmap; + +end acs_activity; +/ +show errors Index: openacs-4/packages/acs-events/sql/postgresql/acs-events-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-events/sql/postgresql/acs-events-create.sql,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/acs-events/sql/postgresql/acs-events-create.sql 4 Mar 2004 14:52:39 -0000 1.9 +++ openacs-4/packages/acs-events/sql/postgresql/acs-events-create.sql 12 Mar 2004 18:48:48 -0000 1.10 @@ -479,7 +479,10 @@ new__creation_date, -- creation_date new__creation_user, -- creation_user new__creation_ip, -- creation_ip - new__context_id -- context_id + new__context_id, -- context_id + ''t'', -- security_inherit_p + new__name, -- title + null -- package_id ); insert into acs_events Index: openacs-4/packages/acs-events/sql/postgresql/activity-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-events/sql/postgresql/activity-create.sql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/acs-events/sql/postgresql/activity-create.sql 4 Mar 2004 14:52:39 -0000 1.5 +++ openacs-4/packages/acs-events/sql/postgresql/activity-create.sql 12 Mar 2004 18:48:48 -0000 1.6 @@ -198,7 +198,10 @@ new__creation_date, -- creation_date new__creation_user, -- creation_user new__creation_ip, -- creation_ip - new__context_id -- context_id + new__context_id, -- context_id + ''t'', -- security_inherit_p + new__name, -- title + null -- package_id ); insert into acs_activities @@ -300,6 +303,10 @@ status_summary = coalesce(edit__status_summary, status_summary) where activity_id = edit__activity_id; + update acs_objects + set title = coalesce(edit__name, name) + where activity_id = edit__activity_id; + return 0; end;' language 'plpgsql'; Index: openacs-4/packages/acs-events/sql/postgresql/upgrade/upgrade-0.4d-0.4d1.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-events/sql/postgresql/upgrade/upgrade-0.4d-0.4d1.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-events/sql/postgresql/upgrade/upgrade-0.4d-0.4d1.sql 12 Mar 2004 18:48:49 -0000 1.3 @@ -0,0 +1,204 @@ +update acs_objects +set title = (select name + from acs_events + where event_id = object_id) +where object_type = 'acs_event'; + +update acs_objects +set title = (select name + from acs_activities + where activity_id = object_id) +where object_type = 'acs_activity'; + + +drop function acs_event__new (integer,varchar,text,boolean,text,integer,integer,integer,varchar,timestamptz,integer,varchar,integer); + +create function acs_event__new ( + -- + -- Creates a new event (20.10.10) + -- + -- @author W. Scott Meeks + -- + -- @param event_id id to use for new event + -- @param name Name of the new event + -- @param description Description of the new event + -- @param html_p Is the description HTML? + -- @param status_summary Optional additional status line to display + -- @param timespan_id initial time interval set + -- @param activity_id initial activity + -- @param recurrence_id id of recurrence information + -- @param object_type 'acs_event' + -- @param creation_date default now() + -- @param creation_user acs_object param + -- @param creation_ip acs_object param + -- @param context_id acs_object param + -- + -- @return The id of the new event. + -- + integer, -- acs_events.event_id%TYPE, + varchar, -- acs_events.name%TYPE, + text, -- acs_events.description%TYPE, + boolean, -- acs_events.html_p%TYPE, + text, -- acs_events.status_summary%TYPE, + integer, -- acs_events.timespan_id%TYPE, + integer, -- acs_events.activity_id%TYPE, + integer, -- acs_events.recurrence_id%TYPE, + varchar, -- acs_object_types.object_type%TYPE, + timestamptz, -- acs_objects.creation_date%TYPE, + integer, -- acs_objects.creation_user%TYPE, + varchar, -- acs_objects.creation_ip%TYPE, + integer -- acs_objects.context_id%TYPE, +) +returns integer as ' -- acs_events.event_id%TYPE +declare + new__event_id alias for $1; -- default null, + new__name alias for $2; -- default null, + new__description alias for $3; -- default null, + new__html_p alias for $4; -- default null + new__status_summary alias for $5; -- default null + new__timespan_id alias for $6; -- default null, + new__activity_id alias for $7; -- default null, + new__recurrence_id alias for $8; -- default null, + new__object_type alias for $9; -- default ''acs_event'', + new__creation_date alias for $10; -- default now(), + new__creation_user alias for $11; -- default null, + new__creation_ip alias for $12; -- default null, + new__context_id alias for $13; -- default null + v_event_id acs_events.event_id%TYPE; +begin + v_event_id := acs_object__new( + new__event_id, -- object_id + new__object_type, -- object_type + new__creation_date, -- creation_date + new__creation_user, -- creation_user + new__creation_ip, -- creation_ip + new__context_id, -- context_id + ''t'', -- security_inherit_p + new__name, -- title + null -- package_id + ); + + insert into acs_events + (event_id, name, description, html_p, status_summary, activity_id, timespan_id, recurrence_id) + values + (v_event_id, new__name, new__description, new__html_p, new__status_summary, new__activity_id, new__timespan_id, + new__recurrence_id); + + return v_event_id; + +end;' language 'plpgsql'; + + + +drop function acs_activity__new (integer,varchar,text,boolean,text,varchar,timestamptz,integer,varchar,integer); + +create function acs_activity__new ( + -- + -- Create a new activity + -- + -- @author W. Scott Meeks + -- + -- @param activity_id Id to use for new activity + -- @param name Name of the activity + -- @param description Description of the activity + -- @param html_p Is the description HTML? + -- @param status_summary Additional status note (optional) + -- @param object_type 'acs_activity' + -- @param creation_date default now() + -- @param creation_user acs_object param + -- @param creation_ip acs_object param + -- @param context_id acs_object param + -- + -- @return The id of the new activity. + -- + integer, -- in acs_activities.activity_id%TYPE + varchar, -- in acs_activities.name%TYPE, + text, -- in acs_activities.description%TYPE + boolean, -- in acs_activities.html_p%TYPE + text, -- in acs_activities.status_summary%TYPE + varchar, -- in acs_object_types.object_type%TYPE + timestamptz, -- in acs_objects.creation_date%TYPE + integer, -- in acs_objects.creation_user%TYPE + varchar, -- in acs_objects.creation_ip%TYPE + integer -- in acs_objects.context_id%TYPE +) +returns integer as ' -- return acs_activities.activity_id%TYPE +declare + new__activity_id alias for $1; -- default null, + new__name alias for $2; + new__description alias for $3; -- default null, + new__html_p alias for $4; -- default ''f'', + new__status_summary alias for $5; -- default null, + new__object_type alias for $6; -- default ''acs_activity'' + new__creation_date alias for $7; -- default now(), + new__creation_user alias for $8; -- default null, + new__creation_ip alias for $9; -- default null, + new__context_id alias for $10; -- default null + v_activity_id acs_activities.activity_id%TYPE; +begin + v_activity_id := acs_object__new( + new__activity_id, -- object_id + new__object_type, -- object_type + new__creation_date, -- creation_date + new__creation_user, -- creation_user + new__creation_ip, -- creation_ip + new__context_id, -- context_id + ''t'', -- security_inherit_p + new__name, -- title + null -- package_id + ); + + insert into acs_activities + (activity_id, name, description, html_p, status_summary) + values + (v_activity_id, new__name, new__description, new__html_p, new__status_summary); + + return v_activity_id; + +end;' language 'plpgsql'; + + +drop function acs_activity__edit (integer,varchar,text,boolean,text); + +create function acs_activity__edit ( + -- + -- Update the name or description of an activity + -- + -- @author W. Scott Meeks + -- + -- @param activity_id activity to update + -- @param name optional New name for this activity + -- @param description optional New description for this activity + -- @param html_p optional New value of html_p for this activity + -- @param status_summary optional New value of status_summary for this activity + -- + -- @return 0 (procedure dummy) + -- + integer, -- acs_activities.activity_id%TYPE, + varchar, -- acs_activities.name%TYPE default null, + text, -- acs_activities.description%TYPE default null, + boolean, -- acs_activities.html_p%TYPE default null + text -- acs_activities.status_summary%TYPE default null, +) returns integer as ' +declare + edit__activity_id alias for $1; + edit__name alias for $2; -- default null, + edit__description alias for $3; -- default null, + edit__html_p alias for $4; -- default null + edit__status_summary alias for $5; -- default null +begin + + update acs_activities + set name = coalesce(edit__name, name), + description = coalesce(edit__description, description), + html_p = coalesce(edit__html_p, html_p), + status_summary = coalesce(edit__status_summary, status_summary) + where activity_id = edit__activity_id; + + update acs_objects + set title = coalesce(edit__name, name) + where activity_id = edit__activity_id; + + return 0; + +end;' language 'plpgsql'; Index: openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql,v diff -u -N -r1.14 -r1.15 --- openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql 4 Mar 2004 14:52:40 -0000 1.14 +++ openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql 12 Mar 2004 18:48:49 -0000 1.15 @@ -261,9 +261,9 @@ -- LARS: Make object_id 0 be a user, not a person insert into acs_objects - (object_id, object_type) + (object_id, object_type, title) values - (0, 'user'); + (0, 'user', 'Unregistered Visitor'); insert into parties (party_id) @@ -338,7 +338,8 @@ object_id integer; begin object_id := acs_object.new ( - object_id => -3 + object_id => -3, + title => 'Default Context' ); insert into acs_magic_objects Index: openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql,v diff -u -N -r1.16 -r1.17 --- openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql 4 Mar 2004 14:52:40 -0000 1.16 +++ openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql 12 Mar 2004 18:48:49 -0000 1.17 @@ -90,6 +90,26 @@ max_n_values => 1 ); + attr_id := acs_attribute.create_attribute ( + object_type => 'acs_object', + attribute_name => 'package_id', + datatype => 'integer', + pretty_name => 'Package ID', + pretty_plural => 'Package IDs', + min_n_values => 0, + max_n_values => 1 + ); + + attr_id := acs_attribute.create_attribute ( + object_type => 'acs_object', + attribute_name => 'title', + datatype => 'string', + pretty_name => 'Title', + pretty_plural => 'Titles', + min_n_values => 0, + max_n_values => 1 + ); + commit; end; / @@ -111,6 +131,8 @@ object_type not null constraint acs_objects_object_type_fk references acs_object_types (object_type), + title varchar2(1000) default null, + package_id integer default null, context_id constraint acs_objects_context_id_fk references acs_objects(object_id), security_inherit_p char(1) default 't' not null, @@ -134,6 +156,9 @@ create index acs_objects_creation_user_idx on acs_objects (creation_user); create index acs_objects_modify_user_idx on acs_objects (modifying_user); +create index acs_objects_package_object_idx on acs_objects (package_id, object_id); +create index acs_objects_title_idx on acs_objects(title); + -- create bitmap index acs_objects_object_type_idx on acs_objects (object_type); create index acs_objects_object_type_idx on acs_objects (object_type); @@ -178,6 +203,18 @@ Who last modified the object '; +comment on column acs_objects.package_id is ' + Which package instance this object belongs to. + Please note that in mid-term this column will replace all + package_ids of package specific tables. +'; + +comment on column acs_objects.title is ' + Title of the object if applicable. + Please note that in mid-term this column will replace all + titles or object_names of package specific tables. +'; + ----------------------- -- CONTEXT HIERARCHY -- ----------------------- @@ -384,7 +421,9 @@ 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 + context_id in acs_objects.context_id%TYPE default null, + title in acs_objects.title%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE; procedure del ( @@ -401,6 +440,10 @@ object_id in acs_objects.object_id%TYPE ) return varchar2; + function package_id ( + object_id in acs_objects.object_id%TYPE + ) return acs_objects.package_id%TYPE; + -- Determine where the attribute is stored and what sql needs to be -- in the where clause to retreive it -- Used in get_attribute and set_attribute @@ -493,11 +536,15 @@ 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 + context_id in acs_objects.context_id%TYPE default null, + title in acs_objects.title%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE is v_object_id acs_objects.object_id%TYPE; + v_title acs_objects.title%TYPE; + v_object_type_pretty_name acs_object_types.pretty_name%TYPE; begin if object_id is null then select acs_object_id_seq.nextval @@ -507,11 +554,22 @@ v_object_id := object_id; end if; + if title is null then + select pretty_name + into v_object_type_pretty_name + from acs_object_types + where object_type = new.object_type; + + v_title := v_object_type_pretty_name || ' ' || v_object_id; + else + v_title := title; + end if; + insert into acs_objects - (object_id, object_type, context_id, + (object_id, object_type, title, package_id, context_id, creation_date, creation_user, creation_ip) values - (v_object_id, object_type, context_id, + (v_object_id, object_type, v_title, package_id, context_id, creation_date, creation_user, creation_ip); acs_object.initialize_attributes(v_object_id); @@ -570,14 +628,22 @@ ) return varchar2 is - object_name varchar2(500); + object_name acs_objects.title%TYPE; v_object_id integer := object_id; begin -- Find the name function for this object, which is stored in the -- name_method column of acs_object_types. Starting with this -- object's actual type, traverse the type hierarchy upwards until -- a non-null name_method value is found. -- + select title into object_name + from acs_objects + where object_id = name.object_id; + + if (object_name is not null) then + return object_name; + end if; + for object_type in (select name_method from acs_object_types @@ -619,6 +685,23 @@ return object_type_pretty_name || ' ' || object_id; end default_name; + function package_id ( + object_id in acs_objects.object_id%TYPE + ) return acs_objects.package_id%TYPE + is + v_package_id acs_objects.package_id%TYPE; + begin + if object_id is null then + return null; + end if; + + select package_id into v_package_id + from acs_objects + where object_id = package_id.object_id; + + return v_package_id; + end package_id; + procedure get_attribute_storage ( object_id_in in acs_objects.object_id%TYPE, attribute_name_in in acs_attributes.attribute_name%TYPE, Index: openacs-4/packages/acs-kernel/sql/oracle/acs-relationships-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-relationships-create.sql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-kernel/sql/oracle/acs-relationships-create.sql 4 Mar 2004 14:52:40 -0000 1.6 +++ openacs-4/packages/acs-kernel/sql/oracle/acs-relationships-create.sql 12 Mar 2004 18:48:49 -0000 1.7 @@ -434,6 +434,7 @@ v_rel_id := acs_object.new ( object_id => rel_id, object_type => rel_type, + title => rel_type || ': ' || object_id_one || ' - ' || object_id_two, context_id => context_id, creation_user => creation_user, creation_ip => creation_ip Index: openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql,v diff -u -N -r1.26 -r1.27 --- openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql 4 Mar 2004 14:52:40 -0000 1.26 +++ openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql 12 Mar 2004 18:48:49 -0000 1.27 @@ -162,6 +162,9 @@ default_locale varchar2(30) ); +alter table acs_objects add constraint acs_objects_package_id_fk +foreign key (package_id) references apm_packages(package_id); + -- create bitmap index apm_packages_package_key_idx on apm_packages (package_key); create index apm_packages_package_key_idx on apm_packages (package_key); @@ -1496,7 +1499,8 @@ -- Create the new parameter. v_parameter_id := acs_object.new( object_id => parameter_id, - object_type => 'apm_parameter' + object_type => 'apm_parameter', + title => register_parameter.package_key || ': Parameter ' || register_parameter.parameter_name ); insert into apm_parameters @@ -1547,6 +1551,13 @@ min_n_values = nvl(update_parameter.min_n_values, min_n_values), max_n_values = nvl(update_parameter.max_n_values, max_n_values) where parameter_id = update_parameter.parameter_id; + + update acs_objects + set title = (select package_key || ': Parameter ' || parameter_name + from apm_parameters + where parameter_id = update_parameter.parameter_id) + where object_id = update_parameter.parameter_id; + return parameter_id; end; @@ -1745,12 +1756,18 @@ creation_ip => creation_ip, context_id => context_id ); + if instance_name is null then v_instance_name := package_key || ' ' || v_package_id; else v_instance_name := instance_name; end if; + update acs_objects + set title = v_instance_name, + package_id = v_package_id + where object_id = v_package_id; + select package_type into v_package_type from apm_package_types where package_key = apm_package.new.package_key; @@ -1951,7 +1968,8 @@ end if; v_version_id := acs_object.new( object_id => v_version_id, - object_type => 'apm_package_version' + object_type => 'apm_package_version', + title => package_key || ', Version ' || version_name ); insert into apm_package_versions (version_id, package_key, version_name, version_uri, summary, description_format, description, @@ -2023,6 +2041,12 @@ release_date, vendor, vendor_uri, auto_mount from apm_package_versions where version_id = copy.version_id; + + update acs_objects + set title = (select v.package_key || ', Version ' || v.version_name + from apm_package_versions v + where v.version_id = copy.version_id) + where object_id = copy.version_id; insert into apm_package_dependencies(dependency_id, version_id, dependency_type, service_uri, service_version) select acs_object_id_seq.nextval, v_version_id, dependency_type, service_uri, service_version @@ -2080,7 +2104,7 @@ else v_version_id := edit.version_id; end if; - + update apm_package_versions set version_uri = edit.version_uri, summary = edit.summary, Index: openacs-4/packages/acs-kernel/sql/oracle/authentication-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/authentication-package-create.sql,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/acs-kernel/sql/oracle/authentication-package-create.sql 4 Mar 2004 14:52:40 -0000 1.7 +++ openacs-4/packages/acs-kernel/sql/oracle/authentication-package-create.sql 12 Mar 2004 18:48:49 -0000 1.8 @@ -69,6 +69,7 @@ v_authority_id := acs_object.new( object_id => new.authority_id, object_type => new.object_type, + title => new.short_name, creation_date => sysdate(), creation_user => new.creation_user, creation_ip => new.creation_ip, Index: openacs-4/packages/acs-kernel/sql/oracle/community-core-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/community-core-create.sql,v diff -u -N -r1.12 -r1.13 --- openacs-4/packages/acs-kernel/sql/oracle/community-core-create.sql 4 Mar 2004 14:52:40 -0000 1.12 +++ openacs-4/packages/acs-kernel/sql/oracle/community-core-create.sql 12 Mar 2004 18:48:49 -0000 1.13 @@ -299,8 +299,14 @@ v_party_id parties.party_id%TYPE; begin v_party_id := - acs_object.new(party_id, object_type, - creation_date, creation_user, creation_ip, context_id); + acs_object.new( + object_id => party_id, + object_type => object_type, + title => lower(email), + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id); insert into parties (party_id, email, url) @@ -444,6 +450,10 @@ values (v_person_id, first_names, last_name); + update acs_objects + set title = first_names || ' ' || last_name + where object_id = v_person_id; + return v_person_id; end new; Index: openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql,v diff -u -N -r1.12 -r1.13 --- openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql 4 Mar 2004 14:52:40 -0000 1.12 +++ openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql 12 Mar 2004 18:48:49 -0000 1.13 @@ -777,7 +777,11 @@ values (v_group_id, group_name, v_join_policy); + update acs_objects + set title = group_name + where object_id = v_group_id; + -- setup the permissible relationship types for this group insert into group_rels (group_rel_id, group_id, rel_type) Index: openacs-4/packages/acs-kernel/sql/oracle/journal-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/journal-create.sql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/acs-kernel/sql/oracle/journal-create.sql 4 Mar 2004 14:52:40 -0000 1.4 +++ openacs-4/packages/acs-kernel/sql/oracle/journal-create.sql 12 Mar 2004 18:48:49 -0000 1.5 @@ -93,6 +93,7 @@ v_journal_id := acs_object.new ( object_id => journal_id, object_type => 'journal_entry', + title => action, creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, Index: openacs-4/packages/acs-kernel/sql/oracle/rel-constraints-body-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/rel-constraints-body-create.sql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/acs-kernel/sql/oracle/rel-constraints-body-create.sql 4 Mar 2004 14:52:40 -0000 1.4 +++ openacs-4/packages/acs-kernel/sql/oracle/rel-constraints-body-create.sql 12 Mar 2004 18:48:49 -0000 1.5 @@ -33,6 +33,7 @@ v_constraint_id := acs_object.new ( object_id => constraint_id, object_type => constraint_type, + title => constraint_name, context_id => context_id, creation_user => creation_user, creation_ip => creation_ip Index: openacs-4/packages/acs-kernel/sql/oracle/rel-segments-body-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/rel-segments-body-create.sql,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/acs-kernel/sql/oracle/rel-segments-body-create.sql 4 Mar 2004 14:52:40 -0000 1.7 +++ openacs-4/packages/acs-kernel/sql/oracle/rel-segments-body-create.sql 12 Mar 2004 18:48:49 -0000 1.8 @@ -39,6 +39,10 @@ party.new(segment_id, object_type, creation_date, creation_user, creation_ip, email, url, context_id); + update acs_objects + set title = segment_name + where object_id = v_segment_id; + insert into rel_segments (segment_id, segment_name, group_id, rel_type) values Index: openacs-4/packages/acs-kernel/sql/oracle/site-nodes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/site-nodes-create.sql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/acs-kernel/sql/oracle/site-nodes-create.sql 4 Mar 2004 14:52:40 -0000 1.5 +++ openacs-4/packages/acs-kernel/sql/oracle/site-nodes-create.sql 12 Mar 2004 18:48:49 -0000 1.6 @@ -126,6 +126,8 @@ v_node_id := acs_object.new ( object_id => node_id, object_type => 'site_node', + title => name, + package_id => object_id, creation_user => creation_user, creation_ip => creation_ip ); Index: openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/upgrade/Attic/upgrade-5.1.0d1-5.1.0d2.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql 12 Mar 2004 18:48:49 -0000 1.3 @@ -0,0 +1,2643 @@ +declare + attr_id acs_attributes.attribute_id%TYPE; +begin + attr_id := acs_attribute.create_attribute ( + object_type => 'acs_object', + attribute_name => 'package_id', + datatype => 'integer', + pretty_name => 'Package ID', + pretty_plural => 'Package IDs', + min_n_values => 0, + max_n_values => 1 + ); + + attr_id := acs_attribute.create_attribute ( + object_type => 'acs_object', + attribute_name => 'title', + datatype => 'string', + pretty_name => 'Title', + pretty_plural => 'Titles', + min_n_values => 0, + max_n_values => 1 + ); + + commit; +end; +/ +show errors + +alter table acs_objects add ( + title varchar2(1000) default null, + package_id integer default null + constraint acs_objects_package_id_fk + references apm_packages(package_id) +); + +create index acs_objects_package_object_idx on acs_objects (package_id, object_id); +create index acs_objects_title_idx on acs_objects(title); + +comment on column acs_objects.package_id is ' + Which package instance this object belongs to. + Please note that in mid-term this column will replace all + package_ids of package specific tables. +'; + +comment on column acs_objects.title is ' + Title of the object if applicable. + Please note that in mid-term this column will replace all + titles or object_names of package specific tables. +'; + +--------- +-- update data +--------- + +update acs_objects +set title = (select group_name + from groups + where group_id = object_id) +where object_id in (select group_id from groups); + +update acs_objects +set title = (select email + from parties + where party_id = object_id) +where object_type = 'party'; + +update acs_objects +set title = (select first_names || ' ' || last_name + from persons + where person_id = object_id) +where object_type in ('user','person'); + +update acs_objects +set title = (select short_name + from auth_authorities + where authority_id = object_id) +where object_type = 'authority'; + +update acs_objects +set title = (select action + from journal_entries + where journal_id = object_id) +where object_type = 'journal_entry'; + +update acs_objects +set title = (select name + from site_nodes + where node_id = acs_objects.object_id), + package_id = (select object_id + from site_nodes + where node_id = acs_objects.object_id) +where object_type = 'site_node'; + +update acs_objects +set title = (select instance_name + from apm_packages + where package_id = object_id), + package_id = object_id +where object_type in ('apm_package','apm_application','apm_service'); + +update acs_objects +set title = (select package_key || ', Version ' || version_name + from apm_package_versions + where version_id = object_id) +where object_type = 'apm_package_version'; + +update acs_objects +set title = (select package_key || ': Parameter ' || parameter_name + from apm_parameters + where parameter_id = object_id) +where object_type = 'apm_parameter'; + +update acs_objects +set title = (select rel_type || ': ' || object_id_one || ' - ' || object_id_two + from acs_rels + where rel_id = object_id) +where object_id in (select rel_id from acs_rels); + +update acs_objects +set title = (select segment_name + from rel_segments + where segment_id = object_id) +where object_type = 'rel_segment'; + +update acs_objects +set title = (select constraint_name + from rel_constraints + where constraint_id = object_id) +where object_type = 'rel_constraint'; + +update acs_objects +set title = 'Unregistered Visitor' +where object_id = 0; + +update acs_objects +set title = 'Default Context' +where object_id = -3; + +update acs_objects +set title = 'Root Security Context' +where object_id = -4; + +------------------------ +-- ACS_OBJECT PACKAGE -- +------------------------ + +create or replace package acs_object +as + + function new ( + object_id in acs_objects.object_id%TYPE default null, + object_type in acs_objects.object_type%TYPE + default 'acs_object', + 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, + title in acs_objects.title%TYPE default null, + package_id in acs_objects.package_id%TYPE default null + ) return acs_objects.object_id%TYPE; + + procedure del ( + object_id in acs_objects.object_id%TYPE + ); + + function name ( + object_id in acs_objects.object_id%TYPE + ) return varchar2; + + -- The acs_object_types.name_method for "acs_object" + -- + function default_name ( + object_id in acs_objects.object_id%TYPE + ) return varchar2; + + function package_id ( + object_id in acs_objects.object_id%TYPE + ) return acs_objects.package_id%TYPE; + + -- Determine where the attribute is stored and what sql needs to be + -- in the where clause to retreive it + -- Used in get_attribute and set_attribute + procedure get_attribute_storage ( + object_id_in in acs_objects.object_id%TYPE, + attribute_name_in in acs_attributes.attribute_name%TYPE, + v_column out varchar2, + v_table_name out varchar2, + v_key_sql out varchar2 + ); + + -- Get/set the value of an object attribute, as long as + -- the type can be cast to varchar2 + function get_attribute ( + object_id_in in acs_objects.object_id%TYPE, + attribute_name_in in acs_attributes.attribute_name%TYPE + ) return varchar2; + + procedure set_attribute ( + object_id_in in acs_objects.object_id%TYPE, + attribute_name_in in acs_attributes.attribute_name%TYPE, + value_in in varchar2 + ); + + function check_representation ( + object_id in acs_objects.object_id%TYPE + ) return char; + + procedure update_last_modified ( + object_id in acs_objects.object_id%TYPE, + modifying_user in acs_objects.modifying_user%TYPE, + modifying_ip in acs_objects.modifying_ip%TYPE, + last_modified in acs_objects.last_modified%TYPE default sysdate + ); + +end acs_object; +/ +show errors + +create or replace package body acs_object +as + + procedure initialize_attributes ( + object_id in acs_objects.object_id%TYPE + ) + is + v_object_type acs_objects.object_type%TYPE; + begin + -- XXX This should be fixed to initialize supertypes properly. + + -- Initialize dynamic attributes + insert into acs_attribute_values + (object_id, attribute_id, attr_value) + select + initialize_attributes.object_id, a.attribute_id, a.default_value + from acs_attributes a, acs_objects o + where a.object_type = o.object_type + and o.object_id = initialize_attributes.object_id + and a.storage = 'generic' + and a.static_p = 'f'; + + -- Retreive type for static attributes + select object_type into v_object_type from acs_objects + where object_id = initialize_attributes.object_id; + + -- Initialize static attributes + begin + insert into acs_static_attr_values + (object_type, attribute_id, attr_value) + select + v_object_type, a.attribute_id, a.default_value + from acs_attributes a, acs_objects o + where a.object_type = o.object_type + and o.object_id = initialize_attributes.object_id + and a.storage = 'generic' + and a.static_p = 't' + and not exists (select 1 from acs_static_attr_values + where object_type = a.object_type); + exception when no_data_found then null; + end; + + end initialize_attributes; + + function new ( + object_id in acs_objects.object_id%TYPE default null, + object_type in acs_objects.object_type%TYPE + default 'acs_object', + 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, + title in acs_objects.title%TYPE default null, + package_id in acs_objects.package_id%TYPE default null + ) + return acs_objects.object_id%TYPE + is + v_object_id acs_objects.object_id%TYPE; + v_title acs_objects.title%TYPE; + v_object_type_pretty_name acs_object_types.pretty_name%TYPE; + begin + if object_id is null then + select acs_object_id_seq.nextval + into v_object_id + from dual; + else + v_object_id := object_id; + end if; + + if title is null then + select pretty_name + into v_object_type_pretty_name + from acs_object_types + where object_type = new.object_type; + + v_title := v_object_type_pretty_name || ' ' || v_object_id; + else + v_title := title; + end if; + + insert into acs_objects + (object_id, object_type, title, package_id, context_id, + creation_date, creation_user, creation_ip) + values + (v_object_id, object_type, v_title, package_id, context_id, + creation_date, creation_user, creation_ip); + + acs_object.initialize_attributes(v_object_id); + + return v_object_id; + end new; + + procedure del ( + object_id in acs_objects.object_id%TYPE + ) + is + v_exists_p char; + begin + + -- Delete dynamic/generic attributes + delete from acs_attribute_values where object_id = acs_object.del.object_id; + + -- Delete directly assigned permissions + -- + -- JCD: We do this as an execute rather than just a direct query since + -- the acs_permissions table is not created when this file is + -- sourced. We need to clean up the creates and once that is done + -- we can turn this into a simple delete statement. + -- + execute immediate 'delete from acs_permissions where object_id = :object_id' + using in object_id; + + execute immediate 'delete from acs_permissions where grantee_id = :object_id' + using in object_id; + + for object_type + in (select table_name, id_column + from acs_object_types + start with object_type = (select object_type + from acs_objects o + where o.object_id = acs_object.del.object_id) + connect by object_type = prior supertype) + loop + -- Delete from the table if it exists. + select decode(count(*),0,'f','t') into v_exists_p + from user_tables + where table_name = upper(object_type.table_name); + + if v_exists_p = 't' then + execute immediate 'delete from ' || object_type.table_name || + ' where ' || object_type.id_column || ' = :object_id' + using in object_id; + end if; + + end loop; + + end del; + + function name ( + object_id in acs_objects.object_id%TYPE + ) + return varchar2 + is + object_name acs_objects.title%TYPE; + v_object_id integer := object_id; + begin + -- Find the name function for this object, which is stored in the + -- name_method column of acs_object_types. Starting with this + -- object's actual type, traverse the type hierarchy upwards until + -- a non-null name_method value is found. + -- + select title into object_name + from acs_objects + where object_id = name.object_id; + + if (object_name is not null) then + return object_name; + end if; + + for object_type + in (select name_method + from acs_object_types + start with object_type = (select object_type + from acs_objects o + where o.object_id = name.object_id) + connect by object_type = prior supertype) + loop + if object_type.name_method is not null then + + -- Execute the first name_method we find (since we're traversing + -- up the type hierarchy from the object's exact type) using + -- Native Dynamic SQL, to ascertain the name of this object. + -- + --execute immediate 'select ' || object_type.name_method || '(:1) from dual' + execute immediate 'begin :1 := ' || object_type.name_method || '(:2); end;' + using out object_name, in object_id; + --into object_name + + exit; + end if; + end loop; + + return object_name; + end name; + + function default_name ( + object_id in acs_objects.object_id%TYPE + ) return varchar2 + is + object_type_pretty_name acs_object_types.pretty_name%TYPE; + begin + select ot.pretty_name + into object_type_pretty_name + from acs_objects o, acs_object_types ot + where o.object_id = default_name.object_id + and o.object_type = ot.object_type; + + return object_type_pretty_name || ' ' || object_id; + end default_name; + + function package_id ( + object_id in acs_objects.object_id%TYPE + ) return acs_objects.package_id%TYPE + is + v_package_id acs_objects.package_id%TYPE; + begin + if object_id is null then + return null; + end if; + + select package_id into v_package_id + from acs_objects + where object_id = package_id.object_id; + + return v_package_id; + end package_id; + + procedure get_attribute_storage ( + object_id_in in acs_objects.object_id%TYPE, + attribute_name_in in acs_attributes.attribute_name%TYPE, + v_column out varchar2, + v_table_name out varchar2, + v_key_sql out varchar2 + ) + is + v_object_type acs_attributes.object_type%TYPE; + v_static acs_attributes.static_p%TYPE := null; + v_attr_id acs_attributes.attribute_id%TYPE := null; + v_storage acs_attributes.storage%TYPE := null; + v_attr_name acs_attributes.attribute_name%TYPE := null; + v_id_column varchar2(200) := null; + v_sql varchar2(4000) := null; + v_return varchar2(4000) := null; + + -- Fetch the most inherited attribute + cursor c_attribute is + select + a.attribute_id, a.static_p, a.storage, a.table_name, a.attribute_name, + a.object_type, a.column_name, t.id_column + from + acs_attributes a, + (select + object_type, id_column + from + acs_object_types + connect by + object_type = prior supertype + start with + object_type = (select object_type from acs_objects + where object_id = object_id_in) + ) t + where + a.attribute_name = attribute_name_in + and + a.object_type = t.object_type; + + begin + + -- Determine the attribute parameters + open c_attribute; + fetch c_attribute into + v_attr_id, v_static, v_storage, v_table_name, v_attr_name, + v_object_type, v_column, v_id_column; + if c_attribute%NOTFOUND then + close c_attribute; + raise_application_error (-20000, + 'No such attribute ' || v_object_type || '::' || attribute_name_in || + ' in acs_object.get_attribute_storage.'); + end if; + close c_attribute; + + -- This should really be done in a trigger on acs_attributes, + -- instead of generating it each time in this function + + -- If there is no specific table name for this attribute, + -- figure it out based on the object type + if v_table_name is null then + + -- Determine the appropriate table name + if v_storage = 'generic' then + -- Generic attribute: table name/column are hardcoded + + v_column := 'attr_value'; + + if v_static = 'f' then + v_table_name := 'acs_attribute_values'; + v_key_sql := '(object_id = ' || object_id_in || ' and ' || + 'attribute_id = ' || v_attr_id || ')'; + else + v_table_name := 'acs_static_attr_values'; + v_key_sql := '(object_type = ''' || v_object_type || ''' and ' || + 'attribute_id = ' || v_attr_id || ')'; + end if; + + else + -- Specific attribute: table name/column need to be retreived + + if v_static = 'f' then + select + table_name, id_column + into + v_table_name, v_id_column + from + acs_object_types + where + object_type = v_object_type; + else + raise_application_error(-20000, + 'No table name specified for storage specific static attribute ' || + v_object_type || '::' || attribute_name_in || + ' in acs_object.get_attribute_storage.'); + end if; + + end if; + else + -- There is a custom table name for this attribute. + -- Get the id column out of the acs_object_tables + -- Raise an error if not found + select id_column into v_id_column from acs_object_type_tables + where object_type = v_object_type + and table_name = v_table_name; + + end if; + + if v_column is null then + + if v_storage = 'generic' then + v_column := 'attr_value'; + else + v_column := v_attr_name; + end if; + + end if; + + if v_key_sql is null then + if v_static = 'f' then + v_key_sql := v_id_column || ' = ' || object_id_in ; + else + v_key_sql := v_id_column || ' = ''' || v_object_type || ''''; + end if; + end if; + + exception when no_data_found then + if c_attribute%ISOPEN then + close c_attribute; + end if; + raise_application_error(-20000, 'No data found for attribute ' || + v_object_type || '::' || attribute_name_in || + ' in acs_object.get_attribute_storage'); + + end get_attribute_storage; + + -- Get/set the value of an object attribute, as long as + -- the type can be cast to varchar2 + function get_attribute ( + object_id_in in acs_objects.object_id%TYPE, + attribute_name_in in acs_attributes.attribute_name%TYPE + ) return varchar2 + is + v_table_name varchar2(200); + v_column varchar2(200); + v_key_sql varchar2(4000); + v_return varchar2(4000); + begin + + get_attribute_storage(object_id_in, attribute_name_in, + v_column, v_table_name, v_key_sql); + + begin + execute immediate 'select ' + || v_column || ' from ' || v_table_name || ' where ' || v_key_sql + into + v_return; + exception when no_data_found then + return null; + end; + + return v_return; + end get_attribute; + + procedure set_attribute ( + object_id_in in acs_objects.object_id%TYPE, + attribute_name_in in acs_attributes.attribute_name%TYPE, + value_in in varchar2 + ) + is + v_table_name varchar2(200); + v_column varchar2(200); + v_key_sql varchar2(4000); + v_return varchar2(4000); + v_dummy integer; + begin + + get_attribute_storage(object_id_in, attribute_name_in, + v_column, v_table_name, v_key_sql); + + execute immediate 'update ' + || v_table_name || ' set ' || v_column || ' = :value where ' || v_key_sql + using value_in; + + end set_attribute; + + function check_context_index ( + object_id in acs_objects.object_id%TYPE, + ancestor_id in acs_objects.object_id%TYPE, + n_generations in integer + ) return char + is + n_rows integer; + n_gens integer; + begin + -- Verify that this row exists in the index. + select decode(count(*),0,0,1) into n_rows + from acs_object_context_index + where object_id = check_context_index.object_id + and ancestor_id = check_context_index.ancestor_id; + + if n_rows = 1 then + -- Verify that the count is correct. + select n_generations into n_gens + from acs_object_context_index + where object_id = check_context_index.object_id + and ancestor_id = check_context_index.ancestor_id; + + if n_gens != n_generations then + acs_log.error('acs_object.check_representation', 'Ancestor ' || + ancestor_id || ' of object ' || object_id || + ' reports being generation ' || n_gens || + ' when it is actually generation ' || n_generations || + '.'); + return 'f'; + else + return 't'; + end if; + else + acs_log.error('acs_object.check_representation', 'Ancestor ' || + ancestor_id || ' of object ' || object_id || + ' is missing an entry in acs_object_context_index.'); + return 'f'; + end if; + end; + + function check_object_ancestors ( + object_id in acs_objects.object_id%TYPE, + ancestor_id in acs_objects.object_id%TYPE, + n_generations in integer + ) return char + is + context_id acs_objects.context_id%TYPE; + security_inherit_p acs_objects.security_inherit_p%TYPE; + n_rows integer; + n_gens integer; + result char(1); + begin + -- OBJECT_ID is the object we are verifying + -- ANCESTOR_ID is the current ancestor we are tracking + -- N_GENERATIONS is how far ancestor_id is from object_id + + -- Note that this function is only supposed to verify that the + -- index contains each ancestor for OBJECT_ID. It doesn''t + -- guarantee that there aren''t extraneous rows or that + -- OBJECT_ID''s children are contained in the index. That is + -- verified by seperate functions. + + result := 't'; + + -- Grab the context and security_inherit_p flag of the current + -- ancestor''s parent. + select context_id, security_inherit_p into context_id, security_inherit_p + from acs_objects + where object_id = check_object_ancestors.ancestor_id; + + if ancestor_id = 0 then + if context_id is null then + result := 't'; + else + -- This can be a constraint, can''t it? + acs_log.error('acs_object.check_representation', + 'Object 0 doesn''t have a null context_id'); + result := 'f'; + end if; + else + if context_id is null or security_inherit_p = 'f' then + context_id := 0; + end if; + + if check_context_index(object_id, ancestor_id, n_generations) = 'f' then + result := 'f'; + end if; + + if check_object_ancestors(object_id, context_id, + n_generations + 1) = 'f' then + result := 'f'; + end if; + end if; + + return result; + end; + + function check_object_descendants ( + object_id in acs_objects.object_id%TYPE, + descendant_id in acs_objects.object_id%TYPE, + n_generations in integer + ) return char + is + result char(1); + begin + -- OBJECT_ID is the object we are verifying. + -- DESCENDANT_ID is the current descendant we are tracking. + -- N_GENERATIONS is how far the current DESCENDANT_ID is from + -- OBJECT_ID. + + -- This function will verfy that each actualy descendant of + -- OBJECT_ID has a row in the index table. It does not check that + -- there aren't extraneous rows or that the ancestors of OBJECT_ID + -- are maintained correctly. + + result := 't'; + + -- First verify that OBJECT_ID and DESCENDANT_ID are actually in + -- the index. + if check_context_index(descendant_id, object_id, n_generations) = 'f' then + result := 'f'; + end if; + + -- For every child that reports inheriting from OBJECT_ID we need to call + -- ourselves recursively. + for obj in (select * + from acs_objects + where context_id = descendant_id + and security_inherit_p = 't') loop + if check_object_descendants(object_id, obj.object_id, + n_generations + 1) = 'f' then + result := 'f'; + end if; + end loop; + + return result; + end; + + function check_path ( + object_id in acs_objects.object_id%TYPE, + ancestor_id in acs_objects.object_id%TYPE + ) return char + is + context_id acs_objects.context_id%TYPE; + security_inherit_p acs_objects.security_inherit_p%TYPE; + begin + if object_id = ancestor_id then + return 't'; + end if; + + select context_id, security_inherit_p into context_id, security_inherit_p + from acs_objects + where object_id = check_path.object_id; + + if context_id is null or security_inherit_p = 'f' then + context_id := 0; + end if; + + return check_path(context_id, ancestor_id); + end; + + function check_representation ( + object_id in acs_objects.object_id%TYPE + ) return char + is + result char(1); + object_type acs_objects.object_type%TYPE; + n_rows integer; + begin + result := 't'; + acs_log.notice('acs_object.check_representation', + 'Running acs_object.check_representation on object_id = ' || + object_id || '.'); + + -- If this fails then there isn''t even an object associated with + -- this id. I'm going to let that error propogate as an exception. + select object_type into object_type + from acs_objects + where object_id = check_representation.object_id; + + acs_log.notice('acs_object.check_representation', + 'OBJECT STORAGE INTEGRITY TEST'); + + -- Let's look through every primary storage table associated with + -- this object type and all of its supertypes and make sure there + -- is a row with OBJECT_ID as theh primary key. + for t in (select t.object_type, t.table_name, t.id_column + from acs_object_type_supertype_map m, acs_object_types t + where m.ancestor_type = t.object_type + and m.object_type = check_representation.object_type + union + select object_type, table_name, id_column + from acs_object_types + where object_type = check_representation.object_type) loop + execute immediate 'select decode(count(*),0,0,1) from ' || t.table_name || + ' where ' || t.id_column || ' = ' || object_id + into n_rows; + + if n_rows = 0 then + result := 'f'; + acs_log.error('acs_object.check_representation', + 'Table ' || t.table_name || ' (primary storage for ' || + t.object_type || ') doesn''t have a row for object ' || + object_id || ' of type ' || object_type || '.'); + end if; + end loop; + + acs_log.notice('acs_object.check_representation', + 'OBJECT CONTEXT INTEGRITY TEST'); + + -- Do a bunch of dirt simple sanity checks. + + -- First let's check that all of our ancestors appear in + -- acs_object_context_index with the correct generation listed. + if check_object_ancestors(object_id, object_id, 0) = 'f' then + result := 'f'; + end if; + + -- Now let's check that all of our descendants appear in + -- acs_object_context_index with the correct generation listed. + if check_object_descendants(object_id, object_id, 0) = 'f' then + result := 'f'; + end if; + + -- Ok, we know that the index contains every entry that it is + -- supposed to have. Now let's make sure it doesn't contain any + -- extraneous entries. + for row in (select * + from acs_object_context_index + where object_id = check_representation.object_id + or ancestor_id = check_representation.object_id) loop + if check_path(row.object_id, row.ancestor_id) = 'f' then + acs_log.error('acs_object.check_representation', + 'acs_object_context_index contains an extraneous row: ' || + 'object_id = ' || row.object_id || ', ancestor_id = ' || + row.ancestor_id || ', n_generations = ' || + row.n_generations || '.'); + result := 'f'; + end if; + end loop; + + acs_log.notice('acs_object.check_representation', + 'Done running acs_object.check_representation ' || + 'on object_id = ' || object_id || '.'); + return result; + end check_representation; + + procedure update_last_modified ( + object_id in acs_objects.object_id%TYPE, + modifying_user in acs_objects.modifying_user%TYPE, + modifying_ip in acs_objects.modifying_ip%TYPE, + last_modified in acs_objects.last_modified%TYPE default sysdate + ) + is + v_parent_id acs_objects.context_id%TYPE; + begin + update acs_objects + set acs_objects.last_modified = acs_object.update_last_modified.last_modified, acs_objects.modifying_user = acs_object.update_last_modified.modifying_user, acs_objects.modifying_ip = acs_object.update_last_modified.modifying_ip + where acs_objects.object_id in (select ao.object_id + from acs_objects ao + connect by prior ao.context_id = ao.object_id + start with ao.object_id = acs_object.update_last_modified.object_id) + and acs_objects.context_id is not null + and acs_objects.object_id != 0; + end update_last_modified; + +end acs_object; +/ +show errors + +------- +-- Acs_Rels +------- + +create or replace package body acs_rel +as + + function new ( + rel_id in acs_rels.rel_id%TYPE default null, + rel_type in acs_rels.rel_type%TYPE default 'relationship', + object_id_one in acs_rels.object_id_one%TYPE, + object_id_two in acs_rels.object_id_two%TYPE, + context_id in acs_objects.context_id%TYPE default null, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null + ) return acs_rels.rel_id%TYPE + is + v_rel_id acs_rels.rel_id%TYPE; + begin + -- XXX This should check that object_id_one and object_id_two are + -- of the appropriate types. + v_rel_id := acs_object.new ( + object_id => rel_id, + object_type => rel_type, + title => rel_type || ': ' || object_id_one || ' - ' || object_id_two, + context_id => context_id, + creation_user => creation_user, + creation_ip => creation_ip + ); + + insert into acs_rels + (rel_id, rel_type, object_id_one, object_id_two) + values + (v_rel_id, new.rel_type, new.object_id_one, new.object_id_two); + + return v_rel_id; + end; + + procedure del ( + rel_id in acs_rels.rel_id%TYPE + ) + is + begin + acs_object.del(rel_id); + end; + +end; +/ +show errors + +--------- +-- APM +--------- + +create or replace package body apm +as + procedure register_package ( + package_key in apm_package_types.package_key%TYPE, + pretty_name in apm_package_types.pretty_name%TYPE, + pretty_plural in apm_package_types.pretty_plural%TYPE, + package_uri in apm_package_types.package_uri%TYPE, + package_type in apm_package_types.package_type%TYPE, + initial_install_p in apm_package_types.initial_install_p%TYPE + default 'f', + singleton_p in apm_package_types.singleton_p%TYPE + default 'f', + spec_file_path in apm_package_types.spec_file_path%TYPE + default null, + spec_file_mtime in apm_package_types.spec_file_mtime%TYPE + default null + ) + is + begin + apm_package_type.create_type( + package_key => register_package.package_key, + pretty_name => register_package.pretty_name, + pretty_plural => register_package.pretty_plural, + package_uri => register_package.package_uri, + package_type => register_package.package_type, + initial_install_p => register_package.initial_install_p, + singleton_p => register_package.singleton_p, + spec_file_path => register_package.spec_file_path, + spec_file_mtime => spec_file_mtime + ); + end register_package; + + function update_package ( + package_key in apm_package_types.package_key%TYPE, + pretty_name in apm_package_types.pretty_name%TYPE + default null, + pretty_plural in apm_package_types.pretty_plural%TYPE + default null, + package_uri in apm_package_types.package_uri%TYPE + default null, + package_type in apm_package_types.package_type%TYPE + default null, + initial_install_p in apm_package_types.initial_install_p%TYPE + default null, + singleton_p in apm_package_types.singleton_p%TYPE + default null, + spec_file_path in apm_package_types.spec_file_path%TYPE + default null, + spec_file_mtime in apm_package_types.spec_file_mtime%TYPE + default null + ) return apm_package_types.package_type%TYPE + is + begin + + return apm_package_type.update_type( + package_key => update_package.package_key, + pretty_name => update_package.pretty_name, + pretty_plural => update_package.pretty_plural, + package_uri => update_package.package_uri, + package_type => update_package.package_type, + initial_install_p => update_package.initial_install_p, + singleton_p => update_package.singleton_p, + spec_file_path => update_package.spec_file_path, + spec_file_mtime => update_package.spec_file_mtime + ); + + end update_package; + + + procedure unregister_package ( + package_key in apm_package_types.package_key%TYPE, + cascade_p in char default 't' + ) + is + begin + apm_package_type.drop_type( + package_key => unregister_package.package_key, + cascade_p => unregister_package.cascade_p + ); + end unregister_package; + + function register_p ( + package_key in apm_package_types.package_key%TYPE + ) return integer + is + v_register_p integer; + begin + select decode(count(*),0,0,1) into v_register_p from apm_package_types + where package_key = register_p.package_key; + return v_register_p; + end register_p; + + procedure register_application ( + package_key in apm_package_types.package_key%TYPE, + pretty_name in apm_package_types.pretty_name%TYPE, + pretty_plural in apm_package_types.pretty_plural%TYPE, + package_uri in apm_package_types.package_uri%TYPE, + initial_install_p in apm_package_types.initial_install_p%TYPE + default 'f', + singleton_p in apm_package_types.singleton_p%TYPE + default 'f', + spec_file_path in apm_package_types.spec_file_path%TYPE + default null, + spec_file_mtime in apm_package_types.spec_file_mtime%TYPE + default null + ) + is + begin + apm.register_package( + package_key => register_application.package_key, + pretty_name => register_application.pretty_name, + pretty_plural => register_application.pretty_plural, + package_uri => register_application.package_uri, + package_type => 'apm_application', + initial_install_p => register_application.initial_install_p, + singleton_p => register_application.singleton_p, + spec_file_path => register_application.spec_file_path, + spec_file_mtime => register_application.spec_file_mtime + ); + end register_application; + + procedure unregister_application ( + package_key in apm_package_types.package_key%TYPE, + cascade_p in char default 'f' + ) + is + begin + apm.unregister_package ( + package_key => unregister_application.package_key, + cascade_p => unregister_application.cascade_p + ); + end unregister_application; + + procedure register_service ( + package_key in apm_package_types.package_key%TYPE, + pretty_name in apm_package_types.pretty_name%TYPE, + pretty_plural in apm_package_types.pretty_plural%TYPE, + package_uri in apm_package_types.package_uri%TYPE, + initial_install_p in apm_package_types.initial_install_p%TYPE + default 'f', + singleton_p in apm_package_types.singleton_p%TYPE + default 'f', + spec_file_path in apm_package_types.spec_file_path%TYPE + default null, + spec_file_mtime in apm_package_types.spec_file_mtime%TYPE + default null + ) + is + begin + apm.register_package( + package_key => register_service.package_key, + pretty_name => register_service.pretty_name, + pretty_plural => register_service.pretty_plural, + package_uri => register_service.package_uri, + package_type => 'apm_service', + initial_install_p => register_service.initial_install_p, + singleton_p => register_service.singleton_p, + spec_file_path => register_service.spec_file_path, + spec_file_mtime => register_service.spec_file_mtime + ); + end register_service; + + procedure unregister_service ( + package_key in apm_package_types.package_key%TYPE, + cascade_p in char default 'f' + ) + is + begin + apm.unregister_package ( + package_key => unregister_service.package_key, + cascade_p => unregister_service.cascade_p + ); + end unregister_service; + + -- Indicate to APM that a parameter is available to the system. + function register_parameter ( + parameter_id in apm_parameters.parameter_id%TYPE + default null, + package_key in apm_parameters.package_key%TYPE, + parameter_name in apm_parameters.parameter_name%TYPE, + description in apm_parameters.description%TYPE + default null, + datatype in apm_parameters.datatype%TYPE + default 'string', + default_value in apm_parameters.default_value%TYPE + default null, + section_name in apm_parameters.section_name%TYPE + default null, + min_n_values in apm_parameters.min_n_values%TYPE + default 1, + max_n_values in apm_parameters.max_n_values%TYPE + default 1 + ) return apm_parameters.parameter_id%TYPE + is + v_parameter_id apm_parameters.parameter_id%TYPE; + cursor all_parameters is + select ap.package_id, p.parameter_id, p.default_value + from apm_parameters p, apm_parameter_values v, apm_packages ap + where p.package_key = ap.package_key + and p.parameter_id = v.parameter_id (+) + and v.attr_value is null + and p.package_key = register_parameter.package_key; + begin + -- Create the new parameter. + v_parameter_id := acs_object.new( + object_id => parameter_id, + object_type => 'apm_parameter', + title => register_parameter.package_key || ': Parameter ' || register_parameter.parameter_name + ); + + insert into apm_parameters + (parameter_id, parameter_name, description, package_key, datatype, + default_value, section_name, min_n_values, max_n_values) + values + (v_parameter_id, register_parameter.parameter_name, register_parameter.description, + register_parameter.package_key, register_parameter.datatype, + register_parameter.default_value, register_parameter.section_name, + register_parameter.min_n_values, register_parameter.max_n_values); + -- Propagate parameter to new instances. + for cur_val in all_parameters + loop + apm.set_value( + package_id => cur_val.package_id, + parameter_id => cur_val.parameter_id, + attr_value => cur_val.default_value + ); + end loop; + return v_parameter_id; + end register_parameter; + + function update_parameter ( + parameter_id in apm_parameters.parameter_id%TYPE, + parameter_name in apm_parameters.parameter_name%TYPE + default null, + description in apm_parameters.description%TYPE + default null, + datatype in apm_parameters.datatype%TYPE + default 'string', + default_value in apm_parameters.default_value%TYPE + default null, + section_name in apm_parameters.section_name%TYPE + default null, + min_n_values in apm_parameters.min_n_values%TYPE + default 1, + max_n_values in apm_parameters.max_n_values%TYPE + default 1 + ) return apm_parameters.parameter_name%TYPE + is + begin + update apm_parameters + set parameter_name = nvl(update_parameter.parameter_name, parameter_name), + default_value = nvl(update_parameter.default_value, default_value), + datatype = nvl(update_parameter.datatype, datatype), + description = nvl(update_parameter.description, description), + section_name = nvl(update_parameter.section_name, section_name), + min_n_values = nvl(update_parameter.min_n_values, min_n_values), + max_n_values = nvl(update_parameter.max_n_values, max_n_values) + where parameter_id = update_parameter.parameter_id; + + update acs_objects + set title = (select package_key || ': Parameter ' || parameter_name + from apm_parameters + where parameter_id = update_parameter.parameter_id) + where object_id = update_parameter.parameter_id; + + return parameter_id; + end; + + function parameter_p( + package_key in apm_package_types.package_key%TYPE, + parameter_name in apm_parameters.parameter_name%TYPE + ) return integer + is + v_parameter_p integer; + begin + select decode(count(*),0,0,1) into v_parameter_p + from apm_parameters + where package_key = parameter_p.package_key + and parameter_name = parameter_p.parameter_name; + return v_parameter_p; + end parameter_p; + + procedure unregister_parameter ( + parameter_id in apm_parameters.parameter_id%TYPE + default null + ) + is + begin + delete from apm_parameter_values + where parameter_id = unregister_parameter.parameter_id; + delete from apm_parameters + where parameter_id = unregister_parameter.parameter_id; + acs_object.del(parameter_id); + end unregister_parameter; + + function id_for_name ( + parameter_name in apm_parameters.parameter_name%TYPE, + package_key in apm_parameters.package_key%TYPE + ) return apm_parameters.parameter_id%TYPE + is + a_parameter_id apm_parameters.parameter_id%TYPE; + begin + select parameter_id into a_parameter_id + from apm_parameters p + where p.parameter_name = id_for_name.parameter_name and + p.package_key = id_for_name.package_key; + return a_parameter_id; + end id_for_name; + + function get_value ( + parameter_id in apm_parameter_values.parameter_id%TYPE, + package_id in apm_packages.package_id%TYPE + ) return apm_parameter_values.attr_value%TYPE + is + value apm_parameter_values.attr_value%TYPE; + begin + select attr_value into value from apm_parameter_values v + where v.package_id = get_value.package_id + and parameter_id = get_value.parameter_id; + return value; + end get_value; + + function get_value ( + package_id in apm_packages.package_id%TYPE, + parameter_name in apm_parameters.parameter_name%TYPE + ) return apm_parameter_values.attr_value%TYPE + is + v_parameter_id apm_parameter_values.parameter_id%TYPE; + begin + select parameter_id into v_parameter_id + from apm_parameters + where parameter_name = get_value.parameter_name + and package_key = (select package_key from apm_packages + where package_id = get_value.package_id); + return apm.get_value( + parameter_id => v_parameter_id, + package_id => get_value.package_id + ); + end get_value; + + + -- Sets a value for a parameter for a package instance. + procedure set_value ( + parameter_id in apm_parameter_values.parameter_id%TYPE, + package_id in apm_packages.package_id%TYPE, + attr_value in apm_parameter_values.attr_value%TYPE + ) + is + v_value_id apm_parameter_values.value_id%TYPE; + begin + -- Determine if the value exists + select value_id into v_value_id from apm_parameter_values + where parameter_id = set_value.parameter_id + and package_id = set_value.package_id; + update apm_parameter_values set attr_value = set_value.attr_value + where parameter_id = set_value.parameter_id + and package_id = set_value.package_id; + exception + when NO_DATA_FOUND + then + v_value_id := apm_parameter_value.new( + package_id => set_value.package_id, + parameter_id => set_value.parameter_id, + attr_value => set_value.attr_value + ); + end set_value; + + procedure set_value ( + package_id in apm_packages.package_id%TYPE, + parameter_name in apm_parameters.parameter_name%TYPE, + attr_value in apm_parameter_values.attr_value%TYPE + ) + is + v_parameter_id apm_parameter_values.parameter_id%TYPE; + begin + select parameter_id into v_parameter_id + from apm_parameters + where parameter_name = set_value.parameter_name + and package_key = (select package_key from apm_packages + where package_id = set_value.package_id); + apm.set_value( + parameter_id => v_parameter_id, + package_id => set_value.package_id, + attr_value => set_value.attr_value + ); + exception + when NO_DATA_FOUND + then + RAISE_APPLICATION_ERROR(-20000, 'The parameter named ' || set_value.parameter_name || ' that you attempted to set does not exist AND/OR the specified package ' || set_value.package_id || ' does not exist in the system.'); + end set_value; +end apm; +/ +show errors + +create or replace package body apm_package +as + procedure initialize_parameters ( + package_id in apm_packages.package_id%TYPE, + package_key in apm_package_types.package_key%TYPE + ) + is + v_value_id apm_parameter_values.value_id%TYPE; + cursor cur is + select parameter_id, default_value + from apm_parameters + where package_key = initialize_parameters.package_key; + begin + -- need to initialize all params for this type + for cur_val in cur + loop + v_value_id := apm_parameter_value.new( + package_id => initialize_parameters.package_id, + parameter_id => cur_val.parameter_id, + attr_value => cur_val.default_value + ); + end loop; + end initialize_parameters; + + function new ( + package_id in apm_packages.package_id%TYPE + default null, + instance_name in apm_packages.instance_name%TYPE + default null, + package_key in apm_packages.package_key%TYPE, + object_type in acs_objects.object_type%TYPE + default 'apm_package', + 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 apm_packages.package_id%TYPE + is + v_singleton_p integer; + v_package_type apm_package_types.package_type%TYPE; + v_num_instances integer; + v_package_id apm_packages.package_id%TYPE; + v_instance_name apm_packages.instance_name%TYPE; + begin + v_singleton_p := apm_package.singleton_p( + package_key => apm_package.new.package_key + ); + v_num_instances := apm_package.num_instances( + package_key => apm_package.new.package_key + ); + + if v_singleton_p = 1 and v_num_instances >= 1 then + select package_id into v_package_id + from apm_packages + where package_key = apm_package.new.package_key; + return v_package_id; + else + if instance_name is null then + v_instance_name := package_key || ' ' || v_package_id; + else + v_instance_name := instance_name; + end if; + + v_package_id := acs_object.new( + object_id => package_id, + object_type => object_type, + title => v_instance_name, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id + ); + + update acs_objects + set package_id = v_package_id + where object_id = v_package_id; + + select package_type into v_package_type + from apm_package_types + where package_key = apm_package.new.package_key; + + insert into apm_packages + (package_id, package_key, instance_name) + values + (v_package_id, package_key, v_instance_name); + + if v_package_type = 'apm_application' then + insert into apm_applications + (application_id) + values + (v_package_id); + else + insert into apm_services + (service_id) + values + (v_package_id); + end if; + + initialize_parameters( + package_id => v_package_id, + package_key => apm_package.new.package_key + ); + return v_package_id; + + end if; +end new; + + procedure del ( + package_id in apm_packages.package_id%TYPE + ) + is + cursor all_values is + select value_id from apm_parameter_values + where package_id = apm_package.del.package_id; + cursor all_site_nodes is + select node_id from site_nodes + where object_id = apm_package.del.package_id; + begin + -- Delete all parameters. + for cur_val in all_values loop + apm_parameter_value.del(value_id => cur_val.value_id); + end loop; + delete from apm_applications where application_id = apm_package.del.package_id; + delete from apm_services where service_id = apm_package.del.package_id; + delete from apm_packages where package_id = apm_package.del.package_id; + -- Delete the site nodes for the objects. + for cur_val in all_site_nodes loop + site_node.del(cur_val.node_id); + end loop; + -- Delete the object. + acs_object.del ( + object_id => package_id + ); + end del; + + function initial_install_p ( + package_key in apm_packages.package_key%TYPE + ) return integer + is + v_initial_install_p integer; + begin + select 1 into v_initial_install_p + from apm_package_types + where package_key = initial_install_p.package_key + and initial_install_p = 't'; + return v_initial_install_p; + + exception + when NO_DATA_FOUND + then + return 0; + end initial_install_p; + + function singleton_p ( + package_key in apm_packages.package_key%TYPE + ) return integer + is + v_singleton_p integer; + begin + select 1 into v_singleton_p + from apm_package_types + where package_key = singleton_p.package_key + and singleton_p = 't'; + return v_singleton_p; + + exception + when NO_DATA_FOUND + then + return 0; + end singleton_p; + + function num_instances ( + package_key in apm_package_types.package_key%TYPE + ) return integer + is + v_num_instances integer; + begin + select count(*) into v_num_instances + from apm_packages + where package_key = num_instances.package_key; + return v_num_instances; + + exception + when NO_DATA_FOUND + then + return 0; + end num_instances; + + function name ( + package_id in apm_packages.package_id%TYPE + ) return varchar2 + is + v_result apm_packages.instance_name%TYPE; + begin + select instance_name into v_result + from apm_packages + where package_id = name.package_id; + + return v_result; + end name; + + function highest_version ( + package_key in apm_package_types.package_key%TYPE + ) return apm_package_versions.version_id%TYPE + is + v_version_id apm_package_versions.version_id%TYPE; + begin + select version_id into v_version_id + from apm_package_version_info i + where apm_package_version.sortable_version_name(version_name) = + (select max(apm_package_version.sortable_version_name(v.version_name)) + from apm_package_version_info v where v.package_key = highest_version.package_key) + and package_key = highest_version.package_key; + return v_version_id; + exception + when NO_DATA_FOUND + then + return 0; + end highest_version; + + function parent_id ( + package_id in apm_packages.package_id%TYPE + ) return apm_packages.package_id%TYPE + is + v_package_id apm_packages.package_id%TYPE; + begin + select sn1.object_id + into v_package_id + from site_nodes sn1 + where sn1.node_id = (select sn2.parent_id + from site_nodes sn2 + where sn2.object_id = apm_package.parent_id.package_id); + + return v_package_id; + + exception when NO_DATA_FOUND then + return -1; + end parent_id; + +end apm_package; +/ +show errors + + +create or replace package body apm_package_version +as + function new ( + version_id in apm_package_versions.version_id%TYPE + default null, + package_key in apm_package_versions.package_key%TYPE, + version_name in apm_package_versions.version_name%TYPE + default null, + version_uri in apm_package_versions.version_uri%TYPE, + summary in apm_package_versions.summary%TYPE, + description_format in apm_package_versions.description_format%TYPE, + description in apm_package_versions.description%TYPE, + release_date in apm_package_versions.release_date%TYPE, + vendor in apm_package_versions.vendor%TYPE, + vendor_uri in apm_package_versions.vendor_uri%TYPE, + auto_mount in apm_package_versions.auto_mount%TYPE, + installed_p in apm_package_versions.installed_p%TYPE + default 'f', + data_model_loaded_p in apm_package_versions.data_model_loaded_p%TYPE + default 'f' + ) return apm_package_versions.version_id%TYPE + is + v_version_id apm_package_versions.version_id%TYPE; + begin + if version_id is null then + select acs_object_id_seq.nextval + into v_version_id + from dual; + else + v_version_id := version_id; + end if; + v_version_id := acs_object.new( + object_id => v_version_id, + object_type => 'apm_package_version', + title => package_key || ', Version ' || version_name + ); + insert into apm_package_versions + (version_id, package_key, version_name, version_uri, summary, description_format, description, + release_date, vendor, vendor_uri, auto_mount, installed_p, data_model_loaded_p) + values + (v_version_id, package_key, version_name, version_uri, + summary, description_format, description, + release_date, vendor, vendor_uri, auto_mount, + installed_p, data_model_loaded_p); + return v_version_id; + end new; + + procedure del ( + version_id in apm_packages.package_id%TYPE + ) + is + begin + delete from apm_package_owners + where version_id = apm_package_version.del.version_id; + + delete from apm_package_dependencies + where version_id = apm_package_version.del.version_id; + + delete from apm_package_versions + where version_id = apm_package_version.del.version_id; + + acs_object.del(apm_package_version.del.version_id); + + end del; + + procedure enable ( + version_id in apm_package_versions.version_id%TYPE + ) + is + begin + update apm_package_versions set enabled_p = 't' + where version_id = enable.version_id; + end enable; + + procedure disable ( + version_id in apm_package_versions.version_id%TYPE + ) + is + begin + update apm_package_versions + set enabled_p = 'f' + where version_id = disable.version_id; + end disable; + + function copy( + version_id in apm_package_versions.version_id%TYPE, + new_version_id in apm_package_versions.version_id%TYPE default null, + new_version_name in apm_package_versions.version_name%TYPE, + new_version_uri in apm_package_versions.version_uri%TYPE + ) return apm_package_versions.version_id%TYPE + is + v_version_id integer; + begin + v_version_id := acs_object.new( + object_id => new_version_id, + object_type => 'apm_package_version' + ); + + insert into apm_package_versions(version_id, package_key, version_name, + version_uri, summary, description_format, description, + release_date, vendor, vendor_uri, auto_mount) + select v_version_id, package_key, copy.new_version_name, + copy.new_version_uri, summary, description_format, description, + release_date, vendor, vendor_uri, auto_mount + from apm_package_versions + where version_id = copy.version_id; + + update acs_objects + set title = (select v.package_key || ', Version ' || v.version_name + from apm_package_versions v + where v.version_id = copy.version_id) + where object_id = copy.version_id; + + insert into apm_package_dependencies(dependency_id, version_id, dependency_type, service_uri, service_version) + select acs_object_id_seq.nextval, v_version_id, dependency_type, service_uri, service_version + from apm_package_dependencies + where version_id = copy.version_id; + + insert into apm_package_callbacks (version_id, type, proc) + select v_version_id, type, proc + from apm_package_callbacks + where version_id = copy.version_id; + + insert into apm_package_owners(version_id, owner_uri, owner_name, sort_key) + select v_version_id, owner_uri, owner_name, sort_key + from apm_package_owners + where version_id = copy.version_id; + + return v_version_id; + end copy; + + function edit ( + new_version_id in apm_package_versions.version_id%TYPE + default null, + version_id in apm_package_versions.version_id%TYPE, + version_name in apm_package_versions.version_name%TYPE + default null, + version_uri in apm_package_versions.version_uri%TYPE, + summary in apm_package_versions.summary%TYPE, + description_format in apm_package_versions.description_format%TYPE, + description in apm_package_versions.description%TYPE, + release_date in apm_package_versions.release_date%TYPE, + vendor in apm_package_versions.vendor%TYPE, + vendor_uri in apm_package_versions.vendor_uri%TYPE, + auto_mount in apm_package_versions.auto_mount%TYPE, + installed_p in apm_package_versions.installed_p%TYPE + default 'f', + data_model_loaded_p in apm_package_versions.data_model_loaded_p%TYPE + default 'f' + ) return apm_package_versions.version_id%TYPE + is + v_version_id apm_package_versions.version_id%TYPE; + version_unchanged_p integer; + begin + -- Determine if version has changed. + select decode(count(*),0,0,1) into version_unchanged_p + from apm_package_versions + where version_id = edit.version_id + and version_name = edit.version_name; + if version_unchanged_p <> 1 then + v_version_id := copy( + version_id => edit.version_id, + new_version_id => edit.new_version_id, + new_version_name => edit.version_name, + new_version_uri => edit.version_uri + ); + else + v_version_id := edit.version_id; + end if; + + update apm_package_versions + set version_uri = edit.version_uri, + summary = edit.summary, + description_format = edit.description_format, + description = edit.description, + release_date = trunc(sysdate), + vendor = edit.vendor, + vendor_uri = edit.vendor_uri, + auto_mount = edit.auto_mount, + installed_p = edit.installed_p, + data_model_loaded_p = edit.data_model_loaded_p + where version_id = v_version_id; + return v_version_id; + end edit; + +-- Add an interface provided by this version. + function add_interface( + interface_id in apm_package_dependencies.dependency_id%TYPE + default null, + version_id in apm_package_versions.version_id%TYPE, + interface_uri in apm_package_dependencies.service_uri%TYPE, + interface_version in apm_package_dependencies.service_version%TYPE + ) return apm_package_dependencies.dependency_id%TYPE + is + v_dep_id apm_package_dependencies.dependency_id%TYPE; + begin + if add_interface.interface_id is null then + select acs_object_id_seq.nextval into v_dep_id from dual; + else + v_dep_id := add_interface.interface_id; + end if; + + insert into apm_package_dependencies + (dependency_id, version_id, dependency_type, service_uri, service_version) + values + (v_dep_id, add_interface.version_id, 'provides', add_interface.interface_uri, + add_interface.interface_version); + return v_dep_id; + end add_interface; + + procedure remove_interface( + interface_id in apm_package_dependencies.dependency_id%TYPE + ) + is + begin + delete from apm_package_dependencies + where dependency_id = remove_interface.interface_id; + end remove_interface; + + procedure remove_interface( + interface_uri in apm_package_dependencies.service_uri%TYPE, + interface_version in apm_package_dependencies.service_version%TYPE, + version_id in apm_package_versions.version_id%TYPE + ) + is + v_dep_id apm_package_dependencies.dependency_id%TYPE; + begin + select dependency_id into v_dep_id from apm_package_dependencies + where service_uri = remove_interface.interface_uri + and interface_version = remove_interface.interface_version; + remove_interface(v_dep_id); + end remove_interface; + + -- Add a requirement for this version. A requirement is some interface that this + -- version depends on. + function add_dependency( + dependency_id in apm_package_dependencies.dependency_id%TYPE + default null, + version_id in apm_package_versions.version_id%TYPE, + dependency_uri in apm_package_dependencies.service_uri%TYPE, + dependency_version in apm_package_dependencies.service_version%TYPE + ) return apm_package_dependencies.dependency_id%TYPE + is + v_dep_id apm_package_dependencies.dependency_id%TYPE; + begin + if add_dependency.dependency_id is null then + select acs_object_id_seq.nextval into v_dep_id from dual; + else + v_dep_id := add_dependency.dependency_id; + end if; + + insert into apm_package_dependencies + (dependency_id, version_id, dependency_type, service_uri, service_version) + values + (v_dep_id, add_dependency.version_id, 'requires', add_dependency.dependency_uri, + add_dependency.dependency_version); + return v_dep_id; + end add_dependency; + + procedure remove_dependency( + dependency_id in apm_package_dependencies.dependency_id%TYPE + ) + is + begin + delete from apm_package_dependencies + where dependency_id = remove_dependency.dependency_id; + end remove_dependency; + + + procedure remove_dependency( + dependency_uri in apm_package_dependencies.service_uri%TYPE, + dependency_version in apm_package_dependencies.service_version%TYPE, + version_id in apm_package_versions.version_id%TYPE + ) + is + v_dep_id apm_package_dependencies.dependency_id%TYPE; + begin + select dependency_id into v_dep_id from apm_package_dependencies + where service_uri = remove_dependency.dependency_uri + and service_version = remove_dependency.dependency_version; + remove_dependency(v_dep_id); + end remove_dependency; + + function sortable_version_name ( + version_name in apm_package_versions.version_name%TYPE + ) return varchar2 + is + a_fields integer; + a_start integer; + a_end integer; + a_order varchar2(1000); + a_char char(1); + a_seen_letter char(1) := 'f'; + begin + a_fields := 0; + a_start := 1; + loop + a_end := a_start; + + -- keep incrementing a_end until we run into a non-number + while substr(version_name, a_end, 1) >= '0' and substr(version_name, a_end, 1) <= '9' loop + a_end := a_end + 1; + end loop; + if a_end = a_start then + return -1; + -- raise_application_error(-20000, 'Expected number at position ' || a_start); + end if; + if a_end - a_start > 4 then + return -1; + -- raise_application_error(-20000, 'Numbers within versions can only be up to 4 digits long'); + end if; + + -- zero-pad and append the number + a_order := a_order || substr('0000', 1, 4 - (a_end - a_start)) || + substr(version_name, a_start, a_end - a_start) || '.'; + a_fields := a_fields + 1; + if a_end > length(version_name) then + -- end of string - we're outta here + if a_seen_letter = 'f' then + -- append the "final" suffix if there haven't been any letters + -- so far (i.e., not development/alpha/beta) + a_order := a_order || lpad(' ',(7 - a_fields)*5,'0000.') || ' 3F.'; + end if; + return a_order; + end if; + + -- what's the next character? if a period, just skip it + a_char := substr(version_name, a_end, 1); + if a_char = '.' then + null; + else + -- if the next character was a letter, append the appropriate characters + if a_char = 'd' then + a_order := a_order || lpad(' ',(7 - a_fields)*5,'0000.') || ' 0D.'; + elsif a_char = 'a' then + a_order := a_order || lpad(' ',(7 - a_fields)*5,'0000.') || ' 1A.'; + elsif a_char = 'b' then + a_order := a_order || lpad(' ',(7 - a_fields)*5,'0000.') || ' 2B.'; + end if; + + -- can't have something like 3.3a1b2 - just one letter allowed! + if a_seen_letter = 't' then + return -1; + -- raise_application_error(-20000, 'Not allowed to have two letters in version name ''' + -- || version_name || ''''); + end if; + a_seen_letter := 't'; + + -- end of string - we're done! + if a_end = length(version_name) then + return a_order; + end if; + end if; + a_start := a_end + 1; + end loop; + end sortable_version_name; + + function version_name_greater( + version_name_one in apm_package_versions.version_name%TYPE, + version_name_two in apm_package_versions.version_name%TYPE + ) return integer is + a_order_a varchar2(1000); + a_order_b varchar2(1000); + begin + a_order_a := sortable_version_name(version_name_one); + a_order_b := sortable_version_name(version_name_two); + if a_order_a < a_order_b then + return -1; + elsif a_order_a > a_order_b then + return 1; + end if; + return 0; + end version_name_greater; + + function upgrade_p( + path in varchar2, + initial_version_name in apm_package_versions.version_name%TYPE, + final_version_name in apm_package_versions.version_name%TYPE + ) return integer + is + v_pos1 integer; + v_pos2 integer; + v_path varchar2(1500); + v_version_from apm_package_versions.version_name%TYPE; + v_version_to apm_package_versions.version_name%TYPE; + begin + + -- Set v_path to the tail of the path (the file name). + v_path := substr(upgrade_p.path, instr(upgrade_p.path, '/', -1) + 1); + + -- Remove the extension, if it's .sql. + v_pos1 := instr(v_path, '.', -1); + if v_pos1 > 0 and substr(v_path, v_pos1) = '.sql' then + v_path := substr(v_path, 1, v_pos1 - 1); + end if; + + -- Figure out the from/to version numbers for the individual file. + v_pos1 := instr(v_path, '-', -1, 2); + v_pos2 := instr(v_path, '-', -1); + if v_pos1 = 0 or v_pos2 = 0 then + -- There aren't two hyphens in the file name. Bail. + return 0; + end if; + + v_version_from := substr(v_path, v_pos1 + 1, v_pos2 - v_pos1 - 1); + v_version_to := substr(v_path, v_pos2 + 1); + + if version_name_greater(upgrade_p.initial_version_name, v_version_from) <= 0 and + version_name_greater(upgrade_p.final_version_name, v_version_to) >= 0 then + return 1; + end if; + + return 0; + exception when others then + -- Invalid version number. + return 0; + end upgrade_p; + + procedure upgrade( + version_id in apm_package_versions.version_id%TYPE + ) + is + begin + update apm_package_versions + set enabled_p = 'f', + installed_p = 'f' + where package_key = (select package_key from apm_package_versions + where version_id = upgrade.version_id); + update apm_package_versions + set enabled_p = 't', + installed_p = 't' + where version_id = upgrade.version_id; + + end upgrade; + +end apm_package_version; +/ +show errors + +------------------- +-- PARTY PACKAGE -- +------------------- + +create or replace package body party +as + + function new ( + party_id in parties.party_id%TYPE default null, + object_type in acs_objects.object_type%TYPE + default 'party', + 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, + email in parties.email%TYPE, + url in parties.url%TYPE default null, + context_id in acs_objects.context_id%TYPE default null + ) + return parties.party_id%TYPE + is + v_party_id parties.party_id%TYPE; + begin + v_party_id := + acs_object.new( + object_id => party_id, + object_type => object_type, + title => lower(email), + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id); + + insert into parties + (party_id, email, url) + values + (v_party_id, lower(email), url); + + return v_party_id; + end new; + + procedure del ( + party_id in parties.party_id%TYPE + ) + is + begin + acs_object.del(party_id); + end del; + + function name ( + party_id in parties.party_id%TYPE + ) + return varchar2 + is + begin + if party_id = -1 then + return 'The Public'; + else + return null; + end if; + end name; + + function email ( + party_id in parties.party_id%TYPE + ) + return varchar2 + is + v_email parties.email%TYPE; + begin + select email + into v_email + from parties + where party_id = email.party_id; + + return v_email; + + end email; + +end party; +/ +show errors + +-------------------- +-- PERSON PACKAGE -- +-------------------- + +create or replace package body person +as + + function new ( + person_id in persons.person_id%TYPE default null, + object_type in acs_objects.object_type%TYPE + default 'person', + 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, + email in parties.email%TYPE, + url in parties.url%TYPE default null, + first_names in persons.first_names%TYPE, + last_name in persons.last_name%TYPE, + context_id in acs_objects.context_id%TYPE default null + ) + return persons.person_id%TYPE + is + v_person_id persons.person_id%TYPE; + begin + v_person_id := + party.new(person_id, object_type, + creation_date, creation_user, creation_ip, + email, url, context_id); + + insert into persons + (person_id, first_names, last_name) + values + (v_person_id, first_names, last_name); + + update acs_objects + set title = first_names || ' ' || last_name + where object_id = v_person_id; + + return v_person_id; + end new; + + procedure del ( + person_id in persons.person_id%TYPE + ) + is + begin + delete from persons + where person_id = person.del.person_id; + + party.del(person_id); + end del; + + function name ( + person_id in persons.person_id%TYPE + ) + return varchar2 + is + person_name varchar2(200); + begin + select first_names || ' ' || last_name + into person_name + from persons + where person_id = name.person_id; + + return person_name; + end name; + + function first_names ( + person_id in persons.person_id%TYPE + ) + return varchar2 + is + person_first_names varchar2(200); + begin + select first_names + into person_first_names + from persons + where person_id = first_names.person_id; + + return person_first_names; + end first_names; + +function last_name ( + person_id in persons.person_id%TYPE + ) + return varchar2 + is + person_last_name varchar2(200); + begin + select last_name + into person_last_name + from persons + where person_id = last_name.person_id; + + return person_last_name; + end last_name; + +end person; +/ +show errors + +--------- +-- Acs Groups +--------- + +create or replace package body acs_group +is + function new ( + group_id in groups.group_id%TYPE default null, + object_type in acs_objects.object_type%TYPE + default 'group', + 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, + email in parties.email%TYPE default null, + url in parties.url%TYPE default null, + group_name in groups.group_name%TYPE, + join_policy in groups.join_policy%TYPE default null, + context_id in acs_objects.context_id%TYPE default null + ) + return groups.group_id%TYPE + is + v_group_id groups.group_id%TYPE; + v_group_type_exists_p integer; + v_join_policy groups.join_policy%TYPE; + begin + v_group_id := + party.new(group_id, object_type, creation_date, creation_user, + creation_ip, email, url, context_id); + + v_join_policy := join_policy; + + -- if join policy wasn't specified, select the default based on group type + if v_join_policy is null then + select count(*) into v_group_type_exists_p + from group_types + where group_type = object_type; + + if v_group_type_exists_p = 1 then + select default_join_policy into v_join_policy + from group_types + where group_type = object_type; + else + v_join_policy := 'open'; + end if; + end if; + + insert into groups + (group_id, group_name, join_policy) + values + (v_group_id, group_name, v_join_policy); + + update acs_objects + set title = group_name + were object_id = v_group_id; + + + -- setup the permissible relationship types for this group + insert into group_rels + (group_rel_id, group_id, rel_type) + select acs_object_id_seq.nextval, v_group_id, g.rel_type + from group_type_rels g + where g.group_type = new.object_type; + + return v_group_id; + end new; + + + procedure del ( + group_id in groups.group_id%TYPE + ) + is + begin + + -- Delete all segments defined for this group + for row in (select segment_id + from rel_segments + where group_id = acs_group.del.group_id) loop + + rel_segment.del(row.segment_id); + + end loop; + + -- Delete all the relations of any type to this group + for row in (select r.rel_id, t.package_name + from acs_rels r, acs_object_types t + where r.rel_type = t.object_type + and (r.object_id_one = acs_group.del.group_id + or r.object_id_two = acs_group.del.group_id)) loop + execute immediate 'begin ' || row.package_name || '.del(' || row.rel_id || '); end;'; + end loop; + + party.del(group_id); + end del; + + function name ( + group_id in groups.group_id%TYPE + ) + return varchar2 + is + group_name varchar2(200); + begin + select group_name + into group_name + from groups + where group_id = name.group_id; + + return group_name; + end name; + + function member_p ( + party_id in parties.party_id%TYPE, + group_id in groups.group_id%TYPE, + cascade_membership char + ) + return char + is + m_result integer; + begin + + if cascade_membership = 't' then + select count(*) + into m_result + from group_member_map + where group_id = member_p.group_id and + member_id = member_p.party_id; + + if m_result > 0 then + return 't'; + end if; + else + select count(*) + into m_result + from acs_rels rels, all_object_party_privilege_map perm + where perm.object_id = rels.rel_id + and perm.privilege = 'read' + and rels.rel_type = 'membership_rel' + and rels.object_id_one = member_p.group_id + and rels.object_id_two = member_p.party_id; + + if m_result > 0 then + return 't'; + end if; + end if; + + return 'f'; + end member_p; + + function check_representation ( + group_id in groups.group_id%TYPE + ) return char + is + result char(1); + begin + result := 't'; + acs_log.notice('acs_group.check_representation', + 'Running check_representation on group ' || group_id); + + if acs_object.check_representation(group_id) = 'f' then + result := 'f'; + end if; + + for c in (select c.rel_id + from acs_rels r, composition_rels c + where r.rel_id = c.rel_id + and r.object_id_one = group_id) loop + if composition_rel.check_representation(c.rel_id) = 'f' then + result := 'f'; + end if; + end loop; + + for m in (select m.rel_id + from acs_rels r, membership_rels m + where r.rel_id = m.rel_id + and r.object_id_one = group_id) loop + if membership_rel.check_representation(m.rel_id) = 'f' then + result := 'f'; + end if; + end loop; + + acs_log.notice('acs_group.check_representation', + 'Done running check_representation on group ' || group_id); + return result; + end; + +end acs_group; +/ +show errors + +-------- +-- Journal +-------- + +create or replace package body journal_entry +as + + function new ( + journal_id in journal_entries.journal_id%TYPE default null, + object_id in journal_entries.object_id%TYPE, + action in journal_entries.action%TYPE, + action_pretty in journal_entries.action_pretty%TYPE, + 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, + msg in journal_entries.msg%TYPE default null + ) return journal_entries.journal_id%TYPE + is + v_journal_id journal_entries.journal_id%TYPE; + begin + v_journal_id := acs_object.new ( + object_id => journal_id, + object_type => 'journal_entry', + title => action, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => object_id + ); + + insert into journal_entries ( + journal_id, object_id, action, action_pretty, msg + ) values ( + v_journal_id, object_id, action, action_pretty, msg + ); + + return v_journal_id; + end new; + + procedure del ( + journal_id in journal_entries.journal_id%TYPE + ) + is + begin + delete from journal_entries where journal_id = journal_entry.del.journal_id; + acs_object.del(journal_entry.del.journal_id); + end del; + + procedure delete_for_object( + object_id in acs_objects.object_id%TYPE + ) + is + cursor journal_cur is + select journal_id from journal_entries where object_id = delete_for_object.object_id; + begin + for journal_rec in journal_cur loop + journal_entry.del(journal_rec.journal_id); + end loop; + end delete_for_object; + +end journal_entry; +/ +show errors; + +-------- +-- Site Nodes +-------- + +create or replace package body site_node +as + + function new ( + node_id in site_nodes.node_id%TYPE default null, + parent_id in site_nodes.node_id%TYPE default null, + name in site_nodes.name%TYPE, + object_id in site_nodes.object_id%TYPE default null, + directory_p in site_nodes.directory_p%TYPE, + pattern_p in site_nodes.pattern_p%TYPE default 'f', + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null + ) return site_nodes.node_id%TYPE + is + v_node_id site_nodes.node_id%TYPE; + v_directory_p site_nodes.directory_p%TYPE; + begin + if parent_id is not null then + select directory_p into v_directory_p + from site_nodes + where node_id = new.parent_id; + + if v_directory_p = 'f' then + raise_application_error ( + -20000, + 'Node ' || parent_id || ' is not a directory' + ); + end if; + end if; + + v_node_id := acs_object.new ( + object_id => node_id, + object_type => 'site_node', + title => name, + package_id => object_id, + creation_user => creation_user, + creation_ip => creation_ip + ); + + insert into site_nodes + (node_id, parent_id, name, object_id, directory_p, pattern_p) + values + (v_node_id, new.parent_id, new.name, new.object_id, + new.directory_p, new.pattern_p); + + return v_node_id; + end; + + procedure del ( + node_id in site_nodes.node_id%TYPE + ) + is + begin + delete from site_nodes + where node_id = site_node.del.node_id; + + acs_object.del(node_id); + end; + + function find_pattern ( + node_id in site_nodes.node_id%TYPE + ) return site_nodes.node_id%TYPE + is + v_pattern_p site_nodes.pattern_p%TYPE; + v_parent_id site_nodes.node_id%TYPE; + begin + if node_id is null then + raise no_data_found; + end if; + + select pattern_p, parent_id into v_pattern_p, v_parent_id + from site_nodes + where node_id = find_pattern.node_id; + + if v_pattern_p = 't' then + return node_id; + else + return find_pattern(v_parent_id); + end if; + end; + + function node_id ( + url in varchar2, + parent_id in site_nodes.node_id%TYPE default null + ) return site_nodes.node_id%TYPE + is + v_pos integer; + v_first site_nodes.name%TYPE; + v_rest varchar2(4000); + v_node_id integer; + v_pattern_p site_nodes.pattern_p%TYPE; + v_url varchar2(4000); + v_directory_p site_nodes.directory_p%TYPE; + v_trailing_slash_p char(1); + begin + v_url := url; + + if substr(v_url, length(v_url), 1) = '/' then + -- It ends with a / so it must be a directory. + v_trailing_slash_p := 't'; + v_url := substr(v_url, 1, length(v_url) - 1); + end if; + + v_pos := 1; + + while v_pos <= length(v_url) and substr(v_url, v_pos, 1) != '/' loop + v_pos := v_pos + 1; + end loop; + + if v_pos = length(v_url) then + v_first := v_url; + v_rest := null; + else + v_first := substr(v_url, 1, v_pos - 1); + v_rest := substr(v_url, v_pos + 1); + end if; + + begin + -- Is there a better way to do these freaking null compares? + select node_id, directory_p into v_node_id, v_directory_p + from site_nodes + where nvl(parent_id, 3.14) = nvl(site_node.node_id.parent_id, 3.14) + and nvl(name, chr(10)) = nvl(v_first, chr(10)); + exception + when no_data_found then + return find_pattern(parent_id); + end; + + if v_rest is null then + if v_trailing_slash_p = 't' and v_directory_p = 'f' then + return find_pattern(parent_id); + else + return v_node_id; + end if; + else + return node_id(v_rest, v_node_id); + end if; + end; + + function url ( + node_id in site_nodes.node_id%TYPE + ) return varchar2 + is + v_parent_id site_nodes.node_id%TYPE; + v_name site_nodes.name%TYPE; + v_directory_p site_nodes.directory_p%TYPE; + begin + if node_id is null then + return ''; + end if; + + select parent_id, name, directory_p into + v_parent_id, v_name, v_directory_p + from site_nodes + where node_id = url.node_id; + + if v_directory_p = 't' then + return url(v_parent_id) || v_name || '/'; + else + return url(v_parent_id) || v_name; + end if; + end; + +end; +/ +show errors + +@@ ../authentication-package-create.sql +@@ ../rel-segments-body-create.sql +@@ ../rel-constraints-body-create.sql Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql,v diff -u -N -r1.27 -r1.28 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql 4 Mar 2004 14:52:41 -0000 1.27 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-create.sql 12 Mar 2004 18:48:50 -0000 1.28 @@ -259,9 +259,9 @@ -- with the user_id assigned throughout the toolkit Tcl code insert into acs_objects - (object_id, object_type) + (object_id, object_type, title) values - (0, ''user''); + (0, ''user'', ''Unregistered Visitor''); insert into parties (party_id) @@ -372,7 +372,8 @@ now(), null, null, - null + null, + 'Default Context' ); insert into acs_magic_objects Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql,v diff -u -N -r1.48 -r1.49 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 4 Mar 2004 14:52:41 -0000 1.48 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 12 Mar 2004 18:48:50 -0000 1.49 @@ -150,6 +150,38 @@ ''f'' ); + attr_id := acs_attribute__create_attribute ( + ''acs_object'', + ''package_id'', + ''integer'', + ''Package ID'', + ''Package IDs'', + null, + null, + null, + 0, + 1, + null, + ''type_specific'', + ''f'' + ); + + attr_id := acs_attribute__create_attribute ( + ''acs_object'', + ''title'', + ''string'', + ''Title'', + ''Titles'', + null, + null, + null, + 0, + 1, + null, + ''type_specific'', + ''f'' + ); + return 0; end;' language 'plpgsql'; @@ -178,6 +210,8 @@ object_type varchar(100) not null constraint acs_objects_object_type_fk references acs_object_types (object_type), + title varchar(1000) default null, + package_id integer default null, context_id integer constraint acs_objects_context_id_fk references acs_objects(object_id), security_inherit_p boolean default 't' not null, @@ -203,6 +237,9 @@ create index acs_objects_creation_user_idx on acs_objects (creation_user); create index acs_objects_modify_user_idx on acs_objects (modifying_user); +create index acs_objects_package_object_idx on acs_objects (package_id, object_id); +create index acs_objects_title_idx on acs_objects(title); + create index acs_objects_object_type_idx on acs_objects (object_type); create function acs_objects_mod_ip_insert_tr () returns opaque as ' @@ -341,6 +378,18 @@ Who last modified the object '; +comment on column acs_objects.package_id is ' + Which package instance this object belongs to. + Please note that in mid-term this column will replace all + package_ids of package specific tables. +'; + +comment on column acs_objects.title is ' + Title of the object if applicable. + Please note that in mid-term this column will replace all + titles or object_names of package specific tables. +'; + ----------------------- -- CONTEXT HIERARCHY -- ----------------------- @@ -584,7 +633,7 @@ -- function new -create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,boolean) +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,boolean,varchar,integer) returns integer as ' declare new__object_id alias for $1; -- default null @@ -594,8 +643,12 @@ new__creation_ip alias for $5; -- default null new__context_id alias for $6; -- default null new__security_inherit_p alias for $7; -- default ''t'' + new__title alias for $8; -- default null + new__package_id alias for $9; -- default null v_object_id acs_objects.object_id%TYPE; v_creation_date timestamptz; + v_title acs_objects.title%TYPE; + v_object_type_pretty_name acs_object_types.pretty_name%TYPE; begin if new__object_id is null then select acs_object_id_seq.nextval @@ -604,17 +657,28 @@ v_object_id := new__object_id; end if; + if new__object_id is null then + select pretty_name + into v_object_type_pretty_name + from acs_object_types + where object_type = new__object_type; + + v_title := v_object_type_pretty_name || '' '' || v_object_id; + else + v_title := new__title; + end if; + if new__creation_date is null then v_creation_date:= now(); else v_creation_date := new__creation_date; end if; insert into acs_objects - (object_id, object_type, context_id, + (object_id, object_type, title, package_id, context_id, creation_date, creation_user, creation_ip, security_inherit_p) values - (v_object_id, new__object_type, new__context_id, + (v_object_id, new__object_type, v_title, new__package_id, new__context_id, v_creation_date, new__creation_user, new__creation_ip, new__security_inherit_p); @@ -637,30 +701,75 @@ v_object_id acs_objects.object_id%TYPE; v_creation_date timestamptz; begin - if new__object_id is null then - select acs_object_id_seq.nextval - into v_object_id from dual; - else - v_object_id := new__object_id; - end if; + return acs_object__new(new__object_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + ''t'', null, null); +end;' language 'plpgsql'; - if new__creation_date is null then - v_creation_date:= now(); - else - v_creation_date := new__creation_date; - end if; +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,boolean) +returns integer as ' +declare + new__object_id alias for $1; -- default null + new__object_type alias for $2; -- default ''acs_object'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__context_id alias for $6; -- default null + new__security_inherit_p alias for $7; -- default ''t'' +begin + return acs_object__new(new__object_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + new__security_inherit_p, null, null); +end;' language 'plpgsql'; - insert into acs_objects - (object_id, object_type, context_id, - creation_date, creation_user, creation_ip) - values - (v_object_id, new__object_type, new__context_id, - v_creation_date, new__creation_user, new__creation_ip); +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,boolean,varchar) +returns integer as ' +declare + new__object_id alias for $1; -- default null + new__object_type alias for $2; -- default ''acs_object'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__context_id alias for $6; -- default null + new__security_inherit_p alias for $7; -- default ''t'' + new__title alias for $8; -- default null +begin + return acs_object__new(new__object_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + new__security_inherit_p, new__title, null); +end;' language 'plpgsql'; - PERFORM acs_object__initialize_attributes(v_object_id); +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,varchar,integer) +returns integer as ' +declare + new__object_id alias for $1; -- default null + new__object_type alias for $2; -- default ''acs_object'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__context_id alias for $6; -- default null + new__title alias for $7; -- default null + new__package_id alias for $8; -- default null +begin + return acs_object__new(new__object_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + ''t'', new__title, new__package_id); +end;' language 'plpgsql'; - return v_object_id; - +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,varchar) +returns integer as ' +declare + new__object_id alias for $1; -- default null + new__object_type alias for $2; -- default ''acs_object'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__context_id alias for $6; -- default null + new__title alias for $7; -- default null +begin + return acs_object__new(new__object_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + ''t'', new__title, null); end;' language 'plpgsql'; create function acs_object__new (integer,varchar) returns integer as ' @@ -750,6 +859,14 @@ -- where o.object_id = name__object_id) -- connect by object_type = prior supertype + select title into object_name + from acs_objects + where object_id = name__object_id; + + if (object_name is not null) then + return object_name; + end if; + for obj_type in select o2.name_method from acs_object_types o1, acs_object_types o2 @@ -799,6 +916,25 @@ end;' language 'plpgsql' stable strict; +-- function package_id +create or replace function acs_object__package_id (integer) +returns integer as ' +declare + p_object_id alias for $1; + v_package_id acs_objects.package_id%TYPE; +begin + if p_object_id is null then + return null; + end if; + + select package_id into v_package_id + from acs_objects + where object_id = p_object_id; + + return v_package_id; +end;' language 'plpgsql' stable strict; + + -- procedure get_attribute_storage create or replace function acs_object__get_attribute_storage (integer,varchar) returns text as ' Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql,v diff -u -N -r1.15 -r1.16 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql 4 Mar 2004 14:52:41 -0000 1.15 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql 12 Mar 2004 18:48:50 -0000 1.16 @@ -462,7 +462,10 @@ now(), creation_user, creation_ip, - context_id + context_id, + ''t'', + new__rel_type || '': '' || new__object_id_one || '' - '' || new__object_id_two, + null ); insert into acs_rels Index: openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql,v diff -u -N -r1.51 -r1.52 --- openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql 4 Mar 2004 14:52:41 -0000 1.51 +++ openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql 12 Mar 2004 18:48:50 -0000 1.52 @@ -227,6 +227,8 @@ create index apm_packages_package_key_idx on apm_packages (package_key); +alter table acs_objects add foreign key (package_id) references apm_packages(package_id); + comment on table apm_packages is ' This table maintains the list of all package instances in the sytem. '; @@ -1340,6 +1342,9 @@ now(), null, null, + null, + ''t'', + register_parameter__package_key || '': Parameter '' || register_parameter__parameter_name, null ); @@ -1396,6 +1401,12 @@ max_n_values = coalesce(update_parameter__max_n_values, max_n_values) where parameter_id = update_parameter__parameter_id; + update acs_objects + set title = (select package_key || '': Parameter '' || parameter_name + from apm_parameters + where parameter_id = update_parameter__parameter_id) + where object_id = update_parameter__parameter_id; + return parameter_id; end;' language 'plpgsql'; @@ -1628,6 +1639,11 @@ v_instance_name := new__instance_name; end if; + update acs_objects + set title = v_instance_name, + package_id = v_package_id + where object_id = v_package_id; + select package_type into v_package_type from apm_package_types where package_key = new__package_key; @@ -1809,6 +1825,9 @@ now(), null, null, + null, + ''t'', + apm_pkg_ver__package_key || '', Version '' || apm_pkg_ver__version_name, null ); @@ -1904,6 +1923,12 @@ from apm_package_versions where version_id = copy__version_id; + update acs_objects + set title = (select v.package_key || '', Version '' || v.version_name + from apm_package_versions v + where v.version_id = copy__version_id) + where object_id = copy__version_id; + insert into apm_package_dependencies(dependency_id, version_id, dependency_type, service_uri, service_version) select nextval(''t_acs_object_id_seq''), v_version_id, dependency_type, service_uri, service_version from apm_package_dependencies Index: openacs-4/packages/acs-kernel/sql/postgresql/authentication-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/authentication-package-create.sql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-kernel/sql/postgresql/authentication-package-create.sql 4 Mar 2004 14:52:41 -0000 1.6 +++ openacs-4/packages/acs-kernel/sql/postgresql/authentication-package-create.sql 12 Mar 2004 18:48:50 -0000 1.7 @@ -66,7 +66,9 @@ p_creation_user, p_creation_ip, p_context_id, - ''t'' + ''t'', + p_short_name, + null ); insert into auth_authorities (authority_id, short_name, pretty_name, enabled_p, Index: openacs-4/packages/acs-kernel/sql/postgresql/community-core-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/community-core-create.sql,v diff -u -N -r1.19 -r1.20 --- openacs-4/packages/acs-kernel/sql/postgresql/community-core-create.sql 4 Mar 2004 14:52:41 -0000 1.19 +++ openacs-4/packages/acs-kernel/sql/postgresql/community-core-create.sql 12 Mar 2004 18:48:50 -0000 1.20 @@ -286,7 +286,8 @@ begin v_party_id := acs_object__new(new__party_id, new__object_type, new__creation_date, - new__creation_user, new__creation_ip, new__context_id); + new__creation_user, new__creation_ip, new__context_id, + ''t'', new__email, null); insert into parties (party_id, email, url) @@ -409,6 +410,10 @@ new__creation_date, new__creation_user, new__creation_ip, new__email, new__url, new__context_id); + update acs_objects + set title = new__first_names || '' '' || new__last_name + where object_id = v_person_id; + insert into persons (person_id, first_names, last_name) values Index: openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql,v diff -u -N -r1.27 -r1.28 --- openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql 4 Mar 2004 14:52:41 -0000 1.27 +++ openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql 12 Mar 2004 18:48:50 -0000 1.28 @@ -833,6 +833,10 @@ end if; end if; + update acs_objects + set title = new__group_name + where object_id = v_group_id; + insert into groups (group_id, group_name, join_policy) values Index: openacs-4/packages/acs-kernel/sql/postgresql/journal-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/journal-create.sql,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/acs-kernel/sql/postgresql/journal-create.sql 4 Mar 2004 14:52:41 -0000 1.7 +++ openacs-4/packages/acs-kernel/sql/postgresql/journal-create.sql 12 Mar 2004 18:48:50 -0000 1.8 @@ -107,7 +107,10 @@ new__creation_date, new__creation_user, new__creation_ip, - new__object_id + new__object_id, + ''t'', + new__action, + null ); insert into journal_entries ( Index: openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-body-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-body-create.sql,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-body-create.sql 4 Mar 2004 14:52:41 -0000 1.10 +++ openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-body-create.sql 12 Mar 2004 18:48:50 -0000 1.11 @@ -56,7 +56,10 @@ now(), new__creation_user, new__creation_ip, - new__context_id + new__context_id, + ''t'', + new__constraint_name, + null ); insert into rel_constraints Index: openacs-4/packages/acs-kernel/sql/postgresql/rel-segments-body-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/rel-segments-body-create.sql,v diff -u -N -r1.13 -r1.14 --- openacs-4/packages/acs-kernel/sql/postgresql/rel-segments-body-create.sql 4 Mar 2004 14:52:41 -0000 1.13 +++ openacs-4/packages/acs-kernel/sql/postgresql/rel-segments-body-create.sql 12 Mar 2004 18:48:50 -0000 1.14 @@ -35,6 +35,10 @@ party__new(new__segment_id, object_type, creation_date, creation_user, creation_ip, email, url, context_id); + update acs_objects + set title = new__segment_name + where object_id = v_segment_id; + insert into rel_segments (segment_id, segment_name, group_id, rel_type) values Index: openacs-4/packages/acs-kernel/sql/postgresql/site-nodes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/site-nodes-create.sql,v diff -u -N -r1.19 -r1.20 --- openacs-4/packages/acs-kernel/sql/postgresql/site-nodes-create.sql 4 Mar 2004 14:52:41 -0000 1.19 +++ openacs-4/packages/acs-kernel/sql/postgresql/site-nodes-create.sql 12 Mar 2004 18:48:50 -0000 1.20 @@ -235,7 +235,10 @@ now(), new__creation_user, new__creation_ip, - null + null, + ''t'', + new__name, + new__object_id ); insert into site_nodes Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/Attic/upgrade-5.1.0d1-5.1.0d2.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql 12 Mar 2004 18:48:50 -0000 1.3 @@ -0,0 +1,1124 @@ +create function inline_0 () +returns integer as ' +declare + attr_id acs_attributes.attribute_id%TYPE; +begin + attr_id := acs_attribute__create_attribute ( + ''acs_object'', + ''package_id'', + ''integer'', + ''Package ID'', + ''Package IDs'', + null, + null, + null, + 0, + 1, + null, + ''type_specific'', + ''f'' + ); + + attr_id := acs_attribute__create_attribute ( + ''acs_object'', + ''title'', + ''string'', + ''Title'', + ''Titles'', + null, + null, + null, + 0, + 1, + null, + ''type_specific'', + ''f'' + ); + + return 0; +end;' language 'plpgsql'; + +select inline_0 (); + +drop function inline_0 (); + +alter table acs_objects add column title varchar(1000); +alter table acs_objects alter column title set default null; +alter table acs_objects add column package_id integer + constraint acs_objects_package_id_fk + references apm_packages(package_id); +alter table acs_objects alter column package_id set default null; + +create index acs_objects_package_object_idx on acs_objects (package_id, object_id); +create index acs_objects_title_idx on acs_objects(title); + +comment on column acs_objects.package_id is ' + Which package instance this object belongs to. + Please note that in mid-term this column will replace all + package_ids of package specific tables. +'; + +comment on column acs_objects.title is ' + Title of the object if applicable. + Please note that in mid-term this column will replace all + titles or object_names of package specific tables. +'; + +---------- +-- update data +---------- + +update acs_objects +set title = (select group_name + from groups + where group_id = object_id) +where object_id in (select group_id from groups); + +update acs_objects +set title = (select email + from parties + where party_id = object_id) +where object_type = 'party'; + +update acs_objects +set title = (select first_names || ' ' || last_name + from persons + where person_id = object_id) +where object_type in ('user','person'); + +update acs_objects +set title = (select short_name + from auth_authorities + where authority_id = object_id) +where object_type = 'authority'; + +update acs_objects +set title = (select action + from journal_entries + where journal_id = object_id) +where object_type = 'journal_entry'; + +update acs_objects +set title = (select name + from site_nodes + where node_id = acs_objects.object_id), + package_id = (select object_id + from site_nodes + where node_id = acs_objects.object_id) +where object_type = 'site_node'; + +update acs_objects +set title = (select instance_name + from apm_packages + where package_id = object_id), + package_id = object_id +where object_type in ('apm_package','apm_application','apm_service'); + +update acs_objects +set title = (select package_key || ', Version ' || version_name + from apm_package_versions + where version_id = object_id) +where object_type = 'apm_package_version'; + +update acs_objects +set title = (select package_key || ': Parameter ' || parameter_name + from apm_parameters + where parameter_id = object_id) +where object_type = 'apm_parameter'; + +update acs_objects +set title = (select rel_type || ': ' || object_id_one || ' - ' || object_id_two + from acs_rels + where rel_id = object_id) +where object_id in (select rel_id from acs_rels); + +update acs_objects +set title = (select segment_name + from rel_segments + where segment_id = object_id) +where object_type = 'rel_segment'; + +update acs_objects +set title = (select constraint_name + from rel_constraints + where constraint_id = object_id) +where object_type = 'rel_constraint'; + +update acs_objects +set title = 'Unregistered Visitor' +where object_id = 0; + +update acs_objects +set title = 'Default Context' +where object_id = -3; + +update acs_objects +set title = 'Root Security Context' +where object_id = -4; + +------------------------ +-- ACS_OBJECT PACKAGE -- +------------------------ + +drop function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,boolean); +drop function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer); + +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,boolean,varchar,integer) +returns integer as ' +declare + new__object_id alias for $1; -- default null + new__object_type alias for $2; -- default ''acs_object'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__context_id alias for $6; -- default null + new__security_inherit_p alias for $7; -- default ''t'' + new__title alias for $8; -- default null + new__package_id alias for $9; -- default null + v_object_id acs_objects.object_id%TYPE; + v_creation_date timestamptz; + v_title acs_objects.title%TYPE; + v_object_type_pretty_name acs_object_types.pretty_name%TYPE; +begin + if new__object_id is null then + select acs_object_id_seq.nextval + into v_object_id from dual; + else + v_object_id := new__object_id; + end if; + + if new__object_id is null then + select pretty_name + into v_object_type_pretty_name + from acs_object_types + where object_type = new__object_type; + + v_title := v_object_type_pretty_name || '' '' || v_object_id; + else + v_title := new__title; + end if; + + if new__creation_date is null then + v_creation_date:= now(); + else + v_creation_date := new__creation_date; + end if; + + insert into acs_objects + (object_id, object_type, title, package_id, context_id, + creation_date, creation_user, creation_ip, security_inherit_p) + values + (v_object_id, new__object_type, v_title, new__package_id, new__context_id, + v_creation_date, new__creation_user, new__creation_ip, + new__security_inherit_p); + + PERFORM acs_object__initialize_attributes(v_object_id); + + return v_object_id; + +end;' language 'plpgsql'; + +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer) +returns integer as ' +declare + new__object_id alias for $1; -- default null + new__object_type alias for $2; -- default ''acs_object'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__context_id alias for $6; -- default null + v_object_id acs_objects.object_id%TYPE; + v_creation_date timestamptz; +begin + return acs_object__new(new__object_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + ''t'', null, null); +end;' language 'plpgsql'; + +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,boolean) +returns integer as ' +declare + new__object_id alias for $1; -- default null + new__object_type alias for $2; -- default ''acs_object'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__context_id alias for $6; -- default null + new__security_inherit_p alias for $7; -- default ''t'' +begin + return acs_object__new(new__object_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + new__security_inherit_p, null, null); +end;' language 'plpgsql'; + +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,boolean,varchar) +returns integer as ' +declare + new__object_id alias for $1; -- default null + new__object_type alias for $2; -- default ''acs_object'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__context_id alias for $6; -- default null + new__security_inherit_p alias for $7; -- default ''t'' + new__title alias for $8; -- default null +begin + return acs_object__new(new__object_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + new__security_inherit_p, new__title, null); +end;' language 'plpgsql'; + +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,varchar,integer) +returns integer as ' +declare + new__object_id alias for $1; -- default null + new__object_type alias for $2; -- default ''acs_object'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__context_id alias for $6; -- default null + new__title alias for $7; -- default null + new__package_id alias for $8; -- default null +begin + return acs_object__new(new__object_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + ''t'', new__title, new__package_id); +end;' language 'plpgsql'; + +create or replace function acs_object__new (integer,varchar,timestamptz,integer,varchar,integer,varchar) +returns integer as ' +declare + new__object_id alias for $1; -- default null + new__object_type alias for $2; -- default ''acs_object'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__context_id alias for $6; -- default null + new__title alias for $7; -- default null +begin + return acs_object__new(new__object_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + ''t'', new__title, null); +end;' language 'plpgsql'; + +drop function acs_object__name (integer); + +create function acs_object__name (integer) +returns varchar as ' +declare + name__object_id alias for $1; + object_name varchar; + v_object_id integer; + obj_type record; + obj record; +begin + -- Find the name function for this object, which is stored in the + -- name_method column of acs_object_types. Starting with this + -- object''s actual type, traverse the type hierarchy upwards until + -- a non-null name_method value is found. + -- + -- select name_method + -- from acs_object_types + -- start with object_type = (select object_type + -- from acs_objects o + -- where o.object_id = name__object_id) + -- connect by object_type = prior supertype + + select title into object_name + from acs_objects + where object_id = name__object_id; + + if (object_name is not null) then + return object_name; + end if; + + for obj_type + in select o2.name_method + from acs_object_types o1, acs_object_types o2 + where o1.object_type = (select object_type + from acs_objects o + where o.object_id = name__object_id) + and o1.tree_sortkey between o2.tree_sortkey and tree_right(o2.tree_sortkey) + order by o2.tree_sortkey desc + loop + if obj_type.name_method != '''' and obj_type.name_method is NOT null then + + -- Execute the first name_method we find (since we''re traversing + -- up the type hierarchy from the object''s exact type) using + -- Native Dynamic SQL, to ascertain the name of this object. + -- + --execute ''select '' || object_type.name_method || ''(:1) from dual'' + + for obj in execute ''select '' || obj_type.name_method || ''('' || name__object_id || '')::varchar as object_name'' loop + object_name := obj.object_name; + exit; + end loop; + + exit; + end if; + end loop; + + return object_name; + +end;' language 'plpgsql' stable strict; + +-- function package_id +create or replace function acs_object__package_id (integer) +returns integer as ' +declare + p_object_id alias for $1; + v_package_id acs_objects.package_id%TYPE; +begin + if p_object_id is null then + return null; + end if; + + select package_id into v_package_id + from acs_objects + where object_id = p_object_id; + + return v_package_id; +end;' language 'plpgsql' stable strict; + + +------- +-- Acs_Rels +------- + +drop function acs_rel__new (integer,varchar,integer,integer,integer,integer,varchar); + +create function acs_rel__new (integer,varchar,integer,integer,integer,integer,varchar) +returns integer as ' +declare + new__rel_id alias for $1; -- default null + new__rel_type alias for $2; -- default ''relationship'' + new__object_id_one alias for $3; + new__object_id_two alias for $4; + context_id alias for $5; -- default null + creation_user alias for $6; -- default null + creation_ip alias for $7; -- default null + v_rel_id acs_rels.rel_id%TYPE; +begin + -- XXX This should check that object_id_one and object_id_two are + -- of the appropriate types. + v_rel_id := acs_object__new ( + new__rel_id, + new__rel_type, + now(), + creation_user, + creation_ip, + context_id, + ''t'', + new__rel_type || '': '' || new__object_id_one || '' - '' || new__object_id_two, + null + ); + + insert into acs_rels + (rel_id, rel_type, object_id_one, object_id_two) + values + (v_rel_id, new__rel_type, new__object_id_one, new__object_id_two); + + return v_rel_id; + +end;' language 'plpgsql'; + +--------- +-- APM +--------- + +drop function apm__register_parameter (integer,varchar,varchar,varchar,varchar,varchar,varchar,integer,integer); + +create or replace function apm__register_parameter (integer,varchar,varchar,varchar,varchar,varchar,varchar,integer,integer) +returns integer as ' +declare + register_parameter__parameter_id alias for $1; -- default null + register_parameter__package_key alias for $2; + register_parameter__parameter_name alias for $3; + register_parameter__description alias for $4; -- default null + register_parameter__datatype alias for $5; -- default ''string'' + register_parameter__default_value alias for $6; -- default null + register_parameter__section_name alias for $7; -- default null + register_parameter__min_n_values alias for $8; -- default 1 + register_parameter__max_n_values alias for $9; -- default 1 + + v_parameter_id apm_parameters.parameter_id%TYPE; + cur_val record; +begin + -- Create the new parameter. + v_parameter_id := acs_object__new( + register_parameter__parameter_id, + ''apm_parameter'', + now(), + null, + null, + null, + ''t'', + register_paramer__package_key || '': Parameter '' || register_parameter__parameter_name, + null + ); + + insert into apm_parameters + (parameter_id, parameter_name, description, package_key, datatype, + default_value, section_name, min_n_values, max_n_values) + values + (v_parameter_id, register_parameter__parameter_name, + register_parameter__description, register_parameter__package_key, + register_parameter__datatype, register_parameter__default_value, + register_parameter__section_name, register_parameter__min_n_values, + register_parameter__max_n_values); + + -- Propagate parameter to new instances. + for cur_val in select ap.package_id, p.parameter_id, p.default_value + from apm_parameters p left outer join apm_parameter_values v + using (parameter_id), apm_packages ap + where p.package_key = ap.package_key + and v.attr_value is null + and p.package_key = register_parameter__package_key + loop + PERFORM apm__set_value( + cur_val.parameter_id, + cur_val.package_id, + cur_val.default_value + ); + end loop; + + return v_parameter_id; + +end;' language 'plpgsql'; + +drop function apm__update_parameter (integer,varchar,varchar,varchar,varchar,varchar,integer,integer); + +create or replace function apm__update_parameter (integer,varchar,varchar,varchar,varchar,varchar,integer,integer) +returns varchar as ' +declare + update_parameter__parameter_id alias for $1; + update_parameter__parameter_name alias for $2; -- default null + update_parameter__description alias for $3; -- default null + update_parameter__datatype alias for $4; -- default ''string'' + update_parameter__default_value alias for $5; -- default null + update_parameter__section_name alias for $6; -- default null + update_parameter__min_n_values alias for $7; -- default 1 + update_parameter__max_n_values alias for $8; -- default 1 +begin + update apm_parameters + set parameter_name = coalesce(update_parameter__parameter_name, parameter_name), + default_value = coalesce(update_parameter__default_value, default_value), + datatype = coalesce(update_parameter__datatype, datatype), + description = coalesce(update_parameter__description, description), + section_name = coalesce(update_parameter__section_name, section_name), + min_n_values = coalesce(update_parameter__min_n_values, min_n_values), + max_n_values = coalesce(update_parameter__max_n_values, max_n_values) + where parameter_id = update_parameter__parameter_id; + + update acs_objects + set title = (select package_key || '': Parameter '' || parameter_name + from apm_parameters + where parameter_id = update_parameter__parameter_id) + where object_id = update_parameter__parameter_id; + + return parameter_id; + +end;' language 'plpgsql'; + +drop function apm_package__new (integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer); + +create or replace function apm_package__new (integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer) +returns integer as ' +declare + new__package_id alias for $1; -- default null + new__instance_name alias for $2; -- default null + new__package_key alias for $3; + new__object_type alias for $4; -- default ''apm_package'' + new__creation_date alias for $5; -- default now() + new__creation_user alias for $6; -- default null + new__creation_ip alias for $7; -- default null + new__context_id alias for $8; -- default null + v_singleton_p integer; + v_package_type apm_package_types.package_type%TYPE; + v_num_instances integer; + v_package_id apm_packages.package_id%TYPE; + v_instance_name apm_packages.instance_name%TYPE; +begin + v_singleton_p := apm_package__singleton_p( + new__package_key + ); + v_num_instances := apm_package__num_instances( + new__package_key + ); + + if v_singleton_p = 1 and v_num_instances >= 1 then + select package_id into v_package_id + from apm_packages + where package_key = new__package_key; + + return v_package_id; + else + v_package_id := acs_object__new( + new__package_id, + new__object_type, + new__creation_date, + new__creation_user, + new__creation_ip, + new__context_id + ); + if new__instance_name is null or new__instance_name = '''' then + v_instance_name := new__package_key || '' '' || v_package_id; + else + v_instance_name := new__instance_name; + end if; + + update acs_objects + set title = v_instance_name, + package_id = v_package_id + where object_id = v_package_id; + + select package_type into v_package_type + from apm_package_types + where package_key = new__package_key; + + insert into apm_packages + (package_id, package_key, instance_name) + values + (v_package_id, new__package_key, v_instance_name); + + if v_package_type = ''apm_application'' then + insert into apm_applications + (application_id) + values + (v_package_id); + else + insert into apm_services + (service_id) + values + (v_package_id); + end if; + + PERFORM apm_package__initialize_parameters( + v_package_id, + new__package_key + ); + + return v_package_id; + + end if; +end;' language 'plpgsql'; + +drop function apm_package_version__new (integer,varchar,varchar,varchar,varchar,varchar,varchar,timestamptz,varchar,varchar,varchar,boolean,boolean); + +create or replace function apm_package_version__new (integer,varchar,varchar,varchar,varchar,varchar,varchar,timestamptz,varchar,varchar,varchar,boolean,boolean) returns integer as ' +declare + apm_pkg_ver__version_id alias for $1; -- default null + apm_pkg_ver__package_key alias for $2; + apm_pkg_ver__version_name alias for $3; -- default null + apm_pkg_ver__version_uri alias for $4; + apm_pkg_ver__summary alias for $5; + apm_pkg_ver__description_format alias for $6; + apm_pkg_ver__description alias for $7; + apm_pkg_ver__release_date alias for $8; + apm_pkg_ver__vendor alias for $9; + apm_pkg_ver__vendor_uri alias for $10; + apm_pkg_ver__auto_mount alias for $11; + apm_pkg_ver__installed_p alias for $12; -- default ''f'' + apm_pkg_ver__data_model_loaded_p alias for $13; -- default ''f'' + v_version_id apm_package_versions.version_id%TYPE; +begin + if apm_pkg_ver__version_id is null then + select nextval(''t_acs_object_id_seq'') + into v_version_id + from dual; + else + v_version_id := apm_pkg_ver__version_id; + end if; + + v_version_id := acs_object__new( + v_version_id, + ''apm_package_version'', + now(), + null, + null, + null, + ''t'', + apm_pkg_ver__package_key || '', Version '' || apm_pkg_ver__version_name, + null + ); + + insert into apm_package_versions + (version_id, package_key, version_name, version_uri, summary, description_format, description, + release_date, vendor, vendor_uri, auto_mount, installed_p, data_model_loaded_p) + values + (v_version_id, apm_pkg_ver__package_key, apm_pkg_ver__version_name, + apm_pkg_ver__version_uri, apm_pkg_ver__summary, + apm_pkg_ver__description_format, apm_pkg_ver__description, + apm_pkg_ver__release_date, apm_pkg_ver__vendor, apm_pkg_ver__vendor_uri, apm_pkg_ver__auto_mount, + apm_pkg_ver__installed_p, apm_pkg_ver__data_model_loaded_p); + + return v_version_id; + +end;' language 'plpgsql'; + +drop function apm_package_version__copy (integer,integer,varchar,varchar,boolean); + +create or replace function apm_package_version__copy (integer,integer,varchar,varchar,boolean) +returns integer as ' +declare + copy__version_id alias for $1; + copy__new_version_id alias for $2; -- default null + copy__new_version_name alias for $3; + copy__new_version_uri alias for $4; + copy__copy_owners_p alias for $5; + v_version_id integer; +begin + v_version_id := acs_object__new( + copy__new_version_id, + ''apm_package_version'', + now(), + null, + null, + null + ); + + insert into apm_package_versions(version_id, package_key, version_name, + version_uri, summary, description_format, description, + release_date, vendor, vendor_uri, auto_mount) + select v_version_id, package_key, copy__new_version_name, + copy__new_version_uri, summary, description_format, description, + release_date, vendor, vendor_uri, auto_mount + from apm_package_versions + where version_id = copy__version_id; + + update acs_objects + set title = (select v.package_key || '', Version '' || v.version_name + from apm_package_versions v + where v.version_id = copy__version_id) + where object_id = copy__version_id; + + insert into apm_package_dependencies(dependency_id, version_id, dependency_type, service_uri, service_version) + select nextval(''t_acs_object_id_seq''), v_version_id, dependency_type, service_uri, service_version + from apm_package_dependencies + where version_id = copy__version_id; + + insert into apm_package_callbacks (version_id, type, proc) + select v_version_id, type, proc + from apm_package_callbacks + where version_id = copy__version_id; + + if copy__copy_owners_p then + insert into apm_package_owners(version_id, owner_uri, owner_name, sort_key) + select v_version_id, owner_uri, owner_name, sort_key + from apm_package_owners + where version_id = copy__version_id; + end if; + + return v_version_id; + +end;' language 'plpgsql'; + +----------- +-- Authentication +----------- + +drop function authority__new (integer,varchar,varchar,varchar,boolean,integer,integer,integer,varchar,varchar,integer,varchar,varchar,integer,varchar,integer); + +create or replace function authority__new ( + integer, -- authority_id + varchar, -- object_type + varchar, -- short_name + varchar, -- pretty_name + boolean, -- enabled_p + integer, -- sort_order + integer, -- auth_impl_id + integer, -- pwd_impl_id + varchar, -- forgotten_pwd_url + varchar, -- change_pwd_url + integer, -- register_impl_id + varchar, -- register_url + varchar, -- help_contact_text + integer, -- creation_user + varchar, -- creation_ip + integer -- context_id +) +returns integer as ' +declare + p_authority_id alias for $1; -- default null, + p_object_type alias for $2; -- default ''authority'' + p_short_name alias for $3; + p_pretty_name alias for $4; + p_enabled_p alias for $5; -- default ''t'' + p_sort_order alias for $6; + p_auth_impl_id alias for $7; -- default null + p_pwd_impl_id alias for $8; -- default null + p_forgotten_pwd_url alias for $9; -- default null + p_change_pwd_url alias for $10; -- default null + p_register_impl_id alias for $11; -- default null + p_register_url alias for $12; -- default null + p_help_contact_text alias for $13; -- default null, + p_creation_user alias for $14; -- default null + p_creation_ip alias for $15; -- default null + p_context_id alias for $16; -- default null + + v_authority_id integer; + v_object_type varchar; + v_sort_order integer; + +begin + if p_object_type is null then + v_object_type := ''authority''; + else + v_object_type := p_object_type; + end if; + + if p_sort_order is null then + select into v_sort_order max(sort_order) + 1 + from auth_authorities; + else + v_sort_order := p_sort_order; + end if; + + -- Instantiate the ACS Object super type with auditing info + v_authority_id := acs_object__new( + p_authority_id, + v_object_type, + now(), + p_creation_user, + p_creation_ip, + p_context_id, + ''t'', + p_short_name, + null + ); + + insert into auth_authorities (authority_id, short_name, pretty_name, enabled_p, + sort_order, auth_impl_id, pwd_impl_id, + forgotten_pwd_url, change_pwd_url, register_impl_id, + help_contact_text) + values (v_authority_id, p_short_name, p_pretty_name, p_enabled_p, + v_sort_order, p_auth_impl_id, p_pwd_impl_id, + p_forgotten_pwd_url, p_change_pwd_url, p_register_impl_id, + p_help_contact_text); + + return v_authority_id; +end; +' language 'plpgsql'; + + +------------------- +-- PARTY PACKAGE -- +------------------- + +drop function party__new (integer,varchar,timestamptz,integer,varchar,varchar,varchar,integer); + +create or replace function party__new (integer,varchar,timestamptz,integer,varchar,varchar,varchar,integer) +returns integer as ' +declare + new__party_id alias for $1; -- default null + new__object_type alias for $2; -- default ''party'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__email alias for $6; + new__url alias for $7; -- default null + new__context_id alias for $8; -- default null + v_party_id parties.party_id%TYPE; +begin + v_party_id := + acs_object__new(new__party_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__context_id, + ''t'', new__email, null); + + insert into parties + (party_id, email, url) + values + (v_party_id, lower(new__email), new__url); + + return v_party_id; + +end;' language 'plpgsql'; + +-------------------- +-- PERSON PACKAGE -- +-------------------- + +drop function person__new (integer,varchar,timestamptz,integer,varchar,varchar,varchar,varchar,varchar,integer); + +create or replace function person__new (integer,varchar,timestamptz,integer,varchar,varchar,varchar,varchar,varchar,integer) +returns integer as ' +declare + new__person_id alias for $1; -- default null + new__object_type alias for $2; -- default ''person'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__email alias for $6; + new__url alias for $7; -- default null + new__first_names alias for $8; + new__last_name alias for $9; + new__context_id alias for $10; -- default null + v_person_id persons.person_id%TYPE; +begin + v_person_id := + party__new(new__person_id, new__object_type, + new__creation_date, new__creation_user, new__creation_ip, + new__email, new__url, new__context_id); + + update acs_objects + set title = new__first_names || '' '' || new__last_name + where object_id = v_person_id; + + insert into persons + (person_id, first_names, last_name) + values + (v_person_id, new__first_names, new__last_name); + + return v_person_id; + +end;' language 'plpgsql'; + +--------- +-- Acs Groups +--------- + +drop function acs_group__new (integer,varchar,timestamptz,integer,varchar,varchar,varchar,varchar,varchar,integer); + +create or replace function acs_group__new (integer,varchar,timestamptz,integer,varchar,varchar,varchar,varchar,varchar,integer) +returns integer as ' +declare + new__group_id alias for $1; -- default null + new__object_type alias for $2; -- default ''group'' + new__creation_date alias for $3; -- default now() + new__creation_user alias for $4; -- default null + new__creation_ip alias for $5; -- default null + new__email alias for $6; -- default null + new__url alias for $7; -- default null + new__group_name alias for $8; + new__join_policy alias for $9; -- default null + new__context_id alias for $10; -- default null + v_group_id groups.group_id%TYPE; + v_group_type_exists_p integer; + v_join_policy groups.join_policy%TYPE; +begin + v_group_id := + party__new(new__group_id, new__object_type, new__creation_date, + new__creation_user, new__creation_ip, new__email, + new__url, new__context_id); + + v_join_policy := new__join_policy; + + -- if join policy was not specified, select the default based on group type + if v_join_policy is null or v_join_policy = '''' then + select count(*) into v_group_type_exists_p + from group_types + where group_type = new__object_type; + + if v_group_type_exists_p = 1 then + select default_join_policy into v_join_policy + from group_types + where group_type = new__object_type; + else + v_join_policy := ''open''; + end if; + end if; + + update acs_objects + set title = new__group_name + where object_id = v_group_id; + + insert into groups + (group_id, group_name, join_policy) + values + (v_group_id, new__group_name, v_join_policy); + + -- setup the permissible relationship types for this group + + -- DRB: we have to call nextval() directly because the select may + -- return more than one row. The sequence hack will only compute + -- one nextval value causing the insert to fail ("may" in PG, which + -- is actually broken. It should ALWAYS return exactly one value for + -- the view. In PG it may or may not depending on the optimizer''s + -- mood. PG group seems uninterested in acknowledging the fact that + -- this is a bug) + + insert into group_rels + (group_rel_id, group_id, rel_type) + select nextval(''t_acs_object_id_seq''), v_group_id, g.rel_type + from group_type_rels g + where g.group_type = new__object_type; + + return v_group_id; + +end;' language 'plpgsql'; + +-------- +-- Journal +-------- + +drop function journal_entry__new (integer,integer,varchar,varchar,timestamptz,integer,varchar,varchar); + +create function journal_entry__new (integer,integer,varchar,varchar,timestamptz,integer,varchar,varchar) +returns integer as ' +declare + new__journal_id alias for $1; -- default null + new__object_id alias for $2; + new__action alias for $3; + new__action_pretty alias for $4; -- default null + new__creation_date alias for $5; -- default now() + new__creation_user alias for $6; -- default null + new__creation_ip alias for $7; -- default null + new__msg alias for $8; -- default null + v_journal_id journal_entries.journal_id%TYPE; +begin + v_journal_id := acs_object__new ( + new__journal_id, + ''journal_entry'', + new__creation_date, + new__creation_user, + new__creation_ip, + new__object_id, + ''t'', + new__action, + null + ); + + insert into journal_entries ( + journal_id, object_id, action, action_pretty, msg + ) values ( + v_journal_id, new__object_id, new__action, + new__action_pretty, new__msg + ); + + return v_journal_id; + +end;' language 'plpgsql'; + +-------- +-- Rel Segments +-------- + +drop function rel_segment__new (integer,varchar,timestamptz,integer,varchar,varchar,varchar,varchar,integer,varchar,integer); + +create or replace function rel_segment__new (integer,varchar,timestamptz,integer,varchar,varchar,varchar,varchar,integer,varchar,integer) +returns integer as ' +declare + new__segment_id alias for $1; -- default null + object_type alias for $2; -- default ''rel_segment'' + creation_date alias for $3; -- default now() + creation_user alias for $4; -- default null + creation_ip alias for $5; -- default null + email alias for $6; -- default null + url alias for $7; -- default null + new__segment_name alias for $8; + new__group_id alias for $9; + new__rel_type alias for $10; + context_id alias for $11; -- default null + v_segment_id rel_segments.segment_id%TYPE; +begin + v_segment_id := + party__new(new__segment_id, object_type, creation_date, creation_user, + creation_ip, email, url, context_id); + + update acs_objects + set title = new__segment_name + where object_id = v_segment_id; + + insert into rel_segments + (segment_id, segment_name, group_id, rel_type) + values + (v_segment_id, new__segment_name, new__group_id, new__rel_type); + + return v_segment_id; + +end;' language 'plpgsql'; + +-------- +-- Rel Constraints +-------- + +drop function rel_constraint__new (integer,varchar,varchar,integer,char,integer,integer,integer,varchar); + +create or replace function rel_constraint__new (integer,varchar,varchar,integer,char,integer,integer,integer,varchar) +returns integer as ' +declare + new__constraint_id alias for $1; -- default null + new__constraint_type alias for $2; -- default ''rel_constraint'' + new__constraint_name alias for $3; + new__rel_segment alias for $4; + new__rel_side alias for $5; -- default ''two'' + new__required_rel_segment alias for $6; + new__context_id alias for $7; -- default null + new__creation_user alias for $8; -- default null + new__creation_ip alias for $9; -- default null + v_constraint_id rel_constraints.constraint_id%TYPE; +begin + v_constraint_id := acs_object__new ( + new__constraint_id, + new__constraint_type, + now(), + new__creation_user, + new__creation_ip, + new__context_id, + ''t'', + new__constraint_name, + null + ); + + insert into rel_constraints + (constraint_id, constraint_name, + rel_segment, rel_side, required_rel_segment) + values + (v_constraint_id, new__constraint_name, + new__rel_segment, new__rel_side, new__required_rel_segment); + + return v_constraint_id; + +end;' language 'plpgsql'; + +-------- +-- Site Nodes +-------- + +drop function site_node__new (integer,integer,varchar,integer,boolean,boolean,integer,varchar); + +create or replace function site_node__new (integer,integer,varchar,integer,boolean,boolean,integer,varchar) +returns integer as ' +declare + new__node_id alias for $1; -- default null + new__parent_id alias for $2; -- default null + new__name alias for $3; + new__object_id alias for $4; -- default null + new__directory_p alias for $5; + new__pattern_p alias for $6; -- default ''f'' + new__creation_user alias for $7; -- default null + new__creation_ip alias for $8; -- default null + v_node_id site_nodes.node_id%TYPE; + v_directory_p site_nodes.directory_p%TYPE; +begin + if new__parent_id is not null then + select directory_p into v_directory_p + from site_nodes + where node_id = new__parent_id; + + if v_directory_p = ''f'' then + raise EXCEPTION ''-20000: Node % is not a directory'', new__parent_id; + end if; + end if; + + v_node_id := acs_object__new ( + new__node_id, + ''site_node'', + now(), + new__creation_user, + new__creation_ip, + null, + ''t'', + new__name, + new__object_id + ); + + insert into site_nodes + (node_id, parent_id, name, object_id, directory_p, pattern_p) + values + (v_node_id, new__parent_id, new__name, new__object_id, + new__directory_p, new__pattern_p); + + return v_node_id; + +end;' language 'plpgsql'; Index: openacs-4/packages/acs-mail/sql/oracle/acs-mail-nt-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/oracle/acs-mail-nt-create.sql,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/acs-mail/sql/oracle/acs-mail-nt-create.sql 4 Mar 2004 14:52:42 -0000 1.8 +++ openacs-4/packages/acs-mail/sql/oracle/acs-mail-nt-create.sql 12 Mar 2004 18:48:50 -0000 1.9 @@ -37,7 +37,8 @@ expand_group in char default 'f', subject in acs_mail_bodies.header_subject%TYPE, message in varchar2, - max_retries in integer default 0 + max_retries in integer default 0, + package_id in acs_objects.package_id%TYPE default null ) return acs_mail_queue_messages.message_id%TYPE; -- /** acs_mail_nt.cancel_request @@ -112,7 +113,8 @@ expand_group in char default 'f', subject in acs_mail_bodies.header_subject%TYPE, message in varchar2, - max_retries in integer default 0 + max_retries in integer default 0, + package_id in acs_objects.package_id%TYPE default null ) return acs_mail_queue_messages.message_id%TYPE is cursor c_expanded_cur is @@ -164,16 +166,18 @@ body_from => party_from, body_date => sysdate, header_subject => subject, - creation_user => v_creation_user + creation_user => v_creation_user, + package_id => package_id ); -- create a CR item to stick message into -- for oracle, we need to stick it in a blob v_item_id := content_item.new ( name => 'acs-mail message' || v_body_id, - title => subject, - text => message + title => subject, + text => message, + package_id => package_id ); -- content_item__new makes a CR revision. We need to get that revision @@ -188,7 +192,8 @@ -- queue the message v_message_id := acs_mail_queue_message.new ( body_id => v_body_id, - creation_user => v_creation_user + creation_user => v_creation_user, + package_id => package_id ); -- now put the message into the outgoing queue Index: openacs-4/packages/acs-mail/sql/oracle/acs-mail-packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/oracle/acs-mail-packages-create.sql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/acs-mail/sql/oracle/acs-mail-packages-create.sql 4 Mar 2004 14:52:42 -0000 1.5 +++ openacs-4/packages/acs-mail/sql/oracle/acs-mail-packages-create.sql 12 Mar 2004 18:48:50 -0000 1.6 @@ -153,7 +153,9 @@ 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 + context_id in acs_objects.context_id%TYPE default null, + title in acs_objects.title%TYPE default null + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE is v_object_id acs_objects.object_id%TYPE; @@ -164,9 +166,13 @@ creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - context_id => context_id + context_id => context_id, + title => title, + package_id => package_id ); + insert into acs_mail_gc_objects values ( v_object_id ); + return v_object_id; end new; @@ -203,24 +209,36 @@ 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 + context_id in acs_objects.context_id%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE is v_object_id acs_objects.object_id%TYPE; + v_package_id acs_objects.package_id%TYPE; v_header_message_id acs_mail_bodies.header_message_id%TYPE; begin + if package_id is null then + v_package_id := acs_object.package_id(content_item_id); + else + v_package_id := package_id; + end if; + v_object_id := acs_mail_gc_object.new ( gc_object_id => body_id, object_type => object_type, creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - context_id => context_id + context_id => context_id, + title => substr(header_subject,1,1000), + package_id => v_package_id ); + v_header_message_id := nvl(header_message_id, sysdate || '.' || v_object_id || '@' || utl_inaddr.get_host_name || '.sddd'); + insert into acs_mail_bodies (body_id, body_reply_to, body_from, body_date, header_message_id, header_reply_to, header_subject, header_from, header_to, @@ -229,6 +247,7 @@ (v_object_id, body_reply_to, body_from, body_date, v_header_message_id, header_reply_to, header_subject, header_from, header_to, content_item_id); + return v_object_id; end new; @@ -276,15 +295,18 @@ header_from acs_mail_bodies.header_from%TYPE; header_to acs_mail_bodies.header_to%TYPE; content_item_id acs_mail_bodies.content_item_id%TYPE; + package_id acs_objects.package_id%TYPE; begin select body_reply_to, body_from, body_date, header_reply_to, header_subject, header_from, header_to, - content_item_id + content_item_id, package_id into body_reply_to, body_from, body_date, header_reply_to, header_subject, header_from, header_to, - content_item_id - from acs_mail_bodies - where body_id = old_body_id; + content_item_id, package_id + from acs_mail_bodies b, acs_objects o + where b.body_id = old_body_id + and o.object_id = b.body_id; + v_object_id := acs_mail_body.new ( body_id => body_id, body_reply_to => body_reply_to, @@ -299,7 +321,8 @@ creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - context_id => context_id + context_id => context_id, + package_id => package_id ); return v_object_id; end clone; @@ -331,7 +354,8 @@ 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 + context_id in acs_objects.context_id%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE is v_object_id acs_objects.object_id%TYPE; @@ -342,10 +366,13 @@ creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - context_id => context_id + context_id => context_id, + package_id => package_id ); + insert into acs_mail_multiparts (multipart_id, multipart_kind) values (v_object_id, multipart_kind); + return v_object_id; end new; @@ -409,26 +436,36 @@ function new ( mail_link_id in acs_mail_links.mail_link_id%TYPE default null, body_id in acs_mail_bodies.body_id%TYPE, - 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, - object_type in acs_objects.object_type%TYPE default 'acs_mail_link' + object_type in acs_objects.object_type%TYPE default 'acs_mail_link', + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE is v_object_id acs_objects.object_id%TYPE; + v_package_id acs_objects.package_id%TYPE; begin + if package_id is null then + v_package_id := acs_object.package_id(body_id); + else + v_package_id := package_id; + end if; + v_object_id := acs_object.new ( object_id => mail_link_id, context_id => context_id, creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - object_type => object_type + object_type => object_type, + package_id => package_id ); + insert into acs_mail_links ( mail_link_id, body_id ) values ( v_object_id, body_id ); + return v_object_id; end; Index: openacs-4/packages/acs-mail/sql/oracle/acs-mail-queue-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/oracle/acs-mail-queue-create.sql,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/acs-mail/sql/oracle/acs-mail-queue-create.sql 4 Mar 2004 14:52:42 -0000 1.9 +++ openacs-4/packages/acs-mail/sql/oracle/acs-mail-queue-create.sql 12 Mar 2004 18:48:50 -0000 1.10 @@ -54,12 +54,12 @@ function new ( mail_link_id in acs_mail_links.mail_link_id%TYPE default null, body_id in acs_mail_bodies.body_id%TYPE, - 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, - object_type in acs_objects.object_type%TYPE default 'acs_mail_link' + object_type in acs_objects.object_type%TYPE default 'acs_mail_link', + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE; procedure del ( @@ -75,27 +75,30 @@ function new ( mail_link_id in acs_mail_links.mail_link_id%TYPE default null, body_id in acs_mail_bodies.body_id%TYPE, - 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, - object_type in acs_objects.object_type%TYPE default 'acs_mail_link' + object_type in acs_objects.object_type%TYPE default 'acs_mail_link', + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE is v_object_id acs_objects.object_id%TYPE; begin v_object_id := acs_mail_link.new ( mail_link_id => mail_link_id, - body_id => body_id, + body_id => body_id, context_id => context_id, creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - object_type => object_type + object_type => object_type, + package_id => package_id ); + insert into acs_mail_queue_messages ( message_id ) values ( v_object_id ); + return v_object_id; end; Index: openacs-4/packages/acs-mail/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-mail/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql 12 Mar 2004 18:48:51 -0000 1.3 @@ -0,0 +1,94 @@ +update acs_objects +set title = 'ACS Mail Object ' || object_id +where object_type = 'acs_mail_gc_object'; + +update acs_objects +set title = (select substr(header_subject,1,1000) + from acs_mail_bodies + where body_id = object_id) +where object_type = 'acs_mail_body'; + +update acs_objects +set title = 'ACS Mail Multipart Object ' || object_id +where object_type = 'acs_mail_multipart'; + +update acs_objects +set title = 'ACS Mail Message ' || object_id +where object_type = 'acs_mail_link'; + +update acs_objects +set title = 'Queued Message ' || object_id +where object_type = 'acs_mail_queue_message'; + + +@@ ../acs-mail-packages-create.sql + +create or replace package acs_mail_queue_message +as + + function new ( + mail_link_id in acs_mail_links.mail_link_id%TYPE default null, + body_id in acs_mail_bodies.body_id%TYPE, + 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, + object_type in acs_objects.object_type%TYPE default 'acs_mail_link', + package_id in acs_objects.package_id%TYPE default null + ) return acs_objects.object_id%TYPE; + + procedure del ( + message_id in acs_mail_links.mail_link_id%TYPE + ); +end acs_mail_queue_message; +/ +show errors + +create or replace package body acs_mail_queue_message +as + + function new ( + mail_link_id in acs_mail_links.mail_link_id%TYPE default null, + body_id in acs_mail_bodies.body_id%TYPE, + 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, + object_type in acs_objects.object_type%TYPE default 'acs_mail_link', + package_id in acs_objects.package_id%TYPE default null + ) return acs_objects.object_id%TYPE + is + v_object_id acs_objects.object_id%TYPE; + begin + v_object_id := acs_mail_link.new ( + mail_link_id => mail_link_id, + body_id => body_id, + context_id => context_id, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + object_type => object_type, + package_id => package_id + ); + + insert into acs_mail_queue_messages ( message_id ) + values ( v_object_id ); + + return v_object_id; + end; + + procedure del ( + message_id in acs_mail_links.mail_link_id%TYPE + ) + is + begin + delete from acs_mail_queue_messages + where message_id = acs_mail_queue_message.del.message_id; + acs_mail_link.del(message_id); + end; + +end acs_mail_queue_message; +/ +show errors + +@@ ../acs-mail-nt-create.sql Index: openacs-4/packages/acs-mail/sql/postgresql/acs-mail-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/postgresql/acs-mail-drop.sql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/acs-mail/sql/postgresql/acs-mail-drop.sql 4 Mar 2004 14:52:43 -0000 1.5 +++ openacs-4/packages/acs-mail/sql/postgresql/acs-mail-drop.sql 12 Mar 2004 18:48:51 -0000 1.6 @@ -12,6 +12,8 @@ drop function acs_mail_queue_message__new (integer,integer, integer,timestamptz,integer,varchar,varchar); +drop function acs_mail_queue_message__new (integer,integer, + integer,timestamptz,integer,varchar,varchar,integer); drop function acs_mail_queue_message__delete (integer); drop table acs_mail_queue_incoming; @@ -26,21 +28,29 @@ drop function acs_mail_gc_object__new (integer,varchar,timestamptz,integer, varchar,integer); +drop function acs_mail_gc_object__new (integer,varchar,timestamptz,integer, + varchar,integer,integer); drop function acs_mail_gc_object__delete(integer); drop function acs_mail_body__new (integer,integer,integer,timestamptz,varchar, varchar,text,text,text,integer,varchar,date,integer,varchar,integer); +drop function acs_mail_body__new (integer,integer,integer,timestamptz,varchar, + varchar,text,text,text,integer,varchar,date,integer,varchar,integer,integer); drop function acs_mail_body__delete(integer); drop function acs_mail_body__body_p(integer); drop function acs_mail_body__clone (integer,integer,varchar,timestamptz, integer,varchar,integer); drop function acs_mail_body__set_content_object (integer,integer); drop function acs_mail_multipart__new (integer,varchar,varchar, timestamptz,integer,varchar,integer); +drop function acs_mail_multipart__new (integer,varchar,varchar, + timestamptz,integer,varchar,integer,integer); drop function acs_mail_multipart__delete (integer); drop function acs_mail_multipart__multipart_p (integer); drop function acs_mail_multipart__add_content (integer,integer); drop function acs_mail_link__new (integer,integer,integer,timestamptz, integer,varchar,varchar); +drop function acs_mail_link__new (integer,integer,integer,timestamptz, + integer,varchar,varchar,integer); drop function acs_mail_link__delete (integer); drop function acs_mail_link__link_p (integer); Index: openacs-4/packages/acs-mail/sql/postgresql/acs-mail-nt-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/postgresql/acs-mail-nt-create.sql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/acs-mail/sql/postgresql/acs-mail-nt-create.sql 4 Mar 2004 14:52:43 -0000 1.5 +++ openacs-4/packages/acs-mail/sql/postgresql/acs-mail-nt-create.sql 12 Mar 2004 18:48:51 -0000 1.6 @@ -27,19 +27,20 @@ -- @return The id of the new request -- */ -create function acs_mail_nt__post_request(integer,integer,boolean,varchar,text,integer) +create or replace function acs_mail_nt__post_request(integer,integer,boolean,varchar,text,integer,integer) returns integer as ' declare p_party_from alias for $1; - p_party_to alias for $2; + p_party_to alias for $2; p_expand_group alias for $3; -- default ''f'' - p_subject alias for $4; - p_message alias for $5; + p_subject alias for $4; + p_message alias for $5; p_max_retries alias for $6; -- default 0 + p_package_id alias for $7; -- default null v_header_from acs_mail_bodies.header_from%TYPE; - v_header_to acs_mail_bodies.header_to%TYPE; - v_body_id acs_mail_bodies.body_id%TYPE; - v_item_id cr_items.item_id%TYPE; + v_header_to acs_mail_bodies.header_to%TYPE; + v_body_id acs_mail_bodies.body_id%TYPE; + v_item_id cr_items.item_id%TYPE; v_revision_id cr_revisions.revision_id%TYPE; v_message_id acs_mail_queue_messages.message_id%TYPE; v_header_to_rec record; @@ -74,31 +75,33 @@ -- create a mail body with empty content select acs_mail_body__new ( - null, -- p_body_id - null, -- p_body_reply_to + null, -- p_body_id + null, -- p_body_reply_to p_party_from, -- p_body_from - now(), -- p_body_date - null, -- p_header_message_id - null, -- p_header_reply_to - p_subject, -- p_header_subject - null, -- p_header_from - null, -- p_header_to - null, -- p_content_item_id + now(), -- p_body_date + null, -- p_header_message_id + null, -- p_header_reply_to + p_subject, -- p_header_subject + null, -- p_header_from + null, -- p_header_to + null, -- p_content_item_id ''acs_mail_body'', -- p_object_type - now(), -- p_creation_date + now(), -- p_creation_date v_creation_user, -- p_creation_user - null, -- p_creation_ip - null -- p_context_id + null, -- p_creation_ip + null, -- p_context_id + p_package_id -- p_package_id ) into v_body_id; -- create a CR item to stick p_message into select content_item__new( - ''acs-mail message'' || v_body_id, -- new__name - null, -- new__parent_id - p_subject, -- new__title - null, -- new__description - p_message -- new__text + ''acs-mail message'' || v_body_id, -- new__name + null, -- new__parent_id + p_subject, -- new__title + null, -- new__description + p_message, -- new__text + p_package_id -- new__package_id ) into v_item_id; -- content_item__new makes a CR revision. We need to get that revision @@ -113,13 +116,14 @@ -- queue the message select acs_mail_queue_message__new ( - null, -- p_mail_link_id - v_body_id, -- p_body_id - null, -- p_context_id - now(), -- p_creation_date + null, -- p_mail_link_id + v_body_id, -- p_body_id + null, -- p_context_id + now(), -- p_creation_date v_creation_user, -- p_creation_user - null, -- p_creation_ip - ''acs_mail_link'' -- p_object_type + null, -- p_creation_ip + ''acs_mail_link'', -- p_object_type + p_package_id -- p_package_id ) into v_message_id; -- now put the message into the outgoing queue @@ -155,6 +159,27 @@ return v_message_id; end;' language 'plpgsql'; +create or replace function acs_mail_nt__post_request(integer,integer,boolean,varchar,text,integer) +returns integer as ' +declare + p_party_from alias for $1; + p_party_to alias for $2; + p_expand_group alias for $3; -- default ''f'' + p_subject alias for $4; + p_message alias for $5; + p_max_retries alias for $6; -- default 0 +begin + return acs_mail_nt__post_request( + p_party_from, -- p_party_from + p_party_to, -- p_party_to + p_expand_group, -- p_expand_group + p_subject, -- p_subject + p_message, -- p_message + p_max_retries, -- p_max_retries + null -- p_package_id + ); +end;' language 'plpgsql'; + -- /** acs_mail_nt__post_request -- * Overloaded function that -- * only uses the basic params @@ -166,25 +191,46 @@ -- @param message The body of the message -- @return The id of the new request -- -create function acs_mail_nt__post_request(integer,integer,varchar,text) +create or replace function acs_mail_nt__post_request(integer,integer,varchar,text,integer) returns integer as ' declare p_party_from alias for $1; - p_party_to alias for $2; - p_subject alias for $3; - p_message alias for $4; + p_party_to alias for $2; + p_subject alias for $3; + p_message alias for $4; + p_package_id alias for $5; begin return acs_mail_nt__post_request( p_party_from, -- p_party_from - p_party_to, -- p_party_to - ''f'', -- p_expand_group - p_subject, -- p_subject - p_message, -- p_message - 0 -- p_max_retries + p_party_to, -- p_party_to + ''f'', -- p_expand_group + p_subject, -- p_subject + p_message, -- p_message + 0, -- p_max_retries + p_package_id -- p_package_id ); end;' language 'plpgsql'; +create or replace function acs_mail_nt__post_request(integer,integer,varchar,text) +returns integer as ' +declare + p_party_from alias for $1; + p_party_to alias for $2; + p_subject alias for $3; + p_message alias for $4; +begin + return acs_mail_nt__post_request( + p_party_from, -- p_party_from + p_party_to, -- p_party_to + ''f'', -- p_expand_group + p_subject, -- p_subject + p_message, -- p_message + 0, -- p_max_retries + null -- p_package_id + ); +end;' language 'plpgsql'; + -- /** acs_mail_nt__cancel_request -- * Cancel a notification request -- * Original author: Stanislav Freidin @@ -193,7 +239,7 @@ -- @param request_id Id of the request to cancel -- */ -create function acs_mail_nt__cancel_request (integer) +create or replace function acs_mail_nt__cancel_request (integer) returns integer as ' declare p_message_id alias for $1; @@ -210,7 +256,7 @@ -- @author Vinod Kurup -- */ -create function acs_mail_nt__expand_requests () +create or replace function acs_mail_nt__expand_requests () returns integer as ' begin raise EXCEPTION ''-20000: Procedure no longer supported.''; @@ -225,7 +271,7 @@ -- @author Vinod Kurup -- */ -create function acs_mail_nt__update_requests () +create or replace function acs_mail_nt__update_requests () returns integer as ' begin raise EXCEPTION ''-20000: Procedure no longer supported.''; @@ -240,7 +286,7 @@ -- @author Vinod Kurup -- */ -create function acs_mail_nt__process_queue (varchar,integer) +create or replace function acs_mail_nt__process_queue (varchar,integer) returns integer as ' declare p_host alias for $1; @@ -262,7 +308,7 @@ -- @author Vinod Kurup -- */ -create function acs_mail_nt__schedule_process (numeric,varchar,integer) +create or replace function acs_mail_nt__schedule_process (numeric,varchar,integer) returns integer as ' declare p_interval alias for $1; Index: openacs-4/packages/acs-mail/sql/postgresql/acs-mail-nt-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/postgresql/acs-mail-nt-drop.sql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/acs-mail/sql/postgresql/acs-mail-nt-drop.sql 4 Mar 2004 14:52:43 -0000 1.4 +++ openacs-4/packages/acs-mail/sql/postgresql/acs-mail-nt-drop.sql 12 Mar 2004 18:48:51 -0000 1.5 @@ -10,6 +10,8 @@ drop function acs_mail_nt__post_request(integer,integer,boolean,varchar,text,integer); drop function acs_mail_nt__post_request(integer,integer,varchar,text); +drop function acs_mail_nt__post_request(integer,integer,boolean,varchar,text,integer,integer); +drop function acs_mail_nt__post_request(integer,integer,varchar,text,integer); drop function acs_mail_nt__cancel_request (integer); drop function acs_mail_nt__expand_requests (); drop function acs_mail_nt__update_requests (); Index: openacs-4/packages/acs-mail/sql/postgresql/acs-mail-packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/postgresql/acs-mail-packages-create.sql,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/acs-mail/sql/postgresql/acs-mail-packages-create.sql 4 Mar 2004 14:52:43 -0000 1.8 +++ openacs-4/packages/acs-mail/sql/postgresql/acs-mail-packages-create.sql 12 Mar 2004 18:48:51 -0000 1.9 @@ -8,7 +8,7 @@ -- Package Implementations --------------------------------------------- -create function acs_mail_gc_object__new (integer,varchar,timestamptz,integer,varchar,integer) +create or replace function acs_mail_gc_object__new (integer,varchar,timestamptz,integer,varchar,integer,varchar,integer) returns integer as ' declare p_gc_object_id alias for $1; -- default null @@ -17,6 +17,8 @@ p_creation_user alias for $4; -- default null p_creation_ip alias for $5; -- default null p_context_id alias for $6; -- default null + p_title alias for $7; -- default null + p_package_id alias for $8; -- default null v_object_id integer; begin v_object_id := acs_object__new ( @@ -25,6 +27,35 @@ p_creation_date, -- creation_date p_creation_user, -- creation_user p_creation_ip, -- creation_ip + p_context_id, -- context_id + ''t'', -- security_inherit_p + p_title, -- title + p_package_id -- package_id + ); + + insert into acs_mail_gc_objects values ( v_object_id ); + + return v_object_id; +end; +' language 'plpgsql'; + +create or replace function acs_mail_gc_object__new (integer,varchar,timestamptz,integer,varchar,integer) +returns integer as ' +declare + p_gc_object_id alias for $1; -- default null + p_object_type alias for $2; -- default acs_mail_gc_object + p_creation_date alias for $3; -- default now + p_creation_user alias for $4; -- default null + p_creation_ip alias for $5; -- default null + p_context_id alias for $6; -- default null + v_object_id integer; +begin + v_object_id := acs_object__new ( + p_gc_object_id, -- object_id + p_object_type, -- object_type + p_creation_date, -- creation_date + p_creation_user, -- creation_user + p_creation_ip, -- creation_ip p_context_id -- context_id ); @@ -34,7 +65,7 @@ end; ' language 'plpgsql'; -create function acs_mail_gc_object__delete(integer) +create or replace function acs_mail_gc_object__delete(integer) returns integer as ' declare p_gc_object_id alias for $1; @@ -51,38 +82,48 @@ -- first create a CR item. -- then call acs_mail_body__new with the CR item's item_id -create function acs_mail_body__new (integer,integer,integer,timestamptz,varchar,varchar,text,text,text,integer,varchar,date,integer,varchar,integer) +create or replace function acs_mail_body__new (integer,integer,integer,timestamptz,varchar,varchar,text,text,text,integer,varchar,date,integer,varchar,integer,integer) returns integer as ' declare - p_body_id alias for $1; -- default null + p_body_id alias for $1; -- default null p_body_reply_to alias for $2; -- default null - p_body_from alias for $3; -- default null - p_body_date alias for $4; -- default null + p_body_from alias for $3; -- default null + p_body_date alias for $4; -- default null p_header_message_id alias for $5; -- default null - p_header_reply_to alias for $6; -- default null - p_header_subject alias for $7; -- default null - p_header_from alias for $8; -- default null - p_header_to alias for $9; -- default null - p_content_item_id alias for $10; -- default null - p_object_type alias for $11; -- default acs_mail_body - p_creation_date alias for $12; -- default now() - p_creation_user alias for $13; -- default null - p_creation_ip alias for $14; -- default null - p_context_id alias for $15; -- default null - v_object_id integer; + p_header_reply_to alias for $6; -- default null + p_header_subject alias for $7; -- default null + p_header_from alias for $8; -- default null + p_header_to alias for $9; -- default null + p_content_item_id alias for $10; -- default null + p_object_type alias for $11; -- default acs_mail_body + p_creation_date alias for $12; -- default now() + p_creation_user alias for $13; -- default null + p_creation_ip alias for $14; -- default null + p_context_id alias for $15; -- default null + p_package_id alias for $16; -- default null + v_object_id integer; + v_package_id acs_objects.package_id%TYPE; v_system_url varchar; v_domain_name varchar; - v_idx integer; + v_idx integer; v_header_message_id acs_mail_bodies.header_message_id%TYPE; begin + if p_package_id is null then + v_package_id := acs_object__package_id(p_content_item_id); + else + v_package_id := p_package_id; + end if; + v_object_id := acs_mail_gc_object__new ( - p_body_id, -- gc_object_id - p_object_type, -- object_type - p_creation_date, -- creation_date - p_creation_user, -- creation_user - p_creation_ip, -- creation_ip - p_context_id -- context_id + p_body_id, -- gc_object_id + p_object_type, -- object_type + p_creation_date, -- creation_date + p_creation_user, -- creation_user + p_creation_ip, -- creation_ip + p_context_id, -- context_id + substr(p_header_subject,1,1000), -- title + v_package_id -- package_id ); -- vinodk: get SystemURL parameter and use it to extract domain name @@ -108,8 +149,47 @@ end; ' language 'plpgsql'; +create or replace function acs_mail_body__new (integer,integer,integer,timestamptz,varchar,varchar,text,text,text,integer,varchar,date,integer,varchar,integer) +returns integer as ' +declare + p_body_id alias for $1; -- default null + p_body_reply_to alias for $2; -- default null + p_body_from alias for $3; -- default null + p_body_date alias for $4; -- default null + p_header_message_id alias for $5; -- default null + p_header_reply_to alias for $6; -- default null + p_header_subject alias for $7; -- default null + p_header_from alias for $8; -- default null + p_header_to alias for $9; -- default null + p_content_item_id alias for $10; -- default null + p_object_type alias for $11; -- default acs_mail_body + p_creation_date alias for $12; -- default now() + p_creation_user alias for $13; -- default null + p_creation_ip alias for $14; -- default null + p_context_id alias for $15; -- default null +begin + return acs_mail_body__new(p_body_id, + p_body_reply_to, + p_body_from, + p_body_date, + p_header_message_id, + p_header_reply_to, + p_header_subject, + p_header_from, + p_header_to, + p_content_item_id, + p_object_type, + p_creation_date, + p_creation_user, + p_creation_ip, + p_content_id, + null + ); +end; +' language 'plpgsql'; -create function acs_mail_body__delete(integer) + +create or replace function acs_mail_body__delete(integer) returns integer as ' declare p_body_id alias for $1; @@ -136,7 +216,7 @@ end; ' language 'plpgsql' stable; -create function acs_mail_body__clone (integer,integer,varchar,timestamptz,integer,varchar,integer) +create or replace function acs_mail_body__clone (integer,integer,varchar,timestamptz,integer,varchar,integer) returns integer as ' declare p_old_body_id alias for $1; @@ -156,15 +236,17 @@ v_header_from text; v_header_to text; v_content_item_id integer; + v_package_id acs_objects.package_id%TYPE; begin select body_reply_to, body_from, body_date, header_reply_to, header_subject, header_from, header_to, - content_item_id + content_item_id, package_id into v_body_reply_to, v_body_from, v_body_date, v_header_reply_to, v_header_subject, v_header_from, v_header_to, - v_content_item_id - from acs_mail_bodies - where body_id = p_old_body_id; + v_content_item_id, v_package_id + from acs_mail_bodies b, acs_objects o + where b.body_id = p_old_body_id + and o.object_id = b.body_id; v_object_id := acs_mail_body__new ( p_body_id, -- body_id @@ -179,15 +261,16 @@ p_object_type, -- object_type p_creation_date, -- creation_date p_creation_user, -- creation_user - p_creation_ip, -- creation_ip - p_context_id -- context_id + p_creation_ip, -- creation_ip + p_context_id, -- context_id + v_package_id -- package_id ); return v_object_id; end; ' language 'plpgsql'; -create function acs_mail_body__set_content_object (integer,integer) +create or replace function acs_mail_body__set_content_object (integer,integer) returns integer as ' declare p_body_id alias for $1; @@ -203,18 +286,52 @@ ---- --create or replace package body acs_mail_multipart -create function acs_mail_multipart__new (integer,varchar,varchar, +create or replace function acs_mail_multipart__new (integer,varchar,varchar, +timestamptz,integer,varchar,integer,integer) +returns integer as ' +declare + p_multipart_id alias for $1; -- default null, + p_multipart_kind alias for $2; + p_object_type alias for $3; -- default acs_mail_multipart + p_creation_date alias for $4; -- default now() + p_creation_user alias for $5; -- default null + p_creation_ip alias for $6; -- default null + p_context_id alias for $7; -- default null + p_package_id alias for $8; -- default null + v_object_id integer; +begin + v_object_id := acs_mail_gc_object__new ( + p_multipart_id, -- gc_object_id + p_object_type, -- object_type + p_creation_date, -- creation_date + p_creation_user, -- creation_user + p_creation_ip, -- creation_ip + p_context_id, -- context_id + null, -- title + p_package_id -- package_id + ); + + insert into acs_mail_multiparts + (multipart_id, multipart_kind) + values + (v_object_id, p_multipart_kind); + + return v_object_id; +end; +' language 'plpgsql'; + +create or replace function acs_mail_multipart__new (integer,varchar,varchar, timestamptz,integer,varchar,integer) returns integer as ' declare p_multipart_id alias for $1; -- default null, p_multipart_kind alias for $2; - p_object_type alias for $3; -- default acs_mail_multipart - p_creation_date alias for $4; -- default now() - p_creation_user alias for $5; -- default null - p_creation_ip alias for $6; -- default null - p_context_id alias for $7; -- default null - v_object_id integer; + p_object_type alias for $3; -- default acs_mail_multipart + p_creation_date alias for $4; -- default now() + p_creation_user alias for $5; -- default null + p_creation_ip alias for $6; -- default null + p_context_id alias for $7; -- default null + v_object_id integer; begin v_object_id := acs_mail_gc_object__new ( p_multipart_id, -- gc_object_id @@ -234,7 +351,7 @@ end; ' language 'plpgsql'; -create function acs_mail_multipart__delete (integer) +create or replace function acs_mail_multipart__delete (integer) returns integer as ' declare p_multipart_id alias for $1; @@ -267,7 +384,7 @@ -- below one, or higher than the highest item already available, -- adds at the end. Otherwise, inserts and renumbers others. -create function acs_mail_multipart__add_content (integer,integer) +create or replace function acs_mail_multipart__add_content (integer,integer) returns integer as ' declare p_multipart_id alias for $1; @@ -295,24 +412,58 @@ --end acs_mail_multipart; --create or replace package body acs_mail_link__ -create function acs_mail_link__new (integer,integer,integer,timestamptz,integer,varchar,varchar) +create or replace function acs_mail_link__new (integer,integer,integer,timestamptz,integer,varchar,varchar,integer) returns integer as ' declare p_mail_link_id alias for $1; -- default null - p_body_id alias for $2; + p_body_id alias for $2; p_context_id alias for $3; -- default null p_creation_date alias for $4; -- default now() p_creation_user alias for $5; -- default null p_creation_ip alias for $6; -- default null p_object_type alias for $7; -- default acs_mail_link - v_mail_link_id acs_mail_links.mail_link_id%TYPE; + p_package_id alias for $8; -- default null + v_mail_link_id acs_mail_links.mail_link_id%TYPE; begin v_mail_link_id := acs_object__new ( p_mail_link_id, -- object_id p_object_type, -- object_type p_creation_date, -- creation_date p_creation_user, -- creation_user p_creation_ip, -- creation_ip + p_context_id, -- context_id + ''t'', -- security_inherit_p + null, -- title + p_package_id -- package_id + ); + + insert into acs_mail_links + ( mail_link_id, body_id ) + values + ( v_mail_link_id, p_body_id ); + + return v_mail_link_id; +end; +' language 'plpgsql'; + +create or replace function acs_mail_link__new (integer,integer,integer,timestamptz,integer,varchar,varchar) +returns integer as ' +declare + p_mail_link_id alias for $1; -- default null + p_body_id alias for $2; + p_context_id alias for $3; -- default null + p_creation_date alias for $4; -- default now() + p_creation_user alias for $5; -- default null + p_creation_ip alias for $6; -- default null + p_object_type alias for $7; -- default acs_mail_link + v_mail_link_id acs_mail_links.mail_link_id%TYPE; +begin + v_mail_link_id := acs_object__new ( + p_mail_link_id, -- object_id + p_object_type, -- object_type + p_creation_date, -- creation_date + p_creation_user, -- creation_user + p_creation_ip, -- creation_ip p_context_id -- context_id ); @@ -325,7 +476,7 @@ end; ' language 'plpgsql'; -create function acs_mail_link__delete (integer) +create or replace function acs_mail_link__delete (integer) returns integer as ' declare p_mail_link_id alias for $1; Index: openacs-4/packages/acs-mail/sql/postgresql/acs-mail-queue-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/postgresql/acs-mail-queue-create.sql,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/acs-mail/sql/postgresql/acs-mail-queue-create.sql 4 Mar 2004 14:52:43 -0000 1.10 +++ openacs-4/packages/acs-mail/sql/postgresql/acs-mail-queue-create.sql 12 Mar 2004 18:48:51 -0000 1.11 @@ -49,21 +49,53 @@ -- API ----------------------------------------------------------------- --create or replace package body acs_mail_queue_message__ +create function acs_mail_queue_message__new (integer,integer,integer,timestamptz,integer,varchar,varchar,integer) +returns integer as ' +declare + p_mail_link_id alias for $1; -- default null + p_body_id alias for $2; + p_context_id alias for $3; -- default null + p_creation_date alias for $4; -- default now() + p_creation_user alias for $5; -- default null + p_creation_ip alias for $6; -- default null + p_object_type alias for $7; -- default acs_mail_link + p_package_id alias for $8; -- default null + v_mail_link_id acs_mail_links.mail_link_id%TYPE; +begin + v_mail_link_id := acs_mail_link__new ( + p_mail_link_id, -- mail_link_id + p_body_id, -- body_id + p_context_id, -- context_id + p_creation_date, -- creation_date + p_creation_user, -- creation_user + p_creation_ip, -- creation_ip + p_object_type, -- object_type + p_package_id -- package_id + ); + + insert into acs_mail_queue_messages + ( message_id ) + values + ( v_mail_link_id ); + + return v_mail_link_id; +end;' language 'plpgsql'; + create function acs_mail_queue_message__new (integer,integer,integer,timestamptz,integer,varchar,varchar) returns integer as ' declare p_mail_link_id alias for $1; -- default null - p_body_id alias for $2; + p_body_id alias for $2; p_context_id alias for $3; -- default null p_creation_date alias for $4; -- default now() p_creation_user alias for $5; -- default null p_creation_ip alias for $6; -- default null p_object_type alias for $7; -- default acs_mail_link - v_mail_link_id acs_mail_links.mail_link_id%TYPE; + v_mail_link_id acs_mail_links.mail_link_id%TYPE; begin v_mail_link_id := acs_mail_link__new ( p_mail_link_id, -- mail_link_id - p_body_id, -- body_id + p_body_id, -- body_id p_context_id, -- context_id p_creation_date, -- creation_date p_creation_user, -- creation_user Index: openacs-4/packages/acs-mail/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-mail/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql 12 Mar 2004 18:48:51 -0000 1.3 @@ -0,0 +1,58 @@ +update acs_objects +set title = 'ACS Mail Object ' || object_id +where object_type = 'acs_mail_gc_object'; + +update acs_objects +set title = (select substr(header_subject,1,1000) + from acs_mail_bodies + where body_id = object_id) +where object_type = 'acs_mail_body'; + +update acs_objects +set title = 'ACS Mail Multipart Object ' || object_id +where object_type = 'acs_mail_multipart'; + +update acs_objects +set title = 'ACS Mail Message ' || object_id +where object_type = 'acs_mail_link'; + +update acs_objects +set title = 'Queued Message ' || object_id +where object_type = 'acs_mail_queue_message'; + + +\i ../acs-mail-packages-create.sql + +create function acs_mail_queue_message__new (integer,integer,integer,timestamptz,integer,varchar,varchar,integer) +returns integer as ' +declare + p_mail_link_id alias for $1; -- default null + p_body_id alias for $2; + p_context_id alias for $3; -- default null + p_creation_date alias for $4; -- default now() + p_creation_user alias for $5; -- default null + p_creation_ip alias for $6; -- default null + p_object_type alias for $7; -- default acs_mail_link + p_package_id alias for $8; -- default null + v_mail_link_id acs_mail_links.mail_link_id%TYPE; +begin + v_mail_link_id := acs_mail_link__new ( + p_mail_link_id, -- mail_link_id + p_body_id, -- body_id + p_context_id, -- context_id + p_creation_date, -- creation_date + p_creation_user, -- creation_user + p_creation_ip, -- creation_ip + p_object_type, -- object_type + p_package_id -- package_id + ); + + insert into acs_mail_queue_messages + ( message_id ) + values + ( v_mail_link_id ); + + return v_mail_link_id; +end;' language 'plpgsql'; + +\i ../acs-mail-nt-create.sql Index: openacs-4/packages/acs-messaging/sql/oracle/acs-messaging-packages.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-messaging/sql/oracle/acs-messaging-packages.sql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-messaging/sql/oracle/acs-messaging-packages.sql 4 Mar 2004 14:52:44 -0000 1.6 +++ openacs-4/packages/acs-messaging/sql/oracle/acs-messaging-packages.sql 12 Mar 2004 18:48:51 -0000 1.7 @@ -27,7 +27,8 @@ creation_user in acs_objects.creation_user%TYPE default null, creation_ip in acs_objects.creation_ip%TYPE default null, object_type in acs_objects.object_type%TYPE default 'acs_message', - is_live in char default 't' + is_live in char default 't', + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE; function edit ( @@ -88,7 +89,8 @@ creation_user in acs_objects.creation_user%TYPE default null, creation_ip in acs_objects.creation_ip%TYPE default null, is_live in char default 't', - storage_type in cr_items.storage_type%TYPE default 'file' + storage_type in cr_items.storage_type%TYPE default 'file', + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE; function edit_file ( @@ -121,7 +123,8 @@ creation_user in acs_objects.creation_user%TYPE default null, creation_ip in acs_objects.creation_ip%TYPE default null, is_live in char default 't', - storage_type in cr_items.storage_type%TYPE default 'file' + storage_type in cr_items.storage_type%TYPE default 'file', + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE; function edit_image ( @@ -151,7 +154,8 @@ parent_id in acs_objects.context_id%TYPE, 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 + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return cr_extlinks.extlink_id%TYPE; function edit_extlink ( @@ -193,7 +197,8 @@ creation_user in acs_objects.creation_user%TYPE default null, creation_ip in acs_objects.creation_ip%TYPE default null, object_type in acs_objects.object_type%TYPE default 'acs_message', - is_live in char default 't' + is_live in char default 't', + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE is v_message_id acs_messages.message_id%TYPE; @@ -226,7 +231,8 @@ creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - item_subtype => object_type + item_subtype => object_type, + package_id => package_id ); insert into acs_messages @@ -394,7 +400,8 @@ creation_user in acs_objects.creation_user%TYPE default null, creation_ip in acs_objects.creation_ip%TYPE default null, is_live in char default 't', - storage_type in cr_items.storage_type%TYPE default 'file' + storage_type in cr_items.storage_type%TYPE default 'file', + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE is v_file_id cr_items.item_id%TYPE; @@ -408,7 +415,8 @@ creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - storage_type => storage_type + storage_type => storage_type, + package_id => package_id ); -- create an initial revision for the new attachment @@ -482,7 +490,8 @@ creation_user in acs_objects.creation_user%TYPE default null, creation_ip in acs_objects.creation_ip%TYPE default null, is_live in char default 't', - storage_type in cr_items.storage_type%TYPE default 'file' + storage_type in cr_items.storage_type%TYPE default 'file', + package_id in acs_objects.package_id%TYPE default null ) return acs_objects.object_id%TYPE is v_image_id cr_items.item_id%TYPE; @@ -496,7 +505,8 @@ creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - storage_type => storage_type + storage_type => storage_type, + package_id => package_id ); -- create an initial revision for the new attachment @@ -580,7 +590,8 @@ parent_id in acs_objects.context_id%TYPE, 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 + creation_ip in acs_objects.creation_ip%TYPE default null, + package_id in acs_objects.package_id%TYPE default null ) return cr_extlinks.extlink_id%TYPE is v_extlink_id cr_extlinks.extlink_id%TYPE; @@ -594,7 +605,8 @@ extlink_id => new_extlink.extlink_id, creation_date => new_extlink.creation_date, creation_user => new_extlink.creation_user, - creation_ip => new_extlink.creation_ip + creation_ip => new_extlink.creation_ip, + package_id => new_extlink.package_id ); end new_extlink; Index: openacs-4/packages/acs-messaging/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-messaging/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-messaging/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql 12 Mar 2004 18:48:52 -0000 1.3 @@ -0,0 +1,8 @@ +update acs_objects +set title = (select name + from cr_items + where item_id = object_id), +package_id = acs_object__package_id(content_item.get_root_folder(object_id)) +where object_type = 'acs_message'; + +@@ ../acs-messaging-packages.sql Index: openacs-4/packages/acs-messaging/sql/postgresql/acs-messaging-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-messaging/sql/postgresql/acs-messaging-drop.sql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-messaging/sql/postgresql/acs-messaging-drop.sql 4 Mar 2004 14:52:44 -0000 1.6 +++ openacs-4/packages/acs-messaging/sql/postgresql/acs-messaging-drop.sql 12 Mar 2004 18:48:52 -0000 1.7 @@ -17,6 +17,9 @@ drop function acs_message__new (integer,integer,timestamptz,integer, varchar,varchar,varchar,varchar,varchar,text, integer,integer,integer,varchar,varchar,boolean); +drop function acs_message__new (integer,integer,timestamptz,integer, + varchar,varchar,varchar,varchar,varchar,text, + integer,integer,integer,varchar,varchar,boolean,integer); drop function acs_message__delete (integer); drop function acs_message__message_p (integer); drop function acs_message__send (integer,varchar,integer,timestamptz); @@ -25,18 +28,26 @@ drop function acs_message__new_file (integer,integer,varchar,varchar, text,varchar,text,timestamptz,integer, varchar,boolean); +drop function acs_message__new_file (integer,integer,varchar,varchar, + text,varchar,text,timestamptz,integer, + varchar,boolean,integer); drop function acs_message__edit_file (integer,varchar,text,varchar, text,timestamptz,integer,varchar,boolean); drop function acs_message__delete_file (integer); drop function acs_message__new_image (integer,integer,varchar,varchar, text,varchar,text,integer,integer, timestamptz,integer,varchar,boolean); +drop function acs_message__new_image (integer,integer,varchar,varchar, + text,varchar,text,integer,integer, + timestamptz,integer,varchar,boolean,integer); drop function acs_message__edit_image (integer,varchar,text,varchar, text,integer,integer,timestamptz,integer, varchar,boolean); drop function acs_message__delete_image (integer); drop function acs_message__new_extlink (varchar,integer,varchar,varchar,text, integer,timestamptz,integer,varchar); +drop function acs_message__new_extlink (varchar,integer,varchar,varchar,text, + integer,timestamptz,integer,varchar,integer); drop function acs_message__edit_extlink (integer,varchar,varchar,text); drop function acs_message__delete_extlink (integer); drop function acs_message__name (integer); Index: openacs-4/packages/acs-messaging/sql/postgresql/acs-messaging-packages.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-messaging/sql/postgresql/acs-messaging-packages.sql,v diff -u -N -r1.16 -r1.17 --- openacs-4/packages/acs-messaging/sql/postgresql/acs-messaging-packages.sql 4 Mar 2004 14:52:44 -0000 1.16 +++ openacs-4/packages/acs-messaging/sql/postgresql/acs-messaging-packages.sql 12 Mar 2004 18:48:52 -0000 1.17 @@ -29,28 +29,28 @@ if p_data is not null then -- need to take care of blob? v_revision_id := content_revision__new ( - p_message_id, -- item_id - p_title, -- title - p_description, -- description - p_data, -- data - p_mime_type, -- mime_type + p_message_id, -- item_id + p_title, -- title + p_description, -- description + p_data, -- data + p_mime_type, -- mime_type p_creation_date, -- creation_date p_creation_user, -- creation_user - p_creation_ip -- creation_ip + p_creation_ip -- creation_ip ); else if p_title is not null or p_text is not null then v_revision_id := content_revision__new ( - p_title, -- title - p_description, -- description - now(), -- publish_date - p_mime_type, -- mime_type - null, -- nls_language - p_text, -- text - p_message_id, -- item_id - null, -- revision_id + p_title, -- title + p_description, -- description + now(), -- publish_date + p_mime_type, -- mime_type + null, -- nls_language + p_text, -- text + p_message_id, -- item_id + null, -- revision_id p_creation_date, -- creation_date p_creation_user, -- creation_user - p_creation_ip -- creation_ip + p_creation_ip -- creation_ip ); end if; end if; @@ -75,7 +75,7 @@ create or replace function acs_message__new (integer,integer,timestamptz,integer, varchar,varchar,varchar,varchar,text,integer,integer,integer,integer, -varchar,varchar,boolean) +varchar,varchar,boolean,integer) returns integer as ' declare p_message_id alias for $1; --default null, @@ -95,6 +95,7 @@ p_creation_ip alias for $14; --default null, p_object_type alias for $15; --default ''acs_message'', p_is_live alias for $16; --default ''t'' + p_package_id alias for $17; v_message_id acs_messages.message_id%TYPE; v_rfc822_id acs_messages.rfc822_id%TYPE; v_revision_id cr_revisions.revision_id%TYPE; @@ -127,22 +128,23 @@ end if; v_message_id := content_item__new ( - v_rfc822_id, -- name - p_parent_id, -- parent_id - p_message_id, -- item_id - null, -- locale + v_rfc822_id, -- name + p_parent_id, -- parent_id + p_message_id, -- item_id + null, -- locale p_creation_date, -- creation_date p_creation_user, -- creation_user - p_context_id, -- context_id - p_creation_ip, -- creation_ip - p_object_type, -- item_subtype - ''acs_message_revision'', -- content_type - null, -- title - null, -- description - ''text/plain'', -- mime_type - null, -- nls_language - null, -- text - ''text'' -- storage_type + p_context_id, -- context_id + p_creation_ip, -- creation_ip + p_object_type, -- item_subtype + ''acs_message_revision'', -- content_type + null, -- title + null, -- description + ''text/plain'', -- mime_type + null, -- nls_language + null, -- text + ''text'', -- storage_type + p_package_id ); insert into acs_messages @@ -152,21 +154,65 @@ -- create an initial revision for the new message v_revision_id := acs_message__edit ( - v_message_id, -- message_id - p_title, -- title - p_description, -- description - p_mime_type, -- mime_type - p_text, -- text - p_data, -- data + v_message_id, -- message_id + p_title, -- title + p_description, -- description + p_mime_type, -- mime_type + p_text, -- text + p_data, -- data p_creation_date, -- creation_date p_creation_user, -- creation_user - p_creation_ip, -- creation_ip - p_is_live -- is_live + p_creation_ip, -- creation_ip + p_is_live -- is_live ); return v_message_id; end;' language 'plpgsql'; +create or replace function acs_message__new (integer,integer,timestamptz,integer, +varchar,varchar,varchar,varchar,text,integer,integer,integer,integer, +varchar,varchar,boolean) +returns integer as ' +declare + p_message_id alias for $1; --default null, + p_reply_to alias for $2; --default null, + p_sent_date alias for $3; --default sysdate, + p_sender alias for $4; --default null, + p_rfc822_id alias for $5; --default null, + p_title alias for $6; --default null, + p_description alias for $7; --default null, + p_mime_type alias for $8; --default ''text/plain'', + p_text alias for $9; --default null, + p_data alias for $10; --default null, + p_parent_id alias for $11; --default 0, + p_context_id alias for $12; + p_creation_date timestamptz := current_timestamp; -- alias for $13 --default sysdate, + p_creation_user alias for $13; --default null, + p_creation_ip alias for $14; --default null, + p_object_type alias for $15; --default ''acs_message'', + p_is_live alias for $16; --default ''t'' +begin + return acs_message__new (p_message_id, + p_reply_to, + p_sent_date, + p_sender, + p_rfc822_id, + p_title, + p_description, + p_mime_type, + p_text, + p_data, + p_parent_id, + p_context_id, + p_creation_date, + p_creation_user, + p_creation_ip, + p_object_type, + p_is_live, + null + ); +end;' language 'plpgsql'; + create or replace function acs_message__delete (integer) returns integer as ' declare @@ -257,7 +303,7 @@ -- by direct calls to CR code in the near future. create or replace function acs_message__new_file (integer,integer,varchar,varchar, -text,varchar,integer,timestamptz,integer,varchar,boolean,varchar) +text,varchar,integer,timestamptz,integer,varchar,boolean,varchar,integer) returns integer as ' declare p_message_id alias for $1; @@ -272,44 +318,79 @@ p_creation_ip alias for $10; -- default null p_is_live alias for $11; -- default ''t'' p_storage_type alias for $12; -- default ''file'' + p_package_id alias for $13; -- default null v_file_id cr_items.item_id%TYPE; v_revision_id cr_revisions.revision_id%TYPE; begin v_file_id := content_item__new ( p_file_name, -- name p_message_id, -- parent_id - p_file_id, -- item_id - null, -- locale + p_file_id, -- item_id + null, -- locale p_creation_date, -- creation_date p_creation_user, -- creation_user - null, -- context_id + null, -- context_id p_creation_ip, -- creation_ip ''content_item'', -- item_subtype ''content_revision'', -- content_type - null, -- title - null, -- description + null, -- title + null, -- description ''text/plain'', -- mime_type - null, -- nls_language - null, -- text - p_storage_type -- storage_type + null, -- nls_language + null, -- text + p_storage_type, -- storage_type + p_package_id -- package_id ); -- create an initial revision for the new attachment v_revision_id := acs_message__edit_file ( - v_file_id, -- file_id - p_title, -- title + v_file_id, -- file_id + p_title, -- title p_description, -- description p_mime_type, -- mime_type - p_data, -- data + p_data, -- data p_creation_date, -- creation_date p_creation_user, -- creation_user p_creation_ip, -- creation_ip - p_is_live -- is_live + p_is_live -- is_live ); return v_file_id; end;' language 'plpgsql'; +create or replace function acs_message__new_file (integer,integer,varchar,varchar, +text,varchar,integer,timestamptz,integer,varchar,boolean,varchar) +returns integer as ' +declare + p_message_id alias for $1; + p_file_id alias for $2; -- default null + p_file_name alias for $3; + p_title alias for $4; -- default null + p_description alias for $5; -- default null + p_mime_type alias for $6; -- default ''text/plain'' + p_data alias for $7; -- default null + p_creation_date alias for $8; -- default sysdate + p_creation_user alias for $9; -- default null + p_creation_ip alias for $10; -- default null + p_is_live alias for $11; -- default ''t'' + p_storage_type alias for $12; -- default ''file'' +begin + return acs_message__new_file (p_message_id, + p_file_id, + p_file_name, + p_title, + p_description, + p_mime_type, + p_data, + p_creation_date, + p_creation_user, + p_creation_ip, + p_is_live, + p_storage_type, + null + ); +end;' language 'plpgsql'; + create or replace function acs_message__edit_file (integer,varchar,text,varchar, integer,timestamptz,integer,varchar,boolean) returns integer as ' @@ -326,13 +407,13 @@ v_revision_id cr_revisions.revision_id%TYPE; begin v_revision_id := content_revision__new ( - p_title, -- title + p_title, -- title p_description, current_timestamp, p_mime_type, -- mime_type NULL, p_data, -- data - p_file_id, -- item_id + p_file_id, -- item_id NULL, p_creation_date, -- creation_date p_creation_user, -- creation_user @@ -357,7 +438,7 @@ end;' language 'plpgsql'; create or replace function acs_message__new_image (integer,integer,varchar,varchar, -text,varchar,integer,integer,integer,timestamptz,integer,varchar,boolean,varchar) +text,varchar,integer,integer,integer,timestamptz,integer,varchar,boolean,varchar,integer) returns integer as ' declare p_message_id alias for $1; @@ -374,46 +455,85 @@ p_creation_ip alias for $12; -- default null p_is_live alias for $13; -- default ''t'' p_storage_type alias for $14; -- default ''file'' + p_package_id alias for $15; -- default null v_image_id cr_items.item_id%TYPE; v_revision_id cr_revisions.revision_id%TYPE; begin v_image_id := content_item__new ( p_file_name, -- name p_message_id, -- parent_id p_image_id, -- item_id - null, -- locale + null, -- locale p_creation_date, -- creation_date p_creation_user, -- creation_user - null, -- context_id + null, -- context_id p_creation_ip, -- creation_ip - ''content_item'', -- item_subtype - ''content_revision'', -- content_type - null, -- title - null, -- description - ''text/plain'', -- mime_type - null, -- nls_language - null, -- text - ''file'' -- storage_type + ''content_item'', -- item_subtype + ''content_revision'', -- content_type + null, -- title + null, -- description + ''text/plain'', -- mime_type + null, -- nls_language + null, -- text + ''file'', -- storage_type + p_package_id -- package_id ); -- create an initial revision for the new attachment v_revision_id := acs_message__edit_image ( v_image_id, -- image_id - p_title, -- title + p_title, -- title p_description, -- description p_mime_type, -- mime_type - p_data, -- data - p_width, -- width - p_height, -- height + p_data, -- data + p_width, -- width + p_height, -- height p_creation_date, -- creation_date p_creation_user, -- creation_user p_creation_ip, -- creation_ip - p_is_live -- is_live + p_is_live -- is_live ); return v_image_id; end;' language 'plpgsql'; +create or replace function acs_message__new_image (integer,integer,varchar,varchar, +text,varchar,integer,integer,integer,timestamptz,integer,varchar,boolean,varchar) +returns integer as ' +declare + p_message_id alias for $1; + p_image_id alias for $2; -- default null + p_file_name alias for $3; + p_title alias for $4; -- default null + p_description alias for $5; -- default null + p_mime_type alias for $6; -- default ''text/plain'' + p_data alias for $7; -- default null + p_width alias for $8; -- default null + p_height alias for $9; -- default null + p_creation_date alias for $10; -- default sysdate + p_creation_user alias for $11; -- default null + p_creation_ip alias for $12; -- default null + p_is_live alias for $13; -- default ''t'' + p_storage_type alias for $14; -- default ''file'' +begin + return acs_message__new_image (p_message_id, + p_image_id, + p_file_name, + p_title, + p_description, + p_mime_type, + p_data, + p_width, + p_height, + p_creation_date, + p_creation_user, + p_creation_ip, + p_is_live, + p_storage_type, + null + ); +end;' language 'plpgsql'; + create or replace function acs_message__edit_image (integer,varchar,text,varchar, integer,integer,integer,timestamptz,integer,varchar,boolean) returns integer as ' @@ -473,7 +593,7 @@ -- XXX should just call content_extlink.new create or replace function acs_message__new_extlink (varchar,integer,varchar, -varchar,text,integer,timestamptz,integer,varchar) +varchar,text,integer,timestamptz,integer,varchar,integer) returns integer as ' declare p_name alias for $1; -- default null @@ -485,23 +605,52 @@ p_creation_date alias for $7; -- default sysdate p_creation_user alias for $8; -- default null p_creation_ip alias for $9; -- default null + p_package_id alias for $10; -- default null v_extlink_id cr_extlinks.extlink_id%TYPE; begin v_extlink_id := content_extlink__new ( - p_name, -- name - p_url, -- url - p_label, -- label + p_name, -- name + p_url, -- url + p_label, -- label p_description, -- description p_parent_id, -- parent_id p_extlink_id, -- extlink_id p_creation_date, -- creation_date p_creation_user, -- creation_user - p_creation_ip -- creation_ip + p_creation_ip, -- creation_ip + p_package_id ); return v_extlink_id; end;' language 'plpgsql'; +create or replace function acs_message__new_extlink (varchar,integer,varchar, +varchar,text,integer,timestamptz,integer,varchar) +returns integer as ' +declare + p_name alias for $1; -- default null + p_extlink_id alias for $2; -- default null + p_url alias for $3; + p_label alias for $4; -- default null + p_description alias for $5; -- default null + p_parent_id alias for $6; + p_creation_date alias for $7; -- default sysdate + p_creation_user alias for $8; -- default null + p_creation_ip alias for $9; -- default null +begin + return acs_message__new_extlink (p_name, + p_extlink_id, + p_url, + p_label, + p_description, + p_parent_id, + p_creation_date, + p_creation_user, + p_creation_ip, + null + ); +end;' language 'plpgsql'; + -- XXX should just edit extlink create or replace function acs_message__edit_extlink (integer,varchar,varchar,text) returns integer as ' Index: openacs-4/packages/acs-messaging/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-messaging/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-messaging/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql 12 Mar 2004 18:48:52 -0000 1.3 @@ -0,0 +1,8 @@ +update acs_objects +set title = (select name + from cr_items + where item_id = object_id), +package_id = acs_object__package_id(content_item__get_root_folder(object_id)) +where object_type = 'acs_message'; + +\i ../acs-messaging-packages.sql Index: openacs-4/packages/acs-reference/sql/oracle/acs-reference-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-reference/sql/oracle/acs-reference-create.sql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-reference/sql/oracle/acs-reference-create.sql 4 Mar 2004 14:52:45 -0000 1.6 +++ openacs-4/packages/acs-reference/sql/oracle/acs-reference-create.sql 12 Mar 2004 18:48:52 -0000 1.7 @@ -134,7 +134,8 @@ creation_date => creation_date, creation_user => creation_user, creation_ip => creation_ip, - object_type => object_type + object_type => object_type, + title => source ); if first_names is not null and last_name is not null then Index: openacs-4/packages/acs-reference/sql/oracle/upgrade/upgrade-5.0.2-5.0.2d1.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-reference/sql/oracle/upgrade/upgrade-5.0.2-5.0.2d1.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-reference/sql/oracle/upgrade/upgrade-5.0.2-5.0.2d1.sql 12 Mar 2004 18:48:53 -0000 1.3 @@ -0,0 +1,115 @@ +update acs_objects +set title = (select source + from acs_reference_repositories + where repository_id = object_id) +where object_type = 'acs_reference_repository'; + + +create or replace package body acs_reference +as + function new ( + repository_id in acs_reference_repositories.repository_id%TYPE default null, + table_name in acs_reference_repositories.table_name%TYPE, + internal_data_p in acs_reference_repositories.internal_data_p%TYPE default 'f', + package_name in acs_reference_repositories.package_name%TYPE default null, + last_update in acs_reference_repositories.last_update%TYPE default sysdate, + source in acs_reference_repositories.source%TYPE default null, + source_url in acs_reference_repositories.source_url%TYPE default null, + effective_date in acs_reference_repositories.effective_date%TYPE default sysdate, + expiry_date in acs_reference_repositories.expiry_date%TYPE default null, + notes in acs_reference_repositories.notes%TYPE default empty_blob(), + 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, + object_type in acs_objects.object_type%TYPE default 'acs_reference_repository', + first_names in persons.first_names%TYPE default null, + last_name in persons.last_name%TYPE default null + ) return acs_objects.object_id%TYPE + is + v_repository_id acs_reference_repositories.repository_id%TYPE; + v_maintainer_id persons.person_id%TYPE; + begin + v_repository_id := acs_object.new ( + object_id => repository_id, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + object_type => object_type, + title => source + ); + + if first_names is not null and last_name is not null then + v_maintainer_id := person.new ( + first_names => first_names, + last_name => last_name, + email => null + ); + else + v_maintainer_id := null; + end if; + + insert into acs_reference_repositories + (repository_id, + table_name, + internal_data_p, + last_update, + package_name, + source, + source_url, + effective_date, + expiry_date, + maintainer_id, + notes) + values + (v_repository_id, + table_name, + internal_data_p, + last_update, + package_name, + source, + source_url, + effective_date, + expiry_date, + v_maintainer_id, + notes); + return v_repository_id; + end new; + + procedure del ( + repository_id in acs_reference_repositories.repository_id%TYPE + ) + is + v_maintainer_id integer; + begin + select maintainer_id into v_maintainer_id + from acs_reference_repositories + where repository_id = acs_reference.del.repository_id; + + delete from acs_reference_repositories + where repository_id = acs_reference.del.repository_id; + + acs_object.del(repository_id); + person.del(v_maintainer_id); + + end del; + + function is_expired_p ( + repository_id integer + ) return char + is + v_expiry_date date; + begin + select expiry_date into v_expiry_date + from acs_reference_repositories + where repository_id = is_expired_p.repository_id; + + if nvl(v_expiry_date,sysdate+1) < sysdate then + return 't'; + else + return 'f'; + end if; + end; + +end acs_reference; +/ +show errors Index: openacs-4/packages/acs-reference/sql/postgresql/acs-reference-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-reference/sql/postgresql/acs-reference-create.sql,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/acs-reference/sql/postgresql/acs-reference-create.sql 4 Mar 2004 14:52:46 -0000 1.10 +++ openacs-4/packages/acs-reference/sql/postgresql/acs-reference-create.sql 12 Mar 2004 18:48:53 -0000 1.11 @@ -108,6 +108,9 @@ now(), p_creation_user, p_creation_ip, + null, + ''t'', + p_source, null ); Index: openacs-4/packages/acs-service-contract/sql/oracle/acs-sc-msg-types-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-service-contract/sql/oracle/acs-sc-msg-types-create.sql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-service-contract/sql/oracle/acs-sc-msg-types-create.sql 4 Mar 2004 14:52:46 -0000 1.6 +++ openacs-4/packages/acs-service-contract/sql/oracle/acs-sc-msg-types-create.sql 12 Mar 2004 18:48:53 -0000 1.7 @@ -95,7 +95,8 @@ v_spec_parse_level integer; begin v_msg_type_id := acs_object.new( - object_type => 'acs_sc_msg_type' + object_type => 'acs_sc_msg_type', + title => msg_type_name ); insert into acs_sc_msg_types ( Index: openacs-4/packages/acs-service-contract/sql/oracle/acs-sc-packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-service-contract/sql/oracle/acs-sc-packages-create.sql,v diff -u -N -r1.14 -r1.15 --- openacs-4/packages/acs-service-contract/sql/oracle/acs-sc-packages-create.sql 4 Mar 2004 14:52:46 -0000 1.14 +++ openacs-4/packages/acs-service-contract/sql/oracle/acs-sc-packages-create.sql 12 Mar 2004 18:48:53 -0000 1.15 @@ -152,7 +152,10 @@ is v_contract_id acs_sc_contracts.contract_id%TYPE; begin - v_contract_id := acs_object.new( object_type=>'acs_sc_contract'); + v_contract_id := acs_object.new( + object_type => 'acs_sc_contract', + title => contract_name + ); insert into acs_sc_contracts ( contract_id, @@ -250,7 +253,10 @@ begin v_contract_id := acs_sc_contract.get_id(contract_name); - v_operation_id := acs_object.new (object_type=>'acs_sc_operation'); + v_operation_id := acs_object.new ( + object_type => 'acs_sc_operation', + title => operation_name + ); v_operation_inputtype_id := acs_sc_msg_type.get_id(operation_inputtype); v_operation_outputtype_id := acs_sc_msg_type.get_id(operation_outputtype); @@ -341,7 +347,10 @@ is v_impl_id acs_sc_impls.impl_id%TYPE; begin - v_impl_id := acs_object.new (object_type => 'acs_sc_implementation'); + v_impl_id := acs_object.new ( + object_type => 'acs_sc_implementation', + title => impl_pretty_name + ); insert into acs_sc_impls ( impl_id, Index: openacs-4/packages/acs-service-contract/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-service-contract/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-service-contract/sql/oracle/upgrade/upgrade-5.1.0d1-5.1.0d2.sql 12 Mar 2004 18:48:54 -0000 1.3 @@ -0,0 +1,603 @@ +update acs_objects +set title = (select msg_type_name + from acs_sc_msg_types + where msg_type_id = object_id) +where object_type = 'acs_sc_msg_type'; + +update acs_objects +set title = (select contract_name + from acs_sc_contracts + where contract_id = object_id) +where object_type = 'acs_sc_contract'; + +update acs_objects +set title = (select operation_name + from acs_sc_operations + where operation_id = object_id) +where object_type = 'acs_sc_operation'; + +update acs_objects +set title = (select impl_pretty_name + from acs_sc_impls + where impl_id = object_id) +where object_type = 'acs_sc_implementation'; + +commit; + + +create or replace package body acs_sc_msg_type +as + + function new ( + msg_type_name in acs_sc_msg_types.msg_type_name%TYPE, + msg_type_spec in varchar2 + ) return acs_sc_msg_types.msg_type_id%TYPE + is + v_msg_type_id integer; + v_spec_parse_level integer; + begin + v_msg_type_id := acs_object.new( + object_type => 'acs_sc_msg_type', + title => msg_type_name + ); + + insert into acs_sc_msg_types ( + msg_type_id, + msg_type_name + ) values ( + v_msg_type_id, + msg_type_name + ); + + v_spec_parse_level := acs_sc_msg_type.parse_spec( + msg_type_name, + msg_type_spec); + + return v_msg_type_id; + + end new; + + procedure del ( + msg_type_id in acs_sc_msg_types.msg_type_id%TYPE default null, + msg_type_name in acs_sc_msg_types.msg_type_name%TYPE default null + ) + is + v_msg_type_id acs_sc_msg_types.msg_type_id%TYPE; + begin + + if msg_type_name is not NULL + then + v_msg_type_id := acs_sc_msg_type.get_id(msg_type_name); + + elsif msg_type_id is not NULL + then + v_msg_type_id := msg_type_id; + + else + raise_application_error(-20000, 'no args supplied to sc_msg_type.delete'); + + end if; + + delete from acs_sc_msg_types + where msg_type_id = v_msg_type_id; + + end del; + + function get_id ( + msg_type_name in acs_sc_msg_types.msg_type_name%TYPE + ) return acs_sc_msg_types.msg_type_id%TYPE + + is + v_msg_type_id acs_sc_msg_types.msg_type_id%TYPE; + begin + + select msg_type_id into v_msg_type_id + from acs_sc_msg_types + where msg_type_name = get_id.msg_type_name; + + return v_msg_type_id; + + end get_id; + + + function get_name ( + msg_type_id in acs_sc_msg_types.msg_type_id%TYPE + ) return acs_sc_msg_types.msg_type_name%TYPE + is + v_msg_type_name acs_sc_msg_types.msg_type_name%TYPE; + begin + + select msg_type_name into v_msg_type_name + from acs_sc_msg_types + where msg_type_id = get_name.msg_type_id; + + return v_msg_type_name; + end get_name; + + + + -- string processing in pl/sql is so much fun + -- i'm sure there is a better way to go about this + function parse_spec ( + msg_type_name in acs_sc_msg_types.msg_type_name%TYPE, + msg_type_spec in varchar2 + ) return integer + is + v_element_pos integer; + v_str_s_idx integer; -- spec str pointers + v_str_e_idx integer; + v_elem_idx integer; -- element str pointer + v_str_len integer; + v_element varchar(200); + v_element_type varchar(200); + v_element_name varchar(200); + v_element_msg_type_name varchar(200); + v_element_msg_type_isset_p char(1); + v_junk_msg_type_id integer; + begin + + -- oracle treats empty strings as nulls + if msg_type_spec is null + then + return 0; + end if; + + + v_element_pos := 1; + v_str_e_idx := 1; + + while TRUE + loop + -- string start check + if v_element_pos = 1 + then + v_str_s_idx := 1; + else + v_str_s_idx := instr(msg_type_spec, ',', v_str_e_idx); + + if v_str_s_idx > 0 then + v_str_s_idx := v_str_s_idx + 1; + end if; + + end if; + + v_str_e_idx := instr(msg_type_spec, ',', v_str_s_idx+1)-1; + + -- end of string check + if v_str_s_idx > 0 and v_str_e_idx <= 0 + then + v_str_e_idx := length(msg_type_spec); + end if; + + -- dbms_output.put_line(v_str_s_idx || ' '|| v_str_e_idx || ' ' || v_element_pos); + -- dbms_output.new_line(); + + if v_str_s_idx > 0 + then + + v_element := substr(msg_type_spec, + v_str_s_idx, + v_str_e_idx+1 - v_str_s_idx); + + v_elem_idx := instr(v_element, ':'); + + if v_elem_idx > 0 + then + v_element_name := trim( substr(v_element, 1, v_elem_idx-1)); + v_element_type := trim( substr(v_element, v_elem_idx+1)); + + if (instr(v_element_type, '[',1,1) = length(v_element_type)-1) and + (instr(v_element_type, ']',1,1) = length(v_element_type)) + then + v_element_msg_type_isset_p := 't'; + v_element_msg_type_name := trim(substr( + v_element_type, + 1, + length(v_element_type)-2)); + + if v_element_msg_type_name = '' + then + raise_application_error (-20001, + 'Wrong Format: Message Type Specification'); + end if; + else + v_element_msg_type_isset_p := 'f'; + v_element_msg_type_name := v_element_type; + + end if; + + v_junk_msg_type_id := acs_sc_msg_type.new_element ( + msg_type_name =>parse_spec.msg_type_name, + element_name => v_element_name, + element_msg_type_name => v_element_msg_type_name, + element_msg_type_isset_p => v_element_msg_type_isset_p, + element_pos => v_element_pos + ); + + else + raise_application_error(-20001,'Wrong Format: Message Type Specification'); + end if; + else + -- yippee we're done + exit; + end if; + + v_element_pos := v_element_pos + 1; + + end loop; + + return v_element_pos - 1; + end parse_spec; + + function new_element ( + msg_type_name in acs_sc_msg_types.msg_type_name%TYPE, + element_name in acs_sc_msg_type_elements.element_name%TYPE, + element_msg_type_name in acs_sc_msg_types.msg_type_name%TYPE, + element_msg_type_isset_p in acs_sc_msg_type_elements.element_msg_type_isset_p%TYPE, + element_pos in acs_sc_msg_type_elements.element_pos%TYPE + ) return acs_sc_msg_types.msg_type_id%TYPE + is + v_msg_type_id integer; + v_element_msg_type_id integer; + begin + + v_msg_type_id := acs_sc_msg_type.get_id(msg_type_name); + + if v_msg_type_id is null + then + raise_application_error (-20001, 'Unknown Message Type: ' || msg_type_name); + end if; + + v_element_msg_type_id := acs_sc_msg_type.get_id(element_msg_type_name); + + if v_element_msg_type_id is null + then + raise_application_error (-20001, 'Unknown Message Type: ' || element_msg_type_name); + end if; + + insert into acs_sc_msg_type_elements ( + msg_type_id, + element_name, + element_msg_type_id, + element_msg_type_isset_p, + element_pos + ) values ( + v_msg_type_id, + element_name, + v_element_msg_type_id, + element_msg_type_isset_p, + element_pos + ); + + return v_msg_type_id; + + end new_element; + +end acs_sc_msg_type; +/ +show errors + + + +create or replace package body acs_sc_contract +as + function new ( + contract_name in acs_sc_contracts.contract_name%TYPE, + contract_desc in acs_sc_contracts.contract_desc%TYPE + ) return acs_sc_contracts.contract_id%TYPE + is + v_contract_id acs_sc_contracts.contract_id%TYPE; + begin + v_contract_id := acs_object.new( + object_type => 'acs_sc_contract', + title => contract_name + ); + + insert into acs_sc_contracts ( + contract_id, + contract_name, + contract_desc + ) values ( + v_contract_id, + contract_name, + contract_desc + ); + + return v_contract_id; + + end new; + + function get_id ( + contract_name in acs_sc_contracts.contract_name%TYPE + ) return acs_sc_contracts.contract_id%TYPE + is + v_contract_id acs_sc_contracts.contract_id%TYPE; + begin + + select contract_id into v_contract_id + from acs_sc_contracts + where contract_name = get_id.contract_name; + + return v_contract_id; + + end get_id; + + function get_name ( + contract_id in acs_sc_contracts.contract_id%TYPE + ) return acs_sc_contracts.contract_name%TYPE + is + v_contract_name acs_sc_contracts.contract_name%TYPE; + begin + + select contract_name into v_contract_name + from acs_sc_contracts + where contract_id = get_name.contract_id; + + return v_contract_name; + + end get_name; + + procedure del ( + contract_name in acs_sc_contracts.contract_name%TYPE default null, + contract_id in acs_sc_contracts.contract_id%TYPE default null + ) + is + v_contract_id acs_sc_contracts.contract_id%TYPE; + begin + + if contract_name is not NULL + then + v_contract_id := acs_sc_contract.get_id(contract_name); + + elsif contract_id is not NULL + then + v_contract_id := contract_id; + + else + raise_application_error(-20001, 'Service Contracts: no valid args supplied to delete'); + end if; + + + delete from acs_sc_contracts + where contract_id = v_contract_id; + acs_object.del(v_contract_id); + + end del; + +end acs_sc_contract; +/ +show errors + + +create or replace package body acs_sc_operation +as + + function new ( + contract_name in acs_sc_contracts.contract_name%TYPE, + operation_name in acs_sc_operations.operation_name%TYPE, + operation_desc in acs_sc_operations.operation_desc%TYPE, + operation_iscachable_p in acs_sc_operations.operation_iscachable_p%TYPE, + operation_nargs in acs_sc_operations.operation_nargs%TYPE, + operation_inputtype in acs_sc_msg_types.msg_type_name%TYPE, + operation_outputtype in acs_sc_msg_types.msg_type_name%TYPE + ) return acs_sc_operations.operation_id%TYPE + is + v_contract_id acs_sc_contracts.contract_id%TYPE; + v_operation_id acs_sc_operations.operation_id%TYPE; + v_operation_inputtype_id acs_sc_operations.operation_inputtype_id%TYPE; + v_operation_outputtype_id acs_sc_operations.operation_outputtype_id%TYPE; + begin + + v_contract_id := acs_sc_contract.get_id(contract_name); + v_operation_id := acs_object.new ( + object_type => 'acs_sc_operation', + title => operation_name + ); + v_operation_inputtype_id := acs_sc_msg_type.get_id(operation_inputtype); + v_operation_outputtype_id := acs_sc_msg_type.get_id(operation_outputtype); + + insert into acs_sc_operations ( + contract_id, + operation_id, + contract_name, + operation_name, + operation_desc, + operation_iscachable_p, + operation_nargs, + operation_inputtype_id, + operation_outputtype_id + ) values ( + v_contract_id, + v_operation_id, + contract_name, + operation_name, + operation_desc, + operation_iscachable_p, + operation_nargs, + v_operation_inputtype_id, + v_operation_outputtype_id + ); + + return v_operation_id; + + end new; + + + function get_id ( + contract_name acs_sc_contracts.contract_name%TYPE, + operation_name acs_sc_operations.operation_name%TYPE + ) return acs_sc_operations.operation_id%TYPE + as + v_operation_id acs_sc_operations.operation_id%TYPE; + begin + select operation_id into v_operation_id + from acs_sc_operations + where contract_name = get_id.contract_name + and operation_name = get_id.operation_name; + + return v_operation_id; + end get_id; + + + procedure del ( + operation_id acs_sc_operations.operation_id%TYPE default null, + operation_name acs_sc_operations.operation_name%TYPE default null, + contract_name acs_sc_contracts.contract_name%TYPE default null + ) + is + v_operation_id acs_sc_operations.operation_id%TYPE; + begin + + if (operation_id is NULL and operation_name is not NULL and contract_name is not NULL) + then + v_operation_id := get_id(contract_name, operation_name); + + elsif operation_id is not NULL + then + v_operation_id := operation_id; + + else + raise_application_error(-20001, 'ACS Contracts: Invalid args to operation delete'); + end if; + + delete from acs_sc_operations + where operation_id = v_operation_id; + + end del; + + +end acs_sc_operation; +/ +show errors + + +create or replace package body acs_sc_impl +as + + function new ( + impl_contract_name acs_sc_impls.impl_contract_name%TYPE, + impl_name acs_sc_impls.impl_name%TYPE, + impl_pretty_name acs_sc_impls.impl_pretty_name%TYPE default null, + impl_owner_name acs_sc_impls.impl_owner_name%TYPE + ) return acs_sc_impls.impl_id%TYPE + is + v_impl_id acs_sc_impls.impl_id%TYPE; + begin + v_impl_id := acs_object.new ( + object_type => 'acs_sc_implementation', + title => impl_pretty_name + ); + + insert into acs_sc_impls ( + impl_id, + impl_name, + impl_pretty_name, + impl_owner_name, + impl_contract_name + ) values ( + v_impl_id, + impl_name, + impl_pretty_name, + impl_owner_name, + impl_contract_name + ); + + return v_impl_id; + end new; + + function get_id ( + impl_contract_name acs_sc_impls.impl_contract_name%TYPE, + impl_name acs_sc_impls.impl_name%TYPE + ) return acs_sc_impls.impl_id%TYPE + as + v_impl_id acs_sc_impls.impl_id%TYPE; + begin + + select impl_id into v_impl_id + from acs_sc_impls + where impl_name = get_id.impl_name + and impl_contract_name = get_id.impl_contract_name; + + return v_impl_id; + + end get_id; + + + function get_name ( + impl_id acs_sc_impls.impl_id%TYPE + ) return acs_sc_impls.impl_name%TYPE + as + v_impl_name acs_sc_impls.impl_name%TYPE; + begin + + select impl_name into v_impl_name + from acs_sc_impls + where impl_id = get_name.impl_id; + + return v_impl_name; + + end get_name; + + procedure del ( + impl_contract_name acs_sc_impls.impl_contract_name%TYPE, + impl_name acs_sc_impls.impl_name%TYPE + ) + as + begin + delete from acs_sc_impls + where impl_contract_name = acs_sc_impl.del.impl_contract_name + and impl_name = acs_sc_impl.del.impl_name; + end del; + + + /* next 2 functions are deprecated. */ + + function new_alias ( + impl_contract_name acs_sc_contracts.contract_name%TYPE, + impl_name acs_sc_impls.impl_name%TYPE, + impl_operation_name acs_sc_operations.operation_name%TYPE, + impl_alias acs_sc_impl_aliases.impl_alias%TYPE, + impl_pl acs_sc_impl_aliases.impl_pl%TYPE + ) return acs_sc_impl_aliases.impl_id%TYPE + is + v_impl_id acs_sc_impls.impl_id%TYPE; + begin + -- FUNCTION DEPRECATED. USE acs_sc_impl_alias.new + dbms_output.put_line('acs_sc_impl.new_alias DEPRECATED. Use acs_sc_impl_alias.new'); + + v_impl_id := acs_sc_impl_alias.new( + impl_contract_name, + impl_name, + impl_operation_name, + impl_alias, + impl_pl + ); + + return v_impl_id; + + end new_alias; + + function delete_alias ( + impl_contract_name acs_sc_contracts.contract_name%TYPE, + impl_name acs_sc_impls.impl_name%TYPE, + impl_operation_name acs_sc_operations.operation_name%TYPE + ) return acs_sc_impls.impl_id%TYPE + is + v_impl_id acs_sc_impls.impl_id%TYPE; + begin + -- FUNCTION DEPRECATED. USE acs_sc_impl_alias.delete + dbms_output.put_line('acs_sc_impl.delete_alias DEPRECATED. Use acs_sc_impl_alias.delete'); + + v_impl_id := acs_sc_impl_alias.del( + impl_contract_name, + impl_name, + impl_operation_name + ); + + return v_impl_id; + + end delete_alias; + +end acs_sc_impl; +/ +show errors Index: openacs-4/packages/acs-service-contract/sql/postgresql/acs-sc-msg-types-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-service-contract/sql/postgresql/acs-sc-msg-types-create.sql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-service-contract/sql/postgresql/acs-sc-msg-types-create.sql 4 Mar 2004 14:52:46 -0000 1.6 +++ openacs-4/packages/acs-service-contract/sql/postgresql/acs-sc-msg-types-create.sql 12 Mar 2004 18:48:54 -0000 1.7 @@ -54,6 +54,9 @@ now(), null, null, + null, + ''t'', + p_msg_type_name, null ); Index: openacs-4/packages/acs-service-contract/sql/postgresql/acs-sc-packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-service-contract/sql/postgresql/acs-sc-packages-create.sql,v diff -u -N -r1.12 -r1.13 --- openacs-4/packages/acs-service-contract/sql/postgresql/acs-sc-packages-create.sql 4 Mar 2004 14:52:46 -0000 1.12 +++ openacs-4/packages/acs-service-contract/sql/postgresql/acs-sc-packages-create.sql 12 Mar 2004 18:48:54 -0000 1.13 @@ -12,6 +12,9 @@ now(), null, null, + null, + ''t'', + p_contract_name, null ); @@ -121,6 +124,9 @@ now(), null, null, + null, + ''t'', + p_operation_name, null ); @@ -224,6 +230,9 @@ now(), null, null, + null, + ''t'', + p_impl_pretty_name, null ); Index: openacs-4/packages/acs-service-contract/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-service-contract/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-service-contract/sql/postgresql/upgrade/upgrade-5.1.0d1-5.1.0d2.sql 12 Mar 2004 18:48:54 -0000 1.3 @@ -0,0 +1,207 @@ +update acs_objects +set title = (select msg_type_name + from acs_sc_msg_types + where msg_type_id = object_id) +where object_type = 'acs_sc_msg_type'; + +update acs_objects +set title = (select contract_name + from acs_sc_contracts + where contract_id = object_id) +where object_type = 'acs_sc_contract'; + +update acs_objects +set title = (select operation_name + from acs_sc_operations + where operation_id = object_id) +where object_type = 'acs_sc_operation'; + +update acs_objects +set title = (select impl_pretty_name + from acs_sc_impls + where impl_id = object_id) +where object_type = 'acs_sc_implementation'; + + + +drop function acs_sc_msg_type__new(varchar,varchar); + +create or replace function acs_sc_msg_type__new(varchar,varchar) +returns integer as ' +declare + p_msg_type_name alias for $1; + p_msg_type_spec alias for $2; + v_msg_type_id integer; +begin + + v_msg_type_id := acs_object__new( + null, + ''acs_sc_msg_type'', + now(), + null, + null, + null, + ''t'', + p_msg_type_name, + null + ); + + insert into acs_sc_msg_types ( + msg_type_id, + msg_type_name + ) values ( + v_msg_type_id, + p_msg_type_name + ); + + perform acs_sc_msg_type__parse_spec(p_msg_type_name,p_msg_type_spec); + + return v_msg_type_id; + +end;' language 'plpgsql'; + + + +drop function acs_sc_contract__new(varchar,text); + +create or replace function acs_sc_contract__new(varchar,text) +returns integer as ' +declare + p_contract_name alias for $1; + p_contract_desc alias for $2; + v_contract_id integer; +begin + + v_contract_id := acs_object__new( + null, + ''acs_sc_contract'', + now(), + null, + null, + null, + ''t'', + p_contract_name, + null + ); + + insert into acs_sc_contracts ( + contract_id, + contract_name, + contract_desc + ) values ( + v_contract_id, + p_contract_name, + p_contract_desc + ); + + return v_contract_id; + +end;' language 'plpgsql'; + + + +drop function acs_sc_operation__new(varchar,varchar,text,boolean,integer,varchar,varchar); + +create or replace function acs_sc_operation__new(varchar,varchar,text,boolean,integer,varchar,varchar) +returns integer as ' +declare + p_contract_name alias for $1; + p_operation_name alias for $2; + p_operation_desc alias for $3; + p_operation_iscachable_p alias for $4; + p_operation_nargs alias for $5; + p_operation_inputtype alias for $6; + p_operation_outputtype alias for $7; + v_contract_id integer; + v_operation_id integer; + v_operation_inputtype_id integer; + v_operation_outputtype_id integer; +begin + + v_contract_id := acs_sc_contract__get_id(p_contract_name); + + v_operation_id := acs_object__new( + null, + ''acs_sc_operation'', + now(), + null, + null, + null, + ''t'', + p_operation_name, + null + ); + + v_operation_inputtype_id := acs_sc_msg_type__get_id(p_operation_inputtype); + + v_operation_outputtype_id := acs_sc_msg_type__get_id(p_operation_outputtype); + + insert into acs_sc_operations ( + contract_id, + operation_id, + contract_name, + operation_name, + operation_desc, + operation_iscachable_p, + operation_nargs, + operation_inputtype_id, + operation_outputtype_id + ) values ( + v_contract_id, + v_operation_id, + p_contract_name, + p_operation_name, + p_operation_desc, + p_operation_iscachable_p, + p_operation_nargs, + v_operation_inputtype_id, + v_operation_outputtype_id + ); + + return v_operation_id; + +end;' language 'plpgsql'; + + + +drop function acs_sc_impl__new(varchar,varchar,varchar,varchar); + +create or replace function acs_sc_impl__new(varchar,varchar,varchar,varchar) +returns integer as ' +declare + p_impl_contract_name alias for $1; + p_impl_name alias for $2; + p_impl_pretty_name alias for $3; + p_impl_owner_name alias for $4; + v_impl_id integer; +begin + + v_impl_id := acs_object__new( + null, + ''acs_sc_implementation'', + now(), + null, + null, + null, + ''t'', + p_impl_pretty_name, + null + ); + + insert into acs_sc_impls ( + impl_id, + impl_name, + impl_pretty_name, + impl_owner_name, + impl_contract_name + ) values ( + v_impl_id, + p_impl_name, + p_impl_pretty_name, + p_impl_owner_name, + p_impl_contract_name + ); + + return v_impl_id; + +end;' language 'plpgsql'; Index: openacs-4/packages/acs-subsite/tcl/group-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/group-procs.tcl,v diff -u -N -r1.21 -r1.22 --- openacs-4/packages/acs-subsite/tcl/group-procs.tcl 4 Mar 2004 14:52:48 -0000 1.21 +++ openacs-4/packages/acs-subsite/tcl/group-procs.tcl 12 Mar 2004 18:48:54 -0000 1.22 @@ -269,6 +269,14 @@ set [join $set_clauses ", "] where group_id = :group_id " + + if {[info exists group_name]} { + db_dml update_object_title { + update acs_objects + set title = :group_name + where object_id = :group_id + } + } } ad_proc -public group::possible_member_states {} { Index: openacs-4/packages/acs-subsite/www/admin/rel-segments/edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/rel-segments/edit.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/acs-subsite/www/admin/rel-segments/edit.tcl 4 Mar 2004 14:52:48 -0000 1.4 +++ openacs-4/packages/acs-subsite/www/admin/rel-segments/edit.tcl 12 Mar 2004 18:48:55 -0000 1.5 @@ -42,6 +42,11 @@ set segment_name = :segment_name where segment_id = :segment_id } + db_dml update_object_title { + update acs_objects + set title = :segment_name + where object_id = :segment_id + } } -after_submit { ad_returnredirect $view_url ad_script_abort Index: openacs-4/packages/acs-subsite/www/user/portrait/upload-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/user/portrait/Attic/upload-2.tcl,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/acs-subsite/www/user/portrait/upload-2.tcl 4 Mar 2004 14:52:48 -0000 1.7 +++ openacs-4/packages/acs-subsite/www/user/portrait/upload-2.tcl 12 Mar 2004 18:48:55 -0000 1.8 @@ -169,13 +169,19 @@ update images set width = :original_width, height = :original_height where image_id = :revision_id" + db_dml update_photo_info " update cr_revisions set description = :portrait_comment, publish_date = sysdate, mime_type = :guessed_file_type, title = :title where revision_id = :revision_id" + + db_dml update_object_title " + update acs_objects + set title = :title + where object_id = :revision_id" } } } Index: openacs-4/packages/acs-subsite/www/user/portrait/upload-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/user/portrait/Attic/upload-2.xql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/acs-subsite/www/user/portrait/upload-2.xql 4 Mar 2004 14:52:48 -0000 1.4 +++ openacs-4/packages/acs-subsite/www/user/portrait/upload-2.xql 12 Mar 2004 18:48:55 -0000 1.5 @@ -43,4 +43,14 @@ + + + + update acs_objects + set title = :title + where object_id = :revision_id + + + + Index: openacs-4/packages/acs-tcl/tcl/acs-kernel-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/acs-kernel-procs.tcl,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/acs-tcl/tcl/acs-kernel-procs.tcl 10 Mar 2004 16:26:46 -0000 1.8 +++ openacs-4/packages/acs-tcl/tcl/acs-kernel-procs.tcl 12 Mar 2004 18:48:55 -0000 1.9 @@ -36,6 +36,8 @@ ad_proc -public ad_verify_install {} { Returns 1 if the acs is properly installed, 0 otherwise. } { + # define util_memoize with proc here to avoid error messages about multiple + # defines. if { ![db_table_exists apm_packages] || ![db_table_exists site_nodes] } { proc util_memoize {script {max_age ""}} {eval $script} return 0 Index: openacs-4/packages/acs-tcl/tcl/apm-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.tcl,v diff -u -N -r1.66 -r1.67 --- openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 4 Mar 2004 14:52:49 -0000 1.66 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.tcl 12 Mar 2004 18:48:55 -0000 1.67 @@ -746,6 +746,12 @@ max_n_values = :max_n_values where parameter_id = :parameter_id } + + db_dml object_title_update { + update acs_objects + set title = :parameter_name + where object_id = :parameter_id + } return $parameter_id } Index: openacs-4/packages/acs-tcl/tcl/apm-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.xql,v diff -u -N -r1.19 -r1.20 --- openacs-4/packages/acs-tcl/tcl/apm-procs.xql 4 Mar 2004 14:52:49 -0000 1.19 +++ openacs-4/packages/acs-tcl/tcl/apm-procs.xql 12 Mar 2004 18:48:55 -0000 1.20 @@ -87,6 +87,14 @@ + + + update acs_objects + set title = :parameter_name + where object_id = :parameter_id + + + select package_id, parameter_id, parameter_name Index: openacs-4/packages/acs-tcl/tcl/community-core-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/community-core-procs.tcl,v diff -u -N -r1.44 -r1.45 --- openacs-4/packages/acs-tcl/tcl/community-core-procs.tcl 8 Mar 2004 14:07:12 -0000 1.44 +++ openacs-4/packages/acs-tcl/tcl/community-core-procs.tcl 12 Mar 2004 18:48:55 -0000 1.45 @@ -223,6 +223,7 @@ update the name of a person } { db_dml update_person {} + db_dml update_object_title {} name_flush -person_id $person_id } @@ -627,6 +628,9 @@ } } db_dml party_update {} + if {[info exists email]} { + db_dml object_title_update {} + } acs_user::flush_cache -user_id $party_id } Index: openacs-4/packages/acs-tcl/tcl/community-core-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/community-core-procs.xql,v diff -u -N -r1.14 -r1.15 --- openacs-4/packages/acs-tcl/tcl/community-core-procs.xql 4 Mar 2004 14:52:49 -0000 1.14 +++ openacs-4/packages/acs-tcl/tcl/community-core-procs.xql 12 Mar 2004 18:48:55 -0000 1.15 @@ -56,6 +56,16 @@ + + + + update acs_objects + set title = :first_names || ' ' || :last_name + where object_id = :person_id + + + + @@ -136,6 +146,17 @@ + + + + update acs_objects + set title = :email + where object_id = :party_id + and object_type = 'party' + + + + Index: openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl,v diff -u -N -r1.54 -r1.55 --- openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl 4 Mar 2004 14:52:49 -0000 1.54 +++ openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl 12 Mar 2004 18:48:55 -0000 1.55 @@ -48,6 +48,7 @@ mount object at site node } { db_dml mount_object {} + db_dml update_object_package_id {} update_cache -node_id $node_id apm_invoke_callback_proc -package_key [apm_package_key_from_id $object_id] -type "after-mount" -arg_list [list node_id $node_id package_id $object_id] @@ -64,6 +65,7 @@ set child_node_ids [get_children -all -node_id $node_id -element node_id] db_dml rename_node {} + db_dml update_object_title {} update_cache -sync_children -node_id $node_id } @@ -151,6 +153,7 @@ apm_invoke_callback_proc -package_key [apm_package_key_from_id $package_id] -type before-unmount -arg_list [list package_id $package_id node_id $node_id] db_dml unmount_object {} + db_dml update_object_package_id {} update_cache -node_id $node_id } Index: openacs-4/packages/acs-tcl/tcl/site-nodes-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/site-nodes-procs.xql,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/acs-tcl/tcl/site-nodes-procs.xql 4 Mar 2004 14:52:49 -0000 1.9 +++ openacs-4/packages/acs-tcl/tcl/site-nodes-procs.xql 12 Mar 2004 18:48:55 -0000 1.10 @@ -9,6 +9,14 @@ + + + update acs_objects + set package_id = :object_id + where object_id = :node_id + + + update site_nodes @@ -17,6 +25,14 @@ + + + update acs_objects + set title = :name + where object_id = :node_id + + + update site_nodes @@ -25,6 +41,14 @@ + + + update acs_objects + set package_id = null + where object_id = :node_id + + + select node_id