Index: openacs-4/packages/workflow/tcl/case-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/tcl/case-procs-postgresql.xql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/workflow/tcl/case-procs-postgresql.xql 9 Jan 2004 15:47:53 -0000 1.6 +++ openacs-4/packages/workflow/tcl/case-procs-postgresql.xql 23 Jan 2004 11:02:27 -0000 1.7 @@ -5,28 +5,48 @@ select c.case_id, - c.top_case_id, c.workflow_id, - top.object_id, + c.object_id, s.state_id, s.short_name as state_short_name, s.pretty_name as pretty_state, - s.hide_fields as state_hide_fields, - parent.parent_enabled_action_id, - (select case_id - from workflow_case_enabled_actions - where enabled_action_id = parent.parent_enabled_action_id) as parent_case_id + s.hide_fields as state_hide_fields from workflow_cases c, - workflow_cases top, workflow_case_fsm cfsm left outer join - workflow_fsm_states s on (s.state_id = cfsm.current_state) left outer join - workflow_case_parent_action parent using (case_id) + workflow_fsm_states s on (s.state_id = cfsm.current_state) where c.case_id = :case_id and cfsm.case_id = c.case_id - and top.case_id = c.top_case_id + and cfsm.parent_enabled_action_id = :parent_enabled_action_id + + + select c.case_id, + c.workflow_id, + c.object_id, + s.state_id, + s.short_name as state_short_name, + s.pretty_name as pretty_state, + s.hide_fields as state_hide_fields + from workflow_cases c, + workflow_case_fsm cfsm left outer join + workflow_fsm_states s on (s.state_id = cfsm.current_state) + where c.case_id = :case_id + and cfsm.case_id = c.case_id + and cfsm.parent_enabled_action_id is null + + + + + + select cfsm.parent_enabled_action_id, + cfsm.current_state as current_state_id + from workflow_case_fsm cfsm + where cfsm.case_id = :case_id + + + select m.party_id, @@ -69,35 +89,12 @@ - - - select a.action_id - from workflow_cases c, - workflow_actions a - where c.case_id = :case_id - and a.workflow_id = c.workflow_id - and not exists (select 1 - from workflow_initial_action wia - where wia.workflow_id = c.workflow_id - and wia.action_id = a.action_id) - and (a.always_enabled_p = 't' - or exists (select 1 - from workflow_case_fsm cfsm, - workflow_fsm_action_en_in_st waeis - where cfsm.case_id = c.case_id - and waeis.state_id = cfsm.current_state - and waeis.action_id = a.action_id)) - order by a.sort_order - - - - select case_id, - action_id + select enabled_action_id from workflow_case_enabled_actions where execution_time <= current_timestamp - and enabled_state = 'enabled' + and completed_p = 'f' @@ -131,25 +128,35 @@ - - - update workflow_case_enabled_actions - set enabled_state = 'completed', - executed_date = current_timestamp - where case_id = :case_id - and action_id = :action_id - and enabled_state = 'enabled' - - - insert into workflow_case_enabled_actions - (enabled_action_id, case_id, action_id, enabled_state, execution_time) - select :enabled_action_id, :case_id, a.action_id, 'enabled', current_timestamp + a.timeout + (enabled_action_id, + case_id, + action_id, + parent_enabled_action_id, + assigned_p, + execution_time) + select :enabled_action_id, + :case_id, + :action_id, + :parent_enabled_action_id, + :db_assigned_p, + current_timestamp + a.timeout from workflow_actions a where a.action_id = :action_id + + + select 1 + from workflow_case_enabled_actions ean + where ean.action_id = :action_id + and ean.case_id = :case_id + and completed_p = 'f' + limit 1 + + +