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 -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl 17 Dec 2003 14:05:22 -0000 1.1 +++ openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl 13 Jan 2004 12:37:12 -0000 1.2 @@ -223,12 +223,17 @@ } } - set spec [workflow::action::fsm::generate_spec -action_id $action_id] + # Get parent spec + array set row [workflow::action::fsm::generate_spec -action_id $action_id] - get -action_id $action_id -array row -local_only + # Get local spec, remove unwanted entries + get -action_id $action_id -array local_row -local_only + array unset local_row recipient + + # Copy local stuff in over the parent stuff + array set row [array get local_row] - array unset row recipient - + # Output the entire thing in alpha sort order foreach name [lsort [array names row]] { if { ![empty_string_p $row($name)] } { lappend spec $name $row($name) Index: openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/sim-role-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl 18 Dec 2003 15:22:55 -0000 1.3 +++ openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl 13 Jan 2004 12:37:12 -0000 1.4 @@ -245,10 +245,16 @@ } } - set spec [workflow::role::generate_spec -role_id $role_id] + # Get parent spec + array set row [workflow::role::generate_spec -role_id $role_id] + + # Get local spec, remove unwanted entries + get -role_id $role_id -array local_row -local_only - get -role_id $role_id -array row -local_only + # Copy local stuff in over the parent stuff + array set row [array get local_row] + # Output the entire thing in alpha sort order foreach name [lsort [array names row]] { if { ![empty_string_p $row($name)] } { lappend spec $name $row($name) 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 -r1.44 -r1.45 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 13 Jan 2004 10:17:11 -0000 1.44 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 13 Jan 2004 12:37:12 -0000 1.45 @@ -691,6 +691,13 @@ ad_proc -public simulation::template::generate_spec { {-workflow_id:required} + {-workflow_handler "simulation::template"} + {-handlers { + roles "simulation::role" + actions "simulation::action" + states "workflow::state::fsm" + }} + {-deep:boolean} } { Generate a spec for a workflow in array list style. @@ -702,19 +709,17 @@ } { set spec [workflow::generate_spec \ -workflow_id $workflow_id \ - -handlers { - roles simulation::role - actions simulation::action - states workflow::state::fsm - }] + -workflow_handler $workflow_handler \ + -handlers $handlers \ + -deep=$deep_p] simulation::template::get -workflow_id $workflow_id -array simulation set inner_spec [lindex $spec 1] lappend inner_spec suggested_duration $simulation(suggested_duration) - set spec [list [lindex $spec 0] $inner_spec] + set spec [lreplace $spec 1 1 $inner_spec] return $spec } @@ -724,10 +729,17 @@ {-object_id {}} {-spec:required} {-array {}} + {-workflow_handler "simulation::template"} + {-handlers { + roles "simulation::role" + states "workflow::state::fsm" + actions "simulation::action" + }} } { Create new simulation template from a spec. Basically encodes the handlers to use. } { # Wrapper for workflow::new_from_spec + # This proc basically defines the handlers for roles, states, actions if { ![empty_string_p $array] } { upvar 1 $array row @@ -738,19 +750,17 @@ -object_id $object_id \ -spec $spec \ -array $array \ - -workflow_handler "simulation::template" \ - -handlers { - roles simulation::role - states workflow::state::fsm - actions simulation::action - }] + -workflow_handler $workflow_handler \ + -handlers $handlers] } ad_proc -public simulation::template::clone { {-workflow_id:required} {-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. @@ -767,43 +777,21 @@ @author Lars Pind (lars@collaboraid.biz) @see workflow::new } { - # Wrapper for workflow::clone + # Wrapper for workflow::clone -- only here to provide the right workflow_handler if { ![empty_string_p $array] } { upvar 1 $array row set array row } - db_transaction { - set workflow_id [workflow::clone \ - -workflow_id $workflow_id \ - -package_key $package_key \ - -object_id $object_id \ - -array $array \ - -workflow_handler simulation::template] + set workflow_id [workflow::clone \ + -deep=$deep_p \ + -workflow_id $workflow_id \ + -package_key $package_key \ + -object_id $object_id \ + -array $array \ + -workflow_handler $workflow_handler] - # Special for simulation template: - # If there is no initial-action, we create one now - - set initial_action_id [workflow::get_element -workflow_id $workflow_id -element initial_action_id] - if { [empty_string_p $initial_action_id] } { - - set action_row(pretty_name) "Start" - set action_row(pretty_past_tense) "Started" - set action_row(initial_action_p) "t" - - set states [workflow::fsm::get_states -workflow_id $workflow_id] - - # We use the first state as the initial state - set action_row(new_state_id) [lindex $states 0] - - workflow::action::fsm::edit \ - -operation "insert" \ - -array action_row \ - -workflow_id $workflow_id - } - } - return $workflow_id } 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 -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/simbuild/template-spec.tcl 17 Dec 2003 16:24:17 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-spec.tcl 13 Jan 2004 12:37:33 -0000 1.3 @@ -5,8 +5,9 @@ @creation-date 2003-12-10 } { workflow_id:integer + {deep_p:boolean "f"} } -set spec [simulation::template::generate_spec -workflow_id $workflow_id] +set spec [simulation::template::generate_spec -workflow_id $workflow_id -deep=[template::util::is_true $deep_p]] ns_return 200 text/plain [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 -r1.8 -r1.9 --- openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl 9 Jan 2004 14:40:03 -0000 1.8 +++ openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl 13 Jan 2004 12:37:33 -0000 1.9 @@ -44,6 +44,7 @@ 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/tcl/sim-action-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/sim-action-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/tcl/sim-action-procs.tcl 17 Dec 2003 14:05:22 -0000 1.1 +++ openacs-4/packages/simulation/tcl/sim-action-procs.tcl 13 Jan 2004 12:37:12 -0000 1.2 @@ -223,12 +223,17 @@ } } - set spec [workflow::action::fsm::generate_spec -action_id $action_id] + # Get parent spec + array set row [workflow::action::fsm::generate_spec -action_id $action_id] - get -action_id $action_id -array row -local_only + # Get local spec, remove unwanted entries + get -action_id $action_id -array local_row -local_only + array unset local_row recipient + + # Copy local stuff in over the parent stuff + array set row [array get local_row] - array unset row recipient - + # Output the entire thing in alpha sort order foreach name [lsort [array names row]] { if { ![empty_string_p $row($name)] } { lappend spec $name $row($name) Index: openacs-4/packages/simulation/tcl/sim-role-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/sim-role-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/simulation/tcl/sim-role-procs.tcl 18 Dec 2003 15:22:55 -0000 1.3 +++ openacs-4/packages/simulation/tcl/sim-role-procs.tcl 13 Jan 2004 12:37:12 -0000 1.4 @@ -245,10 +245,16 @@ } } - set spec [workflow::role::generate_spec -role_id $role_id] + # Get parent spec + array set row [workflow::role::generate_spec -role_id $role_id] + + # Get local spec, remove unwanted entries + get -role_id $role_id -array local_row -local_only - get -role_id $role_id -array row -local_only + # Copy local stuff in over the parent stuff + array set row [array get local_row] + # Output the entire thing in alpha sort order foreach name [lsort [array names row]] { if { ![empty_string_p $row($name)] } { lappend spec $name $row($name) 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 -r1.44 -r1.45 --- openacs-4/packages/simulation/tcl/template-procs.tcl 13 Jan 2004 10:17:11 -0000 1.44 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 13 Jan 2004 12:37:12 -0000 1.45 @@ -691,6 +691,13 @@ ad_proc -public simulation::template::generate_spec { {-workflow_id:required} + {-workflow_handler "simulation::template"} + {-handlers { + roles "simulation::role" + actions "simulation::action" + states "workflow::state::fsm" + }} + {-deep:boolean} } { Generate a spec for a workflow in array list style. @@ -702,19 +709,17 @@ } { set spec [workflow::generate_spec \ -workflow_id $workflow_id \ - -handlers { - roles simulation::role - actions simulation::action - states workflow::state::fsm - }] + -workflow_handler $workflow_handler \ + -handlers $handlers \ + -deep=$deep_p] simulation::template::get -workflow_id $workflow_id -array simulation set inner_spec [lindex $spec 1] lappend inner_spec suggested_duration $simulation(suggested_duration) - set spec [list [lindex $spec 0] $inner_spec] + set spec [lreplace $spec 1 1 $inner_spec] return $spec } @@ -724,10 +729,17 @@ {-object_id {}} {-spec:required} {-array {}} + {-workflow_handler "simulation::template"} + {-handlers { + roles "simulation::role" + states "workflow::state::fsm" + actions "simulation::action" + }} } { Create new simulation template from a spec. Basically encodes the handlers to use. } { # Wrapper for workflow::new_from_spec + # This proc basically defines the handlers for roles, states, actions if { ![empty_string_p $array] } { upvar 1 $array row @@ -738,19 +750,17 @@ -object_id $object_id \ -spec $spec \ -array $array \ - -workflow_handler "simulation::template" \ - -handlers { - roles simulation::role - states workflow::state::fsm - actions simulation::action - }] + -workflow_handler $workflow_handler \ + -handlers $handlers] } ad_proc -public simulation::template::clone { {-workflow_id:required} {-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. @@ -767,43 +777,21 @@ @author Lars Pind (lars@collaboraid.biz) @see workflow::new } { - # Wrapper for workflow::clone + # Wrapper for workflow::clone -- only here to provide the right workflow_handler if { ![empty_string_p $array] } { upvar 1 $array row set array row } - db_transaction { - set workflow_id [workflow::clone \ - -workflow_id $workflow_id \ - -package_key $package_key \ - -object_id $object_id \ - -array $array \ - -workflow_handler simulation::template] + set workflow_id [workflow::clone \ + -deep=$deep_p \ + -workflow_id $workflow_id \ + -package_key $package_key \ + -object_id $object_id \ + -array $array \ + -workflow_handler $workflow_handler] - # Special for simulation template: - # If there is no initial-action, we create one now - - set initial_action_id [workflow::get_element -workflow_id $workflow_id -element initial_action_id] - if { [empty_string_p $initial_action_id] } { - - set action_row(pretty_name) "Start" - set action_row(pretty_past_tense) "Started" - set action_row(initial_action_p) "t" - - set states [workflow::fsm::get_states -workflow_id $workflow_id] - - # We use the first state as the initial state - set action_row(new_state_id) [lindex $states 0] - - workflow::action::fsm::edit \ - -operation "insert" \ - -array action_row \ - -workflow_id $workflow_id - } - } - return $workflow_id } 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 -r1.2 -r1.3 --- openacs-4/packages/simulation/www/simbuild/template-spec.tcl 17 Dec 2003 16:24:17 -0000 1.2 +++ openacs-4/packages/simulation/www/simbuild/template-spec.tcl 13 Jan 2004 12:37:33 -0000 1.3 @@ -5,8 +5,9 @@ @creation-date 2003-12-10 } { workflow_id:integer + {deep_p:boolean "f"} } -set spec [simulation::template::generate_spec -workflow_id $workflow_id] +set spec [simulation::template::generate_spec -workflow_id $workflow_id -deep=[template::util::is_true $deep_p]] ns_return 200 text/plain [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 -r1.8 -r1.9 --- openacs-4/packages/simulation/www/siminst/map-create.tcl 9 Jan 2004 14:40:03 -0000 1.8 +++ openacs-4/packages/simulation/www/siminst/map-create.tcl 13 Jan 2004 12:37:33 -0000 1.9 @@ -44,6 +44,7 @@ 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] \