workflow::case::state_changed_handler (private)
workflow::case::state_changed_handler -case_id case_id \ [ -parent_enabled_action_id parent_enabled_action_id ] \ [ -user_id user_id ]
Defined in packages/workflow/tcl/case-procs.tcl
Scans for newly enabled actions, as well as actions which were enabled but are now no longer enabled. Does not flush the cache. Should only be called indirectly through the workflow API.
- Switches:
- -case_id (required)
- -parent_enabled_action_id (optional)
- -user_id (optional)
- Author:
- Lars Pind <lars@collaboraid.biz>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: db_transaction { #---------------------------------------------------------------------- # 1. Find the actually enabled actions, based on the current state(s) of the case #---------------------------------------------------------------------- workflow::case::get_actual_state -case_id $case_id -parent_enabled_action_id $parent_enabled_action_id -array assigned_p # assigned_p($action_id): 1 = assigned, 0 = enabled, nonexistent = not available ... #---------------------------------------------------------------------- # 2. Output data structure #---------------------------------------------------------------------- # Array with a key entry per action to enable array set enable_action_ids [array get assigned_p] # List of enabled_action_id's of actions that are no longer enabled set unenable_enabled_action_ids [list] #---------------------------------------------------------------------- # 2. Get the rows in workflow_case_enabled_actions #---------------------------------------------------------------------- if { $parent_enabled_action_id eq "" } { set db_rows [db_list_of_lists select_previously_enabled_actions_null_parent {}] } else { set db_rows [db_list_of_lists select_previously_enabled_actions {}] } foreach elm $db_rows { foreach { action_id enabled_action_id } $elm {} if { [info exists assigned_p($action_id)] } { # This action is enabled, and should be enabled => ignore unset enable_action_ids($action_id) } else { # This action is enabled, and shouldn't be, kill it lappend unenable_enabled_action_ids $enabled_action_id } } #---------------------------------------------------------------------- # 3. Unenable the no-longer-enabled actions #---------------------------------------------------------------------- foreach enabled_action_id $unenable_enabled_action_ids { workflow::case::action::unenable -enabled_action_id $enabled_action_id } #---------------------------------------------------------------------- # 4. Enabled the newly enabled actions #---------------------------------------------------------------------- foreach action_id [array names enable_action_ids] { workflow::case::action::enable -case_id $case_id -action_id $action_id -parent_enabled_action_id $parent_enabled_action_id -user_id $user_id -assigned=[expr {[info exists assigned_p($action_id)] && $assigned_p($action_id) == 1}] } #---------------------------------------------------------------------- # 6. Flush cache, assign roles #---------------------------------------------------------------------- workflow::case::flush_cache -case_id $case_id workflow::case::assign_roles -all -case_id $case_id }Generic XQL file: <fullquery name="workflow::case::state_changed_handler.select_previously_enabled_actions"> <querytext> select ena.action_id, ena.enabled_action_id from workflow_case_enabled_actions ena where ena.case_id = :case_id and parent_enabled_action_id = :parent_enabled_action_id </querytext> </fullquery> <fullquery name="workflow::case::state_changed_handler.select_previously_enabled_actions_null_parent"> <querytext> select ena.action_id, ena.enabled_action_id from workflow_case_enabled_actions ena where ena.case_id = :case_id and parent_enabled_action_id is null </querytext> </fullquery>packages/workflow/tcl/case-procs.xql
PostgreSQL XQL file: packages/workflow/tcl/case-procs-postgresql.xql
Oracle XQL file: packages/workflow/tcl/case-procs-oracle.xql