Index: openacs-4/contrib/packages/simulation/simulation.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/Attic/simulation.info,v diff -u -N -r1.13 -r1.14 --- openacs-4/contrib/packages/simulation/simulation.info 15 Mar 2004 14:07:29 -0000 1.13 +++ openacs-4/contrib/packages/simulation/simulation.info 15 Mar 2004 17:22:59 -0000 1.14 @@ -8,7 +8,7 @@ f simulation - + Collaboraid ApS Workflow-based task simulator. Build scenario templates in which various roles must complete tasks such as @@ -18,9 +18,9 @@ www.rechtenonline.nl. 2004-01-30 - + - + Index: openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-tasks.tcl,v diff -u -N -r1.40 -r1.41 --- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 15 Mar 2004 10:31:20 -0000 1.40 +++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 15 Mar 2004 17:22:18 -0000 1.41 @@ -68,6 +68,14 @@ } } +lappend elements copy { + hide_p {[ad_decode $display_mode edit 0 1]} + sub_class narrow + link_url_col copy_url + display_template { + Copy + } +} lappend elements name { label "
Name" @@ -159,7 +167,7 @@ #------------------------------------------------------------- set extend [list] -lappend extend edit_url view_url delete_url assigned_role_edit_url up_url down_url add_child_action_url +lappend extend edit_url view_url delete_url assigned_role_edit_url up_url down_url add_child_action_url copy_url foreach state_id $states { lappend extend state_$state_id @@ -216,6 +224,7 @@ set view_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" -anchor tasks { action_id {return_url "[ad_return_url]\#tasks"}}] set delete_url \ [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url "[ad_return_url]\#tasks"} }] + set copy_url [export_vars -base task-copy { action_id {return_url "[ad_return_url]\#tasks"} }] set assigned_role_edit_url \ [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { { role_id $assigned_role } }] Index: openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/sim-action-procs.tcl,v diff -u -N -r1.7 -r1.8 --- openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl 27 Jan 2004 10:33:16 -0000 1.7 +++ openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl 15 Mar 2004 17:22:18 -0000 1.8 @@ -250,7 +250,11 @@ ad_proc -private simulation::action::generate_spec { {-action_id {}} {-one_id {}} - {-handlers {}} + {-handlers { + roles "simulation::role" + actions "simulation::action" + states "workflow::state::fsm" + }} } { Generate the spec for an individual simulation task definition. @@ -344,3 +348,36 @@ get -action_id $action_id -array row return $row($element) } + +ad_proc -public simulation::action::clone { + {-action_id {}} +} { + Create a copy of the action with given id. Does a shallow copy, i.e. + won't copy child roles, states, or actions. + + @author Peter Marklund +} { + simulation::action::get -action_id $action_id -array action + + array set action_spec [simulation::action::generate_spec -action_id $action_id] + + set action_spec(pretty_name) "Copy of $action_spec(pretty_name)" + + foreach type { child_actions child_states child_roles } { + if { [info exists action_spec($type)] } { + unset action_spec($type) + } + } + + set copy_action_id [simulation::action::edit \ + -operation "insert" \ + -workflow_id $action(workflow_id) \ + -array action_spec] + + array set edit_array [list sort_order [expr $action(sort_order) + 1]] + simulation::action::edit \ + -action_id $copy_action_id \ + -array edit_array + + return $copy_action_id +} Index: openacs-4/contrib/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/template-procs.tcl,v diff -u -N -r1.67 -r1.68 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 15 Mar 2004 14:07:03 -0000 1.67 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 15 Mar 2004 17:22:19 -0000 1.68 @@ -1060,7 +1060,6 @@ actions "simulation::action" states "workflow::state::fsm" }} - {-deep:boolean} } { Generate a spec for a workflow in array list style. @@ -1073,8 +1072,7 @@ set spec [workflow::generate_spec \ -workflow_id $workflow_id \ -workflow_handler $workflow_handler \ - -handlers $handlers \ - -deep=$deep_p] + -handlers $handlers] simulation::template::get -workflow_id $workflow_id -array simulation @@ -1123,7 +1121,6 @@ {-package_key {}} {-object_id {}} {-array {}} - {-deep:boolean} {-workflow_handler "simulation::template"} } { Clones an existing simulation template. The clone must belong to either a package key or an object id. @@ -1149,7 +1146,6 @@ } set workflow_id [workflow::clone \ - -deep=$deep_p \ -workflow_id $workflow_id \ -package_key $package_key \ -object_id $object_id \ Index: openacs-4/contrib/packages/simulation/www/simbuild/task-copy.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/task-copy.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/simbuild/task-copy.tcl 15 Mar 2004 17:22:19 -0000 1.1 @@ -0,0 +1,16 @@ +ad_page_contract { + Copy (clone) a task. + + @author Peter Marklund +} { + action_id:integer + {return_url ""} + +} + +simulation::action::clone -action_id $action_id + +if { [empty_string_p $return_url] } { + set return_url [export_vars -base template-edit { workflow_id }] +} +ad_returnredirect $return_url Index: openacs-4/contrib/packages/simulation/www/simbuild/template-spec.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/template-spec.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/contrib/packages/simulation/www/simbuild/template-spec.tcl 27 Jan 2004 10:33:16 -0000 1.5 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-spec.tcl 15 Mar 2004 17:22:19 -0000 1.6 @@ -5,7 +5,6 @@ @creation-date 2003-12-10 } { workflow_id:integer - {deep_p:boolean "f"} } set page_title "Export" @@ -14,6 +13,6 @@ set context [list [list "." "SimBuild"] [list [export_vars -base template-edit { workflow_id }] "Editing $sim_template_array(pretty_name)"] $page_title] -set spec [simulation::template::generate_spec -workflow_id $workflow_id -deep=[template::util::is_true $deep_p]] +set spec [simulation::template::generate_spec -workflow_id $workflow_id] set spec [util::array_list_spec_pretty $spec] Index: openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/map-create.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl 13 Jan 2004 12:37:33 -0000 1.9 +++ openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl 15 Mar 2004 17:22:20 -0000 1.10 @@ -44,7 +44,6 @@ set new_workflow_array(sim_type) "dev_sim" set workflow_id [simulation::template::clone \ - -deep \ -workflow_id $workflow_id \ -package_key "simulation" \ -object_id [ad_conn package_id] \ Index: openacs-4/packages/simulation/simulation.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/simulation.info,v diff -u -N -r1.13 -r1.14 --- openacs-4/packages/simulation/simulation.info 15 Mar 2004 14:07:29 -0000 1.13 +++ openacs-4/packages/simulation/simulation.info 15 Mar 2004 17:22:59 -0000 1.14 @@ -8,7 +8,7 @@ f simulation - + Collaboraid ApS Workflow-based task simulator. Build scenario templates in which various roles must complete tasks such as @@ -18,9 +18,9 @@ www.rechtenonline.nl. 2004-01-30 - + - + Index: openacs-4/packages/simulation/lib/sim-template-tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-tasks.tcl,v diff -u -N -r1.40 -r1.41 --- openacs-4/packages/simulation/lib/sim-template-tasks.tcl 15 Mar 2004 10:31:20 -0000 1.40 +++ openacs-4/packages/simulation/lib/sim-template-tasks.tcl 15 Mar 2004 17:22:18 -0000 1.41 @@ -68,6 +68,14 @@ } } +lappend elements copy { + hide_p {[ad_decode $display_mode edit 0 1]} + sub_class narrow + link_url_col copy_url + display_template { + Copy + } +} lappend elements name { label "
Name" @@ -159,7 +167,7 @@ #------------------------------------------------------------- set extend [list] -lappend extend edit_url view_url delete_url assigned_role_edit_url up_url down_url add_child_action_url +lappend extend edit_url view_url delete_url assigned_role_edit_url up_url down_url add_child_action_url copy_url foreach state_id $states { lappend extend state_$state_id @@ -216,6 +224,7 @@ set view_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" -anchor tasks { action_id {return_url "[ad_return_url]\#tasks"}}] set delete_url \ [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url "[ad_return_url]\#tasks"} }] + set copy_url [export_vars -base task-copy { action_id {return_url "[ad_return_url]\#tasks"} }] set assigned_role_edit_url \ [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { { role_id $assigned_role } }] Index: openacs-4/packages/simulation/tcl/sim-action-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/sim-action-procs.tcl,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/simulation/tcl/sim-action-procs.tcl 27 Jan 2004 10:33:16 -0000 1.7 +++ openacs-4/packages/simulation/tcl/sim-action-procs.tcl 15 Mar 2004 17:22:18 -0000 1.8 @@ -250,7 +250,11 @@ ad_proc -private simulation::action::generate_spec { {-action_id {}} {-one_id {}} - {-handlers {}} + {-handlers { + roles "simulation::role" + actions "simulation::action" + states "workflow::state::fsm" + }} } { Generate the spec for an individual simulation task definition. @@ -344,3 +348,36 @@ get -action_id $action_id -array row return $row($element) } + +ad_proc -public simulation::action::clone { + {-action_id {}} +} { + Create a copy of the action with given id. Does a shallow copy, i.e. + won't copy child roles, states, or actions. + + @author Peter Marklund +} { + simulation::action::get -action_id $action_id -array action + + array set action_spec [simulation::action::generate_spec -action_id $action_id] + + set action_spec(pretty_name) "Copy of $action_spec(pretty_name)" + + foreach type { child_actions child_states child_roles } { + if { [info exists action_spec($type)] } { + unset action_spec($type) + } + } + + set copy_action_id [simulation::action::edit \ + -operation "insert" \ + -workflow_id $action(workflow_id) \ + -array action_spec] + + array set edit_array [list sort_order [expr $action(sort_order) + 1]] + simulation::action::edit \ + -action_id $copy_action_id \ + -array edit_array + + return $copy_action_id +} Index: openacs-4/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/template-procs.tcl,v diff -u -N -r1.67 -r1.68 --- openacs-4/packages/simulation/tcl/template-procs.tcl 15 Mar 2004 14:07:03 -0000 1.67 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 15 Mar 2004 17:22:19 -0000 1.68 @@ -1060,7 +1060,6 @@ actions "simulation::action" states "workflow::state::fsm" }} - {-deep:boolean} } { Generate a spec for a workflow in array list style. @@ -1073,8 +1072,7 @@ set spec [workflow::generate_spec \ -workflow_id $workflow_id \ -workflow_handler $workflow_handler \ - -handlers $handlers \ - -deep=$deep_p] + -handlers $handlers] simulation::template::get -workflow_id $workflow_id -array simulation @@ -1123,7 +1121,6 @@ {-package_key {}} {-object_id {}} {-array {}} - {-deep:boolean} {-workflow_handler "simulation::template"} } { Clones an existing simulation template. The clone must belong to either a package key or an object id. @@ -1149,7 +1146,6 @@ } set workflow_id [workflow::clone \ - -deep=$deep_p \ -workflow_id $workflow_id \ -package_key $package_key \ -object_id $object_id \ Index: openacs-4/packages/simulation/www/simbuild/task-copy.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/task-copy.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/simbuild/task-copy.tcl 15 Mar 2004 17:22:19 -0000 1.1 @@ -0,0 +1,16 @@ +ad_page_contract { + Copy (clone) a task. + + @author Peter Marklund +} { + action_id:integer + {return_url ""} + +} + +simulation::action::clone -action_id $action_id + +if { [empty_string_p $return_url] } { + set return_url [export_vars -base template-edit { workflow_id }] +} +ad_returnredirect $return_url Index: openacs-4/packages/simulation/www/simbuild/template-spec.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/template-spec.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/simulation/www/simbuild/template-spec.tcl 27 Jan 2004 10:33:16 -0000 1.5 +++ openacs-4/packages/simulation/www/simbuild/template-spec.tcl 15 Mar 2004 17:22:19 -0000 1.6 @@ -5,7 +5,6 @@ @creation-date 2003-12-10 } { workflow_id:integer - {deep_p:boolean "f"} } set page_title "Export" @@ -14,6 +13,6 @@ set context [list [list "." "SimBuild"] [list [export_vars -base template-edit { workflow_id }] "Editing $sim_template_array(pretty_name)"] $page_title] -set spec [simulation::template::generate_spec -workflow_id $workflow_id -deep=[template::util::is_true $deep_p]] +set spec [simulation::template::generate_spec -workflow_id $workflow_id] set spec [util::array_list_spec_pretty $spec] Index: openacs-4/packages/simulation/www/siminst/map-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/map-create.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/simulation/www/siminst/map-create.tcl 13 Jan 2004 12:37:33 -0000 1.9 +++ openacs-4/packages/simulation/www/siminst/map-create.tcl 15 Mar 2004 17:22:20 -0000 1.10 @@ -44,7 +44,6 @@ set new_workflow_array(sim_type) "dev_sim" set workflow_id [simulation::template::clone \ - -deep \ -workflow_id $workflow_id \ -package_key "simulation" \ -object_id [ad_conn package_id] \