+
SIMPLAY
Your live cases:
-
Join a Simulation:
-
+Available simulations
+
-Sim Objects (administrators only)
-
-Add an object
-
-View and edit simulation templates
-
-
If not logged in:
-Sieberdam currently has
-
1580 Inhabitants
-
460 Offices
-
8 running simulations
-
-Join a Simulation
+
+
+
+
+
SIMINST
+
Index: openacs-4/contrib/packages/simulation/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/index.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/contrib/packages/simulation/www/index.tcl 3 Nov 2003 14:13:43 -0000 1.5
+++ openacs-4/contrib/packages/simulation/www/index.tcl 11 Nov 2003 15:32:46 -0000 1.6
@@ -60,10 +60,20 @@
#---------------------------------------------------------------------
# object_count list
#---------------------------------------------------------------------
+if { ![exists_and_not_null parent_id] } {
+ set parent_id [bcms::folder::get_id_by_package_id -parent_id 0]
+}
+set action_list [list "Add an Object" [export_vars -base object-edit { parent_id }] ]
+
+#error "
+#object_add_url: $object_add_url
+#add_action: $add_action"
+
template::list::create \
-name object_count \
-multirow object_count \
+ -actions $action_list \
-html {width "100%"} \
-elements {
type {
@@ -88,6 +98,8 @@
count(content_type) as count
from cr_items
where content_type like 'sim_%'
+ or content_type like 'image'
+ or content_type like 'stylesheet'
group by content_type
" {
set view_url [export_vars -base "object-list" { type }]
Index: openacs-4/contrib/packages/simulation/www/map-master.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/map-master.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/map-master.adp 11 Nov 2003 15:32:46 -0000 1.1
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
Index: openacs-4/contrib/packages/simulation/www/map-master.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/map-master.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/map-master.tcl 11 Nov 2003 15:32:46 -0000 1.1
@@ -0,0 +1,4 @@
+set package_id [ad_conn package_id]
+set return_url "[ad_conn url]?[ad_conn query]"
+set admin_p [permission::permission_p -object_id $package_id -privilege admin]
+set parameters_url [export_vars -base "/shared/parameters" {package_id return_url}]
Index: openacs-4/contrib/packages/simulation/www/map-xml.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/map-xml.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/map-xml.tcl 11 Nov 2003 15:32:46 -0000 1.1
@@ -0,0 +1,7 @@
+ad_page_contract {
+ Display the Map XML document for this package
+
+ @cvs-id $Id: map-xml.tcl,v 1.1 2003/11/11 15:32:46 peterm Exp $
+}
+
+ns_return 200 text/plain [simulation::object::xml::get_doc]
Index: openacs-4/contrib/packages/simulation/www/object-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/object-list.adp,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/simulation/www/object-list.adp 10 Nov 2003 16:56:57 -0000 1.3
+++ openacs-4/contrib/packages/simulation/www/object-list.adp 11 Nov 2003 15:32:46 -0000 1.4
@@ -2,12 +2,24 @@
@page_title;noquote@
@context;noquote@
-
-@notification_widget;noquote@
-
-
» Create new object
+
+
+ Map XML
+
+
+ @notification_widget;noquote@
+
+
+
+ » View Map XML
+
+
+
+ » Generate Map XML file and send notifications
+
+
\ No newline at end of file
Index: openacs-4/contrib/packages/simulation/www/object-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/object-list.tcl,v
diff -u -r1.10 -r1.11
--- openacs-4/contrib/packages/simulation/www/object-list.tcl 10 Nov 2003 16:56:57 -0000 1.10
+++ openacs-4/contrib/packages/simulation/www/object-list.tcl 11 Nov 2003 15:32:46 -0000 1.11
@@ -10,6 +10,8 @@
set page_title "Sim Objects"
set context [list $page_title]
+set package_id [ad_conn package_id]
+set admin_p [permission::permission_p -object_id $package_id -privilege admin]
if { ![exists_and_not_null parent_id] } {
set parent_id [bcms::folder::get_id_by_package_id -parent_id 0]
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.1 -r1.2
--- openacs-4/contrib/packages/simulation/www/sim-template-list.adp 24 Oct 2003 09:46:13 -0000 1.1
+++ openacs-4/contrib/packages/simulation/www/sim-template-list.adp 11 Nov 2003 15:32:46 -0000 1.2
@@ -2,6 +2,4 @@
@page_title;noquote@
@context;noquote@
-
-Add a template
-
Add a template via wizard
\ 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.3 -r1.4
--- openacs-4/contrib/packages/simulation/www/sim-template-list.tcl 27 Oct 2003 07:31:55 -0000 1.3
+++ openacs-4/contrib/packages/simulation/www/sim-template-list.tcl 11 Nov 2003 15:32:46 -0000 1.4
@@ -6,76 +6,3 @@
set context [list $page_title]
set package_id [ad_conn package_id]
-######################################################################
-#
-# sim_templates
-#
-# a list of templates
-#
-######################################################################
-
-template::list::create \
- -name sim_templates \
- -multirow sim_templates \
- -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 {
-
- }
- }
- }
-
-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
- [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/www/simulation-master.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/simulation-master.adp,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/simulation/www/simulation-master.adp 17 Oct 2003 11:11:25 -0000 1.3
+++ openacs-4/contrib/packages/simulation/www/simulation-master.adp 11 Nov 2003 15:32:46 -0000 1.4
@@ -12,4 +12,9 @@
-
\ No newline at end of file
+
+
+
+ Configuration | Documentation
+
+
Index: openacs-4/contrib/packages/simulation/www/simulation-master.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/simulation-master.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/simulation-master.tcl 11 Nov 2003 15:32:46 -0000 1.1
@@ -0,0 +1,4 @@
+set package_id [ad_conn package_id]
+set return_url "[ad_conn url]?[ad_conn query]"
+set admin_p [permission::permission_p -object_id $package_id -privilege admin]
+set parameters_url [export_vars -base "/shared/parameters" {package_id return_url}]
Index: openacs-4/contrib/packages/simulation/www/doc/design.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/doc/Attic/design.html,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/www/doc/design.html 10 Nov 2003 16:56:57 -0000 1.2
+++ openacs-4/contrib/packages/simulation/www/doc/design.html 11 Nov 2003 15:32:46 -0000 1.3
@@ -1,2 +1,2 @@
-
DesignView comments on this page at openacs.org
+
DesignView comments on this page at openacs.org
Index: openacs-4/contrib/packages/simulation/www/doc/index.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/doc/Attic/index.html,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/simulation/www/doc/index.html 10 Nov 2003 16:56:57 -0000 1.3
+++ openacs-4/contrib/packages/simulation/www/doc/index.html 11 Nov 2003 15:32:46 -0000 1.4
@@ -1,2 +1,2 @@
-
SimulationView comments on this page at openacs.org
+
SimulationView comments on this page at openacs.org
Index: openacs-4/contrib/packages/simulation/www/doc/install-sect1.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/doc/Attic/install-sect1.html,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/simulation/www/doc/install-sect1.html 10 Nov 2003 16:56:57 -0000 1.3
+++ openacs-4/contrib/packages/simulation/www/doc/install-sect1.html 11 Nov 2003 15:32:46 -0000 1.4
@@ -1,5 +1,5 @@
-
Package installationRequires workflow and bcms and their prerequisites.
View comments on this page at openacs.org
Index: openacs-4/contrib/packages/simulation/www/doc/xml/admin.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/doc/xml/Attic/admin.xml,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/www/doc/xml/admin.xml 11 Nov 2003 13:13:24 -0000 1.1
+++ openacs-4/contrib/packages/simulation/www/doc/xml/admin.xml 11 Nov 2003 15:32:46 -0000 1.2
@@ -20,20 +20,25 @@
- To activate this feature you need to specify the location
- of the XML file by visiting the parameters page of the package and setting the
- MapXMLFilePath parameter.
+ To activate this feature you need to specify the location of
+ the XML file by visiting the configuration page of the package
+ (start at the index page) and setting
+ the MapXMLFilePath parameter.
- You may view the XML file from a link on the object list page and you may also manually trigger the
- recreation of the XML file from there.
+ You may view the XML file from a link on the object list page and you may also
+ manually trigger the recreation of the XML file from there.
- On the object list page you may sign up for notifications for the Map XML file. You will then be notified
- by email everytime the XML file is regenerated (because something has changed) or everytime there is a problem
- generating the XML file.
-
+ On the
object list page
+ you may sign up for notifications for the Map XML file. You
+ will then be notified by email everytime the XML file is
+ regenerated (because something has changed) or everytime there
+ is a problem generating the XML file.
+
+
Index: openacs-4/contrib/packages/simulation/www/doc/xml/index.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/doc/xml/Attic/index.xml,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/www/doc/xml/index.xml 16 Oct 2003 09:52:32 -0000 1.1
+++ openacs-4/contrib/packages/simulation/www/doc/xml/index.xml 11 Nov 2003 15:32:46 -0000 1.2
@@ -9,6 +9,9 @@
Installation Section Missing
+
+ Admin Section Missing
+
Design Section Missing
Index: openacs-4/packages/simulation/simulation.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/simulation.info,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/simulation/simulation.info 10 Nov 2003 17:06:21 -0000 1.5
+++ openacs-4/packages/simulation/simulation.info 11 Nov 2003 15:32:45 -0000 1.6
@@ -23,7 +23,7 @@
-
+
Index: openacs-4/packages/simulation/lib/sim-template-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/Attic/sim-template-list.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/lib/sim-template-list.adp 11 Nov 2003 15:32:45 -0000 1.1
@@ -0,0 +1 @@
+
Index: openacs-4/packages/simulation/lib/sim-template-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/Attic/sim-template-list.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/lib/sim-template-list.tcl 11 Nov 2003 15:32:45 -0000 1.1
@@ -0,0 +1,107 @@
+# an includelet
+
+# expects paramater "list_mode" = "short" or "long"
+# defaults to short
+
+if { ![exists_and_not_null list_mode] } {
+ set list_mode short
+}
+
+switch $list_mode {
+ 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
+ [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/object-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/object-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/simulation/tcl/object-procs.tcl 10 Nov 2003 16:56:56 -0000 1.2
+++ openacs-4/packages/simulation/tcl/object-procs.tcl 11 Nov 2003 15:32:46 -0000 1.3
@@ -25,11 +25,24 @@
ns_log Notice "Proc simulation::object::xml::file_sweeper executing with simulation_package_ids=$simulation_package_ids"
foreach package_id $simulation_package_ids {
- generate_file -package_id $package_id
+ # An empty file path parameter is valid and signifies that no XML file should be generated
+ if { ![empty_string_p [file_path $package_id]] } {
+ generate_file -package_id $package_id
+ }
}
ns_log Notice "Finished executing simulation::object::xml::file_sweeper"
}
+ad_proc -private simulation::object::xml::file_path { package_id } {
+ return [parameter::get \
+ -parameter [file_path_param_name] \
+ -package_id $package_id]
+}
+
+ad_proc -private simulation::object::xml::file_path_param_name {} {
+ return "MapXMLFilePath"
+}
+
ad_proc -private simulation::object::xml::generate_file {
{-package_id:required}
} {
@@ -41,43 +54,51 @@
@see simulation::object::xml::get_doc
- @return 1 if a new XML file was written and 0 otherwise
+ @return An array list with the elements wrote_file_p and errors. The
+ wrote_file_p attribute will be 1 if a new XML file was written and 0 otherwise.
+ The errors attribute will be a list containing any error messages.
@author Peter Marklund
} {
set errors [list]
- set parameter_name "MapXmlFilePath"
- set file_path [parameter::get -parameter $parameter_name -package_id $package_id]
-
- # An empty file_path signifies that no XML map file should be generated
- if { [empty_string_p $file_path] } {
- return
- }
-
# file_path validity check
+ set parameter_name [file_path_param_name]
+ set file_path [file_path $package_id]
set file_path_error_prefix "Parameter simulation.$parameter_name for package $package_id has invalid value \"${file_path}\"."
- if { ![regexp {^/} $file_path] } {
+ if { [empty_string_p $file_path] } {
+ set error_message "simulation::object::xml::generate_file - parameter simulation.$parameter_name for package $package_id is empty."
+ lappend errors $error_message
+ ns_log Error $error_message
+ } elseif { ![regexp {^/} $file_path] } {
set error_message "$file_path_error_prefix It needs to start with /"
lappend errors $error_message
ns_log Error $error_message
- }
- if { ![file readable $file_path] } {
+ } elseif { [file exists $file_path] && ![file readable $file_path] } {
set error_message "$file_path_error_prefix The file is not readable"
lappend errors $error_message
ns_log Error $error_message
}
set wrote_file_p 0
+
with_catch errmsg {
if { [llength $errors] == 0 } {
- set old_xml_doc [template::util::read_file $file_path]
set new_xml_doc [get_doc -package_id $package_id]
- set xml_changed_p [ad_decode [string compare $old_xml_doc $new_xml_doc] 0 0 1]
- error hej
+
+ if { [file exists $file_path] } {
+ # We have an XML file to compare with
+ set old_xml_doc [template::util::read_file $file_path]
+ # Ignore leading or trailing new lines in comparison
+ set xml_changed_p [ad_decode [string compare [string trim $old_xml_doc] [string trim $new_xml_doc]] 0 0 1]
+ } else {
+ # First time generation
+ set xml_changed_p 1
+ }
+
if { $xml_changed_p } {
- template::util::write_file $file_path
+ template::util::write_file $file_path $new_xml_doc
set wrote_file_p 1
}
}
@@ -96,10 +117,19 @@
-errors $errors
}
- return $wrote_file_p
+ if { $wrote_file_p } {
+ ns_log Notice "simulation::object::xml::generate_file - generated new XML file for package $package_id"
+ } else {
+ ns_log Notice "simulation::object::xml::generate_file - Did not generate new XML file for package $package_id"
+ }
+
+ set return_array(wrote_file_p) $wrote_file_p
+ set return_array(errors) $errors
+
+ return [array get return_array]
}
-ad_proc -private simulatation::object::xml::notify {
+ad_proc -private simulation::object::xml::notify {
{-package_id:required}
{-file_path:required}
{-wrote_file_p:required}
@@ -128,11 +158,17 @@
"
}
- # Send notification
+ # Send notification
+ set type [simulation::notification::xml_map::type_short_name]
+ notification::new \
+ -type_id [notification::type::get_type_id -short_name $type] \
+ -object_id $package_id \
+ -notif_subject $subject \
+ -notif_text $body
}
ad_proc -private simulation::object::xml::get_doc {
- {-package_id:required}
+ {-package_id ""}
} {
Generates XML for all relevant simulation objects in the given
package (that have on_map_p attribute set to true).
@@ -141,6 +177,10 @@
@author Peter Marklund
} {
+ if { [empty_string_p $package_id] } {
+ set package_id [ad_conn package_id]
+ }
+
set full_package_url "[ad_url][apm_package_url_from_id $package_id]"
# Get table names and id column names for the on_map_p attribute of each object type
@@ -165,28 +205,6 @@
# Object type loop.
template::multirow -local foreach sim_table_list {
- ns_log Notice "
- select ci.item_id as id,
- cr.title as name,
- ci.name as uri,
- cr.description,
- ci.content_type,
- (select min(ci2.name)
- from cr_item_rels cir,
- cr_items ci2
- where cir.item_id = ci.item_id
- and cir.related_object_id = ci2.item_id
- and cir.relation_tag = 'thumbnail') as thumbnail_uri
- from cr_items ci
- left outer join cr_item_rels cir on (cir.item_id = ci.item_id),
- cr_revisions cr,
- $table_name st
- where st.on_map_p = 't'
- and st.$id_column = cr.revision_id
- and ci.live_revision = cr.revision_id
- and ci.parent_id = :parent_id
- order by ci.name
- "
db_foreach select_on_map_objects "
select ci.item_id as id,
cr.title as name,
@@ -209,13 +227,14 @@
and ci.parent_id = :parent_id
order by ci.name
" {
- set url "$full_package_url/object/$name"
+ set url "${full_package_url}object/$uri"
+ set thumbnail_url ""
if { [lsearch -exact {sim_location sim_prop sim_character} $content_type] != -1 } {
- set thumbnail_url "${full_package_url}object-content/${thumbnail_uri}"
- } else {
- set thumbnail_url ""
- }
+ if { ![empty_string_p $thumbnail_uri] } {
+ set thumbnail_url "${full_package_url}object-content/${thumbnail_uri}"
+ }
+ }
append xml_doc "