Index: openacs-4/packages/acs-content-repository/tcl/revision-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/revision-procs.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-content-repository/tcl/revision-procs.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+ select content_revision__new(:title,
+ null,
+ now(),
+ 'text/plain',
+ ' ',
+ :item_id
+ )
+
+
+
+
+
+
+
+ update
+ cr_revisions
+ set
+ content = '[cr_create_content_file $item_id $revision_id $path]'
+ where
+ revision_id = :revision_id
+
+
+
+
+
+
+ select i.storage_type, i.storage_area_key, r.mime_type, i.item_id
+ from cr_items i, cr_revisions r
+ where r.revision_id = :revision_id and i.item_id = r.item_id
+
+
+
+
+
+ select content
+ from cr_revisions
+ where revision_id = :revision_id
+
+
+
+
Index: openacs-4/packages/acs-subsite/www/shared/portrait-bits.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/shared/Attic/portrait-bits.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-subsite/www/shared/portrait-bits.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+
+
+ select c.item_id
+ from acs_rels a, cr_items c
+ where a.object_id_two = c.item_id
+ and a.object_id_one = :user_id
+ and a.rel_type = 'user_portrait_rel'
+
+
+
+
Index: openacs-4/packages/general-comments/www/file-add-2-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/file-add-2-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/general-comments/www/file-add-2-oracle.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,70 @@
+
+
+
+ oracle8.1.6
+
+
+
+
+ begin
+ :1 := acs_message.new_image (
+ message_id => :parent_id,
+ image_id => :attach_id,
+ file_name => :client_filename,
+ title => :title,
+ mime_type => :guessed_file_type,
+ content => empty_blob(),
+ width => :original_width,
+ height => :original_height,
+ creation_user => :user_id,
+ creation_ip => :creation_ip,
+ is_live => :is_live
+ );
+ end;
+
+
+
+
+
+
+
+
+ begin
+ :1 := acs_message.new_file (
+ message_id => :parent_id,
+ file_id => :attach_id,
+ file_name => :client_filename,
+ title => :title,
+ mime_type => :guessed_file_type,
+ content => empty_blob(),
+ creation_user => :user_id,
+ creation_ip => :creation_ip,
+ is_live => :is_live
+ );
+ end;
+
+
+
+
+
+
+
+
+ select content_item.get_latest_revision(:attach_id) as revision_id
+ from dual
+
+
+
+
+
+
+
+ update cr_revisions
+ set filename = '$tmp_filename',
+ content_length = $tmp_size
+ where revision_id = :revision_id
+
+
+
+
+
Index: openacs-4/packages/general-comments/www/file-add-2-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/file-add-2-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/general-comments/www/file-add-2-postgresql.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,63 @@
+
+
+
+ postgresql7.1
+
+
+
+
+ select acs_message__new_image (
+ /* message_id => */ :parent_id,
+ /* image_id => */ :attach_id,
+ /* file_name => */ :client_filename,
+ /* title => */ :title,
+ /* description => */ NULL,
+ /* mime_type => */ :guessed_file_type,
+ /* content => */ NULL,
+ /* width => */ :original_width,
+ /* height => */ :original_height,
+ /* create_date => */ current_timestamp,
+ /* creation_user => */ :user_id,
+ /* creation_ip => */ :creation_ip,
+ /* is_live => */ :is_live
+ );
+
+
+
+
+
+
+
+ select acs_message__new_file (
+ /* message_id => */ :parent_id,
+ /* file_id => */ :attach_id,
+ /* file_name => */ :client_filename,
+ /* title => */ :title,
+ /* description => */ NULL,
+ /* mime_type => */ :guessed_file_type,
+ /* content => */ NULL,
+ /* creation_date => */ current_timestamp,
+ /* creation_user => */ :user_id,
+ /* creation_ip => */ :creation_ip,
+ /* is_live => */ :is_live
+ );
+
+
+
+
+
+
+ select content_item__get_latest_revision(:attach_id) as revision_id
+
+
+
+
+
+ update cr_revisions
+ set content = '$tmp_filename',
+ content_length = $tmp_size
+ where revision_id = :revision_id
+
+
+
+
Index: openacs-4/packages/general-comments/www/file-add-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/Attic/file-add-2.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/general-comments/www/file-add-2.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ select mime_type
+ from cr_mime_types
+ where mime_type = :guessed_file_type
+
+
+
+
+
Index: openacs-4/packages/general-comments/www/file-edit-2-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/file-edit-2-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/general-comments/www/file-edit-2-oracle.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,15 @@
+
+
+
+ oracle8.1.6
+
+
+
+
+ select content_item.get_latest_revision(:attach_id) as revision_id from dual
+
+
+
+
+
+
Index: openacs-4/packages/general-comments/www/file-edit-2-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/file-edit-2-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/general-comments/www/file-edit-2-postgresql.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,15 @@
+
+
+
+ postgresql7.1
+
+
+
+
+ select content_item__get_latest_revision(:attach_id) as revision_id
+
+
+
+
+
+
Index: openacs-4/packages/general-comments/www/file-edit-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/file-edit-2.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/general-comments/www/file-edit-2.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ update cr_revisions
+ set title = :title
+ where revision_id = :revision_id
+
+
+
+
+
+
Index: openacs-4/packages/general-comments/www/file-edit-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/file-edit-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/general-comments/www/file-edit-oracle.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,19 @@
+
+
+
+ oracle8.1.6
+
+
+
+
+ select r.title,
+ i.name as file_name
+ from cr_items i, cr_revisions r
+ where i.item_id = :attach_id and
+ r.revision_id = content_item.get_latest_revision(i.item_id)
+
+
+
+
+
+
Index: openacs-4/packages/general-comments/www/file-edit-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/file-edit-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/general-comments/www/file-edit-postgresql.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,19 @@
+
+
+
+ postgresql7.1
+
+
+
+
+ select r.title,
+ i.name as file_name
+ from cr_items i, cr_revisions r
+ where i.item_id = :attach_id and
+ r.revision_id = content_item__get_latest_revision(i.item_id)
+
+
+
+
+
+
Index: openacs-4/packages/general-comments/www/view-image.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/view-image.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/general-comments/www/view-image.xql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ select i.name,
+ r.title,
+ m.width,
+ m.height
+ from cr_items i,
+ cr_revisions r,
+ images m
+ where i.item_id = :image_id and
+ r.revision_id = i.live_revision and
+ r.revision_id = m.image_id
+
+
+
+
+
+
Index: openacs-4/packages/glossary/sql/postgresql/glossary-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/glossary/sql/postgresql/glossary-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/glossary/sql/postgresql/glossary-create.sql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,269 @@
+-- packages/glossary/sql/glossary-create.sql
+
+-- @author Walter McGinnis (walter@arsdigita.com)
+-- @creation-date 2000-08-18
+-- @cvs-id $ID:$
+
+-- glossaries
+--
+
+create table glossaries (
+ glossary_id integer
+ constraint glossaries_glossary_id_fk
+ references cr_revisions on delete cascade
+ constraint glossaries_glossary_id_pk
+ primary key,
+ owner_id integer
+ constraint glossaries_owner_id_fk
+ references parties,
+ package_id integer
+ constraint glossaries_package_id_fk
+ references apm_packages,
+ workflow_key varchar(100)
+ constraint glossaries_workflow_key_fk
+ references wf_workflows
+);
+
+comment on table glossaries is 'glossary table to store the object''s custom attributes,
+note standard auditing information is stored acs_objects,
+such as creation_user, creation_date, last_modified, etc.
+these act as primary containers for terms (glossary content_item),
+a term''s context_id will point to its glossary and terms will also be mapped using cr_child_rels table';
+
+comment on column glossaries.owner_id is 'the creation_user may not always be the owner of a module after is created, so we have a seperate column that references the parties table so that we owner''s can be either individual''s or groups';
+
+comment on column glossaries.package_id is 'we use this rather than always counting on context_id to give us the right permissions, because package instances may share grant the same permission to the same party, but they are not the same set of glossaries ';
+
+-- create a glossary object type
+declare
+ attr_id acs_attributes.attribute_id%TYPE;
+begin
+ content_type.create_type (
+ supertype => 'content_revision',
+ content_type => 'glossary',
+ pretty_name => 'Glossary',
+ pretty_plural => 'Glossaries',
+ table_name => 'glossaries',
+ id_column => 'glossary_id'
+ );
+
+ attr_id := content_type.create_attribute (
+ content_type => 'glossary',
+ attribute_name => 'owner_id',
+ pretty_name => 'Owner_id',
+ datatype => 'number'
+ );
+
+ attr_id := content_type.create_attribute (
+ content_type => 'glossary',
+ attribute_name => 'package_id',
+ pretty_name => 'Package_id',
+ datatype => 'number'
+ );
+
+ attr_id := content_type.create_attribute (
+ content_type => 'glossary',
+ attribute_name => 'workflow_key',
+ pretty_name => 'Workflow Process',
+ datatype => 'string'
+ );
+
+commit;
+end;
+/
+show errors
+
+-- should add locale and nls_language for full internationalization?
+-- this is dependent on the standards for ACS globilization
+-- will do the right thing later
+
+create or replace package glossary
+as
+ function new(
+ owner_id in parties.party_id%TYPE,
+ name in cr_items.name%TYPE,
+ title in cr_revisions.title%TYPE,
+ description in cr_revisions.description%TYPE default null,
+ package_id in apm_packages.package_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,
+ context_id in acs_objects.context_id%TYPE default null,
+ is_live in char default 'f'
+ ) return cr_items.item_id%TYPE;
+
+end;
+/
+show errors
+
+create or replace package body glossary
+as
+ function new(
+ owner_id in parties.party_id%TYPE,
+ name in cr_items.name%TYPE,
+ title in cr_revisions.title%TYPE,
+ description in cr_revisions.description%TYPE default null,
+ package_id in apm_packages.package_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,
+ context_id in acs_objects.context_id%TYPE default null,
+ is_live in char default 'f'
+ ) return cr_items.item_id%TYPE is
+ v_item_id integer;
+ v_revision_id integer;
+ begin
+
+ v_item_id := content_item.new(
+ name => name,
+ content_type => 'glossary',
+ creation_date => creation_date,
+ creation_user => creation_user,
+ creation_ip => creation_ip,
+ context_id => context_id
+ );
+
+ v_revision_id := content_revision.new(
+ item_id => v_item_id,
+ title => title,
+ description => description,
+ creation_date => creation_date,
+ creation_user => creation_user,
+ creation_ip => creation_ip
+ );
+
+ insert into glossaries (
+ glossary_id, owner_id, package_id
+ ) values (
+ v_revision_id, owner_id, package_id
+ );
+
+ if is_live = 't' then
+ update cr_revisions
+ set publish_date = sysdate
+ where revision_id = v_revision_id;
+
+ update cr_items
+ set publish_status = 'live',
+ live_revision = v_revision_id
+ where item_id =v_item_id;
+ end if;
+
+ return v_item_id;
+
+ end new;
+
+end glossary;
+/
+show errors
+
+-- terms
+
+create table glossary_terms (
+ term_id constraint glossary_terms_term_id_fk
+ references cr_revisions on delete cascade
+ constraint glossary_terms_pk
+ primary key
+);
+
+comment on table glossary_terms is 'most of the info for terms is stored in the content repository (cr_items and cr_revisions), terms essentially are composed of the two componants; the term and its definition in addition, an image can be associated with a term as illustration, terms inherit security settings via context_id which should point at the parent glossary), we use the cr_child_rels to map terms to glossaries for general parentage
+';
+
+begin
+ -- create the content type
+ content_type.create_type(
+ supertype => 'content_revision',
+ content_type => 'glossary_term',
+ pretty_name => 'Term',
+ pretty_plural => 'Terms',
+ table_name => 'glossary_terms',
+ id_column => 'term_id'
+ );
+
+ commit;
+
+end;
+/
+show errors
+
+-- establish the parent child relationship between the glossary content type and the glossary term content type
+
+begin
+ content_type.register_child_type('glossary','glossary_term','parent glossary');
+end;
+/
+show errors
+
+create or replace view glossary_terms_latest as
+ select i.item_id, i.live_revision, r.revision_id as latest_revision,
+ title as term, name, content as definition, publish_status, r.mime_type
+ from cr_items i, cr_revisions r
+ where i.content_type = 'glossary_term'
+ and r.item_id = i.item_id
+ and r.revision_id = content_item.get_latest_revision(i.item_id);
+
+create or replace view glossary_terms_live_definition as
+ select i.item_id, r.revision_id,
+ title as term, name, content as definition, r.mime_type
+ from cr_items i, cr_revisions r
+ where i.content_type = 'glossary_term'
+ and r.item_id = i.item_id
+ and r.revision_id = i.live_revision
+ and i.publish_status = 'live';
+
+-- an "illustration" is a mapping of an image content_type to a glossary_term parent content_type
+
+begin
+ content_type.register_child_type('glossary_term','image','illustration');
+end;
+/
+show errors
+
+-- permissions for glossaries and terms and illustrations
+
+-- in the implementation we will grant all of the above on the glossary object
+-- the term object will then point its context_id at the glossary object
+-- to inherit the permissions scheme
+-- note that we grant the generic read privilege to users as well
+begin
+ acs_privilege.create_privilege('glossary_create');
+ acs_privilege.create_privilege('glossary_modify');
+ acs_privilege.create_privilege('glossary_delete');
+ acs_privilege.create_privilege('glossary_term_comment_on');
+ acs_privilege.create_privilege('glossary_term_comment_read');
+ acs_privilege.create_privilege('glossary_term_create');
+ acs_privilege.create_privilege('glossary_term_modify');
+ acs_privilege.create_privilege('glossary_term_delete');
+ acs_privilege.create_privilege('glossary_term_add_illustration');
+ acs_privilege.create_privilege('glossary_term_modify_illustration');
+ acs_privilege.create_privilege('glossary_term_delete_illustration');
+end;
+/
+show errors
+
+begin
+ acs_privilege.create_privilege('glossary_admin');
+
+ acs_privilege.add_child('glossary_admin','glossary_create');
+ acs_privilege.add_child('glossary_admin','glossary_modify');
+ acs_privilege.add_child('glossary_admin','glossary_delete');
+ acs_privilege.add_child('glossary_admin','glossary_term_comment_read');
+ acs_privilege.add_child('glossary_admin','glossary_term_comment_on');
+ acs_privilege.add_child('glossary_admin','glossary_term_create');
+ acs_privilege.add_child('glossary_admin','glossary_term_modify');
+ acs_privilege.add_child('glossary_admin','glossary_term_delete');
+ acs_privilege.add_child('glossary_admin','glossary_term_add_illustration');
+ acs_privilege.add_child('glossary_admin','glossary_term_modify_illustration');
+ acs_privilege.add_child('glossary_admin','glossary_term_delete_illustration');
+end;
+/
+show errors
+
+begin
+ content_folder.register_content_type( -100, 'glossary', 't');
+ content_folder.register_content_type( -100, 'glossary_term', 't');
+end;
+/
+show errors
+
+@@ glossary-workflows.sql
Index: openacs-4/packages/glossary/sql/postgresql/glossary-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/glossary/sql/postgresql/glossary-drop.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/glossary/sql/postgresql/glossary-drop.sql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,123 @@
+-- packages/glossary/sql/glossary-drop.sql
+
+-- @author Walter McGinnis (walter@arsdigita.com)
+-- @creation-date 2000-10-03
+-- @cvs-id $ID:$
+
+-- NOTE THIS SCRIPT IS PRETTY CLOSE TO COMPLETE BUT NOT QUITE
+-- drop scripts have become a real pain in ACS 4.0
+-- will debug for final release
+-- in the meantime this is a good starting point and will get most everything
+-- the main sticking point is dropping privileges
+
+-- drop the glossary data model
+
+select content_folder__unregister_content_type(-100, 'glossary_term', 't');
+select content_folder__unregister_content_type(-100, 'glossary', 't');
+
+drop function glossary__new(integer, varchar, varchar, varchar, integer, integer, varchar, integer, boolean);
+
+-- drop all grantings of privleges
+-- and then drop privileges on glossaries
+
+select acs_privilege__remove_child('glossary_admin','glossary_create');
+select acs_privilege__remove_child('glossary_admin','glossary_modify');
+select acs_privilege__remove_child('glossary_admin','glossary_delete');
+select acs_privilege__remove_child('glossary_admin','glossary_term_comment_read');
+select acs_privilege__remove_child('glossary_admin','glossary_term_comment_on');
+select acs_privilege__remove_child('glossary_admin','glossary_term_create');
+select acs_privilege__remove_child('glossary_admin','glossary_term_modify');
+select acs_privilege__remove_child('glossary_admin','glossary_term_delete');
+select acs_privilege__remove_child('glossary_admin','glossary_term_add_illustration');
+select acs_privilege__remove_child('glossary_admin','glossary_term_modify_illustration');
+select acs_privilege__remove_child('glossary_admin','glossary_term_delete_illustration');
+
+select acs_privilege__drop_privilege('glossary_admin');
+select acs_privilege__drop_privilege('glossary_create');
+select acs_privilege__drop_privilege('glossary_modify');
+select acs_privilege__drop_privilege('glossary_delete');
+select acs_privilege__drop_privilege('glossary_term_comment_on');
+select acs_privilege__drop_privilege('glossary_term_comment_read');
+select acs_privilege__drop_privilege('glossary_term_create');
+select acs_privilege__drop_privilege('glossary_term_modify');
+select acs_privilege__drop_privilege('glossary_term_delete');
+select acs_privilege__drop_privilege('glossary_term_add_illustration');
+select acs_privilege__drop_privilege('glossary_term_modify_illustration');
+select acs_privilege__drop_privilege('glossary_term_delete_illustration');
+
+-- delete all mappings of illustrations
+-- (this leaves the source images in place)
+-- and then the mapping type
+
+delete from cr_child_rels where relation_tag = 'illustration';
+select content_type__unregister_child_type('glossary', 'glossary_term', 'parent glossary');
+select content_type__unregister_child_type('glossary_term','image','illustration');
+
+-- delete all glosary_term objects
+
+-- we must clear out our term objects,
+-- otherwise there will be foreign key constraint problems
+-- hopedully the 'on delete cascade' in glossary_terms.term_id
+-- will clear out the objects that reference the terms in cr_revisions and acs_objects
+-- with the acs_objects table when we try dropping the
+-- object types
+
+create function inline_0() returns integer as '
+declare
+ glossary_term glossary_terms%ROWTYPE;
+begin
+ for glossary_term in select * from glossary_terms loop
+ select content_item__delete(glossary_term.term_id);
+ end loop;
+ return 0;
+end;' language 'plpgsql';
+
+select inline_0();
+drop function inline_0();
+
+select content_type__drop_type('glossary_term', 'f', 'f');
+
+drop view glossary_termsi;
+drop view glossary_termsx;
+drop table glossary_terms;
+
+-- we must clear out our glossary objects,
+-- otherwise there will be foreign key constraint problems
+-- with the acs_objects table when we try dropping the
+-- object types
+
+create function inline_0() returns integer as '
+declare
+ glossary glossaries%ROWTYPE;
+begin
+ for glossary in select * from glossaries loop
+ select content_item__delete(glossary__id);
+ end loop;
+ return 0;
+end;' language 'plpgsql';
+
+select inline_0();
+drop function inline_0();
+
+
+-- dropping the attributes for glossaries
+
+select content_type__drop_type('glossary', 'f', 'f');
+
+-- finish up
+drop view glossary_terms_latest;
+drop view glossary_terms_live_definition;
+drop view glossariesi;
+drop view glossariesx;
+drop table glossaries;
+
+-- drop workflows
+
+drop table full_term_publish_proces_cases;
+select workflow__drop_workflow('full_term_publish_process_wf');
+
+drop table term_submission_process_cases;
+select workflow__drop_workflow('term_submission_process_wf');
+
+drop table term_go_live_process_cases;
+select workflow__drop_workflow('term_go_live_wf');
Index: openacs-4/packages/glossary/sql/postgresql/glossary-workflows.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/glossary/sql/postgresql/glossary-workflows.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/glossary/sql/postgresql/glossary-workflows.sql 31 Oct 2001 20:46:59 -0000 1.1
@@ -0,0 +1,329 @@
+-- glossary/sql/glossary-workflows.sql
+-- walter@arsdigita.com, 11-26-2000
+
+-- load some default workflows for the glossary package
+-- each glossary decides on a workflow
+
+-- create the full term publishing process workflow
+-- the alternative is a simple workflow (i.e. submit -> approve)
+
+
+create table full_term_publish_proces_cases (
+ case_id integer primary key
+ constraint full_term_publish_proc_case_fk
+ references wf_cases on delete cascade
+);
+
+select workflow__create_workflow(
+ 'full_term_publish_process_wf',
+ 'Full Term Publish Process',
+ 'Full Term Publish Processes',
+ 'Fairly sophisticatd standard glossary term publishing. Publisher or Editor create a term. Author writes definition. Editor edits definition. Graphic designer adds and illustration. Editor or publisher approve or reject new term.',
+ 'full_term_publish_proces_cases',
+ 'case_id'
+ );
+
+begin;
+insert into wf_places (
+place_key, workflow_key, place_name, sort_order
+) values (
+'start', 'full_term_publish_process_wf', 'Ready to Author Definition.', 1
+);
+
+insert into wf_places (
+place_key, workflow_key, place_name, sort_order
+) values (
+'before_edit_definiton', 'full_term_publish_process_wf', 'Ready to Edit Definiton', 2
+);
+
+insert into wf_places (
+place_key, workflow_key, place_name, sort_order
+) values (
+'before_add_illustration', 'full_term_publish_process_wf', 'Ready to Add Illustration', 3
+);
+
+insert into wf_places (
+place_key, workflow_key, place_name, sort_order
+) values (
+'before_approve_new_term', 'full_term_publish_process_wf', 'Ready to Approve New Term', 4
+);
+
+insert into wf_places (
+place_key, workflow_key, place_name, sort_order
+) values (
+'end', 'full_term_publish_process_wf', 'Process finished', 5
+);
+end;
+
+begin;
+insert into wf_transitions (
+transition_key, transition_name, workflow_key, sort_order, trigger_type
+) values (
+'author_definition', 'Author Definition.', 'full_term_publish_process_wf', 1, 'user'
+);
+
+insert into wf_transitions (
+transition_key, transition_name, workflow_key, sort_order, trigger_type
+) values (
+'edit_definiton', 'Edit Definiton', 'full_term_publish_process_wf', 2, 'user'
+);
+
+insert into wf_transitions (
+transition_key, transition_name, workflow_key, sort_order, trigger_type
+) values (
+'add_illustration', 'Add Illustration', 'full_term_publish_process_wf', 3, 'user'
+);
+
+insert into wf_transitions (
+transition_key, transition_name, workflow_key, sort_order, trigger_type
+) values (
+'approve_new_term', 'Approve New Term', 'full_term_publish_process_wf', 4, 'user'
+);
+end;
+
+begin;
+insert into wf_arcs (
+workflow_key, transition_key, place_key, direction
+) values (
+'full_term_publish_process_wf', 'author_definition', 'start', 'in'
+);
+
+insert into wf_arcs (
+workflow_key, transition_key, place_key, direction
+) values (
+'full_term_publish_process_wf', 'author_definition',
+'before_edit_definiton', 'out'
+);
+
+insert into wf_arcs (
+workflow_key, transition_key, place_key, direction
+) values (
+'full_term_publish_process_wf', 'edit_definiton',
+'before_edit_definiton', 'in'
+);
+
+insert into wf_arcs (
+workflow_key, transition_key, place_key, direction, guard_callback, guard_description
+) values (
+'full_term_publish_process_wf', 'edit_definiton',
+'start', 'out', '#', 'Not Is definition correct'
+);
+
+insert into wf_arcs (
+workflow_key, transition_key, place_key, direction,
+guard_callback, guard_custom_arg, guard_description
+) values (
+'full_term_publish_process_wf', 'edit_definiton', 'before_add_illustration', 'out',
+'wf_callback.guard_attribute_true', 'edit_definiton_is_definition_correct_p', 'Is definition correct'
+);
+
+insert into wf_arcs (
+workflow_key, transition_key, place_key, direction
+) values (
+'full_term_publish_process_wf', 'add_illustration',
+'before_add_illustration', 'in'
+);
+
+insert into wf_arcs (
+workflow_key, transition_key, place_key, direction
+) values (
+'full_term_publish_process_wf', 'add_illustration',
+'before_approve_new_term', 'out'
+);
+
+insert into wf_arcs (
+workflow_key, transition_key, place_key, direction
+) values (
+'full_term_publish_process_wf', 'approve_new_term',
+'before_approve_new_term', 'in'
+);
+
+insert into wf_arcs (
+workflow_key, transition_key, place_key, direction, guard_callback, guard_description
+) values (
+'full_term_publish_process_wf', 'approve_new_term',
+'before_edit_definiton', 'out', '#', 'Not Approved'
+);
+
+insert into wf_arcs (
+workflow_key, transition_key, place_key, direction,
+guard_callback, guard_custom_arg, guard_description
+) values (
+'full_term_publish_process_wf', 'approve_new_term', 'end', 'out',
+'wf_callback.guard_attribute_true', 'approve_new_term_approved_p', 'Approved'
+);
+end;
+
+create function inline_0() returns integer as '
+declare
+ v_attribute_id integer;
+begin
+ v_attribute_id := workflow__create_attribute(
+ ''full_term_publish_process_wf'',
+ ''edit_definiton_is_definition_correct_p'',
+ ''boolean'',
+ ''Is definition correct'',
+ NULL,
+ NULL,
+ NULL,
+ ''t'',
+ 1,
+ 1,
+ NULL,
+ ''generic'',
+ ''none''
+ );
+
+ insert into wf_transition_attribute_map (
+ workflow_key, transition_key, attribute_id, sort_order
+ ) values (
+ ''full_term_publish_process_wf'', ''edit_definiton'', v_attribute_id, 1);
+
+ return 0;
+
+end;' language 'plpgsql';
+
+select inline_0();
+drop function inline_0();
+
+create function inline_0() returns integer as '
+declare
+ v_attribute_id integer;
+begin
+ v_attribute_id := workflow__create_attribute(
+ ''full_term_publish_process_wf'',
+ ''approve_new_term_approved_p'',
+ ''boolean'',
+ ''Approved'',
+ NULL,
+ NULL,
+ NULL,
+ ''t'',
+ 1,
+ 1,
+ NULL,
+ ''generic'',
+ ''none''
+ );
+
+ insert into wf_transition_attribute_map (
+ workflow_key, transition_key, attribute_id, sort_order
+ ) values (
+ ''full_term_publish_process_wf'', ''approve_new_term'', v_attribute_id, 1
+ );
+
+ return 0;
+
+end;' language 'plpgsql';
+
+select inline_0();
+drop function inline_0();
+
+begin;
+insert into wf_transition_assignment_map (
+workflow_key, transition_key, assign_transition_key
+) values (
+'full_term_publish_process_wf', 'edit_definiton', 'add_illustration'
+);
+
+insert into wf_context_transition_info (
+context_key, workflow_key, transition_key, estimated_minutes
+) values (
+'default', 'full_term_publish_process_wf', 'author_definition', 60
+);
+
+insert into wf_context_transition_info (
+context_key, workflow_key, transition_key, estimated_minutes
+) values (
+'default', 'full_term_publish_process_wf', 'edit_definiton', 20
+);
+
+insert into wf_context_transition_info (
+context_key, workflow_key, transition_key, estimated_minutes
+) values (
+'default', 'full_term_publish_process_wf', 'add_illustration', 120
+);
+
+insert into wf_context_transition_info (
+context_key, workflow_key, transition_key, estimated_minutes
+) values (
+'default', 'full_term_publish_process_wf', 'approve_new_term', 10
+);
+end;
+
+-- simple term submission process
+
+create table term_submission_process_cases (
+ case_id integer primary key
+ constraint term_submission_proces_case_fk
+ references wf_cases on delete cascade
+);
+
+select workflow__create_workflow(
+ 'term_submission_process_wf',
+ 'Term Submission Process',
+ 'Term Submission Processes',
+ 'User submits new term and its definition (and maybe illustration). Administrator approves or rejects submission.',
+ 'term_submission_process_cases',
+ 'case_id'
+ );
+
+begin;
+ insert into wf_places (
+ place_key, workflow_key, place_name, sort_order
+ ) values (
+ 'start', 'term_submission_process_wf', 'Ready to Approve', 1
+ );
+
+ insert into wf_places (
+ place_key, workflow_key, place_name, sort_order
+ ) values (
+ 'end', 'term_submission_process_wf', 'Process finished', 2
+ );
+
+ insert into wf_transitions (
+ transition_key, transition_name, workflow_key, sort_order, trigger_type
+ ) values (
+ 'approve', 'Approve', 'term_submission_process_wf', 1, 'user'
+ );
+
+ insert into wf_arcs (
+ workflow_key, transition_key, place_key, direction
+ ) values (
+ 'term_submission_process_wf', 'approve', 'start', 'in'
+ );
+
+ insert into wf_arcs (
+ workflow_key, transition_key, place_key, direction
+ ) values (
+ 'term_submission_process_wf', 'approve', 'end', 'out'
+ );
+
+ insert into wf_context_transition_info (
+ context_key, workflow_key, transition_key, estimated_minutes
+ ) values (
+ 'default', 'term_submission_process_wf', 'approve', 10
+ );
+end;
+
+-- this is a special case inorder to maintain
+-- constraint integrity
+-- has the disadvantage, that is shows up on the workflow pages
+-- when it is really just a deadend
+-- oh well
+
+create table term_go_live_process_cases (
+ case_id integer primary key
+ constraint term_go_live_proces_case_fk
+ references wf_cases on delete cascade
+);
+
+select workflow__create_workflow(
+ 'term_go_live_wf',
+ 'Term Go Live Process',
+ 'Term Go Live Processes',
+ 'User submits new term and its definition (and maybe illustration) and it goes live immediately.',
+ 'term_go_live_process_cases',
+ 'case_id'
+ );
+