1Workflow::Config(3)   User Contributed Perl Documentation  Workflow::Config(3)
2
3
4

NAME

6       Workflow::Config - Parse configuration files for the workflow
7       components
8

VERSION

10       This documentation describes version 1.12 of this package
11

SYNOPSIS

13        # Reference multiple files
14
15        my $parser = Workflow::Config->new( 'xml' );
16        my @config = $parser->parse(
17            'action', 'workflow_action.xml', 'other_actions.xml'
18        );
19
20        # Read in one of the file contents from somewhere else
21        my $xml_contents = read_contents_from_db( 'other_actions.xml' );
22        my @config = $parser->parse(
23            'action', 'workflow_action.xml', \$xml_contents
24        );
25       _
26        # Reference multiple files of mixed types
27
28        my @action_config = Workflow::Config->parse_all_files(
29            'action', 'my_actions.xml', 'your_actions.perl'
30        );
31

DESCRIPTION

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

CLASS METHODS

39       parse_all_files( $workflow_config_type, @files )
40
41       Runs through each file in @files and processes it according to the
42       valid
43

SUBCLASSING

45   Creating Your Own Parser
46       If you want to store your configuration in a different format you can
47       create your own parser. All you need to do is:
48
49       1.  subclass Workflow::Config
50
51       2.  implement the required methods (listed below)
52
53       3.  register your parser with Workflow::Config.
54
55       For instance, if you wanted to use YAML for configuration files you
56       would do something like:
57
58        # just a convention, you can use any namespace you want
59        package Workflow::Config::YAML;
60
61        use strict;
62
63        # Requirement 1: Subclass Workflow::Config
64        use base qw( Workflow::Config );
65
66        # Requirement 2: Implement required methods
67        sub parse { ... }
68
69       The third requirement is registration, which just tells
70       Workflow::Config which parser to use for a particular type. To do this
71       you have two options.
72
73       Registration option one
74
75       Register yourself in your own class, adding the following call anywhere
76       the end:
77
78        # Option 1: Register ourselves by name
79        Workflow::Config->register_factory_type( yaml => 'Workflow::Config::YAML' );
80
81       Now you just need to include the configuration class in your workflow
82       invocation script:
83
84        use strict;
85        use Workflow::Factory qw( FACTORY );
86        use Workflow::Config::YAML; # <-- brings in the registration
87
88       Registration option two
89
90       You can also just explicitly add the registration from your workflow
91       invocation script:
92
93        use strict;
94        use Workflow::Factory qw( FACTORY );
95        use Workflow::Config;
96
97        # Option 2: explicitly register your configuration parser
98        Workflow::Config->register_factory_type( yaml => 'Workflow::Config::YAML' );
99
100       Whichever one you choose you can now parse (in this example) YAML files
101       alongside the built-in parsers for XML and Perl files:
102
103        FACTORY->add_config_from_file(
104            workflow  => 'workflow.yaml',
105            action    => [ 'my_actions.yaml', 'other_actions.xml' ],
106            validator => 'validators.yaml',
107            condition => [ 'my_conditions.yaml', 'other_conditions.xml' ]
108            persister => 'persister.perl',
109        );
110
111   Inherited Methods
112       new( $parser_type )
113
114       Instantiates an object of the correct type -- see Class::Factory for
115       how this is implemented:
116
117        # Parser of type 'Workflow::Config::XML'
118        my $xml_parser  = Workflow::Config->new( 'xml' );
119
120        # Parser of type 'Workflow::Config::Perl
121        my $perl_parser = Workflow::Config->new( 'perl' );
122
123       is_valid_config_type( $config_type )
124
125       Returns true if $config_type is a valid configuration type, false if
126       not. Valid configuration types are: 'action', 'condition', 'validator',
127       'workflow'.
128
129       get_valid_config_types()
130
131       Returns list of strings representing the valid configuration types.
132
133       get_config_type_tag( $class, $type )
134
135       Returns string representing a valid configuration type, looking up the
136       type parameter in a lookuptable defined in Workflow::Config class.
137
138   Required Object Methods
139       parse( $workflow_config_type, @items )
140
141       Parse each item in @items to a hash reference based on the
142       configuration type $config_type which must pass the
143       "is_valid_config_type()" test. An 'item' is either a filename or a
144       scalar reference with the contents of a file. (You can mix and match as
145       seen in the SYNOPSIS.)
146
147       Should throw an exception if:
148
149       ·   You pass an invalid workflow configuration type. Valid workflow
150           configuration types are registered in Workflow::Config and are
151           available from "get_valid_config_types()"; you can check whether a
152           particular type is valid with "is_valid_config_type()". (See above
153           for descriptions.)
154
155       ·   You pass in a file that cannot be read or parsed because of
156           permissions, malformed XML, incorrect Perl data structure, etc. It
157           does not do a validation check (e.g., to ensure that every 'action'
158           within a workflow state has a 'resulting_state' key).
159
160       Returns: one hash reference for each member of @items
161

CONFIGURATION INFORMATION

163       This gives you an idea of the configuration information in the various
164       workflow pieces:
165
166   workflow
167          workflow
168             type        $
169             description $
170             persister   $
171             observer    \@
172                 sub           $
173                 class         $
174             state       \@
175                 name          $
176                 description   $
177                 action        \@
178                     name            $
179                     resulting_state $
180                     condition       \@
181                         name              $
182
183       ·   the 'type' and 'description' keys are at the top level
184
185       ·   the 'extra_data' key holds an array of zero or more hashrefs with
186           'table', 'field', 'class' and 'context' keys
187
188       ·   'state' key holds array of one or more 'state' declarations; one of
189           them must be 'INITIAL'
190
191       ·   each 'state' declaration holds 'description' and 'name' keys and
192           multiple 'action' declarations
193
194       ·   each 'action' declaration holds 'name' and 'resulting_state' keys
195           and may hold a 'condition' key with one or more named conditions
196
197   condition
198        conditions:
199
200            condition \@
201               name  $
202               class $
203               param \@
204                   name  $
205                   value $
206
207       ·   array of one or more hashrefs with 'name' and 'class' keys
208
209   validator
210        validators:
211
212            validator \@
213               name  $
214               class $
215               param \@
216                   name  $
217                   value $
218
219       ·   array of one or more hashrefs with 'name' and 'class' keys, plus
220           possibly one or more 'param' hashrefs each with 'name' and 'value'
221           keys
222
223   action
224        actions:
225
226           action \@
227              name  $
228              field \@
229                 name         $
230                 is_required  yes|no
231                 type         $
232                 source_list  \@ of $
233                 source_class $
234                 param        \@
235                     name  $
236                     value $
237              validator \@
238                  name $
239                  arg  \@
240                      value $
241
242       ·   array of one or more action hashrefs with 'name', 'class' and
243           'description' keys
244
245       ·   each 'action' may have zero or more values used to fill it; each
246           value has a 'name', 'description' and 'necessity' ('required' or
247           'optional')
248
249       ·   each 'action' may have any number of 'param' hashrefs, each with
250           'name' and 'value'
251
252       ·   each 'action' may have any number of 'validator' hashrefs, each
253           with a 'name' key and array of 'arg' declarations
254
255   persister
256        persister:
257
258          extra_table   $
259          extra_field   $
260          extra_class   $
261          extra_context $
262
264       Copyright (c) 2003-2004 Chris Winters. All rights reserved.
265
266       This library is free software; you can redistribute it and/or modify it
267       under the same terms as Perl itself.
268

AUTHORS

270       Chris Winters <chris@cwinters.com>
271
272
273
274perl v5.12.0                      2010-05-07               Workflow::Config(3)
Impressum