Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/simulation/lib/sim-template-list.adp'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/contrib/packages/simulation/lib/sim-template-list.tcl'.
Fisheye: No comparison available. Pass `N' to diff?
Index: openacs-4/contrib/packages/simulation/lib/sim-template-objects.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-objects.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/lib/sim-template-objects.tcl 6 Nov 2003 15:35:46 -0000 1.1
+++ openacs-4/contrib/packages/simulation/lib/sim-template-objects.tcl 12 Nov 2003 13:14:07 -0000 1.2
@@ -1,17 +1,13 @@
-# an includelet
+simulation::include_contract {
+ A list of all objects associated with the Simulation Template
-##############################################################
-#
-# sim_objects
-#
-# A list of all objects associated with the Simulation Template
-#
-##############################################################
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id$
+} {
+ workflow_id {}
+}
-# maybe replace this chunk of copied text with an includable template
-# which passes in a filter for the workflow_id?
-
-
#-------------------------------------------------------------
# sim_objects list
#-------------------------------------------------------------
Index: openacs-4/contrib/packages/simulation/lib/sim-template-roles.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-roles.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/lib/sim-template-roles.adp 6 Nov 2003 15:35:46 -0000 1.1
+++ openacs-4/contrib/packages/simulation/lib/sim-template-roles.adp 12 Nov 2003 13:14:07 -0000 1.2
@@ -1,2 +1,7 @@
-
-Add a role
+
+
+
+
+
+ » Add a role
+
Index: openacs-4/contrib/packages/simulation/lib/sim-template-roles.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-roles.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/lib/sim-template-roles.tcl 6 Nov 2003 15:35:46 -0000 1.1
+++ openacs-4/contrib/packages/simulation/lib/sim-template-roles.tcl 12 Nov 2003 13:14:07 -0000 1.2
@@ -1,17 +1,15 @@
-# an includelet
+simulation::include_contract {
+ A list of all roles associated with the Simulation Template
-##############################################################
-#
-# roles
-#
-# A list of all roles associated with the Simulation Template
-#
-##############################################################
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id$
+} {
+ workflow_id {}
+}
-# maybe replace this chunk of copied text with an includable template
-# which passes in a filter for the workflow_id?
+set package_id [ad_conn package_id]
-
#-------------------------------------------------------------
# roles list
#-------------------------------------------------------------
Index: openacs-4/contrib/packages/simulation/lib/sim-template-tasks.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-tasks.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.adp 30 Oct 2003 11:15:55 -0000 1.1
+++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.adp 12 Nov 2003 13:14:07 -0000 1.2
@@ -1,5 +1,7 @@
-
- Add a task
-
\ No newline at end of file
+
+
+ » Add a task
+
+
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 -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 6 Nov 2003 15:35:46 -0000 1.2
+++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 12 Nov 2003 13:14:07 -0000 1.3
@@ -1,19 +1,25 @@
-# an includelet
+simulation::include_contract {
+ A list of all tasks associated with the Simulation Template
-# the includelet can be a full edit
-
-if { ![exists_and_not_null usage_mode] } {
- set usage_mode display
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id$
+} {
+ workflow_id {}
+ display_mode {
+ allowed_values {edit display}
+ default_value display
+ }
}
-switch $usage_mode {
+set package_id [ad_conn package_id]
+
+switch $display_mode {
display {}
+
edit {
set add_task_url [export_vars -base "task-edit" { workflow_id } ]
}
- default {
- error "This is an opportunity to inspect the code and find out how we got here, since it should be impossible"
- }
}
##############################################################
@@ -38,7 +44,7 @@
-no_data "No tasks in this Simulation Template" \
-elements {
edit {
- hide_p {[ad_decode $usage_mode edit 0 1]}
+ hide_p {[ad_decode $display_mode edit 0 1]}
sub_class narrow
link_url_col edit_url
display_template {
@@ -47,7 +53,7 @@
}
name {
label "Name"
- link_url_col {[ad_decode $usage_mode edit view_url ""]}
+ link_url_col {[ad_decode $display_mode edit view_url ""]}
}
assigned_name {
label "Assigned to"
@@ -58,7 +64,7 @@
delete {
sub_class narrow
link_url_col delete_url
- hide_p {[ad_decode $usage_mode edit 0 1]}
+ hide_p {[ad_decode $display_mode edit 0 1]}
display_template {
}
Index: openacs-4/contrib/packages/simulation/lib/sim-templates.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-templates.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/lib/sim-templates.adp 12 Nov 2003 13:14:07 -0000 1.1
@@ -0,0 +1 @@
+
Index: openacs-4/contrib/packages/simulation/lib/sim-templates.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-templates.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/lib/sim-templates.tcl 12 Nov 2003 13:14:07 -0000 1.1
@@ -0,0 +1,120 @@
+simulation::include_contract {
+ Displays a list of templates for the current simulation package instance.
+
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id: sim-templates.tcl,v 1.1 2003/11/12 13:14:07 peterm Exp $
+} {
+ display_mode {
+ allowed_values {edit display}
+ default_value display
+ }
+ size {
+ allowed_values {short long}
+ default_value long
+ }
+}
+
+set package_id [ad_conn package_id]
+
+# TODO: make this include honor the display_mode parameter
+
+switch $size {
+ short {
+ template::list::create \
+ -name sim_templates \
+ -multirow sim_templates \
+ -actions { "Add a template" sim-template-edit } \
+ -elements {
+ name {
+ label "Template"
+ link_url_col edit_url
+ orderby upper(ot.pretty_name)
+ }
+ role_count {
+ label "Roles"
+ }
+ task_count {
+ label "Tasks"
+ }
+ }
+ }
+ default {
+ template::list::create \
+ -name sim_templates \
+ -multirow sim_templates \
+ -actions { "Add a template" sim-template-edit } \
+ -elements {
+ edit {
+ sub_class narrow
+ link_url_col edit_url
+ display_template {
+
+ }
+ }
+ name {
+ label "Name"
+ orderby upper(ot.pretty_name)
+ link_url_col view_url
+ }
+ description {
+ label "Description"
+ orderby r.description
+ }
+ created_by {
+ label "Created by"
+ orderby r.createdby
+ }
+ object_count {
+ label "Objects"
+ }
+ role_count {
+ label "Roles"
+ }
+ task_count {
+ label "Tasks"
+ }
+ delete {
+ sub_class narrow
+ link_url_col delete_url
+ display_template {
+
+ }
+ }
+ }
+ }
+}
+
+
+######################################################################
+#
+# sim_templates
+#
+# a list of templates
+#
+######################################################################
+
+db_multirow -extend { edit_url view_url delete_url } sim_templates select_sim_templates "
+ select w.workflow_id,
+ w.pretty_name as name,
+ 'placeholder' as description,
+ a.creation_user as created_by,
+ (select count(object_id)
+ from sim_workflow_object_map
+ where workflow_id = w.workflow_id) as object_count,
+ (select count(role_id)
+ from workflow_roles
+ where workflow_id = w.workflow_id) as role_count,
+ (select count(action_id)
+ from workflow_actions
+ where workflow_id = w.workflow_id) as task_count
+ from workflows w, acs_objects a
+ where w.workflow_id = a.object_id
+ and w.object_id = :package_id
+ [template::list::orderby_clause -orderby -name sim_templates]
+" {
+ set description [string_truncate -len 200 $description]
+ set edit_url [export_vars -base "sim-template-edit?workflow_id=$workflow_id"]
+ set view_url [export_vars -base "sim-template-edit?workflow_id=$workflow_id"]
+ set delete_url [export_vars -base "sim-template-delete?workflow_id=$workflow_id"]
+}
Index: openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/simulation-procs.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 10 Nov 2003 16:56:56 -0000 1.8
+++ openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 12 Nov 2003 13:14:07 -0000 1.9
@@ -9,14 +9,108 @@
namespace eval simulation {}
namespace eval simulation::action {}
namespace eval simulation::object_type {}
-namespace eval simulation::template {}
namespace eval simulation::character {}
namespace eval simulation::role {}
ad_proc -public simulation::package_key {} {
return simulation
}
+ad_proc -public simulation::include_contract { args } {
+ Used to define which parameters an include expecs.
+
+ @param args A list where the first element is an explanation of what the
+ include does, who wrote it when etc. The second element is the optional
+ param spec which is an array list where the keys are parameter (variable)
+ names and the values are array lists where the keys
+ are parameter attributes. Examples below.
+
+
+ simulation::include_contract {
+ Displays a list of templates
+
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id$
+ } {
+ display_mode {
+ allowed_values {edit display}
+ default_value display
+ }
+ size {
+ allowed_values {short long}
+ default_value long
+ }
+ }
+
+
+
+ simulation::include_contract {
+ A list of all objects associated with the Simulation Template
+
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id$
+ } {
+ workflow_id {}
+ }
+
+
+
+ The following attributes can be used for parameters:
+
+
+ - required_p - Is there parameter required? Defaults to 1. Note that if the parameter has a default
+ value that means it is not required.
+ - allowed_values - A list of values that are valid for the parameter. Empty by default, meaning all values are valid.
+ - default_value - Any value that the parameter should default to.
+
+
+
+
+ TODO: Have Lars review this proc and then move it into core
+
+
+ @author Peter Marklund
+} {
+ set description [lindex $args 0]
+ if { [llength $args] == 1 } {
+ # No spec
+ return
+ }
+
+ set spec [lindex $args 1]
+ array set spec_array $spec
+
+ foreach param_name [array names spec_array] {
+ array unset param_array
+ array set param_array $spec_array($param_name)
+
+ upvar $param_name param
+
+ if { ![info exists param_array(required_p)] } {
+ set param_array(required_p) 1
+ }
+
+ # Set default values
+ if { ![info exists param] && [info exists param_array(default_value)] } {
+ set param $param_array(default_value)
+ }
+
+ # Check required params are there
+ if { [string equal $param_array(required_p) 1] && ![info exists param] } {
+ error "Required parameter $param_name not provide to include"
+ }
+
+ # Check param has valid value
+ if { [info exists param] && [info exists param_array(allowed_values)] } {
+ if { [lsearch -exact $param_array(allowed_values) $param] == -1 } {
+ error "Parameter $param_name passed to include has invalid value \"$param\". Valid values are: [join $param_array(allowed_values) ", "]"
+ }
+ }
+ }
+}
+
ad_proc -public simulation::object_type::get_options {
} {
Generate a list of object types formatted as an option list for form-builder's widgets. foo.
@@ -87,42 +181,6 @@
workflow::action::flush_cache -workflow_id $workflow_id
}
-ad_proc -public simulation::template::associate_object {
- -template_id:required
- -object_id:required
-} {
- Associate an object with a simulation template. Succeeds if the record is added or already exists.
-} {
- set exists_p [db_string row_exists {
- select count(*)
- from sim_workflow_object_map
- where workflow_id = :template_id
- and object_id = :object_id
- }]
-
- if { ! $exists_p } {
- db_dml add_object_to_workflow_insert {
- insert into sim_workflow_object_map
- values (:template_id, :object_id)
- }
- }
-}
-
-ad_proc -public simulation::template::dissociate_object {
- -template_id:required
- -object_id:required
-} {
- Dissociate an object with a simulation template
-} {
- db_dml remove_object_from_workflow_delete {
- delete from sim_workflow_object_map
- where workflow_id = :template_id
- and object_id = :object_id
- }
- # no special error handling because the delete is pretty safe
-
-}
-
template_tag relation { params } {
publish::process_tag relation $params
}
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 12 Nov 2003 13:14:07 -0000 1.1
@@ -0,0 +1,84 @@
+ad_library {
+ API for Simulation templates.
+
+ @author Lars Pind (lars@collaboraid.biz)
+ @creation-date 2003-10-14
+ @cvs-id $Id: template-procs.tcl,v 1.1 2003/11/12 13:14:07 peterm Exp $
+}
+
+namespace eval simulation::template {}
+
+ad_proc -public simulation::template::new {
+ {-short_name:required}
+ {-pretty_name:required}
+ {-package_key:required}
+ {-object_id:required}
+} {
+ Create a new simulation template.
+
+ @return The workflow_id of the created simulation.
+
+ @author Peter Marklund
+} {
+ set workflow_id [workflow::new \
+ -short_name $short_name \
+ -pretty_name $pretty_name \
+ -package_key $package_key \
+ -object_id $object_id]
+
+ # create a dummy action with initial action setting because
+ # workflow::get doesn't work on bare workflows
+ workflow::action::fsm::new \
+ -initial_action_p t \
+ -workflow_id $workflow_id \
+ -short_name "dummy action" \
+ -pretty_name "dummy action"
+
+ return $workflow_id
+}
+
+ad_proc -public simulation::template::delete {
+ {-workflow_id:required}
+} {
+ Delete a simulation template.
+
+ @author Peter Marklund
+} {
+ workflow::delete -workflow_id $workflow_id
+}
+
+ad_proc -public simulation::template::associate_object {
+ -template_id:required
+ -object_id:required
+} {
+ Associate an object with a simulation template. Succeeds if the record is added or already exists.
+} {
+ set exists_p [db_string row_exists {
+ select count(*)
+ from sim_workflow_object_map
+ where workflow_id = :template_id
+ and object_id = :object_id
+ }]
+
+ if { ! $exists_p } {
+ db_dml add_object_to_workflow_insert {
+ insert into sim_workflow_object_map
+ values (:template_id, :object_id)
+ }
+ }
+}
+
+ad_proc -public simulation::template::dissociate_object {
+ -template_id:required
+ -object_id:required
+} {
+ Dissociate an object with a simulation template
+} {
+ db_dml remove_object_from_workflow_delete {
+ delete from sim_workflow_object_map
+ where workflow_id = :template_id
+ and object_id = :object_id
+ }
+ # no special error handling because the delete is pretty safe
+
+}
Index: openacs-4/contrib/packages/simulation/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/index.adp,v
diff -u -r1.13 -r1.14
--- openacs-4/contrib/packages/simulation/www/index.adp 11 Nov 2003 17:12:03 -0000 1.13
+++ openacs-4/contrib/packages/simulation/www/index.adp 12 Nov 2003 13:14:07 -0000 1.14
@@ -33,7 +33,7 @@
Index: openacs-4/contrib/packages/simulation/www/sim-template-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-delete.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/sim-template-delete.adp 12 Nov 2003 13:14:07 -0000 1.1
@@ -0,0 +1,15 @@
+
+ @page_title;noquote@
+ @context;noquote@
+
+
+ You are about to delete template "@template_name@". Please review the contents of the template below before you proceed.
+
+
+Roles
+
+
+
+Tasks
+
+
Index: openacs-4/contrib/packages/simulation/www/sim-template-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-delete.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/sim-template-delete.tcl 12 Nov 2003 13:14:07 -0000 1.1
@@ -0,0 +1,17 @@
+ad_page_contract {
+ Delete a simulation template.
+
+ @creation-date 2003-11-12
+ @cvs-id $Id: sim-template-delete.tcl,v 1.1 2003/11/12 13:14:07 peterm Exp $
+} {
+ workflow_id
+}
+
+set template_name [workflow::get_element -workflow_id $workflow_id -element pretty_name]
+set package_id [ad_conn package_id]
+
+set page_title "Deleting template \"$template_name\""
+set template_list_url sim-template-list
+set context [list [list $template_list_url "Templates"] $page_title]
+
+#simulation::template::delete -workflow_id $workflow_id
Index: openacs-4/contrib/packages/simulation/www/sim-template-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-edit.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/contrib/packages/simulation/www/sim-template-edit.adp 11 Nov 2003 17:12:03 -0000 1.6
+++ openacs-4/contrib/packages/simulation/www/sim-template-edit.adp 12 Nov 2003 13:14:07 -0000 1.7
@@ -5,9 +5,16 @@
+
+ » Delete this template
+
+
-Roles
-
-Tasks
-
-
\ No newline at end of file
+ Roles
+
+
+
+ Tasks
+
+
+
Index: openacs-4/contrib/packages/simulation/www/sim-template-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-edit.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/www/sim-template-edit.tcl 27 Oct 2003 07:31:55 -0000 1.2
+++ openacs-4/contrib/packages/simulation/www/sim-template-edit.tcl 12 Nov 2003 13:14:07 -0000 1.3
@@ -40,15 +40,11 @@
set page_title "Create template"
set context [list [list "sim-template-list" "Templates"] $page_title]
} -new_data {
- set workflow_id [workflow::new \
+ set workflow_id [simulation::template::new \
-short_name $name \
-pretty_name $name \
- -package_key $package_key]
- # create a dummy action with initial action setting because
- # workflow::get doesn't work on bare workflows
- workflow::action::fsm::new -initial_action_p t -workflow_id $workflow_id \
- -short_name "dummy action" \
- -pretty_name "dummy action"
+ -package_key $package_key \
+ -object_id $package_id]
} -after_submit {
ad_returnredirect sim-template-edit?workflow_id=$workflow_id
ad_script_abort
@@ -78,6 +74,6 @@
}
}
-set context [list [list "sim-template-list" "Sim Templates"] $page_title]
+set context [list [list "sim-template-list" "Simulation Templates"] $page_title]
-
+set delete_url [export_vars -base sim-template-delete { workflow_id }]
Index: openacs-4/contrib/packages/simulation/www/sim-template-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-list.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/www/sim-template-list.adp 11 Nov 2003 15:32:46 -0000 1.2
+++ openacs-4/contrib/packages/simulation/www/sim-template-list.adp 12 Nov 2003 13:14:07 -0000 1.3
@@ -2,4 +2,4 @@
@page_title;noquote@
@context;noquote@
-
\ No newline at end of file
+
\ No newline at end of file
Index: openacs-4/contrib/packages/simulation/www/sim-template-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-list.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/contrib/packages/simulation/www/sim-template-list.tcl 11 Nov 2003 15:32:46 -0000 1.4
+++ openacs-4/contrib/packages/simulation/www/sim-template-list.tcl 12 Nov 2003 13:14:07 -0000 1.5
@@ -1,8 +1,7 @@
ad_page_contract {
- List workflows designated as templates (but not simulations or cases) on this system.
+ List workflows designated as templates (but not simulations or cases) in this package.
}
set page_title "Simulation Templates"
set context [list $page_title]
set package_id [ad_conn package_id]
-
Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/simulation/lib/sim-template-list.adp'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/simulation/lib/sim-template-list.tcl'.
Fisheye: No comparison available. Pass `N' to diff?
Index: openacs-4/packages/simulation/lib/sim-template-objects.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-objects.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/simulation/lib/sim-template-objects.tcl 6 Nov 2003 15:35:46 -0000 1.1
+++ openacs-4/packages/simulation/lib/sim-template-objects.tcl 12 Nov 2003 13:14:07 -0000 1.2
@@ -1,17 +1,13 @@
-# an includelet
+simulation::include_contract {
+ A list of all objects associated with the Simulation Template
-##############################################################
-#
-# sim_objects
-#
-# A list of all objects associated with the Simulation Template
-#
-##############################################################
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id$
+} {
+ workflow_id {}
+}
-# maybe replace this chunk of copied text with an includable template
-# which passes in a filter for the workflow_id?
-
-
#-------------------------------------------------------------
# sim_objects list
#-------------------------------------------------------------
Index: openacs-4/packages/simulation/lib/sim-template-roles.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-roles.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/simulation/lib/sim-template-roles.adp 6 Nov 2003 15:35:46 -0000 1.1
+++ openacs-4/packages/simulation/lib/sim-template-roles.adp 12 Nov 2003 13:14:07 -0000 1.2
@@ -1,2 +1,7 @@
-
-Add a role
+
+
+
+
+
+ » Add a role
+
Index: openacs-4/packages/simulation/lib/sim-template-roles.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-roles.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/simulation/lib/sim-template-roles.tcl 6 Nov 2003 15:35:46 -0000 1.1
+++ openacs-4/packages/simulation/lib/sim-template-roles.tcl 12 Nov 2003 13:14:07 -0000 1.2
@@ -1,17 +1,15 @@
-# an includelet
+simulation::include_contract {
+ A list of all roles associated with the Simulation Template
-##############################################################
-#
-# roles
-#
-# A list of all roles associated with the Simulation Template
-#
-##############################################################
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id$
+} {
+ workflow_id {}
+}
-# maybe replace this chunk of copied text with an includable template
-# which passes in a filter for the workflow_id?
+set package_id [ad_conn package_id]
-
#-------------------------------------------------------------
# roles list
#-------------------------------------------------------------
Index: openacs-4/packages/simulation/lib/sim-template-tasks.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-tasks.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/simulation/lib/sim-template-tasks.adp 30 Oct 2003 11:15:55 -0000 1.1
+++ openacs-4/packages/simulation/lib/sim-template-tasks.adp 12 Nov 2003 13:14:07 -0000 1.2
@@ -1,5 +1,7 @@
-
- Add a task
-
\ No newline at end of file
+
+
+ » Add a task
+
+
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 -r1.2 -r1.3
--- openacs-4/packages/simulation/lib/sim-template-tasks.tcl 6 Nov 2003 15:35:46 -0000 1.2
+++ openacs-4/packages/simulation/lib/sim-template-tasks.tcl 12 Nov 2003 13:14:07 -0000 1.3
@@ -1,19 +1,25 @@
-# an includelet
+simulation::include_contract {
+ A list of all tasks associated with the Simulation Template
-# the includelet can be a full edit
-
-if { ![exists_and_not_null usage_mode] } {
- set usage_mode display
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id$
+} {
+ workflow_id {}
+ display_mode {
+ allowed_values {edit display}
+ default_value display
+ }
}
-switch $usage_mode {
+set package_id [ad_conn package_id]
+
+switch $display_mode {
display {}
+
edit {
set add_task_url [export_vars -base "task-edit" { workflow_id } ]
}
- default {
- error "This is an opportunity to inspect the code and find out how we got here, since it should be impossible"
- }
}
##############################################################
@@ -38,7 +44,7 @@
-no_data "No tasks in this Simulation Template" \
-elements {
edit {
- hide_p {[ad_decode $usage_mode edit 0 1]}
+ hide_p {[ad_decode $display_mode edit 0 1]}
sub_class narrow
link_url_col edit_url
display_template {
@@ -47,7 +53,7 @@
}
name {
label "Name"
- link_url_col {[ad_decode $usage_mode edit view_url ""]}
+ link_url_col {[ad_decode $display_mode edit view_url ""]}
}
assigned_name {
label "Assigned to"
@@ -58,7 +64,7 @@
delete {
sub_class narrow
link_url_col delete_url
- hide_p {[ad_decode $usage_mode edit 0 1]}
+ hide_p {[ad_decode $display_mode edit 0 1]}
display_template {
}
Index: openacs-4/packages/simulation/lib/sim-templates.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-templates.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/lib/sim-templates.adp 12 Nov 2003 13:14:07 -0000 1.1
@@ -0,0 +1 @@
+
Index: openacs-4/packages/simulation/lib/sim-templates.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-templates.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/lib/sim-templates.tcl 12 Nov 2003 13:14:07 -0000 1.1
@@ -0,0 +1,120 @@
+simulation::include_contract {
+ Displays a list of templates for the current simulation package instance.
+
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id: sim-templates.tcl,v 1.1 2003/11/12 13:14:07 peterm Exp $
+} {
+ display_mode {
+ allowed_values {edit display}
+ default_value display
+ }
+ size {
+ allowed_values {short long}
+ default_value long
+ }
+}
+
+set package_id [ad_conn package_id]
+
+# TODO: make this include honor the display_mode parameter
+
+switch $size {
+ short {
+ template::list::create \
+ -name sim_templates \
+ -multirow sim_templates \
+ -actions { "Add a template" sim-template-edit } \
+ -elements {
+ name {
+ label "Template"
+ link_url_col edit_url
+ orderby upper(ot.pretty_name)
+ }
+ role_count {
+ label "Roles"
+ }
+ task_count {
+ label "Tasks"
+ }
+ }
+ }
+ default {
+ template::list::create \
+ -name sim_templates \
+ -multirow sim_templates \
+ -actions { "Add a template" sim-template-edit } \
+ -elements {
+ edit {
+ sub_class narrow
+ link_url_col edit_url
+ display_template {
+
+ }
+ }
+ name {
+ label "Name"
+ orderby upper(ot.pretty_name)
+ link_url_col view_url
+ }
+ description {
+ label "Description"
+ orderby r.description
+ }
+ created_by {
+ label "Created by"
+ orderby r.createdby
+ }
+ object_count {
+ label "Objects"
+ }
+ role_count {
+ label "Roles"
+ }
+ task_count {
+ label "Tasks"
+ }
+ delete {
+ sub_class narrow
+ link_url_col delete_url
+ display_template {
+
+ }
+ }
+ }
+ }
+}
+
+
+######################################################################
+#
+# sim_templates
+#
+# a list of templates
+#
+######################################################################
+
+db_multirow -extend { edit_url view_url delete_url } sim_templates select_sim_templates "
+ select w.workflow_id,
+ w.pretty_name as name,
+ 'placeholder' as description,
+ a.creation_user as created_by,
+ (select count(object_id)
+ from sim_workflow_object_map
+ where workflow_id = w.workflow_id) as object_count,
+ (select count(role_id)
+ from workflow_roles
+ where workflow_id = w.workflow_id) as role_count,
+ (select count(action_id)
+ from workflow_actions
+ where workflow_id = w.workflow_id) as task_count
+ from workflows w, acs_objects a
+ where w.workflow_id = a.object_id
+ and w.object_id = :package_id
+ [template::list::orderby_clause -orderby -name sim_templates]
+" {
+ set description [string_truncate -len 200 $description]
+ set edit_url [export_vars -base "sim-template-edit?workflow_id=$workflow_id"]
+ set view_url [export_vars -base "sim-template-edit?workflow_id=$workflow_id"]
+ set delete_url [export_vars -base "sim-template-delete?workflow_id=$workflow_id"]
+}
Index: openacs-4/packages/simulation/tcl/simulation-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/simulation-procs.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/simulation/tcl/simulation-procs.tcl 10 Nov 2003 16:56:56 -0000 1.8
+++ openacs-4/packages/simulation/tcl/simulation-procs.tcl 12 Nov 2003 13:14:07 -0000 1.9
@@ -9,14 +9,108 @@
namespace eval simulation {}
namespace eval simulation::action {}
namespace eval simulation::object_type {}
-namespace eval simulation::template {}
namespace eval simulation::character {}
namespace eval simulation::role {}
ad_proc -public simulation::package_key {} {
return simulation
}
+ad_proc -public simulation::include_contract { args } {
+ Used to define which parameters an include expecs.
+
+ @param args A list where the first element is an explanation of what the
+ include does, who wrote it when etc. The second element is the optional
+ param spec which is an array list where the keys are parameter (variable)
+ names and the values are array lists where the keys
+ are parameter attributes. Examples below.
+
+
+ simulation::include_contract {
+ Displays a list of templates
+
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id$
+ } {
+ display_mode {
+ allowed_values {edit display}
+ default_value display
+ }
+ size {
+ allowed_values {short long}
+ default_value long
+ }
+ }
+
+
+
+ simulation::include_contract {
+ A list of all objects associated with the Simulation Template
+
+ @author Joel Aufrecht
+ @creation-date 2003-11-12
+ @cvs-id $Id$
+ } {
+ workflow_id {}
+ }
+
+
+
+ The following attributes can be used for parameters:
+
+
+ - required_p - Is there parameter required? Defaults to 1. Note that if the parameter has a default
+ value that means it is not required.
+ - allowed_values - A list of values that are valid for the parameter. Empty by default, meaning all values are valid.
+ - default_value - Any value that the parameter should default to.
+
+
+
+
+ TODO: Have Lars review this proc and then move it into core
+
+
+ @author Peter Marklund
+} {
+ set description [lindex $args 0]
+ if { [llength $args] == 1 } {
+ # No spec
+ return
+ }
+
+ set spec [lindex $args 1]
+ array set spec_array $spec
+
+ foreach param_name [array names spec_array] {
+ array unset param_array
+ array set param_array $spec_array($param_name)
+
+ upvar $param_name param
+
+ if { ![info exists param_array(required_p)] } {
+ set param_array(required_p) 1
+ }
+
+ # Set default values
+ if { ![info exists param] && [info exists param_array(default_value)] } {
+ set param $param_array(default_value)
+ }
+
+ # Check required params are there
+ if { [string equal $param_array(required_p) 1] && ![info exists param] } {
+ error "Required parameter $param_name not provide to include"
+ }
+
+ # Check param has valid value
+ if { [info exists param] && [info exists param_array(allowed_values)] } {
+ if { [lsearch -exact $param_array(allowed_values) $param] == -1 } {
+ error "Parameter $param_name passed to include has invalid value \"$param\". Valid values are: [join $param_array(allowed_values) ", "]"
+ }
+ }
+ }
+}
+
ad_proc -public simulation::object_type::get_options {
} {
Generate a list of object types formatted as an option list for form-builder's widgets. foo.
@@ -87,42 +181,6 @@
workflow::action::flush_cache -workflow_id $workflow_id
}
-ad_proc -public simulation::template::associate_object {
- -template_id:required
- -object_id:required
-} {
- Associate an object with a simulation template. Succeeds if the record is added or already exists.
-} {
- set exists_p [db_string row_exists {
- select count(*)
- from sim_workflow_object_map
- where workflow_id = :template_id
- and object_id = :object_id
- }]
-
- if { ! $exists_p } {
- db_dml add_object_to_workflow_insert {
- insert into sim_workflow_object_map
- values (:template_id, :object_id)
- }
- }
-}
-
-ad_proc -public simulation::template::dissociate_object {
- -template_id:required
- -object_id:required
-} {
- Dissociate an object with a simulation template
-} {
- db_dml remove_object_from_workflow_delete {
- delete from sim_workflow_object_map
- where workflow_id = :template_id
- and object_id = :object_id
- }
- # no special error handling because the delete is pretty safe
-
-}
-
template_tag relation { params } {
publish::process_tag relation $params
}
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/tcl/template-procs.tcl 12 Nov 2003 13:14:07 -0000 1.1
@@ -0,0 +1,84 @@
+ad_library {
+ API for Simulation templates.
+
+ @author Lars Pind (lars@collaboraid.biz)
+ @creation-date 2003-10-14
+ @cvs-id $Id: template-procs.tcl,v 1.1 2003/11/12 13:14:07 peterm Exp $
+}
+
+namespace eval simulation::template {}
+
+ad_proc -public simulation::template::new {
+ {-short_name:required}
+ {-pretty_name:required}
+ {-package_key:required}
+ {-object_id:required}
+} {
+ Create a new simulation template.
+
+ @return The workflow_id of the created simulation.
+
+ @author Peter Marklund
+} {
+ set workflow_id [workflow::new \
+ -short_name $short_name \
+ -pretty_name $pretty_name \
+ -package_key $package_key \
+ -object_id $object_id]
+
+ # create a dummy action with initial action setting because
+ # workflow::get doesn't work on bare workflows
+ workflow::action::fsm::new \
+ -initial_action_p t \
+ -workflow_id $workflow_id \
+ -short_name "dummy action" \
+ -pretty_name "dummy action"
+
+ return $workflow_id
+}
+
+ad_proc -public simulation::template::delete {
+ {-workflow_id:required}
+} {
+ Delete a simulation template.
+
+ @author Peter Marklund
+} {
+ workflow::delete -workflow_id $workflow_id
+}
+
+ad_proc -public simulation::template::associate_object {
+ -template_id:required
+ -object_id:required
+} {
+ Associate an object with a simulation template. Succeeds if the record is added or already exists.
+} {
+ set exists_p [db_string row_exists {
+ select count(*)
+ from sim_workflow_object_map
+ where workflow_id = :template_id
+ and object_id = :object_id
+ }]
+
+ if { ! $exists_p } {
+ db_dml add_object_to_workflow_insert {
+ insert into sim_workflow_object_map
+ values (:template_id, :object_id)
+ }
+ }
+}
+
+ad_proc -public simulation::template::dissociate_object {
+ -template_id:required
+ -object_id:required
+} {
+ Dissociate an object with a simulation template
+} {
+ db_dml remove_object_from_workflow_delete {
+ delete from sim_workflow_object_map
+ where workflow_id = :template_id
+ and object_id = :object_id
+ }
+ # no special error handling because the delete is pretty safe
+
+}
Index: openacs-4/packages/simulation/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/index.adp,v
diff -u -r1.13 -r1.14
--- openacs-4/packages/simulation/www/index.adp 11 Nov 2003 17:12:03 -0000 1.13
+++ openacs-4/packages/simulation/www/index.adp 12 Nov 2003 13:14:07 -0000 1.14
@@ -33,7 +33,7 @@
Index: openacs-4/packages/simulation/www/sim-template-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-delete.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/www/sim-template-delete.adp 12 Nov 2003 13:14:07 -0000 1.1
@@ -0,0 +1,15 @@
+
+ @page_title;noquote@
+ @context;noquote@
+
+
+ You are about to delete template "@template_name@". Please review the contents of the template below before you proceed.
+
+
+Roles
+
+
+
+Tasks
+
+
Index: openacs-4/packages/simulation/www/sim-template-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-delete.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/www/sim-template-delete.tcl 12 Nov 2003 13:14:07 -0000 1.1
@@ -0,0 +1,17 @@
+ad_page_contract {
+ Delete a simulation template.
+
+ @creation-date 2003-11-12
+ @cvs-id $Id: sim-template-delete.tcl,v 1.1 2003/11/12 13:14:07 peterm Exp $
+} {
+ workflow_id
+}
+
+set template_name [workflow::get_element -workflow_id $workflow_id -element pretty_name]
+set package_id [ad_conn package_id]
+
+set page_title "Deleting template \"$template_name\""
+set template_list_url sim-template-list
+set context [list [list $template_list_url "Templates"] $page_title]
+
+#simulation::template::delete -workflow_id $workflow_id
Index: openacs-4/packages/simulation/www/sim-template-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-edit.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/simulation/www/sim-template-edit.adp 11 Nov 2003 17:12:03 -0000 1.6
+++ openacs-4/packages/simulation/www/sim-template-edit.adp 12 Nov 2003 13:14:07 -0000 1.7
@@ -5,9 +5,16 @@
+
+ » Delete this template
+
+
-Roles
-
-Tasks
-
-
\ No newline at end of file
+ Roles
+
+
+
+ Tasks
+
+
+
Index: openacs-4/packages/simulation/www/sim-template-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-edit.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/simulation/www/sim-template-edit.tcl 27 Oct 2003 07:31:55 -0000 1.2
+++ openacs-4/packages/simulation/www/sim-template-edit.tcl 12 Nov 2003 13:14:07 -0000 1.3
@@ -40,15 +40,11 @@
set page_title "Create template"
set context [list [list "sim-template-list" "Templates"] $page_title]
} -new_data {
- set workflow_id [workflow::new \
+ set workflow_id [simulation::template::new \
-short_name $name \
-pretty_name $name \
- -package_key $package_key]
- # create a dummy action with initial action setting because
- # workflow::get doesn't work on bare workflows
- workflow::action::fsm::new -initial_action_p t -workflow_id $workflow_id \
- -short_name "dummy action" \
- -pretty_name "dummy action"
+ -package_key $package_key \
+ -object_id $package_id]
} -after_submit {
ad_returnredirect sim-template-edit?workflow_id=$workflow_id
ad_script_abort
@@ -78,6 +74,6 @@
}
}
-set context [list [list "sim-template-list" "Sim Templates"] $page_title]
+set context [list [list "sim-template-list" "Simulation Templates"] $page_title]
-
+set delete_url [export_vars -base sim-template-delete { workflow_id }]
Index: openacs-4/packages/simulation/www/sim-template-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-list.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/simulation/www/sim-template-list.adp 11 Nov 2003 15:32:46 -0000 1.2
+++ openacs-4/packages/simulation/www/sim-template-list.adp 12 Nov 2003 13:14:07 -0000 1.3
@@ -2,4 +2,4 @@
@page_title;noquote@
@context;noquote@
-
\ No newline at end of file
+
\ No newline at end of file
Index: openacs-4/packages/simulation/www/sim-template-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-list.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/simulation/www/sim-template-list.tcl 11 Nov 2003 15:32:46 -0000 1.4
+++ openacs-4/packages/simulation/www/sim-template-list.tcl 12 Nov 2003 13:14:07 -0000 1.5
@@ -1,8 +1,7 @@
ad_page_contract {
- List workflows designated as templates (but not simulations or cases) on this system.
+ List workflows designated as templates (but not simulations or cases) in this package.
}
set page_title "Simulation Templates"
set context [list $page_title]
set package_id [ad_conn package_id]
-