Index: openacs-4/packages/cms/sql/postgresql/cms-publishing-wf.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-publishing-wf.sql,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/cms/sql/postgresql/cms-publishing-wf.sql 9 Mar 2002 02:00:02 -0000 1.6 +++ openacs-4/packages/cms/sql/postgresql/cms-publishing-wf.sql 24 Sep 2002 20:47:12 -0000 1.7 @@ -1,383 +1,316 @@ - -/* - * Business Process Definition: Simple Publishing Workflow (publishing_wf) - * - * Auto-generated by ACS Workflow Export, version 4.3 - * - * Context: default - */ - - -/* - * Cases table - */ -create table publishing_wf_cases ( - case_id integer primary key - references wf_cases on delete cascade +create table cr_workflows ( + case_id integer + constraint cr_workflows_pk + primary key + constraint cr_workflows_case_id_fk + references wf_cases ); -/* - * Declare the object type - */ +create function inline_0 () +returns integer as ' +declare + v_workflow_key varchar(100); - -create function inline_0 () returns integer as ' begin - PERFORM workflow__create_workflow ( - ''publishing_wf'', - ''Simple Publishing Workflow'', - ''Simple Publishing Workflows'', - ''A simple linear workflow for authoring, - editing and scheduling content items.'', - ''publishing_wf_cases'', - ''case_id'' - ); + raise notice ''creating publishing_wf workflow''; + v_workflow_key := workflow__create_workflow( + ''publishing_wf'', + ''Simple Publishing Workflow'', + ''Simple Publishing Workflows'', + ''A simple linear workflow for authoring, + editing and scheduling content items.'', + ''cr_workflows'', + ''case_id'' + ); - return null; + /***** + * Places + *****/ -end;' language 'plpgsql'; + perform workflow__add_place( + ''publishing_wf'', + ''start'', + ''Created'', + 1 + ); -select inline_0 (); -drop function inline_0 (); + perform workflow__add_place( + ''publishing_wf'', + ''authored'', + ''Authored'', + 2 + ); - + perform workflow__add_place( + ''publishing_wf'', + ''edited'', + ''Edited'', + 3 + ); + perform workflow__add_place( + ''publishing_wf'', + ''end'', + ''Approved'', + 4 + ); -/***** - * Places - *****/ + /***** + * Roles + *****/ - - select workflow__add_place( - 'publishing_wf', - 'start', - 'Created', + perform workflow__add_role( + ''publishing_wf'', + ''author'', + ''Author'', 1 ); - - - select workflow__add_place( - 'publishing_wf', - 'authored', - 'Authored', + perform workflow__add_role( + ''publishing_wf'', + ''editor'', + ''Editor'', 2 ); + /***** + * Transitions + *****/ - + perform workflow__add_transition( + ''publishing_wf'', + ''authoring'', + ''Authoring'', + ''author'', + 1, + ''user'' + ); - select workflow__add_place( - 'publishing_wf', - 'edited', - 'Edited', - 3 - ); + perform workflow__add_transition( + ''publishing_wf'', + ''editing'', + ''Editing'', + ''editor'', + 2, + ''user'' + ); - + perform workflow__add_transition( + ''publishing_wf'', + ''approval'', + ''Approval'', + ''editor'', + 3, + ''user'' + ); + return 0; +end;' language 'plpgsql'; - select workflow__add_place( - 'publishing_wf', - 'end', - 'Approved', - 4 - ); +select inline_0 (); - -/***** - * Roles - *****/ +drop function inline_0 (); +begin; - select workflow__add_role ( - 'publishing_wf', - 'approval', - 'Approval', - 3 - ); + select workflow__add_arc( + 'publishing_wf', + 'start', + 'authoring' + ); - + select workflow__add_arc( + 'publishing_wf', + 'authoring', + 'authored', + 'publishing_wf__is_next', + null, + null + ); - select workflow__add_role ( - 'publishing_wf', - 'authoring', - 'Authoring', - 1 - ); + select workflow__add_arc( + 'publishing_wf', + 'authoring', + 'start', + '#', + null, + null + ); - + select workflow__add_arc( + 'publishing_wf', + 'authored', + 'editing' + ); - select workflow__add_role ( - 'publishing_wf', - 'editing', - 'Editing', - 2 - ); + + select workflow__add_arc( + 'publishing_wf', + 'editing', + 'authored', + '#', + null, + null + ); - + select workflow__add_arc( + 'publishing_wf', + 'editing', + 'edited', + 'publishing_wf__is_next', + null, + null + ); -/***** - * Transitions - *****/ + select workflow__add_arc( + 'publishing_wf', + 'editing', + 'start', + 'publishing_wf__is_next', + null, + null + ); + select workflow__add_arc( + 'publishing_wf', + 'edited', + 'approval' + ); + select workflow__add_arc( + 'publishing_wf', + 'approval', + 'edited', + '#', + null, + null + ); - select workflow__add_transition ( - 'publishing_wf', - 'authoring', - 'Authoring', - 'authoring', - 1, - 'user' - ); - - + select workflow__add_arc( + 'publishing_wf', + 'approval', + 'end', + 'publishing_wf__is_next', + null, + null + ); - select workflow__add_transition ( - 'publishing_wf', - 'editing', - 'Editing', - 'editing', - 2, - 'user' - ); - - + select workflow__add_arc( + 'publishing_wf', + 'approval', + 'authored', + 'publishing_wf__is_next', + null, + null + ); - select workflow__add_transition ( - 'publishing_wf', - 'approval', - 'Approval', - 'approval', - 3, - 'user' - ); - - -/***** - * Arcs - *****/ + select workflow__add_arc( + 'publishing_wf', + 'approval', + 'start', + 'publishing_wf__is_next', + null, + null + ); +end; + +-- show errors +-- create or replace package publishing_wf as +-- +-- -- simply check the 'next_place' attribute and return true if +-- -- it matches the submitted place_key +-- +-- function is_next ( +-- case_id in number, +-- workflow_key in varchar, +-- transition_key in varchar, +-- place_key in varchar, +-- direction in varchar, +-- custom_arg in varchar +-- ) return char; +-- +-- end publishing_wf; - select workflow__add_arc ( - 'publishing_wf', - 'approval', - 'authored', - 'out', - 'publishing_wf__is_next', - '', - '' - ); +-- show errors - +-- create or replace package body publishing_wf as +-- function is_next +create function publishing_wf__is_next (integer,varchar,varchar,varchar,varchar,varchar) +returns char as ' +declare + p_case_id alias for $1; + p_workflow_key alias for $2; + p_transition_key alias for $3; + p_place_key alias for $4; + p_direction alias for $5; + p_custom_arg alias for $6; + v_next_place varchar(100); + v_result boolean; +begin - select workflow__add_arc ( - 'publishing_wf', - 'approval', - 'edited', - 'out', - '#', - '', - '' - ); + v_next_place := workflow_case__get_attribute_value(p_case_id,''next_place''); - + if v_next_place = p_place_key then + v_result := ''t''; + end if; + + return v_result; + +end;' language 'plpgsql'; - select workflow__add_arc ( - 'publishing_wf', - 'approval', - 'edited', - 'in', - '', - '', - '' - ); - - - select workflow__add_arc ( - 'publishing_wf', - 'approval', - 'end', - 'out', - 'publishing_wf__is_next', - '', - '' - ); - - - - select workflow__add_arc ( - 'publishing_wf', - 'approval', - 'start', - 'out', - 'publishing_wf__is_next', - '', - '' - ); - - - - select workflow__add_arc ( - 'publishing_wf', - 'authoring', - 'authored', - 'out', - 'publishing_wf__is_next', - '', - '' - ); - - - - select workflow__add_arc ( - 'publishing_wf', - 'authoring', - 'start', - 'out', - '#', - '', - '' - ); - - - - select workflow__add_arc ( - 'publishing_wf', - 'authoring', - 'start', - 'in', - '', - '', - '' - ); - - - - select workflow__add_arc ( - 'publishing_wf', - 'editing', - 'authored', - 'out', - '#', - '', - '' - ); - - - - select workflow__add_arc ( - 'publishing_wf', - 'editing', - 'authored', - 'in', - '', - '', - '' - ); - - - - select workflow__add_arc ( - 'publishing_wf', - 'editing', - 'edited', - 'out', - 'publishing_wf__is_next', - '', - '' - ); - - - - select workflow__add_arc ( - 'publishing_wf', - 'editing', - 'start', - 'out', - 'publishing_wf__is_next', - '', - '' - ); - - - -/***** - * Attributes - *****/ - - - - select workflow__create_attribute( - 'publishing_wf', - 'next_place', - 'string', - 'Next Place', - null, - null, - null, - 'start', - 1, - 1, - null, - 'generic' +create function inline_2 () +returns integer as ' +declare + v_attribute_id acs_attributes.attribute_id%TYPE; +begin + v_attribute_id := workflow__create_attribute( + ''publishing_wf'', + ''next_place'', + ''string'', + ''Next Place'', + null, + null, + null, + ''start'', + 1, + 1, + null, + ''generic'' ); - + perform workflow__add_trans_attribute_map ( + ''publishing_wf'', + ''authoring'', + v_attribute_id, + 1); - select workflow__add_trans_attribute_map( - 'publishing_wf', - 'approval', - 'next_place', - 1 - ); + perform workflow__add_trans_attribute_map ( + ''publishing_wf'', + ''editing'', + v_attribute_id, + 1); + + perform workflow__add_trans_attribute_map ( + ''publishing_wf'', + ''approval'', + v_attribute_id, + 1); - + perform workflow__add_trans_role_assign_map( + ''publishing_wf'', + ''authoring'', + ''author''); - select workflow__add_trans_attribute_map( - 'publishing_wf', - 'authoring', - 'next_place', - 1 - ); + return 0; +end;' language 'plpgsql'; - +select inline_2 (); - select workflow__add_trans_attribute_map( - 'publishing_wf', - 'editing', - 'next_place', - 1 - ); +drop function inline_2 (); - -/***** - * Transition-role-assignment-map - *****/ +-- show errors - -/* - * Context/Transition info - * (for context = default) - */ - - - -/* - * Context/Role info - * (for context = default) - */ - - - -/* - * Context Task Panels - * (for context = default) - */ - - -commit;