NAME

Workflow::Config - Parse configuration files for the workflow components

SYNOPSIS

# Reference multiple files

my @config = Workflow::Config->parse(
                   'action', 'workflow_action.xml', 'other_actions.xml' );

# Read in one of the file contents from somewhere else
my $xml_contents = read_contents_from_db( 'other_actions.xml' );
my @config = Workflow::Config->parse(
                   'action', 'workflow_action.xml', \$xml_contents );

DESCRIPTION

Read in configurations for the various workflow components. Currently the class understands XML (preferred) and serialized Perl data structures as valid configuration file formats. (I tried to use INI files but there was too much deeply nested information. Sorry.)

CLASS METHODS

parse( $config_type, @items )

Parse each item in @items to a hash reference based on the configuration type $config_type which must pass the is_valid_config_type() test. An 'item' is either a filename or a scalar reference with the contents of a file. (You can mix and match as seen in the SYNOPSIS.)

If you are using filenames each must end with 'perl' or 'xml' and will be parsed appropriately. If you are using references with the content we do a best-guess to figure out what type of content you are passing us.

Throws an exception if you pass one or more invalid configuration types, if I do not know what configuration parser to use (file ends in something other than 'xml' or 'perl'), or if any file cannot be read or parsed because of permissions, malformed XML, incorrect Perl data structure, etc. It does not do a validation check (e.g., to ensure that every 'action' within a workflow state has a 'resulting_state' key).

Returns: list of hash references for each file in @files

is_valid_config_type( $config_type )

Returns true if $config_type is a valid configuration type, false if not. Valid configuration types are: 'action', 'condition', 'validator', 'workflow'.

get_valid_config_types()

Returns list of strings representing the valid configuration types.

CONFIGURATION INFORMATION

workflow

workflow
   type        $
   description $
   persister   $
   state       \@
       name          $
       description   $
       action        \@
           name            $
           resulting_state $
           condition       \@
               name $
  • the 'type' and 'description' keys are at the top level

  • the 'extra_data' key holds an array of zero or more hashrefs with 'table', 'field', 'class' and 'context' keys

  • 'state' key holds array of one or more 'state' declarations; one of them must be 'INITIAL'

  • each 'state' declaration holds 'description' and 'name' keys and multiple 'action' declarations

  • each 'action' declaration holds 'name' and 'resulting_state' keys and may hold a 'condition' key with one or more named conditions

condition

conditions:

    condition \@
       name  $
       class $
       param \@
           name  $
           value $
  • array of one or more hashrefs with 'name' and 'class' keys

validator

validators:

    validator \@
       name  $
       class $
       param \@
           name  $
           value $
  • array of one or more hashrefs with 'name' and 'class' keys, plus possibly one or more 'param' hashrefs each with 'name' and 'value' keys

action

actions:

   action \@
      name  $
      field \@
         name         $
         is_required  yes|no
         type         $
         source_list  \@ of $
         source_class $
         param        \@
             name  $
             value $
      validator \@
          name $
          arg  \@
              value $
  • array of one or more action hashrefs with 'name', 'class' and 'description' keys

  • each 'action' may have zero or more values used to fill it; each value has a 'name', 'description' and 'necessity' ('required' or 'optional')

  • each 'action' may have any number of 'param' hashrefs, each with 'name' and 'value'

  • each 'action' may have any number of 'validator' hashrefs, each with a 'name' key and array of 'arg' declarations

persister

persister:

  extra_table   $
  extra_field   $
  extra_class   $
  extra_context $

COPYRIGHT

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.

AUTHORS

Chris Winters <chris@cwinters.com>