Forum OpenACS Development: workflow actions

Collapse
Posted by Iuri Sampaio on
Hi there,

something in workflow package is confusing me.
I don't know if my thoughts are correct, but they follow a very logical and common sense to me.

I believed action_id and workflow_id should match in order to have the properly workflow action enabled as per user choices.

The scenario is: i want to get the short_name of the workflow_action enabled by the user in the bug interface page. I searched for an API already created for that specific purpose, but i didn't found. I created one.

From start,
i am at page bug.tcl and when the user clicks on "Edit button" for example.
it must show at logs the $workflow_id and $action_id set at that moment.

then, i created the code somewhere in the page bug.tcl

###
ns_log Notice "actid: $action_id | $workflow_id"
set action_short_name [workflow::action::get_short_name -action_id $enabled_action_id -workflow_id $workflow_id]
###

and the respective API i wrote in the file /packages/workflow/tcl/actions-procs.tcl

###
ad_proc -public workflow::action::get_short_name {
{-action_id:required}
{-workflow_id:required}
} {
API to get the name of an action by the action_id parameter
@author iuri sampaio mailto:iuri.sampaio@gmail.com
@creation-date 2009-07-28
} {

ns_log Notice "Running workflow::action::get_pretty_name"
ns_log Notice "actid: $action_id | $workflow_id"

return [db_list select_name { SELECT wa.short_name FROM workflow_actions wa WHERE action_id = :action_id AND workflow_id = :workflow_id}]
}
###

as expected i have the results of action_id and workflow_id at logs:

###
[28/Jul/2009:04:48:07][2540.3034213296][-conn:openacs::1] Notice: actions: enabled_action_id: -5-
[28/Jul/2009:04:48:07][2540.3034213296][-conn:openacs::1] Notice: Running workflow::action::get_pretty_name
[28/Jul/2009:04:48:07][2540.3034213296][-conn:openacs::1] Notice: actid: 5 | 1113
###

Then i looked at the table workflow_actions in attempt to find a match of 5 and 1113 and be able to visualize how things are organized in the datamodel.

Table "public.workflow_actions"
Column | Type | Modifiers
-----------------------+-------------------------+-----------------------------------
action_id | integer | not null
workflow_id | integer | not null
sort_order | integer | not null
short_name | character varying(100) | not null
pretty_name | character varying(200) | not null
pretty_past_tense | character varying(200) |
description | text |
description_mime_type | character varying(200) |
edit_fields | character varying(4000) |
assigned_role | integer |
always_enabled_p | boolean | default false
timeout | interval |
parent_action_id | integer |
trigger_type | character varying(50) | default 'user'::character varying
Indexes:

openacs=# select action_id, workflow_id,short_name from workflow_actions;
action_id | workflow_id | short_name
-----------+-------------+------------
1 | 1079 | open
2 | 1079 | comment
3 | 1079 | edit
4 | 1079 | reassign
5 | 1079 | resolve
6 | 1079 | close
7 | 1079 | reopen
8 | 1096 | open
9 | 1096 | comment
10 | 1096 | edit
11 | 1096 | reassign
12 | 1096 | resolve
13 | 1096 | close
14 | 1096 | reopen
15 | 1113 | open
16 | 1113 | comment
17 | 1113 | edit
18 | 1113 | reassign
19 | 1113 | resolve
20 | 1113 | close
21 | 1113 | reopen
(21 rows)

I was expecting to find something as 5 | 113 | edit
However i only found 5 | 1079 | resolve

Wasn't it supposed to have such a match?

What is the purpose of the table workflow_actions then?