Index: openacs-4/packages/bug-tracker/bug-tracker.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bug-tracker/bug-tracker.info,v diff -u -r1.11 -r1.12 --- openacs-4/packages/bug-tracker/bug-tracker.info 28 Mar 2003 15:14:54 -0000 1.11 +++ openacs-4/packages/bug-tracker/bug-tracker.info 14 Apr 2003 13:33:29 -0000 1.12 @@ -7,13 +7,13 @@ f f - + Lars Pind Tracks bugs and features, versions and maintainers, in software projects. Contains the best of SDM, Bugzilla, FogBUGZ, and bughost.com. 2003-02-28 Musea Technologies - + Index: openacs-4/packages/bug-tracker/sql/oracle/bug-tracker-create-packages.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bug-tracker/sql/oracle/bug-tracker-create-packages.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/bug-tracker/sql/oracle/bug-tracker-create-packages.sql 5 Mar 2003 17:40:06 -0000 1.1 +++ openacs-4/packages/bug-tracker/sql/oracle/bug-tracker-create-packages.sql 14 Apr 2003 13:34:03 -0000 1.2 @@ -212,9 +212,6 @@ bt_patch.delete(rec.patch_id); end loop; - -- delete the content folder - content_folder.delete(v_folder_id); - -- delete the projects keywords bt_project.keywords_delete( project_id => project_id, @@ -227,6 +224,10 @@ delete from bt_user_prefs where project_id = bt_project.delete.project_id; delete from bt_projects where project_id = bt_project.delete.project_id; + + -- delete the content folder + content_folder.delete(v_folder_id); + end delete; procedure keywords_delete ( Index: openacs-4/packages/bug-tracker/sql/oracle/upgrade-1.2d2-1.2d6.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bug-tracker/sql/oracle/upgrade-1.2d2-1.2d6.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bug-tracker/sql/oracle/upgrade-1.2d2-1.2d6.sql 14 Apr 2003 13:34:03 -0000 1.1 @@ -0,0 +1,174 @@ +-- Change CR keywords to be deleted after row in bt_projects to avoid +-- referentail constraint violation + +create or replace package body bt_project +as + procedure new ( + package_id in integer + ) + is + v_count integer; + v_instance_name varchar(300); + v_creation_user integer; + v_creation_ip varchar(50); + v_folder_id integer; + v_root_folder_id integer; + v_keyword_id integer; + begin + select count (*) + into v_count + from bt_projects + where project_id = new.package_id; + + if v_count > 0 then + return; + end if; + + -- get instance name for the content folder + select p.instance_name, o.creation_user, o.creation_ip + into v_instance_name, v_creation_user, v_creation_ip + from apm_packages p, + acs_objects o + where p.package_id = bt_project.new.package_id + and p.package_id = o.object_id; + + select content_item.get_root_folder + into v_root_folder_id + from dual; + + -- create a root CR folder + v_folder_id := content_folder.new( + name => 'bug_tracker_' || bt_project.new.package_id, + label => v_instance_name, + description => null, + parent_id => v_root_folder_id + ); + + -- register our content type + content_folder.register_content_type ( + folder_id => v_folder_id, + content_type => 'bt_bug_revision', + include_subtypes => 't' + ); + + -- create the instance root keyword + v_keyword_id := content_keyword.new( + heading => v_instance_name, + description => null, + parent_id => null, + keyword_id => null, + creation_date => sysdate(), + creation_user => v_creation_user, + creation_ip => v_creation_ip, + object_type => 'content_keyword' + ); + + -- insert the row into bt_projects + insert into bt_projects + (project_id, folder_id, root_keyword_id) + values + (bt_project.new.package_id, v_folder_id, v_keyword_id); + + -- Create a General component to start with + insert into bt_components + (component_id, project_id, component_name) + values + (acs_object_id_seq.nextval, bt_project.new.package_id, 'General'); + + return; + end new; + + procedure delete ( + project_id in integer + ) + is + v_folder_id integer; + v_root_keyword_id integer; + begin + + -- get the content folder for this instance + select folder_id, root_keyword_id + into v_folder_id, v_root_keyword_id + from bt_projects + where project_id = bt_project.delete.project_id; + + -- This get''s done in tcl before we are called ... for now + -- Delete the bugs + -- for rec in select item_id from cr_items where parent_id = v_folder_id + -- loop + -- bt_bug.delete(rec.item_id); + -- end loop; + + -- Delete the patches + for rec in (select patch_id from bt_patches where project_id = bt_project.delete.project_id) + loop + bt_patch.delete(rec.patch_id); + end loop; + + -- delete the projects keywords + bt_project.keywords_delete( + project_id => project_id, + delete_root_p => 't' + ); + + -- These tables should really be set up to cascade + delete from bt_versions where project_id = bt_project.delete.project_id; + delete from bt_components where project_id = bt_project.delete.project_id; + delete from bt_user_prefs where project_id = bt_project.delete.project_id; + + delete from bt_projects where project_id = bt_project.delete.project_id; + + -- delete the content folder + content_folder.delete(v_folder_id); + + end delete; + + procedure keywords_delete ( + project_id in integer, + delete_root_p in varchar2 default 'f' + ) + is + v_root_keyword_id integer; + v_changed_p char(1); + begin + -- get the content folder for this instance + select root_keyword_id + into v_root_keyword_id + from bt_projects + where project_id = keywords_delete.project_id; + + -- if we are deleting the root, remove it from the project as well + if delete_root_p = 't' then + update bt_projects + set root_keyword_id = null + where project_id = keywords_delete.project_id; + end if; + + -- delete the projects keywords + + -- Keep looping over all project keywords, deleting all + -- leaf nodes, until everything has been deleted + loop + v_changed_p := 'f'; + for rec in + (select keyword_id + from (select keyword_id + from cr_keywords + start with keyword_id = v_root_keyword_id + connect by prior keyword_id = parent_id) q + where content_keyword.is_leaf(keyword_id) = 't') + loop + if (delete_root_p = 't') or (rec.keyword_id != v_root_keyword_id) then + content_keyword.delete(rec.keyword_id); + v_changed_p := 't'; + end if; + end loop; + + exit when v_changed_p = 'f'; + end loop; + + end keywords_delete; + +end bt_project; +/ +show errors Index: openacs-4/packages/bug-tracker/sql/postgresql/bug-tracker-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bug-tracker/sql/postgresql/bug-tracker-create.sql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/bug-tracker/sql/postgresql/bug-tracker-create.sql 5 Mar 2003 17:40:28 -0000 1.7 +++ openacs-4/packages/bug-tracker/sql/postgresql/bug-tracker-create.sql 14 Apr 2003 13:34:44 -0000 1.8 @@ -122,10 +122,6 @@ perform bt_patch__delete(rec.patch_id); end loop; - -- delete the content folder - raise notice ''about to delete content_folder.''; - perform content_folder__delete(v_folder_id); - -- delete the projects keywords perform bt_projects__keywords_delete(p_project_id, ''t''); @@ -136,6 +132,10 @@ delete from bt_projects where project_id = p_project_id; + -- delete the content folder + raise notice ''about to delete content_folder.''; + perform content_folder__delete(v_folder_id); + return 0; end; ' language 'plpgsql'; Index: openacs-4/packages/bug-tracker/sql/postgresql/upgrade-1.2d2-1.2d6.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bug-tracker/sql/postgresql/upgrade-1.2d2-1.2d6.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bug-tracker/sql/postgresql/upgrade-1.2d2-1.2d6.sql 14 Apr 2003 13:34:44 -0000 1.1 @@ -0,0 +1,49 @@ +-- Change CR keywords to be deleted after row in bt_projects to avoid +-- referentail constraint violation + +create or replace function bt_project__delete( + integer -- project_id +) returns integer +as ' +declare + p_project_id alias for $1; + v_folder_id integer; + v_root_keyword_id integer; + rec record; +begin + -- get the content folder for this instance + select folder_id, root_keyword_id + into v_folder_id, v_root_keyword_id + from bt_projects + where project_id = p_project_id; + + -- This gets done in tcl before we are called ... for now + -- Delete the bugs + -- for rec in select item_id from cr_items where parent_id = v_folder_id + -- loop + -- perform bt_bug__delete(rec.item_id); + -- end loop; + + -- Delete the patches + for rec in select patch_id from bt_patches where project_id = p_project_id + loop + perform bt_patch__delete(rec.patch_id); + end loop; + + -- delete the projects keywords + perform bt_projects__keywords_delete(p_project_id, ''t''); + + -- These tables should really be set up to cascade + delete from bt_versions where project_id = p_project_id; + delete from bt_components where project_id = p_project_id; + delete from bt_user_prefs where project_id = p_project_id; + + delete from bt_projects where project_id = p_project_id; + + -- delete the content folder + raise notice ''about to delete content_folder.''; + perform content_folder__delete(v_folder_id); + + return 0; +end; +' language 'plpgsql';