Index: openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/acs-workflow-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/acs-workflow-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/acs-workflow-create.sql 9 Apr 2001 23:13:49 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/acs-workflow-create.sql 13 Apr 2001 00:29:01 -0000 1.2 @@ -10,11 +10,11 @@ -- @cvs-id $Id$ -- -\i wf-core-create -\i workflow-case-package -\i workflow-package -\i wf-callback-package -\i jobs-start +\i wf-core-create.sql +\i workflow-case-package.sql +\i workflow-package.sql +\i wf-callback-package.sql +-- \i jobs-start.sql -\i sample-expenses-create -\i sample-article-create +\i sample-expenses-create.sql +\i sample-article-create.sql Index: openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/sample-article-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/sample-article-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/sample-article-create.sql 12 Apr 2001 00:12:06 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/sample-article-create.sql 13 Apr 2001 00:29:01 -0000 1.2 @@ -151,13 +151,12 @@ 'default', 'article_wf', 'specification', 'wf_callback.time_sysdate_plus_x', 1/24 ); -commit; -- create or replace package wf_article_callback -- is -- procedure notification( --- task_id in number, +-- task_id in integer, -- custom_arg in varchar2, -- party_to in integer, -- party_from in out integer, @@ -174,7 +173,7 @@ -- FIXME: last three variables are in/out variables. -create function notification(number,varchar,integer,integer,varchar,varchar) +create function notification(integer,varchar,integer,integer,varchar,varchar) returns integer as ' declare notification__task_id alias for $1; @@ -188,7 +187,7 @@ v_transition_name wf_transitions.transition_name%TYPE; v_name varchar(1000); begin - select to_char(ta.deadline,'Mon fmDDfm, YYYY HH24:MI:SS'), + select to_char(ta.deadline,''Mon fmDDfm, YYYY HH24:MI:SS''), acs_object.name(c.object_id), tr.transition_name into v_deadline_pretty, Index: openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/sample-expenses-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/sample-expenses-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/sample-expenses-create.sql 12 Apr 2001 18:28:31 -0000 1.2 +++ openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/sample-expenses-create.sql 13 Apr 2001 00:29:01 -0000 1.3 @@ -16,7 +16,7 @@ references wf_cases on delete cascade ); -create function inline_0 () returns int as ' +create function inline_0 () returns integer as ' declare v_workflow_key varchar; begin @@ -25,15 +25,15 @@ ''Expense Authorization'', ''Expense authorizations'', ''Workflow for authorizing employee\\\'s expenses on the company\\\'s behalf'', - ''wf_expenses_cases'' + ''wf_expenses_cases'', ''case_id'' ); return null; -end;' lanuage 'plpgsql'; +end;' language 'plpgsql'; select inline_0 (); -drop functon inline_0 (); +drop function inline_0 (); insert into wf_places(place_key, workflow_key, place_name, sort_order) values ('start', 'expenses_wf', 'Initial state', 1); @@ -125,40 +125,60 @@ values ('expenses_wf', 'buy', 'end', 'out'); -create functon inline_1 () returns integer as ' +create function inline_1 () returns integer as ' declare v_attribute_id acs_attributes.attribute_id%TYPE; begin v_attribute_id := workflow__create_attribute( - workflow_key => 'expenses_wf', - attribute_name => 'supervisor_ok', - datatype => 'boolean', - pretty_name => 'Supervisor Approval', - default_value => 'f' + ''expenses_wf'', + ''supervisor_ok'', + ''boolean'', + ''Supervisor Approval'', + null, + null, + null, + ''f'', + 1, + 1, + null, + ''generic'', + ''none'' ); insert into wf_transition_attribute_map (workflow_key, transition_key, attribute_id, sort_order) values - ('expenses_wf', 'supervisor_approval', v_attribute_id, 1); + (''expenses_wf'', ''supervisor_approval'', v_attribute_id, 1); v_attribute_id := workflow__create_attribute( - workflow_key => 'expenses_wf', - attribute_name => 'other_ok', - datatype => 'boolean', - pretty_name => 'Other Approval', - default_value => 'f' + ''expenses_wf'', + ''other_ok'', + ''boolean'', + ''Other Approval'', + null, + null, + null, + ''f'', + 1, + 1, + null, + ''generic'', + ''none'' ); insert into wf_transition_attribute_map (workflow_key, transition_key, attribute_id, sort_order) values - ('expenses_wf', 'other_approval', v_attribute_id, 1); + (''expenses_wf'', ''other_approval'', v_attribute_id, 1); return null; end;' language 'plpgsql'; +select inline_1 (); + +drop function inline_1 (); + insert into wf_transition_assignment_map (workflow_key, transition_key, assign_transition_key) values @@ -231,7 +251,7 @@ --is -- -- function guard_both_approved_p ( --- case_id in number, +-- case_id in integer, -- workflow_key in varchar2, -- transition_key in varchar2, -- place_key in varchar2, @@ -246,17 +266,17 @@ --create or replace package body wf_expenses -create function function guard_both_approved_p (number,varchar,varchar,varchar,varchar,varchar) +create function guard_both_approved_p (integer,varchar,varchar,varchar,varchar,varchar) returns boolean as ' declare - case_id alias for $1;, - workflow_key alias for $2; - transition_key alias for $3; - place_key alias for $4; - direction_in alias for $5; - custom_arg alias for $6; - v_other_ok_p boolean; - v_supervisor_ok_p boolean; + guard_both_approved_p__case_id alias for $1; + guard_both_approved_p__workflow_key alias for $2; + guard_both_approved_p__transition_key alias for $3; + guard_both_approved_p__place_key alias for $4; + guard_both_approved_p__direction_in alias for $5; + guard_both_approved_p__custom_arg alias for $6; + v_other_ok_p boolean; + v_supervisor_ok_p boolean; begin v_other_ok_p := workflow_case__get_attribute_value( guard_both_approved_p__case_id, Index: openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/wf-callback-package.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/wf-callback-package.sql,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/wf-callback-package.sql 11 Apr 2001 04:50:30 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/wf-callback-package.sql 13 Apr 2001 00:29:01 -0000 1.2 @@ -15,7 +15,7 @@ -- as -- -- function guard_attribute_true( --- case_id in number, +-- case_id in integer, -- workflow_key in varchar2, -- transition_key in varchar2, -- place_key in varchar2, @@ -24,7 +24,7 @@ -- ) return char; -- -- function time_sysdate_plus_x( --- case_id in number, +-- case_id in integer, -- transition_key in varchar2, -- custom_arg in varchar2 -- ) return date; @@ -35,7 +35,7 @@ -- create or replace package body wf_callback -- function guard_attribute_true -create function wf_callback__guard_attribute_true (number,varchar,varchar,varchar,varchar,varchar) +create function wf_callback__guard_attribute_true (integer,varchar,varchar,varchar,varchar,varchar) returns char as ' declare guard_attribute_true__case_id alias for $1; @@ -54,14 +54,14 @@ -- function time_sysdate_plus_x -create function wf_callback__time_sysdate_plus_x (number,varchar,varchar) +create function wf_callback__time_sysdate_plus_x (integer,varchar,varchar) returns timestamp as ' declare time_sysdate_plus_x__case_id alias for $1; time_sysdate_plus_x__transition_key alias for $2; time_sysdate_plus_x__custom_arg alias for $3; begin - return now() + to_number(time_sysdate_plus_x__custom_arg); + return now() + to_integer(time_sysdate_plus_x__custom_arg); end;' language 'plpgsql'; Index: openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/wf-core-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/wf-core-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/wf-core-create.sql 9 Apr 2001 23:13:49 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/wf-core-create.sql 13 Apr 2001 00:29:01 -0000 1.2 @@ -20,7 +20,7 @@ create function inline_0 () returns integer as ' begin - select acs_object_type__create_type ( + PERFORM acs_object_type__create_type ( ''workflow'', ''Workflow'', ''Workflow'', @@ -121,7 +121,7 @@ check (direction in ('','in','out')), /* Must be satisfied for the arc to be traveled by a token * This is the name of a PL/SQL function to execute, which must return t or f - * Signature: (case_id in number, workflow_key in varchar, transition_key in varchar2, + * Signature: (case_id in integer, workflow_key in varchar, transition_key in varchar2, * place_key in varchar, direction in varchar2, custom_arg in varchar2) * return char(1) */ @@ -225,7 +225,7 @@ -* +/* * Contexts */ @@ -249,7 +249,11 @@ the call-backs, etc. '; -* Insert a default context that all new cases will use if nothing else is defined */ +/* + * Insert a default context that all new cases will use if nothing else + * is defined + */ + insert into wf_contexts (context_key, context_name) values ('default', 'Default Context'); commit; @@ -264,11 +268,11 @@ references wf_workflows, transition_key varchar(100) default '' not null, /* information for the transition in the context */ - /* The number of minutes this task is estimated to take */ + /* The integer of minutes this task is estimated to take */ estimated_minutes integer, /* * Will be called when the transition is enabled/fired. - * signature: (case_id in number, transition_key in varchar, custom_arg in varchar2) + * signature: (case_id in integer, transition_key in varchar, custom_arg in varchar2) */ enable_callback varchar(100) default '' not null, enable_custom_arg text default '' not null, @@ -277,21 +281,21 @@ /* * Must insert rows into the wf_task_assignments table. * Will be called when the transition becomes enabled - * signature: (task_id in number, custom_arg in varchar) + * signature: (task_id in integer, custom_arg in varchar) */ assignment_callback varchar(100) default '' not null, assignment_custom_arg text default '' not null, /* * Must return the date that the timed transition should fire * Will be called when the transition is enabled - * signature: (case_id in number, transition_key in varchar, custom_arg in varchar2) return date + * signature: (case_id in integer, transition_key in varchar, custom_arg in varchar2) return date */ time_callback varchar(100) default '' not null, time_custom_arg text default '' not null, /* * Returns the deadline for this task. * Will be called when the transition becomes enabled - * Signature: (case_id in number, transition_key in varchar, custom_arg in varchar2) return date + * Signature: (case_id in integer, transition_key in varchar, custom_arg in varchar2) return date */ deadline_callback varchar(100) default '' not null, deadline_custom_arg text default '' not null, @@ -300,15 +304,15 @@ /* * Must return the date that the user's hold on the task times out. * called when the user starts the task. - * signature: (case_id in number, transition_key in varchar, custom_arg in varchar2) return date + * signature: (case_id in integer, transition_key in varchar, custom_arg in varchar2) return date */ hold_timeout_callback varchar(100) default '' not null, hold_timeout_custom_arg text default '' not null, /* * Notification callback * Will be called when a notification is sent i.e., when a transition is enabled, * or assignment changes. - * signature: (task_id in number, + * signature: (task_id in integer, * custom_arg in varchar, * party_to in integer, * party_from in out integer, @@ -320,7 +324,7 @@ /* * Unassigned callback * Will be called whenever a task becomes unassigned - * Signature: (case_id in number, transition_key in varchar, custom_arg in varchar2) + * Signature: (case_id in integer, transition_key in varchar, custom_arg in varchar2) */ unassigned_callback varchar(100) default '' not null, unassigned_custom_arg text default '' not null, @@ -622,7 +626,7 @@ '; -* Should evetually be done by acs_objects automatically */ +/* Should evetually be done by acs_objects automatically */ create table wf_attribute_value_audit ( case_id integer @@ -649,7 +653,7 @@ '; -* +/* * This is the cartesian product of transitions and contexts. * We need this in order to compute the following wf_transition_info view, * because Oracle won't let us outer join against more than one table. @@ -666,7 +670,7 @@ -* +/* * Returns all the information stored about a certain transition * in all contexts. You'll usually want to use this with a * "where context = " clause. @@ -704,7 +708,7 @@ -* +/* * This view makes it easy to get the input/output places of a transition */ create view wf_transition_places as @@ -724,7 +728,7 @@ and p.workflow_key = a.workflow_key; -* +/* * This view returns information about all currently enabled transitions. * It does not include transitions that are started. This information, along * with additional, dynamic information, such as the user assignment or the @@ -787,12 +791,12 @@ -* +/* * This view joins wf_tasks with the parties data model to figure out who can perform the tasks. * It should contain one row per ( user x task ) */ -* Replaced 'unique' with 'distinct', because Stas had problems with Oracle behaving mysteriously */ +/* Replaced 'unique' with 'distinct', because Stas had problems with Oracle behaving mysteriously */ create view wf_user_tasks as select distinct ta.task_id, Index: openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-case-package.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-case-package.sql,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-case-package.sql 11 Apr 2001 04:47:19 -0000 1.3 +++ openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-case-package.sql 13 Apr 2001 00:29:01 -0000 1.4 @@ -16,7 +16,7 @@ -- is -- -- function new ( --- case_id in number default null, +-- case_id in integer default null, -- workflow_key in varchar2, -- context_key in varchar2 default null, -- object_id in integer, @@ -26,60 +26,60 @@ -- ) return integer; -- -- procedure add_manual_assignment ( --- case_id in number, +-- case_id in integer, -- transition_key in varchar2, --- party_id in number +-- party_id in integer -- ); -- -- procedure remove_manual_assignment ( --- case_id in number, +-- case_id in integer, -- transition_key in varchar2, --- party_id in number +-- party_id in integer -- ); -- -- procedure clear_manual_assignments ( --- case_id in number, +-- case_id in integer, -- transition_key in varchar2 -- ); -- -- procedure start_case ( --- case_id in number, +-- case_id in integer, -- creation_user in integer default null, -- creation_ip in varchar2 default null, -- msg in varchar2 default null -- ); -- -- procedure delete( --- case_id in number +-- case_id in integer -- ); -- -- procedure suspend( --- case_id in number, --- user_id in number default null, +-- case_id in integer, +-- user_id in integer default null, -- ip_address in varchar2 default null, -- msg in varchar2 default null -- ); -- -- procedure resume( --- case_id in number, --- user_id in number default null, +-- case_id in integer, +-- user_id in integer default null, -- ip_address in varchar2 default null, -- msg in varchar2 default null -- ); -- -- procedure cancel( --- case_id in number, --- user_id in number default null, +-- case_id in integer, +-- user_id in integer default null, -- ip_address in varchar2 default null, -- msg in varchar2 default null -- ); -- -- procedure fire_message_transition ( --- task_id in number +-- task_id in integer -- ); -- -- /* To perform an action on the workflow: --- * (numbers in parenthesis is the number of times each function should get called) +-- * (integers in parenthesis is the integer of times each function should get called) -- * -- * 1. begin_task_action (1) -- * 2. set_attribute_value (0..*) @@ -88,51 +88,51 @@ -- * 5. end_task_action (1) -- */ -- function begin_task_action ( --- task_id in number, +-- task_id in integer, -- action in varchar2, -- action_ip in varchar2, --- user_id in number, +-- user_id in integer, -- msg in varchar2 default null --- ) return number; +-- ) return integer; -- -- procedure set_attribute_value ( --- journal_id in number, +-- journal_id in integer, -- attribute_name in varchar2, -- value in varchar2 -- ); -- -- procedure end_task_action ( --- journal_id in number, +-- journal_id in integer, -- action in varchar2, --- task_id in number +-- task_id in integer -- ); -- -- /* Shortcut, that does both begin and end, when you have no attributes to set or assignments to make */ -- function task_action ( --- task_id in number, +-- task_id in integer, -- action in varchar2, -- action_ip in varchar2, --- user_id in number, +-- user_id in integer, -- msg in varchar2 default null --- ) return number; +-- ) return integer; -- -- function get_attribute_value ( --- case_id in number, +-- case_id in integer, -- attribute_name in varchar2 -- ) return varchar2; -- -- procedure add_task_assignment ( --- task_id in number, --- party_id in number +-- task_id in integer, +-- party_id in integer -- ); -- -- procedure remove_task_assignment ( --- task_id in number, --- party_id in number +-- task_id in integer, +-- party_id in integer -- ); -- -- procedure clear_task_assignments ( --- task_id in number +-- task_id in integer -- ); -- -- @@ -148,7 +148,7 @@ -- create or replace package body workflow_case -- function new -create function workflow_case__new (number,varchar,varchar,integer,timestamp,integer,varchar) +create function workflow_case__new (integer,varchar,varchar,integer,timestamp,integer,varchar) returns integer as ' declare new__case_id alias for $1; @@ -158,7 +158,7 @@ new__creation_date alias for $5; new__creation_user alias for $6; new__creation_ip alias for $7; - v_case_id number; + v_case_id integer; v_workflow_case_table varchar; v_context_key_for_query varchar; begin @@ -197,7 +197,7 @@ -- procedure add_manual_assignment -create function workflow_case__add_manual_assignment (number,varchar,number) +create function workflow_case__add_manual_assignment (integer,varchar,integer) returns integer as ' declare add_manual_assignment__case_id alias for $1; @@ -221,7 +221,7 @@ -- procedure remove_manual_assignment -create function workflow_case__remove_manual_assignment (number,varchar,number) +create function workflow_case__remove_manual_assignment (integer,varchar,integer) returns integer as ' declare remove_manual_assignment__case_id alias for $1; @@ -242,7 +242,7 @@ -- procedure clear_manual_assignments -create function workflow_case__clear_manual_assignments (number,varchar) +create function workflow_case__clear_manual_assignments (integer,varchar) returns integer as ' declare clear_manual_assignments__case_id alias for $1; @@ -262,21 +262,22 @@ -- procedure start_case -create function workflow_case__start_case (number,integer,varchar,varchar) +create function workflow_case__start_case (integer,integer,varchar,varchar) returns integer as ' declare start_case__case_id alias for $1; start_case__creation_user alias for $2; start_case__creation_ip alias for $3; start_case__msg alias for $4; - v_journal_id number; + v_journal_id integer; begin /* Add an entry to the journal */ v_journal_id := journal_entry__new( null, start_case__case_id, ''case start'', ''Case started'', + now(), start_case__creation_user, start_case__creation_ip, start_case__msg @@ -303,7 +304,7 @@ -- procedure delete -create function workflow_case__delete (number) +create function workflow_case__delete (integer) returns integer as ' declare delete__case_id alias for $1; @@ -352,15 +353,15 @@ -- procedure suspend -create function workflow_case__suspend (number,number,varchar,varchar) +create function workflow_case__suspend (integer,integer,varchar,varchar) returns integer as ' declare suspend__case_id alias for $1; suspend__user_id alias for $2; suspend__ip_address alias for $3; suspend__msg alias for $4; v_state varchar; - v_journal_id number; + v_journal_id integer; begin select state into v_state from wf_cases @@ -391,15 +392,15 @@ -- procedure resume -create function workflow_case__resume (number,number,varchar,varchar) +create function workflow_case__resume (integer,integer,varchar,varchar) returns integer as ' declare resume__case_id alias for $1; resume__user_id alias for $2; resume__ip_address alias for $3; resume__msg alias for $4; v_state varchar; - v_journal_id number; + v_journal_id integer; begin select state into v_state from wf_cases @@ -430,15 +431,15 @@ -- procedure cancel -create function workflow_case__cancel (number,number,varchar,varchar) +create function workflow_case__cancel (integer,integer,varchar,varchar) returns integer as ' declare cancel__case_id alias for $1; cancel__user_id alias for $2; cancel__ip_address alias for $3; cancel__msg alias for $4; v_state varchar; - v_journal_id number; + v_journal_id integer; begin select state into v_state from wf_cases @@ -469,14 +470,14 @@ -- procedure fire_message_transition -create function workflow_case__fire_message_transition (number) +create function workflow_case__fire_message_transition (integer) returns integer as ' declare fire_message_transition__task_id alias for $1; - v_case_id number; + v_case_id integer; v_transition_name varchar; v_trigger_type varchar; - v_journal_id number; + v_journal_id integer; begin select t.case_id, tr.transition_name, tr.trigger_type into v_case_id, v_transition_name, v_trigger_type @@ -516,7 +517,7 @@ -- function begin_task_action -create function workflow_case__begin_task_action (number,varchar,varchar,number,varchar) +create function workflow_case__begin_task_action (integer,varchar,varchar,integer,varchar) returns integer as ' declare begin_task_action__task_id alias for $1; @@ -525,10 +526,10 @@ begin_task_action__user_id alias for $4; begin_task_action__msg alias for $5; v_state varchar; - v_journal_id number; - v_case_id number; + v_journal_id integer; + v_case_id integer; v_transition_name varchar; - v_num_rows number; + v_num_rows integer; begin select state into v_state from wf_tasks @@ -583,7 +584,7 @@ else if begin_task_action__action = ''comment'' then -- We currently allow anyone to comment on a task - -- (need this line because PL/SQL doens''t like empty if blocks) + -- (need this line because PL/SQL does not like empty if blocks) v_num_rows := 0; end if; end if; end if; @@ -613,13 +614,13 @@ -- procedure end_task_action -create function workflow_case__end_task_action (number,varchar,number) +create function workflow_case__end_task_action (integer,varchar,integer) returns integer as ' declare - journal_id alias for $1; - action alias for $2; - task_id alias for $3; - v_user_id number; + end_task_action__journal_id alias for $1; + end_task_action__action alias for $2; + end_task_action__task_id alias for $3; + v_user_id integer; begin select creation_user into v_user_id from acs_objects @@ -649,8 +650,8 @@ -- function task_action -create function workflow_case__task_action (number,varchar,varchar,number,varchar) -returns number as ' +create function workflow_case__task_action (integer,varchar,varchar,integer,varchar) +returns integer as ' declare task_action__task_id alias for $1; task_action__action alias for $2; @@ -679,15 +680,15 @@ -- procedure set_attribute_value -create function workflow_case__set_attribute_value (number,varchar,varchar) +create function workflow_case__set_attribute_value (integer,varchar,varchar) returns integer as ' declare set_attribute_value__journal_id alias for $1; set_attribute_value__attribute_name alias for $2; set_attribute_value__value alias for $3; v_workflow_key varchar; - v_case_id number; - v_attribute_id number; + v_case_id integer; + v_attribute_id integer; begin select o.object_type, o.object_id into v_workflow_key, v_case_id from journal_entries je, acs_objects o @@ -716,7 +717,7 @@ -- function get_attribute_value -create function workflow_case__get_attribute_value (number,varchar) +create function workflow_case__get_attribute_value (integer,varchar) returns integer as ' declare get_attribute_value__case_id alias for $1; @@ -731,22 +732,22 @@ -- procedure add_task_assignment -create function workflow_case__add_task_assignment (number,number) +create function workflow_case__add_task_assignment (integer,integer) returns integer as ' declare - add_task_assignment_task_id alias for $1; - add_task_assignment_party_id alias for $2; + add_task_assignment__task_id alias for $1; + add_task_assignment__party_id alias for $2; v_count integer; - v_workflow_key wf_workflows.workflow_key%TYPE; - v_context_key wf_contexts.context_key%TYPE; - v_case_id wf_cases.case_id%TYPE; - v_transition_key wf_transitions.transition_key%TYPE; - v_notification_callback wf_context_transition_info.notification_callback%TYPE; + v_workflow_key wf_workflows.workflow_key%TYPE; + v_context_key wf_contexts.context_key%TYPE; + v_case_id wf_cases.case_id%TYPE; + v_transition_key wf_transitions.transition_key%TYPE; + v_notification_callback wf_context_transition_info.notification_callback%TYPE; v_notification_custom_arg wf_context_transition_info.notification_custom_arg%TYPE; - callback_rec c_callback%ROWTYPE; - v_assigned_user record; + callback_rec record; + v_assigned_user record; begin - -- check that we don not hit the unique constraint + -- check that we do not hit the unique constraint select count(*) into v_count from wf_task_assignments @@ -788,7 +789,7 @@ -- notify any new assignees for v_assigned_user in - select distinct u.user_id + select distinct u.user_id from users u where u.user_id not in ( select distinct u2.user_id @@ -826,17 +827,17 @@ -- procedure remove_task_assignment -create function workflow_case__remove_task_assignment (number,number) +create function workflow_case__remove_task_assignment (integer,integer) returns integer as ' declare remove_task_assignment__task_id alias for $1; remove_task_assignment__party_id alias for $2; - v_num_assigned number; - v_case_id number; + v_num_assigned integer; + v_case_id integer; v_workflow_key varchar; v_transition_key varchar; v_context_key varchar; - callback_rec c_callback%ROWTYPE; + callback_rec record; begin delete from wf_task_assignments @@ -870,7 +871,7 @@ if FOUND then PERFORM workflow_case__execute_unassigned_callback ( callback_rec.unassigned_callback, - task_id, + remove_task_assignment__task_id, callback_rec.unassigned_custom_arg ); end if; @@ -880,11 +881,11 @@ -- procedure clear_task_assignments -create function workflow_case__clear_task_assignments (number) +create function workflow_case__clear_task_assignments (integer) returns integer as ' declare clear_task_assignments__task_id alias for $1; - v_case_id number; + v_case_id integer; v_transition_key varchar; v_workflow_key varchar; v_context_key varchar; @@ -914,7 +915,7 @@ PERFORM workflow_case__execute_unassigned_callback ( v_callback, - task_id, + clear_task_assignments__task_id, v_custom_arg ); @@ -923,7 +924,7 @@ -- function evaluate_guard -create function workflow_case__evaluate_guard (varchar,varchar,number,varchar,varchar,varchar,varchar) +create function workflow_case__evaluate_guard (varchar,varchar,integer,varchar,varchar,varchar,varchar) returns boolean as ' declare evaluate_guard__callback alias for $1; @@ -951,7 +952,7 @@ evaluate_guard__transition_key || '','' || evaluate_guard__place_key || '','' || evaluate_guard__direction || '','' || - evaluate_guard__custom_arg || '')'' + evaluate_guard__custom_arg || '') as guard_happy_p'' LOOP return v_rec.guard_happy_p; end LOOP; @@ -964,27 +965,27 @@ -- procedure execute_transition_callback -create function workflow_case__execute_transition_callback (varchar,varchar,number,varchar) +create function workflow_case__execute_transition_callback (varchar,varchar,integer,varchar) returns integer as ' declare execute_transition_callback__callback alias for $1; execute_transition_callback__custom_arg alias for $2; execute_transition_callback__case_id alias for $3; execute_transition_callback__transition_key alias for $4; begin - if execute_transition_callback__callback is not null then + if execute_transition_callback__callback != '''' then execute ''select '' || execute_transition_callback__callback || ''('' || execute_transition_callback__case_id || '','' || execute_transition_callback__transition_key || '','' || - execute_transition_callback__custom_arg '')'' + execute_transition_callback__custom_arg || '')''; end if; return 0; end;' language 'plpgsql'; -- function execute_time_callback -create function workflow_case__execute_time_callback (varchar,varchar,number,varchar) +create function workflow_case__execute_time_callback (varchar,varchar,integer,varchar) returns timestamp as ' declare execute_time_callback__callback alias for $1; @@ -1011,7 +1012,7 @@ -- function get_task_deadline -create function workflow_case__get_task_deadline (varchar,varchar,varchar,number,varchar) +create function workflow_case__get_task_deadline (varchar,varchar,varchar,integer,varchar) returns integer as ' declare get_task_deadline__callback alias for $1; @@ -1021,9 +1022,11 @@ get_task_deadline__transition_key alias for $5; v_deadline timestamp; v_rec record; + v_str varchar; begin + raise notice ''workflow_case__get_task_deadline''; /* - * 1. or if there''s a row in wf_case_deadlines, we use that + * 1. or if there is a row in wf_case_deadlines, we use that * 2. if there is a callback, we execute that * 3. otherwise, if there is an attribute, we use that */ @@ -1034,19 +1037,21 @@ where case_id = get_task_deadline__case_id and transition_key = get_task_deadline__transition_key; + raise notice ''get_task_deadline__callback = %'',get_task_deadline__callback; if NOT FOUND then - if get_task_deadline__callback is not null then + if get_task_deadline__callback != '''' then /* callback */ - for v_rec in - execute ''select '' || get_task_deadline__callback || ''('' || + v_str := ''select '' || get_task_deadline__callback || ''('' || get_task_deadline__case_id || '','' || get_task_deadline__transition_key || '','' || - get_task_deadline__custom_arg || '') as deadline'' + get_task_deadline__custom_arg || '') as deadline''; + raise notice ''v_str = %'', v_str; + for v_rec in execute v_str LOOP v_deadline := v_rec.deadline; exit; end LOOP; - else if get_task_deadline__attribute_name is not null then + else if get_task_deadline__attribute_name != '''' then /* attribute */ v_deadline := acs_object__get_attribute( get_task_deadline__case_id, @@ -1063,7 +1068,7 @@ -- function execute_hold_timeout_callback -create function workflow_case__execute_hold_timeout_callback (varchar,varchar,number,varchar) +create function workflow_case__execute_hold_timeout_callback (varchar,varchar,integer,varchar) returns integer as ' declare execute_hold_timeout_callback__callback alias for $1; @@ -1082,7 +1087,7 @@ || ''('' || execute_hold_timeout_callback__case_id || '','' || execute_hold_timeout_callback__transition_key || '','' || - execute_hold_timeout_callback__custom_arg || '') into hold_timeout'' + execute_hold_timeout_callback__custom_arg || '') as hold_timeout'' LOOP return v_rec.hold_timeout; end LOOP; @@ -1093,14 +1098,14 @@ -- procedure execute_unassigned_callback -create function workflow_case__execute_unassigned_callback (varchar,number,varchar) +create function workflow_case__execute_unassigned_callback (varchar,integer,varchar) returns integer as ' declare callback alias for $1; task_id alias for $2; custom_arg alias for $3; begin - if callback is not null then + if callback != '''' then execute ''select '' || callback || ''('' || task_id || '','' || custom_arg || '')''; end if; @@ -1110,14 +1115,15 @@ -- procedure set_task_assignments -create function workflow_case__set_task_assignments (number,varchar,varchar) +create function workflow_case__set_task_assignments (integer,varchar,varchar) returns integer as ' declare set_task_assignments__task_id alias for $1; set_task_assignments__callback alias for $2; set_task_assignments__custom_arg alias for $3; v_done_p boolean; case_assignment_rec record; + context_assignment_rec record; begin /* Find out who to assign the given task to. @@ -1139,29 +1145,29 @@ LOOP v_done_p := ''t''; PERFORM workflow_case__add_task_assignment ( - task_id, + set_task_assignments__task_id, case_assignment_rec.party_id ); end loop; if v_done_p != ''t'' then - if set_task_assignments__callback is not null then + if set_task_assignments__callback != '''' then execute ''select ''|| set_task_assignments__callback || ''('' || set_task_assignments__task_id || '','' || set_task_assignments__custom_arg || '')''; else for context_assignment_rec in - select party_id - from wf_context_assignments ca, wf_cases c, wf_tasks t - where t.task_id = set_task_assignments__task_id - and c.case_id = t.case_id - and ca.context_key = c.context_key - and ca.workflow_key = t.workflow_key - and ca.transition_key = t.transition_key + select party_id + from wf_context_assignments ca, wf_cases c, wf_tasks t + where t.task_id = set_task_assignments__task_id + and c.case_id = t.case_id + and ca.context_key = c.context_key + and ca.workflow_key = t.workflow_key + and ca.transition_key = t.transition_key LOOP PERFORM workflow_case__add_task_assignment ( - task_id, + set_task_assignments__task_id, context_assignment_rec.party_id ); end LOOP; @@ -1173,13 +1179,13 @@ -- procedure add_token -create function workflow_case__add_token (number,varchar,number) +create function workflow_case__add_token (integer,varchar,integer) returns integer as ' declare add_token__case_id alias for $1; add_token__place_key alias for $2; add_token__journal_id alias for $3; - v_token_id number; + v_token_id integer; v_workflow_key varchar; begin select wf_token_id_seq.nextval into v_token_id from dual; @@ -1199,7 +1205,7 @@ -- procedure lock_token -create function workflow_case__lock_token (number,varchar,number,number) +create function workflow_case__lock_token (integer,varchar,integer,integer) returns integer as ' declare lock_token__case_id alias for $1; @@ -1223,16 +1229,18 @@ locked_task_id = lock_token__task_id, locked_date = now(), locked_journal_id = lock_token__journal_id - where case_id = lock_token__case_id - and place_key = lock_token__place_key - and state = ''free''; + where token_id = (select token_id + from wf_tokens + where case_id = lock_token__case_id + and place_key = lock_token__place_key + and state = ''free''); return 0; end;' language 'plpgsql'; -- procedure release_token -create function workflow_case__release_token (number,number) +create function workflow_case__release_token (integer,integer) returns integer as ' declare release_token__task_id alias for $1; @@ -1268,15 +1276,15 @@ -- procedure consume_token -create function workflow_case__consume_token (number,varchar,number,number) +create function workflow_case__consume_token (integer,varchar,integer,integer) returns integer as ' declare consume_token__case_id alias for $1; consume_token__place_key alias for $2; consume_token__journal_id alias for $3; consume_token__task_id alias for $4; begin - if task_id is null then + if consume_token__task_id is null then update wf_tokens set state = ''consumed'', consumed_date = now(), @@ -1301,7 +1309,7 @@ -- procedure sweep_automatic_transitions -create function workflow_case__sweep_automatic_transitions (number,number) +create function workflow_case__sweep_automatic_transitions (integer,integer) returns integer as ' declare sweep_automatic_transitions__case_id alias for $1; @@ -1320,7 +1328,15 @@ sweep_automatic_transitions__journal_id); if v_finished_p = ''f'' then - for task_rec in enabled_automatic_transitions loop + for task_rec in + select task_id + from wf_tasks ta, wf_transitions tr + where tr.workflow_key = ta.workflow_key + and tr.transition_key = ta.transition_key + and tr.trigger_type = ''automatic'' + and ta.state = ''enabled'' + and ta.case_id = sweep_automatic_transitions__case_id + LOOP PERFORM workflow_case__fire_transition_internal( task_rec.task_id, sweep_automatic_transitions__journal_id @@ -1338,15 +1354,15 @@ -- function finished_p -create function workflow_case__finished_p (number,number) +create function workflow_case__finished_p (integer,integer) returns booleanr as ' declare finished_p__case_id alias for $1; finished_p__journal_id alias for $2; v_case_state varchar; - v_token_id number; - v_num_rows number; - v_journal_id number; + v_token_id integer; + v_num_rows integer; + v_journal_id integer; begin select state into v_case_state from wf_cases @@ -1355,7 +1371,7 @@ if v_case_state = ''finished'' then return ''t''; else - /* Let''s see if the case is actually finished, but just not marked so */ + /* Let us see if the case is actually finished, but just not marked so */ select case when count(*) = 0 then 0 else 1 end into v_num_rows from wf_tokens where case_id = finished_p__case_id @@ -1364,8 +1380,8 @@ if v_num_rows = 0 then return ''f''; else - /* There''s a token in the end place. - * Count the total number of tokens to make sure the wf is well-constructed. + /* There is a token in the end place. + * Count the total integer of tokens to make sure the wf is well-constructed. */ select case when count(*) = 0 then 0 @@ -1416,8 +1432,10 @@ end;' language 'plpgsql'; + + -- procedure notify_assignee -create function workflow_case__notify_assignee (integer,integer,<=>,varchar) +create function workflow_case__notify_assignee (integer,integer,varchar,varchar) returns integer as ' declare notify_assignee__task_id alias for $1; @@ -1435,7 +1453,7 @@ v_request_id integer; begin select to_char(ta.deadline,''Mon fmDDfm, YYYY HH24:MI:SS''), - acs_object.name(c.object_id), + acs_object__name(c.object_id), tr.transition_key, tr.transition_name into v_deadline_pretty, @@ -1449,25 +1467,26 @@ and tr.transition_key = ta.transition_key; /* Default values */ - v_party_from := -1; /* This default value should probably be pulled from somewhere */ - v_subject := ''Assignment: ''|| v_transition_name || '' '' || v_object_name; + /* This default value should probably be pulled from somewhere */ + v_party_from := -1; + v_subject := ''Assignment: '' || v_transition_name || '' '' || v_object_name; v_body := ''You have been assigned to a task. -''||'' -Task : ''||v_transition_name||'' -Object : ''||v_object_name||'' +'' || '' +Task : '' || v_transition_name || '' +Object : '' || v_object_name || '' ''; if v_deadline_pretty != '''' then - v_body := v_body ||''Deadline: ''||v_deadline_pretty||'' + v_body := v_body || ''Deadline: '' || v_deadline_pretty || '' ''; end if; - /* We''d like to add a URL to go visit, but how do we get that URL? */ + /* We would like to add a URL to go visit, but how do we get that URL? */ /* The notifications should really be sent from the application server layer, not from the database */ -- FIXME: last three args are also out varibles. - if notify_assignee__callback is not null then + if notify_assignee__callback != '''' then execute ''select '' || notify_assignee__callback || ''('' || notify_assignee__task_id || '','' || notify_assignee__custom_arg || '','' || @@ -1478,34 +1497,34 @@ end if; -- FIXME: notifications package not ported yet. - +/* v_request_id := nt__post_request ( v_party_from, notify_assignee__user_id, - ''f'' , + ''f'', v_subject, v_body, 3 ); - +*/ return 0; end;' language 'plpgsql'; -- procedure enable_transitions -create function workflow_case__enable_transitions (number) +create function workflow_case__enable_transitions (integer) returns integer as ' declare enable_transitions__case_id alias for $1; - v_task_id number; + v_task_id integer; v_workflow_key varchar; v_trigger_time timestamp; v_deadline_date timestamp; v_party_from integer; v_subject varchar; v_body text; - v_num_assigned number; - request_id nt_requests.request_id%TYPE; + v_num_assigned integer; +-- request_id nt_requests.request_id%TYPE; trans_rec record; begin select workflow_key into v_workflow_key @@ -1571,7 +1590,7 @@ trans_rec.transition_key); end if; end if; - /* we''re ready to insert the row */ + /* we are ready to insert the row */ select wf_task_id_seq.nextval into v_task_id from dual; insert into wf_tasks ( @@ -1616,12 +1635,12 @@ -- procedure fire_transition_internal -create function workflow_case__fire_transition_internal (number,number) +create function workflow_case__fire_transition_internal (integer,integer) returns integer as ' declare fire_transition_internal__task_id alias for $1; fire_transition_internal__journal_id alias for $2; - v_case_id number; + v_case_id integer; v_state varchar; v_transition_key varchar; v_workflow_key varchar; @@ -1631,7 +1650,7 @@ v_fire_callback varchar; v_fire_custom_arg text; v_found_happy_guard boolean; - v_locked_task_id number; + v_locked_task_id integer; place_rec record; begin select t.case_id, t.state, t.workflow_key, t.transition_key, ti.fire_callback, ti.fire_custom_arg @@ -1711,7 +1730,7 @@ end loop; - /* If we didn''t find any happy guards, look for arcs with the special hash (#) guard */ + /* If we did not find any happy guards, look for arcs with the special hash (#) guard */ if v_found_happy_guard = ''f'' then for place_rec in @@ -1745,12 +1764,12 @@ -- procedure ensure_task_in_state -create function workflow_case__ensure_task_in_state (number,varchar) +create function workflow_case__ensure_task_in_state (integer,varchar) returns integer as ' declare ensure_task_in_state__task_id alias for $1; ensure_task_in_state__state alias for $2; - v_count number; + v_count integer; begin select case when count(*) 0 then 0 else 1 end into v_count from wf_tasks @@ -1766,13 +1785,13 @@ -- procedure start_task -create function workflow_case__start_task (number,number,number) +create function workflow_case__start_task (integer,integer,integer) returns integer as ' declare start_task__task_id alias for $1; start_task__user_id alias for $2; start_task__journal_id alias for $3; - v_case_id number; + v_case_id integer; v_workflow_key wf_workflows.workflow_key%TYPE; v_transition_key varchar(100); v_hold_timeout_callback varchar(100); @@ -1828,7 +1847,7 @@ -- procedure cancel_task -create function workflow_case__cancel_task (number,number) +create function workflow_case__cancel_task (integer,integer) returns integer as ' declare cancel_task__task_id alias for $1; @@ -1867,7 +1886,7 @@ -- procedure finish_task -create function workflow_case__finish_task (number,number) +create function workflow_case__finish_task (integer,integer) returns integer as ' declare finish_task__task_id alias for $1; @@ -1902,12 +1921,12 @@ create function inline_0 () returns integer as ' begin - PERFORM nt__schedule_process (1,'localhost',25); + PERFORM nt__schedule_process (1,''localhost'',25); return 0; end;' language 'plpgsql'; -select inline_0 (); +-- select inline_0 (); drop function inline_0 (); Index: openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-package.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-package.sql,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-package.sql 11 Apr 2001 04:47:19 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/acs-workflow/sql/postgresql/workflow-package.sql 13 Apr 2001 00:29:02 -0000 1.2 @@ -114,20 +114,20 @@ -- create or replace package body workflow -- function create_workflow create function workflow__create_workflow (varchar,varchar,varchar,varchar,varchar,varchar) -returns integer as ' +returns varchar as ' declare create_workflow__workflow_key alias for $1; create_workflow__pretty_name alias for $2; create_workflow__pretty_plural alias for $3; create_workflow__description alias for $4; create_workflow__table_name alias for $5; create_workflow__id_column alias for $6; - v_num_rows number; + v_num_rows integer; v_workflow_key varchar; begin select count(*) into v_num_rows - from user_tables - where table_name = upper(create_workflow__table_name); + from pg_class + where relname = lower(create_workflow__table_name); if v_num_rows = 0 then raise EXCEPTION ''-20000: The table \\\'%\\\'must be created before calling workflow.create_workflow.'', create_workflow__table_name; @@ -169,16 +169,16 @@ declare drop_workflow__workflow_key alias for $1; v_table_name varchar; - v_num_rows number; + v_num_rows integer; attribute_rec record; begin select table_name into v_table_name from acs_object_types where object_type = drop_workflow__workflow_key; select case when count(*) = 0 then 0 else 1 end into v_num_rows - from user_tables - where table_name = upper(v_table_name); + from pg_class + where relname = lower(v_table_name); if v_num_rows > 0 then raise EXCEPTION ''-20000: The table \\\'%\\\' must be dropped before calling workflow.drop_workflow.'', v_table_name; @@ -223,7 +223,7 @@ from acs_attributes where object_type = drop_workflow__workflow_key LOOP - /* there''s no on delete cascade, so we have to manually + /* there is no on delete cascade, so we have to manually * delete all the values */ @@ -285,7 +285,7 @@ create_attribute__sort_order alias for $11; create_attribute__storage alias for $12; create_attribute__wf_datatype alias for $13; - v_attribute_id number; + v_attribute_id integer; begin v_attribute_id := acs_attribute__create_attribute( create_attribute__workflow_key, @@ -319,7 +319,7 @@ declare drop_attribute__workflow_key alias for $1; drop_attribute__attribute_name alias for $2; - v_attribute_id number; + v_attribute_id integer; begin select attribute_id into v_attribute_id from acs_attributes @@ -408,7 +408,7 @@ -- procedure add_arc -create function workflow__add_arc (varchar,varchar,varchar,varchar,<=>,varchar,varchar) +create function workflow__add_arc (varchar,varchar,varchar,varchar,varchar,varchar,varchar) returns integer as ' declare add_arc__workflow_key alias for $1; @@ -470,7 +470,7 @@ v_end_place wf_places.place_key%TYPE; v_transition_key wf_transitions.transition_key%TYPE; begin - /* Let''s do some simple checks first */ + /* Let us do some simple checks first */ /* Places with more than one arc out */ select count(*) into v_count @@ -515,8 +515,8 @@ end if; /* Now we do the more complicated checks. - * We keep a list of visited places because I couldn''t think - * of a nicer way that wasn''t susceptable to infinite loops. + * We keep a list of visited places because I could not think + * of a nicer way that was not susceptable to infinite loops. */