workflow::case::action::execute (public)
workflow::case::action::execute [ -no_notification ] \ [ -no_perm_check ] [ -no_logging ] \ [ -enabled_action_id enabled_action_id ] [ -case_id case_id ] \ [ -action_id action_id ] \ [ -parent_enabled_action_id parent_enabled_action_id ] \ [ -comment comment ] [ -comment_mime_type comment_mime_type ] \ [ -user_id user_id ] [ -initial ] [ -entry_id entry_id ] \ [ -package_id package_id ]
Defined in packages/workflow/tcl/case-procs.tcl
Execute the action. Either provide (case_id, action_id, parent_enabled_action_id), or simply enabled_action_id.
- Switches:
- -no_notification (optional, boolean)
- -no_perm_check (optional, boolean)
- Set this switch if you do not want to have any workflow_case loggings.
- -no_logging (optional, boolean)
- -enabled_action_id (optional)
- The ID of the enabled action to execute. Alternatively, you can specify the case_id/action_id pair.
- -case_id (optional)
- The ID of the case.
- -action_id (optional)
- The ID of the action
- -parent_enabled_action_id (optional)
- -comment (optional)
- Comment for the case activity log
- -comment_mime_type (optional, defaults to
"text/plain"
)- MIME Type of the comment, according to OpenACS standard text formatting
- -user_id (optional)
- The user who's executing the action
- -initial (optional, boolean)
- Use this switch to signal that this is the initial action. This causes permissions/enabled checks to be bypasssed, and causes all roles to get assigned.
- -entry_id (optional)
- Optional item_id for double-click protection. If you call workflow::case::fsm::get with a non-empty action_id, it will generate a new entry_id for you, which you can pass in here.
- -package_id (optional)
- The package_id the case object belongs to. This is optional but is useful if the case objects are not CR items.
- Returns:
- entry_id of the new log entry (will be a cr_item).
- Author:
- Lars Pind <lars@collaboraid.biz>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if { (![info exists user_id] || $user_id eq "") } { if { ![ad_conn isconnected] } { set user_id 0 } else { set user_id [ad_conn user_id] } } if { (![info exists package_id] || $package_id eq "") } { if { ![ad_conn isconnected] } { set package_id {} } else { set package_id [ad_conn package_id] } } if { $case_id eq "" || $action_id eq "" } { if { $enabled_action_id eq "" } { error "You must supply either case_id and action_id, or enabled_action_id" } } if { $enabled_action_id eq "" } { if { $initial_p } { set enabled_action_id {} } else { # This will not work with dynamic actions # This is provided for backwards-compatibility, so we hope there's no dynamicism # TODO: Figure out a better solution to this problem set enabled_action_id [workflow::case::action::get_enabled_action_id -any_parent -case_id $case_id -action_id $action_id] if { $enabled_action_id eq "" } { error "This action is not enabled at this time." } } } if { $enabled_action_id ne "" } { workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action set case_id $enabled_action(case_id) set action_id $enabled_action(action_id) set parent_enabled_action_id $enabled_action(parent_enabled_action_id) set parent_trigger_type $enabled_action(parent_trigger_type) } else { set parent_trigger_type "workflow" } if { !$initial_p && !$no_perm_check_p } { if { ![workflow::case::action::permission_p -enabled_action_id $enabled_action_id -user_id $user_id] } { error "This user ($user_id) is not allowed to perform this action ($action_id) at this time." } } if { $comment eq "" } { # single-space comment set comment { } } # We can't have empty comment_mime_type, default to text/plain if { $comment_mime_type eq "" } { set comment_mime_type "text/plain" } #ns_log notice "case::execute start = [set start [clock clicks -milliseconds]]" db_transaction { # Double-click protection if { $entry_id ne "" } { if { [db_string log_entry_exists_p {}] } { return $entry_id } } # Update the case workflow state workflow::case::action::fsm::execute_state_change -initial=$initial_p -enabled_action_id $enabled_action_id -case_id $case_id -action_id $action_id -parent_enabled_action_id $parent_enabled_action_id #ns_log notice "case::execute two = [expr {[set two [clock clicks -milliseconds]] - $start}]" # Mark the action completed if { $enabled_action_id ne "" } { workflow::case::action::complete -enabled_action_id $enabled_action_id -user_id $user_id } #ns_log notice "case::execute three = [expr {[set three [clock clicks -milliseconds]] - $two}]" # Insert activity log entry if {!$no_logging_p} { set extra_vars [ns_set create entry_id $entry_id case_id $case_id action_id $action_id comment $comment comment_mime_type $comment_mime_type package_id $package_id ] set entry_id [package_instantiate_object -creation_user $user_id -extra_vars $extra_vars -package_name "workflow_case_log_entry" "workflow_case_log_entry"] } # Fire side-effects workflow::case::action::do_side_effects -case_id $case_id -action_id $action_id -entry_id $entry_id #ns_log notice "case::execute five = [expr {[set five [clock clicks -milliseconds]] - $three}]" # Scan for enabled actions if {$parent_trigger_type eq "workflow"} { workflow::case::state_changed_handler -case_id $case_id -parent_enabled_action_id $parent_enabled_action_id -user_id $user_id } #ns_log notice "case::execute six = [expr {[set six [clock clicks -milliseconds]] - $five}]" # Notifications if { !$no_notification_p } { workflow::case::action::notify -case_id $case_id -action_id $action_id -entry_id $entry_id -comment $comment -comment_mime_type $comment_mime_type } #ns_log notice "case::execute seven = [expr {[set seven [clock clicks -milliseconds]] - $six}]" # If there's a parent, alert the parent if { $parent_enabled_action_id ne "" } { workflow::case::child_state_changed_handler -parent_enabled_action_id $parent_enabled_action_id -user_id $user_id } } #ns_log notice "case::execute eight = [expr {[set eight [clock clicks -milliseconds]] - $seven}]" workflow::case::flush_cache -case_id $case_id #ns_log notice "case::execute nine = [expr {[set nine [clock clicks -milliseconds]] - $eight}]" #ns_log notice "case::execute end = [expr {[set end [clock clicks -milliseconds]] - $start}]" return $entry_idGeneric XQL file: <fullquery name="workflow::case::action::execute.log_entry_exists_p"> <querytext> select count(*) from cr_items where item_id = :entry_id </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