Index: openacs-4/packages/workflow/tcl/install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/tcl/install-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/workflow/tcl/install-procs.tcl 20 Jan 2003 15:45:00 -0000 1.2 +++ openacs-4/packages/workflow/tcl/install-procs.tcl 3 Feb 2003 12:23:01 -0000 1.3 @@ -10,199 +10,337 @@ namespace eval workflow::install {} -# Array-list with list of lists style -set operations { - GetObjectType { - {operation_desc "Get the object type for which this operation is valid."} - {inputspec {}} - {outputspec {object_type:string}} - {nargs 0} - {iscachable_p "t"} + +##### +# +# Install procs +# +##### + +ad_proc -private workflow::install::package_install {} { + Workflow package install proc +} { + + db_transaction { + + create_service_contracts + + register_implementations + } - GetPrettyName { - {operation_desc "Get the pretty name. May contain #...#, so should be localized."} - {inputspec {}} - {outputspec {pretty_name:string}} - {nargs 0} - {iscachable_p "t"} - } - GetAssignees { - {operation_desc "Get the assignees as a Tcl list of party_ids, of the default assignees for this case, object, role"} - {inputspec {case_id:integer,object_id:integer,role_id:integer}} - {outputspec {party_ids:[integer]}} - {nargs 3} - {iscachable_p "f"} - } } -namespace eval acs_sc::contract {} -namespace eval acs_sc::contract::define {} +ad_proc -private workflow::install::package_uninstall {} { + Workflow package uninstall proc +} { -proc acs_sc::contract::new { contract_name {operations {}} } { - puts "New Contract: $contract_name" - if { ![string equal $operations ""] } { - puts "Operations:" - namespace eval ::acs_sc::contract::define variable contract_name $contract_name - namespace eval ::acs_sc::contract::define $operations + db_transaction { + + delete_service_contracts + + unregister_implementations + } } -proc acs_sc::contract::define::operation { operation_name } { - variable contract_name - puts "Operation: ${contract_name}.${operation_name}" -} - + ##### # -# Style one: Lists of lists of lists with potentially unclear semantics +# Create service contracts # ##### ad_proc -private workflow::install::create_service_contracts {} { + Create the service contracts needed by workflow +} { - # Array-list style - -acs_sc::contract::new \ - -contract_name [workflow::service_contract::role_default_assignee] \ - -contract_desc "Service contract to get the default assignees for a role from parameters case_id, object_id and role_id" \ - -operations { + db_transaction { - GetObjectType { - operation_desc "Get the object type for which this operation is valid." - inputspec {} - outputspec {object_type:string} - nargs 0 - iscachable_p "t" - } + workflow::install::create_default_assignees_service_contract - GetPrettyName { - operation_desc "Get the pretty name. May contain #...#, so should be localized." - inputspec {} - outputspec {pretty_name:string} - nargs 0 - iscachable_p "t" + workflow::install::create_assignee_pick_list_service_contract + + workflow::install::create_assignee_subquery_service_contract + + workflow::install::create_action_side_effect_service_contract + + workflow::install::create_activity_log_format_title_service_contract + } +} - GetAssignees { - operation_desc "Get the assignees as a Tcl list of party_ids, of the default assignees for this case, object, role" - inputspec {case_id:integer,object_id:integer,role_id:integer} - outputspec {party_ids:[integer]} - nargs 3 - iscachable_p "f" + +ad_proc -private workflow::install::delete_service_contracts {} { + + db_transaction { + + acs_sc::contract::delete -name [workflow::service_contract::role_default_assignees] + + acs_sc::contract::delete -name [workflow::service_contract::role_assignee_pick_list] + + acs_sc::contract::delete -name [workflow::service_contract::role_assignee_subquery] + + acs_sc::contract::delete -name [workflow::service_contract::action_side_effect] + + acs_sc::contract::delete -name [workflow::service_contract::activity_log_format_title] + } } + +ad_proc -private workflow::install::create_default_assignees_service_contract {} { + set default_assignees_spec { + description "Get default assignees for a role in a workflow case" + operations { + GetObjectType { + description "Get the object type for which this implementation is valid." + output { object_type:string } + iscachable_p "t" + } + GetPrettyName { + description "Get the pretty name of this implementation. Will be localized, so i may contain #...#." + output { pretty_name:string } + iscachable_p "t" + } + GetAssignees { + description "Get the assignees as a Tcl list of party_ids, of the default assignees for this case, object, role" + input { + case_id:integer + object_id:integer + role_id:integer + } + output { + party_ids:integer,multiple + } + } + } + } + + acs_sc::contract::new_from_spec \ + -spec [concat [list name [workflow::service_contract::role_default_assignees]] $default_assignees_spec] } -##### -# -# Style two: Using procs in procs with global variables -# -##### +ad_proc -private workflow::install::create_assignee_pick_list_service_contract {} { -ad_proc -private workflow::install::create_service_contracts {} { + set assignee_pick_list_spec { + description "Get the most likely assignees for a role in a workflow case" + operations { + GetObjectType { + description "Get the object type for which this implementation is valid." + output { object_type:string } + iscachable_p "t" + } + GetPrettyName { + description "Get the pretty name of this implementation. Will be localized, so i may contain #...#." + output { pretty_name:string } + iscachable_p "t" + } + GetPickList { + description "Get the most likely assignees for this case, object and role, as a Tcl list of party_ids" + input { + case_id:integer + object_id:integer + role_id:integer + } + output { + party_ids:integer,multiple + } + } + } + } -acs_sc::contract::new \ - -contract_name [workflow::service_contract::role_default_assignee] \ - -contract_desc "Service contract to get the default assignees for a role from parameters case_id, object_id and role_id" \ - -operations { + acs_sc::contract::new_from_spec \ + -spec [concat [list name [workflow::service_contract::role_assignee_pick_list]] $assignee_pick_list_spec] +} - operation \ - -operation_name GetObjectType \ - -operation_desc "Get the object type for which this operation is valid." \ - -inputspec {} \ - -outputspec {object_type:string} \ - -nargs 0 \ - -iscachable_p "t" +ad_proc -private workflow::install::create_assignee_subquery_service_contract {} { + + set assignee_subquery_spec { + description "Get the name of a subquery to use when searching for users" + operations { + GetObjectType { + description "Get the object type for which this implementation is valid." + output { object_type:string } + iscachable_p "t" + } + GetPrettyName { + description "Get the pretty name of this implementation. Will be localized, so i may contain #...#." + output { pretty_name:string } + iscachable_p "t" + } + GetSubQueryName { + description "Get the Query Dispatcher query name of the query which will return the list of parties who can be assigned to the role, and optionally bind variables to be filled in. Names of bind variables cannot start with an underscore (_)." + input { + case_id:integer + object_id:integer + role_id:integer + } + output { + subquery_name:string + bind:string,multiple + } + } + } + } - operation \ - -operation_name GetPrettyName \ - -operation_desc "Get the pretty name. May contain #...#, so should be localized." \ - -inputspec {} \ - -outputspec {pretty_name:string} \ - -nargs 0 \ - -iscachable_p "t" + acs_sc::contract::new_from_spec \ + -spec [concat [list name [workflow::service_contract::role_assignee_subquery]] $assignee_subquery_spec] +} - operation \ - -operation_name GetAssignees \ - -operation_desc "Get the assignees as a Tcl list of party_ids, of the default assignees for this case, object, role" \ - -inputspec {case_id:integer,object_id:integer,role_id:integer} \ - -outputspec {party_ids:[integer]} \ - -nargs 3 \ - -iscachable_p "f" +ad_proc -private workflow::install::create_action_side_effect_service_contract {} { + + set side_effect_spec { + description "Get the name of the side effect to create action" + operations { + GetObjectType { + description "Get the object type for which this implementation is valid." + output { object_type:string } + iscachable_p "t" + } + GetPrettyName { + description "Get the pretty name of this implementation. Will be localized, so it may contain #...#." + output { object_type:string } + iscachable_p "t" + } + DoSideEffect { + description "Do the side effect" + input { + case_id:integer + object_id:integer + action_id:integer + entry_id:integer + } + } + } + } + + acs_sc::contract::new_from_spec \ + -spec [concat [list name [workflow::service_contract::action_side_effect]] $side_effect_spec] + } +ad_proc -private workflow::install::create_activity_log_format_title_service_contract {} { + + set format_title_spec { + description "Create the title format for activity log" + operations { + GetObjectType { + description "Get the object type for which this implementation is valid." + output { + object_type:string + } + iscachable_p "t" + } + GetPrettyName { + description "Get the pretty name of this implementation. Will be localized, so it may contain #...#." + output { object_type:string } + iscachable_p "t" + } + GetTitle { + description "Get the title name of this implementation." + input { + entry_id:integer + } + output { + title:string + } + iscachable_p "t" + } + } + } + + acs_sc::contract::new_from_spec \ + -spec [concat [list name [workflow::service_contract::activity_log_format_title]] $format_title_spec] } +##### # -# Corresponding Service Contract Definition API +# Register implementations # +##### -ad_proc -public acs_sc::contract::new { - {-contract_name:required} - {-contract_dec {}} - {-oprations} -} { - insert -contract_name $contract_name -contract_desc $contract_desc +ad_proc -private workflow::install::register_implementations {} { + Register service contract implementations +} { - if { [exists_and_not_null operations] } { + db_transaction { - namespace eval ::acs_sc::contract::define variable contract_name $contract_name + workflow::install::register_default_assignees_creation_user_impl - namespace eval ::acs_sc::contract::define $operations + workflow::install::register_default_assignees_static_assignee_impl + + workflow::install::register_pick_list_current_assignee_impl } } -ad_proc -public acs_sc::contract::define::operation { - {-operation_name:required} - {-operation_desc {}} - {-inputspec {}} - {-outputspec {}} - {-nargs 0} - {-iscachable_p "f"} +ad_proc -private workflow::install::unregister_implementations {} { + Unregister service contract implementations } { - variable contract_name - set inputtype "${contract_name}.${operatoin_name}.InputType" + db_transaction { - acs_sc::msg_type::insert \ - -msg_type_name $inputtype \ - -msg_type_spec $inputspec - - set outputtype "${contract_name}.${operation_name}.OutputType" + acs_sc::impl::delete \ + -contract_name [workflow::service_contract::role_default_assignees] \ + -impl_name "Role_DefaultAssignees_CreationUser" - acs_sc::msg_type::insert \ - -msg_type_name $outputtype \ - -msg_type_spec $outputspec - - acs_sc::operation::insert \ - -contract_name $contract_name \ - -operation_desc $operation_desc \ - -inputtype $inputtype \ - -outputtype $outputtype \ - -nargs $nargs \ - -iscachable_p $iscachable_p + acs_sc::impl::delete \ + -contract_name [workflow::service_contract::role_default_assignees] \ + -impl_name "Role_DefaultAssignees_StaticAssignees" + + acs_sc::impl::delete \ + -contract_name [workflow::service_contract::role_assignee_pick_list] \ + -impl_name "Role_PickList_CurrentAssignees" + } } +ad_proc -private workflow::install::register_default_assignees_creation_user_impl {} { + set spec { + name "Role_DefaultAssignees_CreationUser" + aliases { + GetObjectType workflow::impl::acs_object + GetPrettyName workflow::impl::role_default_assignees::creation_user::pretty_name + GetAssignees workflow::impl::role_default_assignees::creation_user::get_assignees + } + } + + lappend spec contract_name [workflow::service_contract::role_default_assignees] + lappend spec owner [workflow::package_key] + + acs_sc::impl::new_from_spec -spec $spec +} +ad_proc -private workflow::install::register_default_assignees_static_assignee_impl {} { -############################################################# + set spec { + name "Role_DefaultAssignees_StaticAssignees" + aliases { + GetObjectType workflow::impl::acs_object + GetPrettyName workflow::impl::role_default_assignees::static_assignees::pretty_name + GetAssignees workflow::impl::role_default_assignees::static_assignees::get_assignees + } + } + + lappend spec contract_name [workflow::service_contract::role_default_assignees] + lappend spec owner [workflow::package_key] + + acs_sc::impl::new_from_spec -spec $spec +} +ad_proc -private workflow::install::register_pick_list_current_assignee_impl {} { -proc create_service_contracts {} { - acs_sc::contract::new DefaultAssignees { - operation GetObjectType - operation GetPrettyName - operation GetAssignees + set spec { + name "Role_PickList_CurrentAssignees" + aliases { + GetObjectType workflow::impl::acs_object + GetPrettyName workflow::impl::role_assignee_pick_list::pretty_name + GetPickList workflow::impl::role_assignee_pick_list::get_pick_list + } } - acs_sc::contract::new SideEffect { - operation GetObjectType - operation GetPrettyName - operation DoSideEffect - } -} -#create_service_contracts + lappend spec contract_name [workflow::service_contract::role_assignee_pick_list] + lappend spec owner [workflow::package_key] + acs_sc::impl::new_from_spec -spec $spec +} \ No newline at end of file