Index: openacs-4/contrib/obsolete-packages/acs-workflow/sql/oracle/sample-article-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/sql/oracle/sample-article-create.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/obsolete-packages/acs-workflow/sql/oracle/sample-article-create.sql	16 Oct 2001 01:36:19 -0000	1.3
+++ openacs-4/contrib/obsolete-packages/acs-workflow/sql/oracle/sample-article-create.sql	19 Nov 2001 18:17:46 -0000	1.4
@@ -19,7 +19,8 @@
 
 
 declare
-    v_workflow_key varchar2(40);
+    v_workflow_key wf_workflows.workflow_key%TYPE;
+    v_attribute_id acs_attributes.attribute_id%TYPE;
 begin
     v_workflow_key := workflow.create_workflow(
 	workflow_key => 'article_wf', 
@@ -28,73 +29,170 @@
 	description => 'Workflow for managing the publication of an article',
 	table_name => 'wf_article_cases'
     );
-end;
-/
-show errors
 
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('start', 'article_wf', 'Initial state', 1);
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('to_be_written', 'article_wf', 'Needs to be written', 2);
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('to_be_reviewed', 'article_wf', 'Needs review', 3);
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('to_go_to_press', 'article_wf', 'Ready to go to press', 4);
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('end', 'article_wf', 'End state', 5);
+    /*****
+     * Places 
+     *****/
+ 
+    workflow.add_place(
+        workflow_key => 'article_wf',
+        place_key => 'start',
+        place_name => 'Start place',
+        sort_order => 1
+    );
 
+    workflow.add_place(
+        workflow_key => 'article_wf',
+        place_key => 'to_be_written', 
+	place_name => 'Needs to be written', 
+        sort_order => 2
+    );
 
-insert into wf_transitions(transition_key, transition_name, workflow_key, sort_order, trigger_type) 
-    values ('specification', 'Description and assignment by editor', 'article_wf', 1, 'user');
-insert into wf_transitions(transition_key, transition_name, workflow_key, sort_order, trigger_type) 
-    values ('writing', 'Writing by author', 'article_wf', 2, 'user');
-insert into wf_transitions(transition_key, transition_name, workflow_key, sort_order, trigger_type)
-    values ('review', 'Approval by reviewer', 'article_wf', 3, 'user');
-insert into wf_transitions(transition_key, transition_name, workflow_key, sort_order, trigger_type) 
-    values ('press', 'Publication of article', 'article_wf', 4, 'automatic');
+    workflow.add_place(
+        workflow_key => 'article_wf',
+        place_key => 'to_be_reviewed', 
+	place_name => 'Needs review', 
+        sort_order => 3
+    );
 
+    workflow.add_place(
+        workflow_key => 'article_wf',
+        place_key => 'to_be_published', 
+	place_name => 'Ready to go to press', 
+        sort_order => 4
+    );
 
--- specification --
--- in
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('article_wf', 'specification', 'start', 'in');
--- out
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('article_wf', 'specification', 'to_be_written', 'out');
+    workflow.add_place(
+        workflow_key => 'article_wf',
+        place_key => 'end', 
+	place_name => 'End place', 
+        sort_order => 5
+    );
 
+    /*****
+     * Roles
+     *****/
 
--- writing
--- in
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('article_wf', 'writing', 'to_be_written', 'in');
--- out
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('article_wf', 'writing', 'to_be_reviewed', 'out');
+    workflow.add_role(
+        workflow_key => 'article_wf',
+        role_key => 'author',
+        role_name => 'Author',
+        sort_order => 1
+    );
 
+    workflow.add_role(
+        workflow_key => 'article_wf',
+        role_key => 'editor',
+        role_name => 'Editor',
+        sort_order => 2
+    );
 
--- review (or-split)
--- in
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('article_wf', 'review', 'to_be_reviewed', 'in');
--- out
-insert into wf_arcs(workflow_key, transition_key, place_key, direction, guard_callback, guard_custom_arg, guard_description) 
-    values ('article_wf', 'review', 'to_go_to_press', 'out', 'wf_callback.guard_attribute_true', 'reviewer_ok', 'Reviewer approved article');
-insert into wf_arcs(workflow_key, transition_key, place_key, direction, guard_callback, guard_description)
-    values ('article_wf', 'review', 'to_be_written', 'out', '#',  'Reviewer disapproved article');
+    /*****
+     * Transitions 
+     *****/
 
+    workflow.add_transition(
+        workflow_key => 'article_wf',
+        transition_key => 'specify',
+        transition_name => 'Describe task and assign author',
+        role_key => 'editor',
+        sort_order => 1,
+        trigger_type => 'user'
+    );
+        
+    workflow.add_transition(
+        workflow_key => 'article_wf',
+        transition_key => 'write',
+        transition_name => 'Write article',
+        role_key => 'author',
+        sort_order => 2,
+        trigger_type => 'user'
+    );
+        
+    workflow.add_transition(
+        workflow_key => 'article_wf',
+        transition_key => 'review',
+        transition_name => 'Review article',
+        role_key => 'editor',
+        sort_order => 3,
+        trigger_type => 'user'
+    );
+        
+    workflow.add_transition(
+        workflow_key => 'article_wf',
+        transition_key => 'publish',
+        transition_name => 'Publish article',
+        sort_order => 4,
+        trigger_type => 'automatic'
+    );
 
--- press
--- in
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('article_wf', 'press', 'to_go_to_press', 'in');
--- out
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('article_wf', 'press', 'end', 'out');
+    /*****
+     * Arcs 
+     *****/
 
+    workflow.add_arc(
+        workflow_key => 'article_wf',
+        from_place_key => 'start',
+        to_transition_key => 'specify'
+    );
 
-declare
-    v_attribute_id acs_attributes.attribute_id%TYPE;
-begin
+    workflow.add_arc(
+        workflow_key => 'article_wf',
+        from_transition_key => 'specify',
+        to_place_key => 'to_be_written'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'article_wf',
+        from_place_key => 'to_be_written',
+        to_transition_key => 'write'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'article_wf',
+        from_transition_key => 'write',
+        to_place_key => 'to_be_reviewed'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'article_wf',
+        from_place_key => 'to_be_reviewed',
+        to_transition_key => 'review'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'article_wf',
+        from_transition_key => 'review',
+        to_place_key => 'to_be_published',
+        guard_callback => 'wf_callback.guard_attribute_true',
+        guard_custom_arg => 'reviewer_ok',
+        guard_description => 'Reviewer approved article'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'article_wf',
+        from_transition_key => 'review',
+        to_place_key => 'to_be_written',
+        guard_callback => '#',
+        guard_description => 'Reviewer did not approve article'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'article_wf',
+        from_place_key => 'to_be_published',
+        to_transition_key => 'publish'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'article_wf',
+        from_transition_key => 'publish',
+        to_place_key => 'end'
+    );
+
+    /*****
+     * Attributes
+     *****/
+
     v_attribute_id := workflow.create_attribute(
 	workflow_key => 'article_wf',
 	attribute_name => 'reviewer_ok',
@@ -103,35 +201,42 @@
 	default_value => 'f'
     );
 
-    insert into wf_transition_attribute_map
-        (workflow_key, transition_key, attribute_id, sort_order) 
-    values
-        ('article_wf', 'review', v_attribute_id, 1);
+    workflow.add_trans_attribute_map(
+        workflow_key => 'article_wf',
+        transition_key => 'review',
+        attribute_name => 'reviewer_ok',
+        sort_order => 1
+    );
 
+    /*****
+     * Assignment
+     *****/
+
+    workflow.add_trans_role_assign_map(
+        workflow_key => 'article_wf',
+        transition_key => 'specify',
+        assign_role_key => 'author'
+    );
+
 end;
 /
-show errors;
+show errors
 
 
--- assignment as part of workflow
-insert into wf_transition_assignment_map 
-    (workflow_key, transition_key, assign_transition_key)
-values
-    ('article_wf', 'specification', 'writing');
-
-insert into wf_transition_assignment_map 
-    (workflow_key, transition_key, assign_transition_key)
-values
-    ('article_wf', 'specification', 'review');
-
-
 /* Context stuff */
 
-
 insert into wf_context_transition_info (
-    context_key, workflow_key, transition_key, hold_timeout_callback, hold_timeout_custom_arg
+    context_key, 
+    workflow_key,
+    transition_key, 
+    hold_timeout_callback, 
+    hold_timeout_custom_arg
 ) values (
-    'default', 'article_wf', 'specification', 'wf_callback.time_sysdate_plus_x', 1/24
+    'default', 
+    'article_wf', 
+    'specify', 
+    'wf_callback.time_sysdate_plus_x', 
+    1/24
 );
 
 commit;
@@ -169,7 +274,6 @@
         v_object_name varchar2(4000);
         v_transition_name wf_transitions.transition_name%TYPE;
         v_name varchar2(1000);
-        v_request_id integer;
     begin
         select to_char(ta.deadline,'Mon fmDDfm, YYYY HH24:MI:SS'),
                acs_object.name(c.object_id),
@@ -196,40 +300,19 @@
             body := body ||'Deadline: '||v_deadline_pretty||'
 ';
         end if;
-
-        -- NOTICE, NOTICE, NOTICE
-        --
-        -- Since postgresql does not support out parameters, this 
-        -- function call has been moved into the callback function.
-        -- If you implement a new notification callback, make sure 
-        -- that this function call is included at the end of the 
-        -- callback routine.
-
-        -- The oracle version has been changed to be consistent 
-        -- with the postgresql version, even though technically
-        -- it is not necessary.
-        --
-        -- DanW (dcwickstrom@earthlink.net)
-
-        v_request_id := acs_mail_nt.post_request (       
-             party_from => party_from,
-             party_to => party_to,
-             expand_group => 'f',
-             subject => subject,
-             message => body,
-             max_retries => 0
-         );
     end notification;
 
 end wf_article_callback;
 /
 show errors
 
 
+
+
 update wf_context_transition_info
-set notification_callback = 'wf_article_callback.notification'
-where workflow_key = 'article_wf'
-and   context_key = 'default'
-and   transition_key = 'specification';
+   set notification_callback = 'wf_article_callback.notification'
+ where workflow_key = 'article_wf'
+   and context_key = 'default'
+   and transition_key = 'specify';
 
 commit;
