Index: openacs-4/packages/workflow/sql/postgresql/workflow-tables-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/sql/postgresql/workflow-tables-create.sql,v diff -u -N -r1.25 -r1.26 --- openacs-4/packages/workflow/sql/postgresql/workflow-tables-create.sql 23 Jan 2004 11:02:27 -0000 1.25 +++ openacs-4/packages/workflow/sql/postgresql/workflow-tables-create.sql 26 Jan 2004 12:33:21 -0000 1.26 @@ -189,7 +189,7 @@ constraint wf_actions_short_name_un unique (workflow_id, short_name), constraint wf_actions_pretty_name_un - unique (workflow_id, pretty_name) + unique (workflow_id, parent_action_id, pretty_name) ); create sequence workflow_actions_seq; @@ -286,7 +286,7 @@ constraint wf_fsm_states_short_name_un unique (workflow_id, short_name), constraint wf_fsm_states_pretty_name_un - unique (workflow_id, pretty_name) + unique (workflow_id, parent_action_id, pretty_name) ); create index wf_fsm_states_workflow_idx on workflow_fsm_states(workflow_id); Index: openacs-4/packages/workflow/sql/postgresql/upgrade/upgrade-1.2-2.0d1.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/sql/postgresql/upgrade/upgrade-1.2-2.0d1.sql,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/workflow/sql/postgresql/upgrade/upgrade-1.2-2.0d1.sql 23 Jan 2004 11:02:27 -0000 1.8 +++ openacs-4/packages/workflow/sql/postgresql/upgrade/upgrade-1.2-2.0d1.sql 26 Jan 2004 12:33:21 -0000 1.9 @@ -258,3 +258,16 @@ workflow_user_deputy_map wudm where pamm.party_id = wcrpm.party_id and wudm.on_behalf_of_user_id = pamm.member_id; + +-- pretty-name unique per parent, not per workflow +alter table workflow_actions + drop constraint wf_actions_pretty_name_un; +alter table workflow_actions + add constraint wf_actions_pretty_name_un + unique (workflow_id, parent_action_id, pretty_name); + +alter table workflow_fsm_states + drop constraint wf_fsm_states_pretty_name_un; +alter table workflow_fsm_states + add constraint wf_fsm_states_pretty_name_un + unique (workflow_id, parent_action_id, pretty_name); Index: openacs-4/packages/workflow/tcl/action-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/tcl/action-procs.tcl,v diff -u -N -r1.29 -r1.30 --- openacs-4/packages/workflow/tcl/action-procs.tcl 23 Jan 2004 16:00:43 -0000 1.29 +++ openacs-4/packages/workflow/tcl/action-procs.tcl 26 Jan 2004 12:33:22 -0000 1.30 @@ -669,7 +669,7 @@ } { set result [list] - foreach action_id [workflow::get_actions -workflow_id $workflow_id] { + foreach action_id [workflow::get_actions -all -workflow_id $workflow_id] { if { [empty_string_p $ignore_action_id] || ![string equal $ignore_action_id $action_id] } { lappend result [workflow::action::get_element -action_id $action_id -element short_name] } @@ -716,7 +716,9 @@ } ad_proc -public workflow::action::get_ids { + {-all:boolean} {-workflow_id:required} + {-parent_action_id {}} } { Get the action_id's of all the actions in the workflow. @@ -728,16 +730,35 @@ } { # Use cached data about actions array set action_data [workflow::action::get_all_info -workflow_id $workflow_id] - return $action_data(action_ids) + + if { $all_p } { + return $action_data(action_ids) + } + + set action_ids [list] + foreach action_id $action_data(action_ids) { + if { [workflow::action::get_element \ + -action_id $action_id \ + -element parent_action_id] == $parent_action_id } { + lappend action_ids $action_id + } + } + return $action_ids } + ad_proc -public workflow::action::get_options { + {-all:boolean} {-workflow_id:required} + {-parent_action_id {}} } { Get an options list of actions for use with form builder. } { set result [list] - foreach action_id [workflow::action::get_ids -workflow_id $workflow_id] { + foreach action_id [workflow::get_actions \ + -all=$all_p \ + -workflow_id $workflow_id \ + -parent_action_id $parent_action_id] { workflow::action::get -action_id $action_id -array action lappend result [list $action(pretty_name) $action_id] } @@ -747,6 +768,7 @@ ad_proc -public workflow::action::pretty_name_unique_p { -workflow_id:required -pretty_name:required + {-parent_action_id {}} {-action_id {}} } { Check if suggested pretty_name is unique. @@ -758,6 +780,7 @@ from workflow_actions where workflow_id = :workflow_id and pretty_name = :pretty_name + and (:parent_action_id is null or parent_action_id = :parent_action_id) and (:action_id is null or action_id != :action_id) }] return [expr !$exists_p] @@ -1546,7 +1569,9 @@ } ad_proc -public workflow::action::fsm::get_ids { + {-all:boolean} {-workflow_id:required} + {-parent_action_id {}} } { Get the action_id's of all the actions in the workflow. @@ -1556,6 +1581,6 @@ @author Lars Pind (lars@collaboraid.biz) } { - return [workflow::action::get_ids -workflow_id $workflow_id] + return [workflow::action::get_ids -all=$all_p -workflow_id $workflow_id -parent_action_id $parent_action_id] } Index: openacs-4/packages/workflow/tcl/role-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/tcl/role-procs.tcl,v diff -u -N -r1.18 -r1.19 --- openacs-4/packages/workflow/tcl/role-procs.tcl 23 Jan 2004 11:02:27 -0000 1.18 +++ openacs-4/packages/workflow/tcl/role-procs.tcl 26 Jan 2004 12:33:22 -0000 1.19 @@ -521,11 +521,15 @@ } ad_proc -private workflow::role::get_ids { + {-all:boolean} {-workflow_id:required} + {-parent_action_id {}} } { Get the IDs of all the roles in the right order. @param workflow_id The id of the workflow to get roles for. + + @param parent_action_id No meaning. Provided for compatibility with similar procs for actions and states. @return A list of role IDs. @@ -690,7 +694,7 @@ } { set result [list] - foreach role_id [workflow::get_roles -workflow_id $workflow_id] { + foreach role_id [workflow::get_roles -all -workflow_id $workflow_id] { if { [empty_string_p $ignore_role_id] || ![string equal $ignore_role_id $role_id] } { lappend result [workflow::role::get_element -role_id $role_id -element short_name] } Index: openacs-4/packages/workflow/tcl/state-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/tcl/state-procs.tcl,v diff -u -N -r1.13 -r1.14 --- openacs-4/packages/workflow/tcl/state-procs.tcl 23 Jan 2004 16:00:43 -0000 1.13 +++ openacs-4/packages/workflow/tcl/state-procs.tcl 26 Jan 2004 12:33:22 -0000 1.14 @@ -374,7 +374,7 @@ } { set result [list] - foreach state_id [workflow::fsm::get_states -workflow_id $workflow_id] { + foreach state_id [workflow::fsm::get_states -all -workflow_id $workflow_id] { if { [empty_string_p $ignore_state_id] || ![string equal $ignore_state_id $state_id] } { lappend result [workflow::state::fsm::get_element -state_id $state_id -element short_name] } @@ -498,6 +498,7 @@ ad_proc -public workflow::state::fsm::pretty_name_unique_p { -workflow_id:required -pretty_name:required + {-parent_action_id {}} {-state_id {}} } { Check if suggested pretty_name is unique. @@ -509,6 +510,7 @@ from workflow_fsm_states where workflow_id = :workflow_id and pretty_name = :pretty_name + and (:parent_action_id is null or parent_action_id = :parent_action_id) and (:state_id is null or state_id != :state_id) }] return [expr !$exists_p] @@ -521,6 +523,7 @@ ##### ad_proc -private workflow::state::fsm::get_ids { + {-all:boolean} {-workflow_id:required} {-parent_action_id {}} } { @@ -533,9 +536,14 @@ } { # Use cached data array set state_data [workflow::state::fsm::get_all_info -workflow_id $workflow_id] + if { $all_p } { + return $state_data(state_ids) + } set state_ids [list] foreach state_id $state_data(state_ids) { - if { [workflow::state::fsm::get_element -state_id $state_id -element parent_action_id] == $parent_action_id } { + if { [workflow::state::fsm::get_element \ + -state_id $state_id \ + -element parent_action_id] == $parent_action_id } { lappend state_ids $state_id } } Index: openacs-4/packages/workflow/tcl/workflow-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/tcl/workflow-procs.tcl,v diff -u -N -r1.22 -r1.23 --- openacs-4/packages/workflow/tcl/workflow-procs.tcl 23 Jan 2004 16:00:43 -0000 1.22 +++ openacs-4/packages/workflow/tcl/workflow-procs.tcl 26 Jan 2004 12:33:22 -0000 1.23 @@ -423,7 +423,9 @@ } ad_proc -public workflow::get_roles { + {-all:boolean} {-workflow_id:required} + {-parent_action_id {}} } { Get the role_id's of all the roles in the workflow. @@ -432,11 +434,13 @@ @author Lars Pind (lars@collaboraid.biz) } { - return [workflow::role::get_ids -workflow_id $workflow_id] + return [workflow::role::get_ids -all=$all_p -workflow_id $workflow_id -parent_action_id $parent_action_id] } ad_proc -public workflow::get_actions { + {-all:boolean} {-workflow_id:required} + {-parent_action_id {}} } { Get the action_id's of all the actions in the workflow. @@ -445,7 +449,7 @@ @author Lars Pind (lars@collaboraid.biz) } { - return [workflow::action::get_ids -workflow_id $workflow_id] + return [workflow::action::get_ids -all=$all_p -workflow_id $workflow_id -parent_action_id $parent_action_id] } ad_proc -public workflow::definition_changed_handler { @@ -588,7 +592,7 @@ foreach { key namespace } $handlers { set subspec [list] - foreach sub_id [${namespace}::get_ids -workflow_id $workflow_id] { + foreach sub_id [${namespace}::get_ids -all -workflow_id $workflow_id] { set sub_short_name [${namespace}::get_element \ -one_id $sub_id \ -element short_name] @@ -1155,6 +1159,7 @@ } ad_proc -public workflow::fsm::get_states { + {-all:boolean} {-workflow_id:required} {-parent_action_id {}} } { @@ -1165,7 +1170,7 @@ @author Lars Pind (lars@collaboraid.biz) } { - return [workflow::state::fsm::get_ids -workflow_id $workflow_id -parent_action_id $parent_action_id] + return [workflow::state::fsm::get_ids -all=$all_p -workflow_id $workflow_id -parent_action_id $parent_action_id] } ad_proc -public workflow::fsm::get_initial_state {