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

NAME

6       Workflow::Config - Parse configuration files for the workflow compo‐
7       nents
8

SYNOPSIS

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

DESCRIPTION

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

CLASS METHODS

36       parse_all_files( $workflow_config_type, @files )
37
38       Runs through each file in @files and processes it according to the
39       valid
40

SUBCLASSING

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

CONFIGURATION INFORMATION

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

AUTHORS

269       Chris Winters <chris@cwinters.com>
270
271
272
273perl v5.8.8                       2007-04-25               Workflow::Config(3)
Impressum