Index: openacs-4/contrib/obsolete-packages/acs-workflow/sql/oracle/sample-expenses-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/sql/oracle/sample-expenses-create.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/obsolete-packages/acs-workflow/sql/oracle/sample-expenses-create.sql	12 Apr 2001 18:28:31 -0000	1.3
+++ openacs-4/contrib/obsolete-packages/acs-workflow/sql/oracle/sample-expenses-create.sql	19 Nov 2001 18:17:46 -0000	1.4
@@ -9,15 +9,18 @@
 --
 -- @cvs-id $Id$
 --
+
 /* This table will hold one row for each case using this workflow. */
 create table wf_expenses_cases (
   case_id 		integer primary key
 			constraint wf_expenses_cases_case_fk
 			references wf_cases on delete cascade
 );
 
+
 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 => 'expenses_wf', 
@@ -26,142 +29,311 @@
 	description => 'Workflow for authorizing employee''s expenses on the company''s behalf', 
 	table_name => 'wf_expenses_cases'
     );
-end;
-/
-show errors
 
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('start', 'expenses_wf', 'Initial state', 1);
-insert into wf_places(place_key, workflow_key, place_name, sort_order)
-    values ('assignments_done', 'expenses_wf', 'Tasks have been assigned', 2);
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('supervisor_to_approve', 'expenses_wf', 'Supervisor is to approve', 3);
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('other_to_approve', 'expenses_wf', 'Other is to approve', 4);
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('supervisor_approved', 'expenses_wf', 'Supervisor has approved', 5);
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('other_approved', 'expenses_wf', 'Other has approved', 6);
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('ready_to_buy', 'expenses_wf', 'Both have approved', 8);
-insert into wf_places(place_key, workflow_key, place_name, sort_order) 
-    values ('end', 'expenses_wf', 'End state', 9);
+    /*****
+     * Places
+     *****/
 
+    workflow.add_place(
+        workflow_key => 'expenses_wf',
+        place_key => 'start',
+        place_name => 'Start place',
+        sort_order => 1
+    );
+    
+    workflow.add_place(
+        workflow_key => 'expenses_wf',
+        place_key => 'assignments_done',
+        place_name => 'Tasks have been assigned',
+        sort_order => 2
+    );
 
-insert into wf_transitions(transition_key, transition_name, workflow_key, sort_order, trigger_type) 
-    values ('assign', 'Assign users to approval', 'expenses_wf', 1, 'user');
-insert into wf_transitions(transition_key, transition_name, workflow_key, sort_order, trigger_type) 
-    values ('and_split', 'Both supervisor and Other approval', 'expenses_wf', 2, 'automatic');
-insert into wf_transitions(transition_key, transition_name, workflow_key, sort_order, trigger_type) 
-    values ('supervisor_approval', 'Supervisor approval', 'expenses_wf', 3, 'user');
-insert into wf_transitions(transition_key, transition_name, workflow_key, sort_order, trigger_type)
-    values ('other_approval', 'Other approval', 'expenses_wf', 4, 'user');
-insert into wf_transitions(transition_key, transition_name, workflow_key, sort_order, trigger_type) 
-    values ('and_join', 'Supervisor and other approval both done', 'expenses_wf', 5, 'automatic');
-insert into wf_transitions(transition_key, transition_name, workflow_key, sort_order, trigger_type) 
-    values ('buy', 'Buy stuff', 'expenses_wf', 6, 'user');
+    workflow.add_place(
+        workflow_key => 'expenses_wf',
+        place_key => 'supervisor_to_approve',
+        place_name => 'Supervisor is to approve',
+        sort_order => 3
+    );
 
--- assign --
--- in
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'assign', 'start', 'in');
--- out
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'assign', 'assignments_done', 'out');
+    workflow.add_place(
+        workflow_key => 'expenses_wf',
+        place_key => 'other_to_approve',
+        place_name => 'Other is to approve',
+        sort_order => 4
+    );
 
+    workflow.add_place(
+        workflow_key => 'expenses_wf',
+        place_key => 'supervisor_approved',
+        place_name => 'Supervisor has approved',
+        sort_order => 5
+    );
 
--- and-split --
--- in
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'and_split', 'assignments_done', 'in');
--- out
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'and_split', 'supervisor_to_approve', 'out');
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'and_split', 'other_to_approve', 'out');
+    workflow.add_place(
+        workflow_key => 'expenses_wf',
+        place_key => 'other_approved',
+        place_name => 'Other has approved',
+        sort_order => 6
+    );
 
+    workflow.add_place(
+        workflow_key => 'expenses_wf',
+        place_key => 'ready_to_buy',
+        place_name => 'Both have approved',
+        sort_order => 7
+    );
 
--- supervisor_approval
--- in
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'supervisor_approval', 'supervisor_to_approve', 'in');
--- out
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'supervisor_approval', 'supervisor_approved', 'out');
+    workflow.add_place(
+        workflow_key => 'expenses_wf',
+        place_key => 'end',
+        place_name => 'End place',
+        sort_order => 8
+    );
 
+    /*****
+     * Roles
+     *****/
 
--- other-approval
--- in
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'other_approval', 'other_to_approve', 'in');
--- out
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'other_approval', 'other_approved', 'out');
+    workflow.add_role(
+        workflow_key => 'expenses_wf',
+        role_key => 'assignor',
+        role_name => 'Assignor',
+        sort_order => 1
+    );
 
+    workflow.add_role(
+        workflow_key => 'expenses_wf',
+        role_key => 'supervisor',
+        role_name => 'Supervisor',
+        sort_order => 2
+    );
 
--- and-join and or-split
--- in
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'and_join', 'supervisor_approved', 'in');
-insert into wf_arcs(workflow_key, transition_key, place_key, direction) 
-    values ('expenses_wf', 'and_join', 'other_approved', 'in');
--- out
-insert into wf_arcs(workflow_key, transition_key, place_key, direction, guard_callback, guard_description) 
-    values ('expenses_wf', 'and_join', 'ready_to_buy', 'out', 'wf_expenses.guard_both_approved_p', 'Both supervisor and CEO approved');
-insert into wf_arcs(workflow_key, transition_key, place_key, direction, guard_callback, guard_description)
-    values ('expenses_wf', 'and_join', 'end', 'out', '#', 'Either supervisor or CEO did not approve');
+    workflow.add_role(
+        workflow_key => 'expenses_wf',
+        role_key => 'other',
+        role_name => 'Other approver',
+        sort_order => 3
+    );
 
--- buy
--- in
-insert into wf_arcs(workflow_key, transition_key, place_key, direction)
-    values ('expenses_wf', 'buy', 'ready_to_buy', 'in');
--- out
-insert into wf_arcs(workflow_key, transition_key, place_key, direction)
-    values ('expenses_wf', 'buy', 'end', 'out');
+    workflow.add_role(
+        workflow_key => 'expenses_wf',
+        role_key => 'requestor',
+        role_name => 'Requestor',
+        sort_order => 4
+    );
 
+    /*****
+     * Transitions 
+     *****/
 
-declare
-    v_attribute_id acs_attributes.attribute_id%TYPE;
-begin
+    workflow.add_transition(
+        workflow_key => 'expenses_wf',
+        transition_key => 'assign',
+        transition_name => 'Assign users to approval',
+        role_key => 'assignor',
+        sort_order => 1,
+        trigger_type => 'user'
+    );
+
+    workflow.add_transition(
+        workflow_key => 'expenses_wf',
+        transition_key => 'and_split',
+        transition_name => 'Parallel approval by supervisor and other',
+        sort_order => 2,
+        trigger_type => 'automatic'
+    );
+
+    workflow.add_transition(
+        workflow_key => 'expenses_wf',
+        transition_key => 'supervisor_approval',
+        transition_name => 'Approve (Supervisor)',
+        role_key => 'supervisor',
+        sort_order => 3,
+        trigger_type => 'user'
+    );
+
+    workflow.add_transition(
+        workflow_key => 'expenses_wf',
+        transition_key => 'other_approval',
+        transition_name => 'Approve (Other)',
+        role_key => 'other',
+        sort_order => 4,
+        trigger_type => 'user'
+    );
+
+    workflow.add_transition(
+        workflow_key => 'expenses_wf',
+        transition_key => 'and_join',
+        transition_name => 'Re-synchronization from approval by supervisor and other',
+        sort_order => 5,
+        trigger_type => 'automatic'
+    );
+
+    workflow.add_transition(
+        workflow_key => 'expenses_wf',
+        transition_key => 'buy',
+        transition_name => 'Buy stuff',
+        role_key => 'requestor',
+        sort_order => 6,
+        trigger_type => 'user'
+    );
+        
+    /*****
+     * Arcs 
+     *****/
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_place_key => 'start',
+        to_transition_key => 'assign'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_transition_key => 'assign',
+        to_place_key => 'assignments_done'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_place_key => 'assignments_done',
+        to_transition_key => 'and_split'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_transition_key => 'and_split',
+        to_place_key => 'supervisor_to_approve'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_transition_key => 'and_split',
+        to_place_key => 'other_to_approve'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_place_key => 'supervisor_to_approve',
+        to_transition_key => 'supervisor_approval'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_transition_key => 'supervisor_approval',
+        to_place_key => 'supervisor_approved'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_place_key => 'other_to_approve',
+        to_transition_key => 'other_approval'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_transition_key => 'other_approval',
+        to_place_key => 'other_approved'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_place_key => 'supervisor_approved',
+        to_transition_key => 'and_join'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_place_key => 'other_approved',
+        to_transition_key => 'and_join'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_transition_key => 'and_join',
+        to_place_key => 'ready_to_buy',
+        guard_callback => 'wf_expenses.guard_both_approved_p',
+        guard_description => 'Both Supervisor and the Other approver approved'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_transition_key => 'and_join',
+        to_place_key => 'end',
+        guard_callback => '#',
+        guard_description => 'Either Supervisor or the Other approver did not approve'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_place_key => 'ready_to_buy',
+        to_transition_key => 'buy'
+    );
+
+    workflow.add_arc(
+        workflow_key => 'expenses_wf',
+        from_transition_key => 'buy',
+        to_place_key => 'end'
+    );
+
+    /*****
+     * Attributes
+     *****/
+
     v_attribute_id := workflow.create_attribute(
 	workflow_key => 'expenses_wf',
 	attribute_name => 'supervisor_ok',
 	datatype => 'boolean',
 	pretty_name => 'Supervisor Approval',
-	default_value => 'f'
+	default_value => 'f',
+        sort_order => 1
     );
 
-    insert into wf_transition_attribute_map
-        (workflow_key, transition_key, attribute_id, sort_order) 
-    values
-        ('expenses_wf', 'supervisor_approval', v_attribute_id, 1);
+    workflow.add_trans_attribute_map(
+        workflow_key => 'expenses_wf',
+        transition_key => 'supervisor_approval',
+        attribute_name => 'supervisor_ok',
+        sort_order => 1
+    );
 
     v_attribute_id := workflow.create_attribute(
 	workflow_key => 'expenses_wf',
 	attribute_name => 'other_ok',
 	datatype => 'boolean',
 	pretty_name => 'Other Approval',
-	default_value => 'f'
+	default_value => 'f',
+        sort_order => 2
     );
 
-    insert into wf_transition_attribute_map
-        (workflow_key, transition_key, attribute_id, sort_order) 
-    values 
-        ('expenses_wf', 'other_approval', v_attribute_id, 1);
+    workflow.add_trans_attribute_map(
+        workflow_key => 'expenses_wf',
+        transition_key => 'other_approval',
+        attribute_name => 'other_ok',
+        sort_order => 1
+    );
 
+    /*****
+     * Assignment
+     *****/
+
+    workflow.add_trans_role_assign_map(
+        workflow_key => 'expenses_wf',
+        transition_key => 'assign',
+        assign_role_key => 'supervisor'
+    );
+
+    workflow.add_trans_role_assign_map(
+        workflow_key => 'expenses_wf',
+        transition_key => 'assign',
+        assign_role_key => 'other'
+    );
+
+
 end;
 /
-show errors;
+show errors
 
-insert into wf_transition_assignment_map 
-    (workflow_key, transition_key, assign_transition_key)
-values
-    ('expenses_wf', 'assign', 'supervisor_approval');
 
-insert into wf_transition_assignment_map 
-    (workflow_key, transition_key, assign_transition_key)
-values
-    ('expenses_wf', 'assign', 'other_approval');
 
 
 
@@ -193,25 +365,25 @@
 
 
 insert into wf_context_task_panels (
-    context_key, workflow_key, transition_key, sort_key, header, template_url
+    context_key, workflow_key, transition_key, sort_order, header, template_url
 ) values (
     'default', 'expenses_wf', 'supervisor_approval', 1, 'Claim Info', 'sample/expenses-claim-info'
 );
 
 insert into wf_context_task_panels (
-    context_key, workflow_key, transition_key, sort_key, header, template_url
+    context_key, workflow_key, transition_key, sort_order, header, template_url
 ) values (
     'default', 'expenses_wf', 'supervisor_approval', 2, 'Logic and Aids', 'sample/expenses-approval-aids'
 );
 
 insert into wf_context_task_panels (
-    context_key, workflow_key, transition_key, sort_key, header, template_url
+    context_key, workflow_key, transition_key, sort_order, header, template_url
 ) values (
     'default', 'expenses_wf', 'other_approval', 1, 'Claim Info', 'sample/expenses-claim-info'
 );
 
 insert into wf_context_task_panels (
-    context_key, workflow_key, transition_key, sort_key, header, template_url
+    context_key, workflow_key, transition_key, sort_order, header, template_url
 ) values (
     'default', 'expenses_wf', 'other_approval', 2, 'Logic and Aids', 'sample/expenses-approval-aids'
 );
@@ -273,4 +445,3 @@
 /
 show errors;
 
-
