Re: [Perl-workflow-devel] How to get a workflow's possible states?
Brought to you by:
jonasbn
From: Phil R. <phi...@un...> - 2010-09-08 14:49:47
|
Thanks Alejandro - I hadn't thought of extending the persister, so that's very helpful - and fast. Cheers, Phil That's clever, thanks On 08/09/10 15:33, Alejandro Imass wrote: > On Wed, Sep 8, 2010 at 7:26 AM, Phil Robinson > <phi...@un...> wrote: > >> Hi all >> Does anyone know if there's a way to get a list of all the possible >> states a workflow could have? >> >> > As you suspected there is no method per-se to obtain a wf's states, > but you wouldn't have to craft your own parser either. Look into > Config.pm and you could probably get what you need from there. > > > >> My app. creates lots of workflows for 'jobs', and can display them in >> lists. I want to have a >> way where the user can select which ones they see based on their state. >> >> > Ok, this requirement makes more sense, and for this you don't need to > mess with the config. workflow.pm provides a way to extend the > persister with ExtraData. For example in p2ee we have a workflow inbox > screen where each user sees a list of workflows she has opened. Here > is how it works: > > <persisters> > <persister name="Inventory" > class="Workflow::Persister::DBI::ExtraData" > dsn="DBI:Pg:dbname=p2ee" > user="inventory" > password="inventory" > date_format="%Y-%m-%d %H:%M" > autocommit="1" > workflow_table="wf" > workflow_sequence="wf_workflow_id_seq" > history_table="wf_history" > history_sequence="wf_history_workflow_hist_id_seq" > extra_table="wf_p2ee" > extra_data_field="creator,citho,citho_since" > /> > </persisters> > > The extra table provides the tie between users and Worflows like so: > > CREATE TABLE wf_p2ee( > -- Attributes -- > workflow_id integer, > creator text, > citho text, > citho_since timestamp, > memo text, > state_data text, > PRIMARY KEY (workflow_id), > FOREIGN KEY (workflow_id) REFERENCES wf (workflow_id)); > > > So when users login the get presented a screen with each Workflow, the > state, "Currently In The Hands Of", since, etc. I use DBIx::Class of > course but I easily get this list with a View: > > CREATE VIEW wf_user AS > SELECT > wf.workflow_id AS id, > wf.type AS type, > wf_p2ee.memo AS memo, > wf.state AS state, > wf_p2ee.creator AS creator, > wf_p2ee.citho AS citho, > wf_p2ee.citho_since AS citho_since, > wf.last_update AS last_update > FROM > wf_p2ee JOIN wf ON (wf_p2ee.workflow_id = wf.workflow_id); > > > >> So I need a menu where the user can select for display (eg) INITIAL, >> ORDERED, PROCESSED, >> FINISHED, DESPATCHED. Of course, I could hardcode it but I'd really like >> to be able to >> change the workflow without having to change the code too. >> >> > No need. From the example above you could do something like: > > sub get_open_wfs { > my $self = shift; > my $c = $self->{c}; > my $type = $self->{type}; > my $userid = $c->stash->{userid}; > > my @wfs = $c->model('inventory::WfUser')->search( > { > -and => [ > type => { '!=', 'root'}, > state => { '!=', 'CLOSED' }, > -or => [ > creator => $userid, > citho => $userid > ], > ], > } > ); > > return \@wfs; > } > > >> The only thing I can think of is to create a test workflow, get the >> initial actions and then recursively >> run all the actions, gathering up all the states I pass though them, It >> would be a nightmare >> though as there are lots of conditions etc. >> >> > >> Come to think of it I could read and parse the xml workflow definition >> which would be simpler. >> >> > Yeah, for a list to filter the open workflows by state your oculd do > that, or tap into the config object. But IMHO you don't really need to > do any of that, because with the ideas above you could just use a > select distinct of the states of the actual open workflows, I mean why > show the user a filter on states the you have no workflows in those > states? > > > Best, > Alejandro Imass > > >> Any better ideas? TIA Cheers, Phil >> +++++++++++++++++++++++++++++++++++++ >> phi...@un... >> +++++++++++++++++++++++++++++++++++++ >> >> >> ------------------------------------------------------------------------------ >> This SF.net Dev2Dev email is sponsored by: >> >> Show off your parallel programming skills. >> Enter the Intel(R) Threading Challenge 2010. >> http://p.sf.net/sfu/intel-thread-sfd >> _______________________________________________ >> Perl-workflow-devel mailing list >> Per...@li... >> https://lists.sourceforge.net/lists/listinfo/perl-workflow-devel >> >> -- +++++++++++++++++++++++++++++++++++++ phi...@un... Tel: +44 (0)161 881 5225 +++++++++++++++++++++++++++++++++++++ |