BPM-Engine

 view release on metacpan or  search on metacpan

lib/BPM/Engine/ProcessRunner.pm  view on Meta::CPAN

Arguments: $activity, $instance

=item I<execute_activity>

Argments: $activity, $instance

On this event, the callback should return false if the workflow process should
be interrupted, true (default) if otherwise, which executes the activity and
progresses the workflow.

=item I<execute_task>

Argments: $task, $activity_instance

Returning true (default) will assume the task completed and call
C<complete_activity()> within ProcessRunner. Return false to halt the process
thread.

=item I<complete_activity>

Arguments: $activity, $instance

=item I<execute_transition>

Arguments: $transition, $from_instance

=item I<complete_process>

Arguments: $process, $process_instance

Returning true (default) will set the process state to C<closed.comleted>.

=back

Callback methods are directly available under its name prefixed by C<cb_>, for
example

    $runner->cb_start_process($process, $process_instance);
 
The callback handler receives the following options:

=over 4

=item * C<$runner>

This ProcessRunner instance.

=item * C<$entity>

Type of entity the node represents. This is either I<process>, I<activity>,
I<transition> or I<task>.

=item * C<$action>

The event action called on the entity. This is either I<start>, I<continue>,
I<complete> or I<execute>.

=item * C<$node>

The first argument passed to the C<cb_*> callback method, the respective entity
node in the process that this callback is emitted for. On activity callbacks,
this is the activity object, the task object on task callbacks, the process
object for process entities, and transition for transition calls.

=item * C<$instance>

The second argument passed to the C<cb_*> callback method, being the instance
for the node called on. In case of a transition callback, this is the activity
instance the transition originated from (the activity being executed).

=back

The callback should return true on succesful/normal processing of events, and
false if something stalled or went wrong. Example:

    my $callback = sub {
        my($runner, $entity, $action, $node, $instance) = @_;
            
        ## call your task execution sub when tasks need executing:
        if ($entity eq 'task' && $action eq 'execute') {
            return &execute_task($node, $instance); 
            }

        return 1;
        };

    my $runner = BPM::Engine::ProcessRunner->new(
        callback => $callback,
        process_instance => $pi
        );



=head1 CONSTRUCTOR

=head2 new

Returns a new BPM::Engine::ProcessRunner instance. Optional arguments are:

=over 4

=item C<< process_instance => $process_instance >>

The process instance to run. Required.

=item C<< callback => \&cb >>

Optional callback I<&cb> which is called on all process instance events.

=item C<< dryrun => 0 | 1 >>

Boolean indicating whether or not the execute_task phase should be skipped.
Defaults to 0.

=back

=head1 ATTRIBUTE METHODS

=head2 process_instance

The L<BPM::Engine::Store::Result::ProcessInstance> to run.



( run in 1.587 second using v1.01-cache-2.11-cpan-140bd7fdf52 )