Workflow::Persister::DBI::ExtraData - Fetch extra data with each workflow and put it into the context
<persister name="MyPersister" class="Workflow::Persister::DBI::ExtraData" dsn="DBI:mysql:database=workflows" user="wf" password="mypass" extra_table="workflow_ticket" extra_data_field="ticket_id" extra_context_key="ticket_id"/>
Simple subclass of Workflow::Persister::DBI to allow you to declare an extra table and data field(s) from which to fetch data whenever you fetch a workflow. There is a simple restriction: the table must have a field 'workflow_id' of the same datatype as the 'workflow_id' field in the 'workflow' table.
# Specify a single field 'ticket_id' from the table 'workflow_ticket' # and store it in the context using the same key: <persister ... extra_table="workflow_ticket" extra_data_field="ticket_id" ... # How you would use this: my $wf = FACTORY->fetch_workflow( 'Ticket', 55 ); print "Workflow is associated with ticket: ", $wf->context->param( 'ticket_id' ); # Specify a single field 'ticket_id' from the table 'workflow_ticket' # and store it in the context using a different key <persister ... extra_table="workflow_ticket" extra_data_field="ticket_id" extra_context_key="THE_TICKET_ID" ... # How you would use this: my $wf = FACTORY->fetch_workflow( 'Ticket', 55 ); print "Workflow is associated with ticket: ", $wf->context->param( 'THE_TICKET_ID' ); # Specify multiple fields ('ticket_id', 'last_viewer', # 'last_view_date') to pull from the 'workflow_ticket' table: <persister ... extra_table="workflow_ticket" extra_data_field="ticket_id,last_viewer,last_view_date" ... # How you would use this: my $wf = FACTORY->fetch_workflow( 'Ticket', 55 ); print "Workflow is associated with ticket: ", $wf->context->param( 'ticket_id' ), " ", "which was last viewed by ", $wf->context->param( 'last_viewer' ), " on ", $wf->context->param( 'last_view_date' );
extra_table (required)
Table where the extra data are kept.
extra_data_field (required)
Can be a single field or a comma-separated list of fields, all in the same table. If a single field specified you have the option of declaring a different extra_context_key under which the value should be stored in the workflow context. Otherwise the values are stored by the field names in the workflow context.
extra_context_key
extra_context_key (optional)
Key under which to save the data from extra_data_field in the workflow context.
extra_data_field
Note: this is ignored when you specify multiple fields in extra_data_field; we just use the fieldnames for the context keys in that case. And if you specify a single data field and do not specify a context key we also use the data field name.
#=head3 init
#=head3 fetch_extra_workflow_data
Copyright (c) 2003-2004 Chris Winters. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Chris Winters <chris@cwinters.com>
To install Workflow, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Workflow
CPAN shell
perl -MCPAN -e shell install Workflow
For more information on module installation, please visit the detailed CPAN module installation guide.