Index: openacs-4/contrib/packages/simulation/lib/sim-template-objects.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-objects.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/lib/sim-template-objects.adp 6 Nov 2003 15:35:46 -0000 1.1 @@ -0,0 +1,3 @@ +
Add Sim +Objects to this Workflow 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 -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/lib/sim-template-objects.tcl 6 Nov 2003 15:35:46 -0000 1.1 @@ -0,0 +1,83 @@ +# an includelet + +############################################################## +# +# sim_objects +# +# A list of all objects associated with the Simulation Template +# +############################################################## + +# maybe replace this chunk of copied text with an includable template +# which passes in a filter for the workflow_id? + + +#------------------------------------------------------------- +# sim_objects list +#------------------------------------------------------------- + +template::list::create \ + -name sim_objects \ + -multirow sim_objects \ + -no_data "No Sim Objects are associated with this Simulation Template" \ + -elements { + edit { + sub_class narrow + link_url_col edit_url + display_template { + + } + } + 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 + } + } + +db_multirow -extend { edit_url view_url delete_url } sim_objects select_sim_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, + sim_workflow_object_map swom + 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 + and swom.workflow_id = :workflow_id + and swom.object_id = i.item_id + + [template::list::orderby_clause -orderby -name "sim_objects"] +" { + set description [string_truncate -len 200 $description] + set edit_url [export_vars -base "object-edit" { item_id }] + set view_url [export_vars -base "object/$name"] + set delete_url [export_vars -base "object-delete" { item_id }] +} + +set sim_types { sim_character sim_prop sim_location } + +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/lib/sim-template-roles.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-roles.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/lib/sim-template-roles.adp 6 Nov 2003 15:35:46 -0000 1.1 @@ -0,0 +1,2 @@ +
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 -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/lib/sim-template-roles.tcl 6 Nov 2003 15:35:46 -0000 1.1
@@ -0,0 +1,68 @@
+# an includelet
+
+##############################################################
+#
+# roles
+#
+# A list of all roles associated with the Simulation Template
+#
+##############################################################
+
+# maybe replace this chunk of copied text with an includable template
+# which passes in a filter for the workflow_id?
+
+
+#-------------------------------------------------------------
+# roles list
+#-------------------------------------------------------------
+
+template::list::create \
+ -name roles \
+ -multirow roles \
+ -no_data "No roles in this Simulation Template" \
+ -elements {
+ edit {
+ sub_class narrow
+ link_url_col edit_url
+ display_template {
+
+ }
+ }
+ name {
+ label "Name"
+ }
+ char_name {
+ label "Character"
+ link_url_col char_url
+ }
+ delete {
+ sub_class narrow
+ link_url_col delete_url
+ display_template {
+
+ }
+ }
+ }
+#-------------------------------------------------------------
+# roles db_multirow
+#-------------------------------------------------------------
+set return_url "[ad_conn url]?[ad_conn query]"
+db_multirow -extend { edit_url char_url delete_url } roles select_roles "
+ select wr.role_id,
+ wr.pretty_name as name,
+ wr.sort_order,
+ cr.title as char_name
+ from workflow_roles wr,
+ sim_roles sr,
+ cr_items ci,
+ cr_revisions cr
+ where wr.workflow_id = :workflow_id
+ and sr.role_id = wr.role_id
+ and ci.item_id = sr.character_id
+ and cr.revision_id = ci.live_revision
+ [template::list::orderby_clause -orderby -name "roles"]
+" {
+ set edit_url [export_vars -base "role-edit" { role_id }]
+ set char_url [export_vars -base "object/$char_name"]
+ set delete_url [export_vars -base "role-delete" { role_id return_url }]
+}
Index: openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-tasks.tcl,v
diff -u -N -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 30 Oct 2003 11:15:55 -0000 1.1
+++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 6 Nov 2003 15:35:46 -0000 1.2
@@ -69,7 +69,7 @@
# tasks db_multirow
#-------------------------------------------------------------
# TODO: fix this so it returns rows when it should
-
+set return_url "[ad_conn url]?[ad_conn query]"
db_multirow -extend { edit_url view_url delete_url } tasks select_tasks "
select wa.action_id,
wa.pretty_name as name,
@@ -88,5 +88,5 @@
" {
set edit_url [export_vars -base "task-edit" { action_id }]
set view_url [export_vars -base "task-edit" { action_id }]
- set delete_url [export_vars -base "task-delete" { action_id }]
+ set delete_url [export_vars -base "task-delete" { action_id return_url }]
}
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 -N -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-create.sql 27 Oct 2003 12:41:24 -0000 1.2
+++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-create.sql 6 Nov 2003 15:35:46 -0000 1.3
@@ -3,80 +3,88 @@
-- @cvs-id $Id$
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),
+ workflow_id integer constraint sim_workflows_object_map_fk
+ references workflows(workflow_id)
+ on delete cascade,
+ object_id integer constraint sim_workflows_object_map_2_fk
+ references acs_objects(object_id)
+ on delete cascade,
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
- references cr_items
+ role_id integer constraint sim_roles_ri_fk
+ references workflow_roles(role_id)
+ on delete cascade
+ constraint sim_roles_pk
+ primary key,
+ character_id integer constraint sim_roles_character_fk
+ references cr_items
+ on delete cascade
);
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
+ task_id integer constraint sim_tasks_fk
+ references workflow_actions
+ on delete cascade
+ constraint sim_tasks_pk
+ primary key,
+ recipient integer constraint sim_tasks_recipient_fk
+ references sim_roles
+ on delete cascade
);
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,
+ simulation_id integer constraint sim_simulations_fk
+ references workflows
+ on delete cascade
+ 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,
+ 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
- );
-
+ '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
+ simulation_id integer constraint sim_party_sim_map_sim_fk
+ references sim_simulations
+ on delete cascade,
+ party_id integer constraint sim_party_sim_map_party_fk
+ references parties
+ on delete cascade,
+ 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/simulation-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/simulation-procs.tcl,v
diff -u -N -r1.6 -r1.7
--- openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 3 Nov 2003 14:13:43 -0000 1.6
+++ openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 6 Nov 2003 15:35:47 -0000 1.7
@@ -10,6 +10,8 @@
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::object_type::get_options {
} {
@@ -42,6 +44,8 @@
{-always_enabled_p f}
{-initial_action_p f}
{-recipient_role:required {}}
+ {-description {}}
+ {-description_mime_type {}}
} {
Edit an action. Mostly a wrapper for fsm, plus some simulation-specific stuff.
} {
@@ -58,21 +62,20 @@
set workflow_id [workflow::action::get_workflow_id -action_id $action_id]
- set assigned_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $assigned_role ]
- set recipient_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $recipient_role ]
-
db_transaction {
db_dml edit_workflow_action {
update workflow_actions
set short_name = :short_name,
pretty_name = :pretty_name,
- assigned_role = :assigned_role_id
+ assigned_role = :assigned_role,
+ description = :description,
+ description_mime_type = :description_mime_type
where action_id = :action_id
}
db_dml edit_sim_role {
update sim_tasks
- set recipient = :recipient_role_id
+ set recipient = :recipient_role
where task_id = :action_id
}
}
@@ -86,28 +89,18 @@
} {
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
+ }]
- with_catch errmsg {
+ if { ! $exists_p } {
db_dml add_object_to_workflow_insert {
insert into sim_workflow_object_map
values (:template_id, :object_id)
}
- } {
- # can only be 0 or 1 due to table constraints
- 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 } {
- # the record already exists. Return normally
- } {
- # the record didn't exist, so pass on the error
- global errorInfo
- error $errmsg $errorInfo
- }
}
}
@@ -129,3 +122,96 @@
template_tag relation { params } {
publish::process_tag relation $params
}
+
+################################
+#
+# simulation::character namespace
+#
+################################
+
+ad_proc -public simulation::character::get {
+ {-character_id:required}
+ {-array:required}
+} {
+ Get basic information about a character. Gets the following attributes: uri, title.
+
+ @param array The name of an array into which you want the information put.
+
+ @author Peter Marklund
+} {
+ upvar $array row
+
+ db_1row select_character_info {} -column_array row
+}
+
+ad_proc -public simulation::character::get_element {
+ {-character_id:required}
+ {-element:required}
+} {
+ Get a particular attribute from a character object.
+
+ @param element Name of the attribute you want to retrieve
+
+ @see simulation::character::get
+
+ @author Peter Marklund
+} {
+ get -character_id $character_id -array character
+
+ return $character($element)
+}
+
+################################
+#
+# simulation::role namespace
+#
+################################
+
+ad_proc -public simulation::role::new {
+ {-template_id:required}
+ {-character_id:required}
+ {-role_short_name ""}
+ {-role_pretty_name ""}
+} {
+ Create a new simulation role for a given simulation template
+ and character. Will map the character to the template if this
+ is not already done.
+
+ @author Peter Marklund
+} {
+ # Set default values for names
+ if { [empty_string_p $role_short_name] || [empty_string_p $role_pretty_name] } {
+ set character_name [simulation::character::get_element \
+ -character_id $character_id \
+ -element title]
+ }
+ if { [empty_string_p $role_short_name] } {
+ set role_short_name $character_name
+ }
+ if { [empty_string_p $role_pretty_name] } {
+ set role_pretty_name $character_name
+ }
+
+ db_transaction {
+ simulation::template::associate_object \
+ -template_id $template_id \
+ -object_id $character_id
+
+ # create the role
+ set role_id [workflow::role::new \
+ -workflow_id $template_id \
+ -short_name $role_short_name \
+ -pretty_name $role_pretty_name]
+ # and then add extra data for simulation
+ db_dml set_role_character {
+ insert into sim_roles
+ values (:role_id, :character_id)
+ }
+ }
+}
+
+ad_proc -public simulation::role::delete {
+ {-role_id:required}
+} {
+ workflow::role::delete -role_id $role_id
+}
Index: openacs-4/contrib/packages/simulation/tcl/simulation-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/simulation-procs.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/tcl/simulation-procs.xql 6 Nov 2003 15:35:47 -0000 1.1
@@ -0,0 +1,16 @@
+
+Associated Sim Objects
-Roles
-Tasks
Add Sim -Objects to this Workflow Index: openacs-4/contrib/packages/simulation/www/sim-template-objects.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-objects.tcl,v diff -u -N --- openacs-4/contrib/packages/simulation/www/sim-template-objects.tcl 31 Oct 2003 11:08:38 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,83 +0,0 @@ -# an includelet - -############################################################## -# -# sim_objects -# -# A list of all objects associated with the Simulation Template -# -############################################################## - -# maybe replace this chunk of copied text with an includable template -# which passes in a filter for the workflow_id? - - -#------------------------------------------------------------- -# sim_objects list -#------------------------------------------------------------- - -template::list::create \ - -name sim_objects \ - -multirow sim_objects \ - -no_data "No Sim Objects are associated with this Simulation Template" \ - -elements { - edit { - sub_class narrow - link_url_col edit_url - display_template { - - } - } - 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 - } - } - -db_multirow -extend { edit_url view_url delete_url } sim_objects select_sim_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, - sim_workflow_object_map swom - 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 - and swom.workflow_id = :workflow_id - and swom.object_id = i.item_id - - [template::list::orderby_clause -orderby -name "sim_objects"] -" { - set description [string_truncate -len 200 $description] - set edit_url [export_vars -base "object-edit" { item_id }] - set view_url [export_vars -base "object/$name"] - set delete_url [export_vars -base "object-delete" { item_id }] -} - -set sim_types { sim_character sim_prop sim_location } - -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/sim-template-roles.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-roles.adp,v diff -u -N --- openacs-4/contrib/packages/simulation/www/sim-template-roles.adp 27 Oct 2003 07:42:48 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,2 +0,0 @@ -
Add a role Index: openacs-4/contrib/packages/simulation/www/sim-template-roles.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-roles.tcl,v diff -u -N --- openacs-4/contrib/packages/simulation/www/sim-template-roles.tcl 27 Oct 2003 12:41:24 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,66 +0,0 @@ -# an includelet - -############################################################## -# -# roles -# -# A list of all roles associated with the Simulation Template -# -############################################################## - -# maybe replace this chunk of copied text with an includable template -# which passes in a filter for the workflow_id? - - -#------------------------------------------------------------- -# roles list -#------------------------------------------------------------- - -template::list::create \ - -name roles \ - -multirow roles \ - -no_data "No roles in this Simulation Template" \ - -elements { - edit { - sub_class narrow - link_url_col edit_url - display_template { - - } - } - name { - label "Name" - } - char_name { - label "Character" - link_url_col char_url - } - delete { - sub_class narrow - link_url_col delete_url - display_template { - - } - } - } -#------------------------------------------------------------- -# roles db_multirow -#------------------------------------------------------------- -# TODO: fix this so it returns rows when it should -db_multirow -extend { edit_url char_url delete_url } roles select_roles " - select wr.role_id, - wr.pretty_name as name, - wr.sort_order, - ci.name as char_name - from workflow_roles wr, - sim_roles sr, - cr_items ci - where wr.workflow_id = :workflow_id - and sr.role_id = wr.role_id - and ci.item_id = sr.character_id - [template::list::orderby_clause -orderby -name "roles"] -" { - set edit_url [export_vars -base "role-edit" { role_id }] - set char_url [export_vars -base "object/$char_name"] - set delete_url [export_vars -base "role-delete" { role_id }] -} Index: openacs-4/contrib/packages/simulation/www/sim-template-tasks.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-tasks.adp,v diff -u -N --- openacs-4/contrib/packages/simulation/www/sim-template-tasks.adp 29 Oct 2003 12:57:13 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,2 +0,0 @@ -
Add a task Index: openacs-4/contrib/packages/simulation/www/sim-template-tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/sim-template-tasks.tcl,v diff -u -N --- openacs-4/contrib/packages/simulation/www/sim-template-tasks.tcl 29 Oct 2003 12:57:13 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,78 +0,0 @@ -# an includelet - -# the includelet can be a full -if { ![exists_and_not_null usage_mode] } { - set usage_mode normal -} - -############################################################## -# -# tasks -# -# A list of all tasks associated with the Simulation Template -# -############################################################## - -#------------------------------------------------------------- -# tasks list -#------------------------------------------------------------- -# TODO: missing: discription, type -# how is type going to work? open question pending prototyping - -set hide_edit_p 1 - -template::list::create \ - -name tasks \ - -multirow tasks \ - -no_data "No tasks in this Simulation Template" \ - -elements { - edit { - hide_p $hide_edit_p - sub_class narrow - link_url_col edit_url - display_template { - - } - } - name { - label "Name" - } - assigned_name { - label "Assigned to" - } - recipient_name { - label "Recipient" - } - delete { - sub_class narrow - link_url_col delete_url - display_template { - - } - } - } - -#------------------------------------------------------------- -# tasks db_multirow -#------------------------------------------------------------- -# TODO: fix this so it returns rows when it should - -db_multirow -extend { edit_url delete_url } tasks select_tasks " - select wa.action_id, - wa.pretty_name as name, - (select pretty_name - from workflow_roles - where role_id = wa.assigned_role) as assigned_name, - (select pretty_name - from workflow_roles - where role_id = st.recipient) as recipient_name, - wa.sort_order - from workflow_actions wa, - sim_tasks st - where wa.workflow_id = :workflow_id - and st.task_id = wa.action_id - [template::list::orderby_clause -orderby -name "tasks"] -" { - set edit_url [export_vars -base "task-edit" { action_id }] - set delete_url [export_vars -base "task-delete" { action_id }] -} Index: openacs-4/contrib/packages/simulation/www/task-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/task-delete.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/task-delete.tcl 6 Nov 2003 15:35:47 -0000 1.1 @@ -0,0 +1,11 @@ +ad_page_contract { + Delete a task + +} { + action_id:integer + {return_url "sim-template-list"} +} + +workflow::action::fsm::delete -action_id $action_id + +ad_returnredirect $return_url \ No newline at end of file Index: openacs-4/contrib/packages/simulation/www/task-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/task-edit.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/task-edit.tcl 30 Oct 2003 11:15:55 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/task-edit.tcl 6 Nov 2003 15:35:47 -0000 1.3 @@ -45,7 +45,7 @@ set role_options [db_list_of_lists role_option_list " select wr.pretty_name, - wr.short_name + wr.role_id from workflow_roles wr where wr.workflow_id = :workflow_id "] @@ -96,6 +96,12 @@ workflow::get -workflow_id $workflow_id -array sim_template_array set page_title "Edit Task $name" set context [list [list "sim-template-list" "Sim Templates"] [list "sim-template-edit?workflow_id=$workflow_id" "$sim_template_array(pretty_name)"] $page_title] + set recipient_role [db_string select_recipient { + select recipient + from sim_tasks + where task_id = :action_id + }] + set assigned_role $task_array(assigned_role) } -new_request { @@ -113,22 +119,24 @@ # create the task + set assigned_role_name [workflow::role::get_element \ + -role_id $assigned_role \ + -element short_name] set action_id [workflow::action::fsm::new \ -workflow_id $workflow_id \ -short_name $name \ -pretty_name $name \ - -assigned_role $assigned_role \ + -assigned_role $assigned_role_name \ -description $description_content \ -description_mime_type $description_mime_type] # TODO - put this stuff into simulation api and change previous call # and then add extra data for simulation # because workflow::action::fsm::new wants role.short_name instead of # role_id, we stay consistent for recipient_role - set recipient_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $recipient_role] db_dml set_role_recipient { insert into sim_tasks - values (:action_id, :recipient_role_id) + values (:action_id, :recipient_role) } } -edit_data { Index: openacs-4/packages/simulation/lib/sim-template-objects.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-objects.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/lib/sim-template-objects.adp 6 Nov 2003 15:35:46 -0000 1.1 @@ -0,0 +1,3 @@ +
Add Sim +Objects to this Workflow 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 -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/lib/sim-template-objects.tcl 6 Nov 2003 15:35:46 -0000 1.1 @@ -0,0 +1,83 @@ +# an includelet + +############################################################## +# +# sim_objects +# +# A list of all objects associated with the Simulation Template +# +############################################################## + +# maybe replace this chunk of copied text with an includable template +# which passes in a filter for the workflow_id? + + +#------------------------------------------------------------- +# sim_objects list +#------------------------------------------------------------- + +template::list::create \ + -name sim_objects \ + -multirow sim_objects \ + -no_data "No Sim Objects are associated with this Simulation Template" \ + -elements { + edit { + sub_class narrow + link_url_col edit_url + display_template { + + } + } + 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 + } + } + +db_multirow -extend { edit_url view_url delete_url } sim_objects select_sim_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, + sim_workflow_object_map swom + 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 + and swom.workflow_id = :workflow_id + and swom.object_id = i.item_id + + [template::list::orderby_clause -orderby -name "sim_objects"] +" { + set description [string_truncate -len 200 $description] + set edit_url [export_vars -base "object-edit" { item_id }] + set view_url [export_vars -base "object/$name"] + set delete_url [export_vars -base "object-delete" { item_id }] +} + +set sim_types { sim_character sim_prop sim_location } + +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/lib/sim-template-roles.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-roles.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/lib/sim-template-roles.adp 6 Nov 2003 15:35:46 -0000 1.1 @@ -0,0 +1,2 @@ +
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 -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/lib/sim-template-roles.tcl 6 Nov 2003 15:35:46 -0000 1.1
@@ -0,0 +1,68 @@
+# an includelet
+
+##############################################################
+#
+# roles
+#
+# A list of all roles associated with the Simulation Template
+#
+##############################################################
+
+# maybe replace this chunk of copied text with an includable template
+# which passes in a filter for the workflow_id?
+
+
+#-------------------------------------------------------------
+# roles list
+#-------------------------------------------------------------
+
+template::list::create \
+ -name roles \
+ -multirow roles \
+ -no_data "No roles in this Simulation Template" \
+ -elements {
+ edit {
+ sub_class narrow
+ link_url_col edit_url
+ display_template {
+
+ }
+ }
+ name {
+ label "Name"
+ }
+ char_name {
+ label "Character"
+ link_url_col char_url
+ }
+ delete {
+ sub_class narrow
+ link_url_col delete_url
+ display_template {
+
+ }
+ }
+ }
+#-------------------------------------------------------------
+# roles db_multirow
+#-------------------------------------------------------------
+set return_url "[ad_conn url]?[ad_conn query]"
+db_multirow -extend { edit_url char_url delete_url } roles select_roles "
+ select wr.role_id,
+ wr.pretty_name as name,
+ wr.sort_order,
+ cr.title as char_name
+ from workflow_roles wr,
+ sim_roles sr,
+ cr_items ci,
+ cr_revisions cr
+ where wr.workflow_id = :workflow_id
+ and sr.role_id = wr.role_id
+ and ci.item_id = sr.character_id
+ and cr.revision_id = ci.live_revision
+ [template::list::orderby_clause -orderby -name "roles"]
+" {
+ set edit_url [export_vars -base "role-edit" { role_id }]
+ set char_url [export_vars -base "object/$char_name"]
+ set delete_url [export_vars -base "role-delete" { role_id return_url }]
+}
Index: openacs-4/packages/simulation/lib/sim-template-tasks.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-tasks.tcl,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/simulation/lib/sim-template-tasks.tcl 30 Oct 2003 11:15:55 -0000 1.1
+++ openacs-4/packages/simulation/lib/sim-template-tasks.tcl 6 Nov 2003 15:35:46 -0000 1.2
@@ -69,7 +69,7 @@
# tasks db_multirow
#-------------------------------------------------------------
# TODO: fix this so it returns rows when it should
-
+set return_url "[ad_conn url]?[ad_conn query]"
db_multirow -extend { edit_url view_url delete_url } tasks select_tasks "
select wa.action_id,
wa.pretty_name as name,
@@ -88,5 +88,5 @@
" {
set edit_url [export_vars -base "task-edit" { action_id }]
set view_url [export_vars -base "task-edit" { action_id }]
- set delete_url [export_vars -base "task-delete" { action_id }]
+ set delete_url [export_vars -base "task-delete" { action_id return_url }]
}
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 -N -r1.2 -r1.3
--- openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql 27 Oct 2003 12:41:24 -0000 1.2
+++ openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql 6 Nov 2003 15:35:46 -0000 1.3
@@ -3,80 +3,88 @@
-- @cvs-id $Id$
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),
+ workflow_id integer constraint sim_workflows_object_map_fk
+ references workflows(workflow_id)
+ on delete cascade,
+ object_id integer constraint sim_workflows_object_map_2_fk
+ references acs_objects(object_id)
+ on delete cascade,
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
- references cr_items
+ role_id integer constraint sim_roles_ri_fk
+ references workflow_roles(role_id)
+ on delete cascade
+ constraint sim_roles_pk
+ primary key,
+ character_id integer constraint sim_roles_character_fk
+ references cr_items
+ on delete cascade
);
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
+ task_id integer constraint sim_tasks_fk
+ references workflow_actions
+ on delete cascade
+ constraint sim_tasks_pk
+ primary key,
+ recipient integer constraint sim_tasks_recipient_fk
+ references sim_roles
+ on delete cascade
);
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,
+ simulation_id integer constraint sim_simulations_fk
+ references workflows
+ on delete cascade
+ 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,
+ 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
- );
-
+ '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
+ simulation_id integer constraint sim_party_sim_map_sim_fk
+ references sim_simulations
+ on delete cascade,
+ party_id integer constraint sim_party_sim_map_party_fk
+ references parties
+ on delete cascade,
+ 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/simulation-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/simulation-procs.tcl,v
diff -u -N -r1.6 -r1.7
--- openacs-4/packages/simulation/tcl/simulation-procs.tcl 3 Nov 2003 14:13:43 -0000 1.6
+++ openacs-4/packages/simulation/tcl/simulation-procs.tcl 6 Nov 2003 15:35:47 -0000 1.7
@@ -10,6 +10,8 @@
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::object_type::get_options {
} {
@@ -42,6 +44,8 @@
{-always_enabled_p f}
{-initial_action_p f}
{-recipient_role:required {}}
+ {-description {}}
+ {-description_mime_type {}}
} {
Edit an action. Mostly a wrapper for fsm, plus some simulation-specific stuff.
} {
@@ -58,21 +62,20 @@
set workflow_id [workflow::action::get_workflow_id -action_id $action_id]
- set assigned_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $assigned_role ]
- set recipient_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $recipient_role ]
-
db_transaction {
db_dml edit_workflow_action {
update workflow_actions
set short_name = :short_name,
pretty_name = :pretty_name,
- assigned_role = :assigned_role_id
+ assigned_role = :assigned_role,
+ description = :description,
+ description_mime_type = :description_mime_type
where action_id = :action_id
}
db_dml edit_sim_role {
update sim_tasks
- set recipient = :recipient_role_id
+ set recipient = :recipient_role
where task_id = :action_id
}
}
@@ -86,28 +89,18 @@
} {
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
+ }]
- with_catch errmsg {
+ if { ! $exists_p } {
db_dml add_object_to_workflow_insert {
insert into sim_workflow_object_map
values (:template_id, :object_id)
}
- } {
- # can only be 0 or 1 due to table constraints
- 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 } {
- # the record already exists. Return normally
- } {
- # the record didn't exist, so pass on the error
- global errorInfo
- error $errmsg $errorInfo
- }
}
}
@@ -129,3 +122,96 @@
template_tag relation { params } {
publish::process_tag relation $params
}
+
+################################
+#
+# simulation::character namespace
+#
+################################
+
+ad_proc -public simulation::character::get {
+ {-character_id:required}
+ {-array:required}
+} {
+ Get basic information about a character. Gets the following attributes: uri, title.
+
+ @param array The name of an array into which you want the information put.
+
+ @author Peter Marklund
+} {
+ upvar $array row
+
+ db_1row select_character_info {} -column_array row
+}
+
+ad_proc -public simulation::character::get_element {
+ {-character_id:required}
+ {-element:required}
+} {
+ Get a particular attribute from a character object.
+
+ @param element Name of the attribute you want to retrieve
+
+ @see simulation::character::get
+
+ @author Peter Marklund
+} {
+ get -character_id $character_id -array character
+
+ return $character($element)
+}
+
+################################
+#
+# simulation::role namespace
+#
+################################
+
+ad_proc -public simulation::role::new {
+ {-template_id:required}
+ {-character_id:required}
+ {-role_short_name ""}
+ {-role_pretty_name ""}
+} {
+ Create a new simulation role for a given simulation template
+ and character. Will map the character to the template if this
+ is not already done.
+
+ @author Peter Marklund
+} {
+ # Set default values for names
+ if { [empty_string_p $role_short_name] || [empty_string_p $role_pretty_name] } {
+ set character_name [simulation::character::get_element \
+ -character_id $character_id \
+ -element title]
+ }
+ if { [empty_string_p $role_short_name] } {
+ set role_short_name $character_name
+ }
+ if { [empty_string_p $role_pretty_name] } {
+ set role_pretty_name $character_name
+ }
+
+ db_transaction {
+ simulation::template::associate_object \
+ -template_id $template_id \
+ -object_id $character_id
+
+ # create the role
+ set role_id [workflow::role::new \
+ -workflow_id $template_id \
+ -short_name $role_short_name \
+ -pretty_name $role_pretty_name]
+ # and then add extra data for simulation
+ db_dml set_role_character {
+ insert into sim_roles
+ values (:role_id, :character_id)
+ }
+ }
+}
+
+ad_proc -public simulation::role::delete {
+ {-role_id:required}
+} {
+ workflow::role::delete -role_id $role_id
+}
Index: openacs-4/packages/simulation/tcl/simulation-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/simulation-procs.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/simulation/tcl/simulation-procs.xql 6 Nov 2003 15:35:47 -0000 1.1
@@ -0,0 +1,16 @@
+
+Associated Sim Objects
-Roles
-Tasks
Add Sim -Objects to this Workflow Index: openacs-4/packages/simulation/www/sim-template-objects.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-objects.tcl,v diff -u -N --- openacs-4/packages/simulation/www/sim-template-objects.tcl 31 Oct 2003 11:08:38 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,83 +0,0 @@ -# an includelet - -############################################################## -# -# sim_objects -# -# A list of all objects associated with the Simulation Template -# -############################################################## - -# maybe replace this chunk of copied text with an includable template -# which passes in a filter for the workflow_id? - - -#------------------------------------------------------------- -# sim_objects list -#------------------------------------------------------------- - -template::list::create \ - -name sim_objects \ - -multirow sim_objects \ - -no_data "No Sim Objects are associated with this Simulation Template" \ - -elements { - edit { - sub_class narrow - link_url_col edit_url - display_template { - - } - } - 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 - } - } - -db_multirow -extend { edit_url view_url delete_url } sim_objects select_sim_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, - sim_workflow_object_map swom - 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 - and swom.workflow_id = :workflow_id - and swom.object_id = i.item_id - - [template::list::orderby_clause -orderby -name "sim_objects"] -" { - set description [string_truncate -len 200 $description] - set edit_url [export_vars -base "object-edit" { item_id }] - set view_url [export_vars -base "object/$name"] - set delete_url [export_vars -base "object-delete" { item_id }] -} - -set sim_types { sim_character sim_prop sim_location } - -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/sim-template-roles.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-roles.adp,v diff -u -N --- openacs-4/packages/simulation/www/sim-template-roles.adp 27 Oct 2003 07:42:48 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,2 +0,0 @@ -
Add a role Index: openacs-4/packages/simulation/www/sim-template-roles.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-roles.tcl,v diff -u -N --- openacs-4/packages/simulation/www/sim-template-roles.tcl 27 Oct 2003 12:41:24 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,66 +0,0 @@ -# an includelet - -############################################################## -# -# roles -# -# A list of all roles associated with the Simulation Template -# -############################################################## - -# maybe replace this chunk of copied text with an includable template -# which passes in a filter for the workflow_id? - - -#------------------------------------------------------------- -# roles list -#------------------------------------------------------------- - -template::list::create \ - -name roles \ - -multirow roles \ - -no_data "No roles in this Simulation Template" \ - -elements { - edit { - sub_class narrow - link_url_col edit_url - display_template { - - } - } - name { - label "Name" - } - char_name { - label "Character" - link_url_col char_url - } - delete { - sub_class narrow - link_url_col delete_url - display_template { - - } - } - } -#------------------------------------------------------------- -# roles db_multirow -#------------------------------------------------------------- -# TODO: fix this so it returns rows when it should -db_multirow -extend { edit_url char_url delete_url } roles select_roles " - select wr.role_id, - wr.pretty_name as name, - wr.sort_order, - ci.name as char_name - from workflow_roles wr, - sim_roles sr, - cr_items ci - where wr.workflow_id = :workflow_id - and sr.role_id = wr.role_id - and ci.item_id = sr.character_id - [template::list::orderby_clause -orderby -name "roles"] -" { - set edit_url [export_vars -base "role-edit" { role_id }] - set char_url [export_vars -base "object/$char_name"] - set delete_url [export_vars -base "role-delete" { role_id }] -} Index: openacs-4/packages/simulation/www/sim-template-tasks.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-tasks.adp,v diff -u -N --- openacs-4/packages/simulation/www/sim-template-tasks.adp 29 Oct 2003 12:57:13 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,2 +0,0 @@ -
Add a task Index: openacs-4/packages/simulation/www/sim-template-tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/sim-template-tasks.tcl,v diff -u -N --- openacs-4/packages/simulation/www/sim-template-tasks.tcl 29 Oct 2003 12:57:13 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,78 +0,0 @@ -# an includelet - -# the includelet can be a full -if { ![exists_and_not_null usage_mode] } { - set usage_mode normal -} - -############################################################## -# -# tasks -# -# A list of all tasks associated with the Simulation Template -# -############################################################## - -#------------------------------------------------------------- -# tasks list -#------------------------------------------------------------- -# TODO: missing: discription, type -# how is type going to work? open question pending prototyping - -set hide_edit_p 1 - -template::list::create \ - -name tasks \ - -multirow tasks \ - -no_data "No tasks in this Simulation Template" \ - -elements { - edit { - hide_p $hide_edit_p - sub_class narrow - link_url_col edit_url - display_template { - - } - } - name { - label "Name" - } - assigned_name { - label "Assigned to" - } - recipient_name { - label "Recipient" - } - delete { - sub_class narrow - link_url_col delete_url - display_template { - - } - } - } - -#------------------------------------------------------------- -# tasks db_multirow -#------------------------------------------------------------- -# TODO: fix this so it returns rows when it should - -db_multirow -extend { edit_url delete_url } tasks select_tasks " - select wa.action_id, - wa.pretty_name as name, - (select pretty_name - from workflow_roles - where role_id = wa.assigned_role) as assigned_name, - (select pretty_name - from workflow_roles - where role_id = st.recipient) as recipient_name, - wa.sort_order - from workflow_actions wa, - sim_tasks st - where wa.workflow_id = :workflow_id - and st.task_id = wa.action_id - [template::list::orderby_clause -orderby -name "tasks"] -" { - set edit_url [export_vars -base "task-edit" { action_id }] - set delete_url [export_vars -base "task-delete" { action_id }] -} Index: openacs-4/packages/simulation/www/task-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/task-delete.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/task-delete.tcl 6 Nov 2003 15:35:47 -0000 1.1 @@ -0,0 +1,11 @@ +ad_page_contract { + Delete a task + +} { + action_id:integer + {return_url "sim-template-list"} +} + +workflow::action::fsm::delete -action_id $action_id + +ad_returnredirect $return_url \ No newline at end of file Index: openacs-4/packages/simulation/www/task-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/Attic/task-edit.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/simulation/www/task-edit.tcl 30 Oct 2003 11:15:55 -0000 1.2 +++ openacs-4/packages/simulation/www/task-edit.tcl 6 Nov 2003 15:35:47 -0000 1.3 @@ -45,7 +45,7 @@ set role_options [db_list_of_lists role_option_list " select wr.pretty_name, - wr.short_name + wr.role_id from workflow_roles wr where wr.workflow_id = :workflow_id "] @@ -96,6 +96,12 @@ workflow::get -workflow_id $workflow_id -array sim_template_array set page_title "Edit Task $name" set context [list [list "sim-template-list" "Sim Templates"] [list "sim-template-edit?workflow_id=$workflow_id" "$sim_template_array(pretty_name)"] $page_title] + set recipient_role [db_string select_recipient { + select recipient + from sim_tasks + where task_id = :action_id + }] + set assigned_role $task_array(assigned_role) } -new_request { @@ -113,22 +119,24 @@ # create the task + set assigned_role_name [workflow::role::get_element \ + -role_id $assigned_role \ + -element short_name] set action_id [workflow::action::fsm::new \ -workflow_id $workflow_id \ -short_name $name \ -pretty_name $name \ - -assigned_role $assigned_role \ + -assigned_role $assigned_role_name \ -description $description_content \ -description_mime_type $description_mime_type] # TODO - put this stuff into simulation api and change previous call # and then add extra data for simulation # because workflow::action::fsm::new wants role.short_name instead of # role_id, we stay consistent for recipient_role - set recipient_role_id [workflow::role::get_id -workflow_id $workflow_id -short_name $recipient_role] db_dml set_role_recipient { insert into sim_tasks - values (:action_id, :recipient_role_id) + values (:action_id, :recipient_role) } } -edit_data {