Forum OpenACS Development: More complex workflows
Does anybody have a more complex workflow defined, something with all
those nice automated callbacks (e.g. timed, deadlined, etc.)? I've
tried to build even a simple sample one and never seemed to manage to
get anywhere...
To elaborate a bit -- I'd like to see a workflow that sets either of the following:
enable_callback, enable_custom_arg, fire_callback, fire_custom_arg, time_callback, time_custom_arg, deadline_callback, deadline_custom_arg, deadline_attribute_name, hold_timeout_callback, hold_timeout_custom_arg, notification_callback, notification_custom_arg, unassigned_callback, unassigned_custom_argthx
To elaborate even further, suppose the following workflow is defined (sorry for a long dump):
begin;
create table test_wf_cases (
case_id integer primary key
references wf_cases on delete cascade
);
/*
* Declare the object type
*/
create function inline_0 () returns integer as '
begin
PERFORM workflow__create_workflow (
''test_wf'',
''Test'',
''Test'',
''A test workflow.'',
''test_wf_cases'',
''case_id''
);
return null;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
/*****
* Places
*****/
select workflow__add_place(
'test_wf',
'start',
'Ready to Write',
null
);
select workflow__add_place(
'test_wf',
'before_review',
'Ready to Review',
null
);
select workflow__add_place(
'test_wf',
'before_publish',
'Ready to Publish',
null
);
select workflow__add_place(
'test_wf',
'end',
'Process finished',
null
);
/*****
* Roles
*****/
select workflow__add_role (
'test_wf',
'write',
'Write',
1
);
select workflow__add_role (
'test_wf',
'review',
'Review',
2
);
select workflow__add_role (
'test_wf',
'publish',
'Publish',
3
);
/*****
* Transitions
*****/
select workflow__add_transition (
'test_wf',
'write',
'Write',
'write',
1,
'user'
);
select workflow__add_transition (
'test_wf',
'review',
'Review',
'review',
2,
'user'
);
select workflow__add_transition (
'test_wf',
'publish',
'Publish',
'publish',
3,
'user'
);
/*****
* Arcs
*****/
select workflow__add_arc (
'test_wf',
'publish',
'before_publish',
'in',
'',
'',
''
);
select workflow__add_arc (
'test_wf',
'publish',
'end',
'out',
'',
'',
''
);
select workflow__add_arc (
'test_wf',
'review',
'before_review',
'in',
'',
'',
''
);
select workflow__add_arc (
'test_wf',
'review',
'start',
'out',
'#',
'',
'Not Good'
);
select workflow__add_arc (
'test_wf',
'review',
'before_publish',
'out',
'wf_callback__guard_attribute_tr',
'review_is_it_good_p',
'Good'
);
select workflow__add_arc (
'test_wf',
'write',
'start',
'in',
'',
'',
''
);
select workflow__add_arc (
'test_wf',
'write',
'before_review',
'out',
'',
'',
''
);
/*****
* Attributes
*****/
select workflow__create_attribute(
'test_wf',
'review_is_it_good_p',
'boolean',
'Is it good',
null,
null,
null,
't',
1,
1,
null,
'generic'
);
select workflow__add_trans_attribute_map(
'test_wf',
'review',
'review_is_it_good_p',
1
);
/*****
* Transition-role-assignment-map
*****/
/*
* Context/Transition info
* (for context = default)
*/
insert into wf_context_transition_info
(context_key,
workflow_key,
transition_key,
estimated_minutes,
instructions,
enable_callback,
enable_custom_arg,
fire_callback,
fire_custom_arg,
time_callback,
time_custom_arg,
deadline_callback,
deadline_custom_arg,
deadline_attribute_name,
hold_timeout_callback,
hold_timeout_custom_arg,
notification_callback,
notification_custom_arg,
unassigned_callback,
unassigned_custom_arg)
values
('default',
'test_wf',
'write',
15,
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'');
insert into wf_context_transition_info
(context_key,
workflow_key,
transition_key,
estimated_minutes,
instructions,
enable_callback,
enable_custom_arg,
fire_callback,
fire_custom_arg,
time_callback,
time_custom_arg,
deadline_callback,
deadline_custom_arg,
deadline_attribute_name,
hold_timeout_callback,
hold_timeout_custom_arg,
notification_callback,
notification_custom_arg,
unassigned_callback,
unassigned_custom_arg)
values
('default',
'test_wf',
'review',
5,
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'');
insert into wf_context_transition_info
(context_key,
workflow_key,
transition_key,
estimated_minutes,
instructions,
enable_callback,
enable_custom_arg,
fire_callback,
fire_custom_arg,
time_callback,
time_custom_arg,
deadline_callback,
deadline_custom_arg,
deadline_attribute_name,
hold_timeout_callback,
hold_timeout_custom_arg,
notification_callback,
notification_custom_arg,
unassigned_callback,
unassigned_custom_arg)
values
('default',
'test_wf',
'publish',
1,
'',
'',
'',
'',
'',
'wf_callback__time_sysdate_plus_x', -- time_callback
'0.005',
'',
'',
'',
'',
'',
'',
'',
'',
'');
/*
* Context/Role info
* (for context = default)
*/
/*
* Context Task Panels
* (for context = default)
*/
commit;
I assume that 24*60*0.005=7min after publish transition is reached it should automatically finish. Am I missing something? Should I, instead, have pl/pgsql proc that uses wf_callback__time_sysdate_plus_x to get the time that it is due to fire and then modify the case state?
You could use a hold_timeout and supply use the wf_callback.time_sysdate_plus_x funxtion to specify the timing offset. This will cancel the users task and allow someone else to be assigned to it.
I've used workflows a good bit, and I found there are a lot of things you can do by writing your own callbacks. You could for example use the time callback and write a function which will take a time offset. If the sysdate minus the offset = the creation date of the task, then you can manually finish it. Next time around the fire-transitions will automatically finish the case.