Index: openacs-4/contrib/packages/simulation/simulation.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/Attic/simulation.info,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/simulation.info 13 Oct 2003 13:26:37 -0000 1.2 +++ openacs-4/contrib/packages/simulation/simulation.info 14 Oct 2003 13:58:03 -0000 1.3 @@ -13,9 +13,13 @@ Workflow-based task simulator. 2003-10-13 + + + + Index: openacs-4/contrib/packages/simulation/lib/object-display.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/object-display.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/lib/object-display.adp 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,6 @@ + + @page_title;noquote@ + @context;noquote@ + +

+ Index: openacs-4/contrib/packages/simulation/lib/object-display.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/object-display.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/lib/object-display.tcl 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,51 @@ +ad_page_contract { + Displays a Simulation Object + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-10-14 + @cvs-id $Id: object-display.tcl,v 1.1 2003/10/14 13:58:03 lars Exp $ +} { + revision_id:optional,naturalnum + {printer_friendly_p:optional 0} +} + +set root_id [bcms::folder::get_id_by_package_id -parent_id 0] + +# This little exercise removes the object/ part from the extra_url +set extra_url [eval file join [lrange [file split [ad_conn extra_url]] 1 end]] + +if { [empty_string_p $extra_url] } { + set extra_url "index" +} + +# get the item by url if now revision id is given +if { ![info exists revision_id] } { + array set current_item [bcms::item::get_item_by_url -root_id $root_id -url $extra_url -revision live] +} else { + array set current_item [bcms::revision::get_revision -revision_id $revision_id] +} + +# TODO: Render using template +#set rendered [publish::merge_with_template $current_item(item_id)] + +template::list::create \ + -name attributes \ + -multirow attributes \ + -elements { + attribute { + label "Attribute" + } + value { + label "Value" + } + } + +multirow create attributes attribute value + +set page_title $current_item(title) +set context [list [list ../object-list "Objects"] $page_title] + +foreach name [array names current_item] { + multirow append attributes $name $current_item($name) +} + Index: openacs-4/contrib/packages/simulation/sql/postgresql/simulation-content-types-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/sql/postgresql/Attic/simulation-content-types-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-content-types-create.sql 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,117 @@ +-- @author Lars Pind (lars@collaboraid.biz) +-- @creation-date 2003-10-14 +-- @cvs-id $Id: simulation-content-types-create.sql,v 1.1 2003/10/14 13:58:03 lars Exp $ + + +-- sim_character + +select content_type__create_type( + 'sim_character', -- content_type + 'content_revision', -- supertype + 'Character', -- pretty_name, + 'Characters', -- pretty_plural + 'sim_characters', -- table_name + 'character_id', -- id_column + null -- name_method +); + + + + +-- sim_prop + +select content_type__create_type( + 'sim_prop', -- content_type + 'content_revision', -- supertype + 'Prop', -- pretty_name, + 'Props', -- pretty_plural + 'sim_props', -- table_name + 'prop_id', -- id_column + null -- name_method +); + + + +-- sim_home + +select content_type__create_type( + 'sim_home', -- content_type + 'content_revision', -- supertype + 'Home', -- pretty_name, + 'Homes', -- pretty_plural + 'sim_homes', -- table_name + 'home_id', -- id_column + null -- name_method +); + +select content_type__create_attribute( + 'sim_home', -- content_type + 'address', -- attribute_name + 'string', -- datatype + 'Addresss', -- pretty_name + 'Addresses', -- pretty_plural + 1, -- sort_order + null, -- default_value + 'varchar(4000)' -- column_spec +); + +select content_type__create_attribute( + 'sim_home', -- content_type + 'city', -- attribute_name + 'string', -- datatype + 'City', -- pretty_name + 'Cities', -- pretty_plural + 2, -- sort_order + null, -- default_value + 'varchar(4000)' -- column_spec +); + +select content_type__create_attribute( + 'sim_home', -- content_type + 'history', -- attribute_name + 'text', -- datatype + 'History', -- pretty_name + 'Histories', -- pretty_plural + 3, -- sort_order + null, -- default_value + 'text' -- column_spec +); + +select content_type__create_attribute( + 'sim_home', -- content_type + 'stylesheet', -- attribute_name + 'string', -- datatype + 'Stylesheet', -- pretty_name + 'Stylesheets', -- pretty_plural + 5, -- sort_order + null, -- default_value + 'varchar(4000)' -- column_spec +); + + + + + + +-- sim_contact + +select content_type__create_type( + 'sim_contact', -- content_type + 'content_revision', -- supertype + 'Contact', -- pretty_name, + 'Contacts', -- pretty_plural + 'sim_contacts', -- table_name + 'contact_id', -- id_column + null -- name_method +); + +select content_type__create_attribute( + 'sim_contact', -- content_type + 'internal_mail_adress', -- attribute_name + 'string', -- datatype + 'Internal Mail Addresss', -- pretty_name + 'Internal Mail Addresses', -- pretty_plural + 1, -- sort_order + null, -- default_value + 'varchar(1000)' -- column_spec +); Index: openacs-4/contrib/packages/simulation/sql/postgresql/simulation-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/sql/postgresql/Attic/simulation-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/sql/postgresql/simulation-create.sql 13 Oct 2003 07:58:52 -0000 1.1 +++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-create.sql 14 Oct 2003 13:58:03 -0000 1.2 @@ -7,5 +7,6 @@ -- -- -\i simulation-create-tables.sql -\i simulation-create-functions.sql \ No newline at end of file +\i simulation-tables-create.sql +\i simulation-content-types-create.sql +\i simulation-packages-create.sql Index: openacs-4/contrib/packages/simulation/sql/postgresql/simulation-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/sql/postgresql/Attic/simulation-drop.sql,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/sql/postgresql/simulation-drop.sql 13 Oct 2003 09:57:02 -0000 1.2 +++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-drop.sql 14 Oct 2003 13:58:03 -0000 1.3 @@ -5,9 +5,6 @@ select drop_package('sim_object'); -delete from acs_permissions - where object_id in (select sim_object_id from sim_objects); - --drop objects --declare -- object_rec record; @@ -25,7 +22,6 @@ drop table sim_tasks; drop table sim_roles; drop table sim_workflow_object_map; -drop table sim_objects; --drop types Index: openacs-4/contrib/packages/simulation/sql/postgresql/simulation-packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/sql/postgresql/Attic/simulation-packages-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-packages-create.sql 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,4 @@ +-- @author joel@collaboraid.net +-- @creation-date 2003-10-12 +-- @cvs-id $Id: simulation-packages-create.sql,v 1.1 2003/10/14 13:58:03 lars Exp $ + Index: openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/sql/postgresql/Attic/simulation-tables-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-create.sql 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,82 @@ +-- @author joel@collaboraid.net +-- @creation-date 2003-10-12 +-- @cvs-id $Id: simulation-tables-create.sql,v 1.1 2003/10/14 13:58:03 lars Exp $ + +create table sim_workflow_object_map ( + workflow_id integer constraint sim_workflows_object_map_fk + references workflows(workflow_id), + object_id integer constraint sim_workflows_object_map_2_fk + references acs_objects(object_id), + constraint sim_workflow_object_map_pk + primary key (workflow_id, object_id) +); + +comment on table sim_workflow_object_map is 'Each record indicates that one object is used in one simulation template. If a sim_object is a child of another sim_object which is in this table, the child sim_object should not be in the table.'; + +create table sim_roles ( + role_id integer constraint sim_roles_fk + references workflow_roles + constraint sim_roles_pk + primary key, + character_id integer constraint sim_roles_character_fk + check (1=1) +); + +comment on table sim_roles is 'Each record is a role within a simulation template to be played by one or more users or a computer agent when the template is instantiated into cases.'; + +create table sim_tasks ( + task_id integer constraint sim_tasks_fk + references workflow_actions + constraint sim_tasks_pk + primary key, + recipient integer constraint sim_tasks_recipient_fk + references sim_roles +); + +comment on table sim_tasks is 'Each record is a task that a role must perform, possibly upon another role.'; + +create table sim_simulations ( + simulation_id integer constraint sim_simulations_fk + references workflows + constraint sim_simulation_pk + primary key, + enroll_type varchar(20) constraint sim_simulations_enroll_type_ck + check (1=1), + casting_type varchar(20) constraint sim_simulations_casting_type_ck + check (1=1), + enroll_start timestamptz, + enroll_end timestamptz, + constraint sim_simulations_enroll_end_after_start_end_ck + check (enroll_end >= enroll_start), + case_start timestamptz, + case_end timestamptz, + constraint sim_simulations_case_end_after_start_ck + check (case_end >= case_start) +); + +select acs_object_type__create_type ( + 'simulation', -- object_type + 'Simulation', -- pretty_name + 'Simulations', -- pretty_plural + 'workflow_lite', -- supertype + 'sim_simulations', -- table_name + 'simulation_id', -- id_column + null, -- package_name + 'f', -- abstract_p + null, -- type_extension_table + 'sim_simulation__name' -- name_method + ); + +comment on table sim_simulations is 'Each record is an instantiation of a simulation template, and the parent of zero to many simulation cases.'; + +create table sim_party_sim_map ( + simulation_id integer constraint sim_party_sim_map_sim_fk + references sim_simulations, + party_id integer constraint sim_party_sim_map_party_fk + references parties, + constraint sim_party_sim_map_pk + primary key (simulation_id, party_id) +); + +comment on table sim_party_sim_map is 'Each record is an invitation to a party to participate in a simulation.'; + Index: openacs-4/contrib/packages/simulation/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/apm-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/tcl/apm-callback-procs.tcl 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,26 @@ +ad_library { + Installation, instantiation, etc. procs + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-10-13 + @cvs-id $Id: apm-callback-procs.tcl,v 1.1 2003/10/14 13:58:03 lars Exp $ +} + +namespace eval simulation::apm {} + + +ad_proc -private simulation::apm::after_instantiate { + {-package_id:required} +} { + Create the package root folder. +} { + set instance_name [apm_instance_name_from_id $package_id] + + set folder_id [bcms::folder::create_folder \ + -name "simulation_${package_id}_root" \ + -folder_label "${instance_name} Root" \ + -parent_id 0 \ + -package_id $package_id \ + -content_types { sim_character sim_prop sim_home sim_contact file_storage_object }] +} + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,13 @@ +ad_library { + API for Simulation. + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-10-14 + @cvs-id $Id: simulation-procs.tcl,v 1.1 2003/10/14 13:58:03 lars Exp $ +} + +namespace eval simulation {} + + + +# Lars: Nothing here yet, keeping it in case we want to add something 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.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/index.adp 13 Oct 2003 13:27:02 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/index.adp 14 Oct 2003 13:58:03 -0000 1.2 @@ -1,18 +1,21 @@ -
- -Active simulations ... +

Your live cases:

+

+

Active simulations:

+

TODO

+
-Flash map of city... +

Flash map of city:

+

TODO

+
-If user has permission to edit simulation objects: + +

If user has permission to edit simulation objects:

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.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/index.tcl 13 Oct 2003 13:27:02 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/index.tcl 14 Oct 2003 13:58:03 -0000 1.2 @@ -25,9 +25,8 @@ # number of active tasks for that role db_multirow cases cases_sql { - select 'case one', 'case two' as case_name, - 0,2 as task_count - from dual + select 'case one' as case_name, + 2 as task_count } template::list::create \ @@ -48,4 +47,4 @@ select 'case one', 'case two' as case_name, 0,2 as task_count from dual -} \ No newline at end of file +} Index: openacs-4/contrib/packages/simulation/www/object-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/object-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/object-edit.adp 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,6 @@ + + @page_title;noquote@ + @context;noquote@ + object.title + + Index: openacs-4/contrib/packages/simulation/www/object-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/object-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/object-edit.tcl 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,168 @@ +ad_page_contract { + Add/edit object. + + @creation-date 2003-10-13 + @cvs-id $Id: object-edit.tcl,v 1.1 2003/10/14 13:58:03 lars Exp $ +} { + object_id:integer,optional + parent_id:integer + content_type +} + +set page_title "Create Object" +set context [list [list "object-list" "Objects"] $page_title] + +ad_form -name object -form { + {object_id:key} + {content_type:text(hidden)} + {parent_id:integer(hidden)} + {title:text + {label "Title"} + {html {size 50}} + } + {name:text,optional + {label "URL name"} + {html {size 50}} + {help_text "This will become part of the URL for the object."} + } + {description:text(textarea),optional + {label "Description"} + {html {cols 60 rows 8}} + } +} + +# LARS: I'm doing this as a proof-of-concept type thing. If it works well enough for us, +# we'll want to generalize and move into acs-content-repository + +array set form_datatype { + string text + boolean text + number text + integer integer + money text + date text + timestamp text + time_of_day text + enumeration text + url text + email text + text text + keyword integer +} + +array set form_widget { + string text + boolean text + number text + integer text + money text + date text + timestamp text + time_of_day text + enumeration text + url text + email text + text textarea + keyword integer +} + +array set form_extra { + string { + {html {size 50}} + } + boolean {} + number {} + integer {} + money {} + date {} + timestamp {} + time_of_day {} + enumeration {} + url { + {html {size 50}} + } + email { + {html {size 50}} + } + text { + {html {cols 60 rows 8}} + } + keyword {} +} + +db_foreach select_attributes { + select attribute_name, pretty_name, datatype, default_value, min_n_values + from acs_attributes + where object_type = :content_type + and storage = 'type_specific' + and static_p = 'f' + order by sort_order +} { + set elm_decl "attr__${content_type}__${attribute_name}:$form_datatype($datatype)($form_widget($datatype))" + + set optional_p [expr ![empty_string_p $default_value] || $min_n_values == 0] + if { $optional_p } { + append elm_decl ",optional" + } + + ad_form -extend -name object -form \ + [list [concat [list $elm_decl [list label \$pretty_name]] $form_extra($datatype)]] +} + + +ad_form -extend -name object -new_request { + # Set element values from local vars +} -new_data { + + set existing_items [db_list select_items { select name from cr_items where parent_id = :parent_id }] + if { [empty_string_p $name] } { + set name [util_text_to_url -existing_urls $existing_items -text $title] + } else { + if { [lsearch $existing_items $name] != -1 } { + form set_error object name "This name is already in use" + break + } + } + + set attributes [list] + + db_foreach select_attributes { + select attribute_name, pretty_name, datatype, default_value, min_n_values + from acs_attributes + where object_type = :content_type + and storage = 'type_specific' + and static_p = 'f' + order by sort_order + } { + lappend attributes $attribute_name [set attr__${content_type}__${attribute_name}] + } + + set item_id [bcms::item::create_item \ + -item_name $name \ + -parent_id $parent_id \ + -content_type $content_type] + + set revision_id [bcms::revision::add_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -mime_type "text/plain" \ + -description $description \ + -additional_properties $attributes] + + bcms::revision::set_revision_status \ + -revision_id $revision_id \ + -status "live" + +} -edit_request { + + error TODO + +} -edit_data { + + error TODO + +} -after_submit { + ad_returnredirect object-list + ad_script_abort +} 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/object-list.adp 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,11 @@ + + @page_title;noquote@ + @context;noquote@ + +

+ + +

+ » @object_types.label@ +

+
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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/object-list.tcl 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,70 @@ +ad_page_contract { + + @creation-date 2003-10-13 + @cvs-id $Id: object-list.tcl,v 1.1 2003/10/14 13:58:03 lars Exp $ +} { + parent_id:optional + {orderby "title,asc"} +} + +set page_title "Objects" +set context [list $page_title] + +if { ![exists_and_not_null parent_id] } { + set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] +} + +template::list::create \ + -name objects \ + -multirow objects \ + -elements { + object_type_pretty { + label "Type" + orderby upper(ot.pretty_name) + } + title { + label "Title" + orderby r.title + link_url_col view_url + } + description { + label "Description" + orderby r.description + } + } + + +set package_id [ad_conn package_id] + +db_multirow -extend { view_url } objects select_objects " + select i.item_id, + i.name, + r.title, + r.description, + i.content_type, + ot.pretty_name as object_type_pretty + from cr_folders f, + cr_items i, + cr_revisions r, + acs_object_types ot + where f.package_id = :package_id + and i.parent_id = f.folder_id + and r.revision_id = i.live_revision + and ot.object_type = i.content_type + [template::list::orderby_clause -orderby -name "objects"] +" { + set description [string_truncate -len 200 $description] + set view_url [export_vars -base "object/$name"] +} + +set sim_types { sim_character sim_prop sim_home sim_contact file_storage_object } + +db_multirow -extend { create_url label } object_types select_object_types " + select ot.object_type as content_type, + ot.pretty_name + from acs_object_types ot + where ot.object_type in ('[join $sim_types "','"]') +" { + set create_url [export_vars -base object-edit { content_type parent_id }] + set label "Create new $pretty_name" +} Index: openacs-4/contrib/packages/simulation/www/object/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/object/Attic/index.vuh,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/object/index.vuh 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,9 @@ +ad_page_contract { + Displays a Simulation Object + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-10-14 + @cvs-id $Id: index.vuh,v 1.1 2003/10/14 13:58:03 lars Exp $ +} + +rp_internal_redirect -absolute_path [file join [acs_package_root_dir "simulation"] lib object-display] Index: openacs-4/packages/simulation/simulation.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/simulation.info,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/simulation.info 13 Oct 2003 13:26:37 -0000 1.2 +++ openacs-4/packages/simulation/simulation.info 14 Oct 2003 13:58:03 -0000 1.3 @@ -13,9 +13,13 @@ Workflow-based task simulator. 2003-10-13 + + + + Index: openacs-4/packages/simulation/lib/object-display.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/object-display.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/lib/object-display.adp 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,6 @@ + + @page_title;noquote@ + @context;noquote@ + +

+ Index: openacs-4/packages/simulation/lib/object-display.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/object-display.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/lib/object-display.tcl 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,51 @@ +ad_page_contract { + Displays a Simulation Object + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-10-14 + @cvs-id $Id: object-display.tcl,v 1.1 2003/10/14 13:58:03 lars Exp $ +} { + revision_id:optional,naturalnum + {printer_friendly_p:optional 0} +} + +set root_id [bcms::folder::get_id_by_package_id -parent_id 0] + +# This little exercise removes the object/ part from the extra_url +set extra_url [eval file join [lrange [file split [ad_conn extra_url]] 1 end]] + +if { [empty_string_p $extra_url] } { + set extra_url "index" +} + +# get the item by url if now revision id is given +if { ![info exists revision_id] } { + array set current_item [bcms::item::get_item_by_url -root_id $root_id -url $extra_url -revision live] +} else { + array set current_item [bcms::revision::get_revision -revision_id $revision_id] +} + +# TODO: Render using template +#set rendered [publish::merge_with_template $current_item(item_id)] + +template::list::create \ + -name attributes \ + -multirow attributes \ + -elements { + attribute { + label "Attribute" + } + value { + label "Value" + } + } + +multirow create attributes attribute value + +set page_title $current_item(title) +set context [list [list ../object-list "Objects"] $page_title] + +foreach name [array names current_item] { + multirow append attributes $name $current_item($name) +} + Index: openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/sql/postgresql/simulation-content-types-create.sql 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,117 @@ +-- @author Lars Pind (lars@collaboraid.biz) +-- @creation-date 2003-10-14 +-- @cvs-id $Id: simulation-content-types-create.sql,v 1.1 2003/10/14 13:58:03 lars Exp $ + + +-- sim_character + +select content_type__create_type( + 'sim_character', -- content_type + 'content_revision', -- supertype + 'Character', -- pretty_name, + 'Characters', -- pretty_plural + 'sim_characters', -- table_name + 'character_id', -- id_column + null -- name_method +); + + + + +-- sim_prop + +select content_type__create_type( + 'sim_prop', -- content_type + 'content_revision', -- supertype + 'Prop', -- pretty_name, + 'Props', -- pretty_plural + 'sim_props', -- table_name + 'prop_id', -- id_column + null -- name_method +); + + + +-- sim_home + +select content_type__create_type( + 'sim_home', -- content_type + 'content_revision', -- supertype + 'Home', -- pretty_name, + 'Homes', -- pretty_plural + 'sim_homes', -- table_name + 'home_id', -- id_column + null -- name_method +); + +select content_type__create_attribute( + 'sim_home', -- content_type + 'address', -- attribute_name + 'string', -- datatype + 'Addresss', -- pretty_name + 'Addresses', -- pretty_plural + 1, -- sort_order + null, -- default_value + 'varchar(4000)' -- column_spec +); + +select content_type__create_attribute( + 'sim_home', -- content_type + 'city', -- attribute_name + 'string', -- datatype + 'City', -- pretty_name + 'Cities', -- pretty_plural + 2, -- sort_order + null, -- default_value + 'varchar(4000)' -- column_spec +); + +select content_type__create_attribute( + 'sim_home', -- content_type + 'history', -- attribute_name + 'text', -- datatype + 'History', -- pretty_name + 'Histories', -- pretty_plural + 3, -- sort_order + null, -- default_value + 'text' -- column_spec +); + +select content_type__create_attribute( + 'sim_home', -- content_type + 'stylesheet', -- attribute_name + 'string', -- datatype + 'Stylesheet', -- pretty_name + 'Stylesheets', -- pretty_plural + 5, -- sort_order + null, -- default_value + 'varchar(4000)' -- column_spec +); + + + + + + +-- sim_contact + +select content_type__create_type( + 'sim_contact', -- content_type + 'content_revision', -- supertype + 'Contact', -- pretty_name, + 'Contacts', -- pretty_plural + 'sim_contacts', -- table_name + 'contact_id', -- id_column + null -- name_method +); + +select content_type__create_attribute( + 'sim_contact', -- content_type + 'internal_mail_adress', -- attribute_name + 'string', -- datatype + 'Internal Mail Addresss', -- pretty_name + 'Internal Mail Addresses', -- pretty_plural + 1, -- sort_order + null, -- default_value + 'varchar(1000)' -- column_spec +); Index: openacs-4/packages/simulation/sql/postgresql/simulation-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/sql/postgresql/simulation-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/sql/postgresql/simulation-create.sql 13 Oct 2003 07:58:52 -0000 1.1 +++ openacs-4/packages/simulation/sql/postgresql/simulation-create.sql 14 Oct 2003 13:58:03 -0000 1.2 @@ -7,5 +7,6 @@ -- -- -\i simulation-create-tables.sql -\i simulation-create-functions.sql \ No newline at end of file +\i simulation-tables-create.sql +\i simulation-content-types-create.sql +\i simulation-packages-create.sql Index: openacs-4/packages/simulation/sql/postgresql/simulation-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/sql/postgresql/simulation-drop.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/sql/postgresql/simulation-drop.sql 13 Oct 2003 09:57:02 -0000 1.2 +++ openacs-4/packages/simulation/sql/postgresql/simulation-drop.sql 14 Oct 2003 13:58:03 -0000 1.3 @@ -5,9 +5,6 @@ select drop_package('sim_object'); -delete from acs_permissions - where object_id in (select sim_object_id from sim_objects); - --drop objects --declare -- object_rec record; @@ -25,7 +22,6 @@ drop table sim_tasks; drop table sim_roles; drop table sim_workflow_object_map; -drop table sim_objects; --drop types Index: openacs-4/packages/simulation/sql/postgresql/simulation-packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/sql/postgresql/simulation-packages-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/sql/postgresql/simulation-packages-create.sql 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,4 @@ +-- @author joel@collaboraid.net +-- @creation-date 2003-10-12 +-- @cvs-id $Id: simulation-packages-create.sql,v 1.1 2003/10/14 13:58:03 lars Exp $ + Index: openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,82 @@ +-- @author joel@collaboraid.net +-- @creation-date 2003-10-12 +-- @cvs-id $Id: simulation-tables-create.sql,v 1.1 2003/10/14 13:58:03 lars Exp $ + +create table sim_workflow_object_map ( + workflow_id integer constraint sim_workflows_object_map_fk + references workflows(workflow_id), + object_id integer constraint sim_workflows_object_map_2_fk + references acs_objects(object_id), + constraint sim_workflow_object_map_pk + primary key (workflow_id, object_id) +); + +comment on table sim_workflow_object_map is 'Each record indicates that one object is used in one simulation template. If a sim_object is a child of another sim_object which is in this table, the child sim_object should not be in the table.'; + +create table sim_roles ( + role_id integer constraint sim_roles_fk + references workflow_roles + constraint sim_roles_pk + primary key, + character_id integer constraint sim_roles_character_fk + check (1=1) +); + +comment on table sim_roles is 'Each record is a role within a simulation template to be played by one or more users or a computer agent when the template is instantiated into cases.'; + +create table sim_tasks ( + task_id integer constraint sim_tasks_fk + references workflow_actions + constraint sim_tasks_pk + primary key, + recipient integer constraint sim_tasks_recipient_fk + references sim_roles +); + +comment on table sim_tasks is 'Each record is a task that a role must perform, possibly upon another role.'; + +create table sim_simulations ( + simulation_id integer constraint sim_simulations_fk + references workflows + constraint sim_simulation_pk + primary key, + enroll_type varchar(20) constraint sim_simulations_enroll_type_ck + check (1=1), + casting_type varchar(20) constraint sim_simulations_casting_type_ck + check (1=1), + enroll_start timestamptz, + enroll_end timestamptz, + constraint sim_simulations_enroll_end_after_start_end_ck + check (enroll_end >= enroll_start), + case_start timestamptz, + case_end timestamptz, + constraint sim_simulations_case_end_after_start_ck + check (case_end >= case_start) +); + +select acs_object_type__create_type ( + 'simulation', -- object_type + 'Simulation', -- pretty_name + 'Simulations', -- pretty_plural + 'workflow_lite', -- supertype + 'sim_simulations', -- table_name + 'simulation_id', -- id_column + null, -- package_name + 'f', -- abstract_p + null, -- type_extension_table + 'sim_simulation__name' -- name_method + ); + +comment on table sim_simulations is 'Each record is an instantiation of a simulation template, and the parent of zero to many simulation cases.'; + +create table sim_party_sim_map ( + simulation_id integer constraint sim_party_sim_map_sim_fk + references sim_simulations, + party_id integer constraint sim_party_sim_map_party_fk + references parties, + constraint sim_party_sim_map_pk + primary key (simulation_id, party_id) +); + +comment on table sim_party_sim_map is 'Each record is an invitation to a party to participate in a simulation.'; + Index: openacs-4/packages/simulation/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/apm-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/tcl/apm-callback-procs.tcl 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,26 @@ +ad_library { + Installation, instantiation, etc. procs + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-10-13 + @cvs-id $Id: apm-callback-procs.tcl,v 1.1 2003/10/14 13:58:03 lars Exp $ +} + +namespace eval simulation::apm {} + + +ad_proc -private simulation::apm::after_instantiate { + {-package_id:required} +} { + Create the package root folder. +} { + set instance_name [apm_instance_name_from_id $package_id] + + set folder_id [bcms::folder::create_folder \ + -name "simulation_${package_id}_root" \ + -folder_label "${instance_name} Root" \ + -parent_id 0 \ + -package_id $package_id \ + -content_types { sim_character sim_prop sim_home sim_contact file_storage_object }] +} + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/tcl/simulation-procs.tcl 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,13 @@ +ad_library { + API for Simulation. + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-10-14 + @cvs-id $Id: simulation-procs.tcl,v 1.1 2003/10/14 13:58:03 lars Exp $ +} + +namespace eval simulation {} + + + +# Lars: Nothing here yet, keeping it in case we want to add something Index: openacs-4/packages/simulation/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/index.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/www/index.adp 13 Oct 2003 13:27:02 -0000 1.1 +++ openacs-4/packages/simulation/www/index.adp 14 Oct 2003 13:58:03 -0000 1.2 @@ -1,18 +1,21 @@ -
- -Active simulations ... +

Your live cases:

+

+

Active simulations:

+

TODO

+
-Flash map of city... +

Flash map of city:

+

TODO

+
-If user has permission to edit simulation objects: + +

If user has permission to edit simulation objects:

Index: openacs-4/packages/simulation/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/index.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/www/index.tcl 13 Oct 2003 13:27:02 -0000 1.1 +++ openacs-4/packages/simulation/www/index.tcl 14 Oct 2003 13:58:03 -0000 1.2 @@ -25,9 +25,8 @@ # number of active tasks for that role db_multirow cases cases_sql { - select 'case one', 'case two' as case_name, - 0,2 as task_count - from dual + select 'case one' as case_name, + 2 as task_count } template::list::create \ @@ -48,4 +47,4 @@ select 'case one', 'case two' as case_name, 0,2 as task_count from dual -} \ No newline at end of file +} Index: openacs-4/packages/simulation/www/object-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/object-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/object-edit.adp 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,6 @@ + + @page_title;noquote@ + @context;noquote@ + object.title + + Index: openacs-4/packages/simulation/www/object-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/object-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/object-edit.tcl 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,168 @@ +ad_page_contract { + Add/edit object. + + @creation-date 2003-10-13 + @cvs-id $Id: object-edit.tcl,v 1.1 2003/10/14 13:58:03 lars Exp $ +} { + object_id:integer,optional + parent_id:integer + content_type +} + +set page_title "Create Object" +set context [list [list "object-list" "Objects"] $page_title] + +ad_form -name object -form { + {object_id:key} + {content_type:text(hidden)} + {parent_id:integer(hidden)} + {title:text + {label "Title"} + {html {size 50}} + } + {name:text,optional + {label "URL name"} + {html {size 50}} + {help_text "This will become part of the URL for the object."} + } + {description:text(textarea),optional + {label "Description"} + {html {cols 60 rows 8}} + } +} + +# LARS: I'm doing this as a proof-of-concept type thing. If it works well enough for us, +# we'll want to generalize and move into acs-content-repository + +array set form_datatype { + string text + boolean text + number text + integer integer + money text + date text + timestamp text + time_of_day text + enumeration text + url text + email text + text text + keyword integer +} + +array set form_widget { + string text + boolean text + number text + integer text + money text + date text + timestamp text + time_of_day text + enumeration text + url text + email text + text textarea + keyword integer +} + +array set form_extra { + string { + {html {size 50}} + } + boolean {} + number {} + integer {} + money {} + date {} + timestamp {} + time_of_day {} + enumeration {} + url { + {html {size 50}} + } + email { + {html {size 50}} + } + text { + {html {cols 60 rows 8}} + } + keyword {} +} + +db_foreach select_attributes { + select attribute_name, pretty_name, datatype, default_value, min_n_values + from acs_attributes + where object_type = :content_type + and storage = 'type_specific' + and static_p = 'f' + order by sort_order +} { + set elm_decl "attr__${content_type}__${attribute_name}:$form_datatype($datatype)($form_widget($datatype))" + + set optional_p [expr ![empty_string_p $default_value] || $min_n_values == 0] + if { $optional_p } { + append elm_decl ",optional" + } + + ad_form -extend -name object -form \ + [list [concat [list $elm_decl [list label \$pretty_name]] $form_extra($datatype)]] +} + + +ad_form -extend -name object -new_request { + # Set element values from local vars +} -new_data { + + set existing_items [db_list select_items { select name from cr_items where parent_id = :parent_id }] + if { [empty_string_p $name] } { + set name [util_text_to_url -existing_urls $existing_items -text $title] + } else { + if { [lsearch $existing_items $name] != -1 } { + form set_error object name "This name is already in use" + break + } + } + + set attributes [list] + + db_foreach select_attributes { + select attribute_name, pretty_name, datatype, default_value, min_n_values + from acs_attributes + where object_type = :content_type + and storage = 'type_specific' + and static_p = 'f' + order by sort_order + } { + lappend attributes $attribute_name [set attr__${content_type}__${attribute_name}] + } + + set item_id [bcms::item::create_item \ + -item_name $name \ + -parent_id $parent_id \ + -content_type $content_type] + + set revision_id [bcms::revision::add_revision \ + -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -mime_type "text/plain" \ + -description $description \ + -additional_properties $attributes] + + bcms::revision::set_revision_status \ + -revision_id $revision_id \ + -status "live" + +} -edit_request { + + error TODO + +} -edit_data { + + error TODO + +} -after_submit { + ad_returnredirect object-list + ad_script_abort +} Index: openacs-4/packages/simulation/www/object-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/object-list.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/object-list.adp 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,11 @@ + + @page_title;noquote@ + @context;noquote@ + +

+ + +

+ » @object_types.label@ +

+
Index: openacs-4/packages/simulation/www/object-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/object-list.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/object-list.tcl 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,70 @@ +ad_page_contract { + + @creation-date 2003-10-13 + @cvs-id $Id: object-list.tcl,v 1.1 2003/10/14 13:58:03 lars Exp $ +} { + parent_id:optional + {orderby "title,asc"} +} + +set page_title "Objects" +set context [list $page_title] + +if { ![exists_and_not_null parent_id] } { + set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] +} + +template::list::create \ + -name objects \ + -multirow objects \ + -elements { + object_type_pretty { + label "Type" + orderby upper(ot.pretty_name) + } + title { + label "Title" + orderby r.title + link_url_col view_url + } + description { + label "Description" + orderby r.description + } + } + + +set package_id [ad_conn package_id] + +db_multirow -extend { view_url } objects select_objects " + select i.item_id, + i.name, + r.title, + r.description, + i.content_type, + ot.pretty_name as object_type_pretty + from cr_folders f, + cr_items i, + cr_revisions r, + acs_object_types ot + where f.package_id = :package_id + and i.parent_id = f.folder_id + and r.revision_id = i.live_revision + and ot.object_type = i.content_type + [template::list::orderby_clause -orderby -name "objects"] +" { + set description [string_truncate -len 200 $description] + set view_url [export_vars -base "object/$name"] +} + +set sim_types { sim_character sim_prop sim_home sim_contact file_storage_object } + +db_multirow -extend { create_url label } object_types select_object_types " + select ot.object_type as content_type, + ot.pretty_name + from acs_object_types ot + where ot.object_type in ('[join $sim_types "','"]') +" { + set create_url [export_vars -base object-edit { content_type parent_id }] + set label "Create new $pretty_name" +} Index: openacs-4/packages/simulation/www/object/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/object/index.vuh,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/object/index.vuh 14 Oct 2003 13:58:03 -0000 1.1 @@ -0,0 +1,9 @@ +ad_page_contract { + Displays a Simulation Object + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-10-14 + @cvs-id $Id: index.vuh,v 1.1 2003/10/14 13:58:03 lars Exp $ +} + +rp_internal_redirect -absolute_path [file join [acs_package_root_dir "simulation"] lib object-display]