jonasbn > Workflow > Workflow::Persister::DBI::ExtraData

Download:
Workflow-1.41.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

New  4
Open  2
View/Report Bugs
Module Version: 1.05   Source  

NAME ^

Workflow::Persister::DBI::ExtraData - Fetch extra data with each workflow and put it into the context

VERSION ^

This documentation describes version 1.05 of this package

SYNOPSIS ^

 <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"/>

DESCRIPTION ^

Overview

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.

Examples

 # 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' );

Configuration

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 (optional)

Key under which to save the data from extra_data_field in the workflow context.

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.

METHODS

init ( \%params )

Initializes persister for extra workflow data.

Throws Workflow::Exception if initialization is not successful.

fetch_extra_workflow_data ( $wf )

Fetches extra data from database and feeds this to context of given workflow.

Takes a single parameter, a workflow object to which extra data are feed if retrieved successfully.

Throws Workflow::Exception if retrieval is not successful.

COPYRIGHT ^

Copyright (c) 2003-2007 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.

AUTHORS ^

Jonas B. Nielsen (jonasbn) <jonasbn@cpan.org> is the current maintainer.

Chris Winters <chris@cwinters.com>, original author.

syntax highlighting: