line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Workflow::Persister::DBI::SequenceId; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
118
|
use warnings; |
|
13
|
|
|
|
|
38
|
|
|
13
|
|
|
|
|
513
|
|
4
|
13
|
|
|
13
|
|
79
|
use strict; |
|
13
|
|
|
|
|
35
|
|
|
13
|
|
|
|
|
407
|
|
5
|
13
|
|
|
13
|
|
105
|
use base qw( Class::Accessor ); |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
1264
|
|
6
|
13
|
|
|
13
|
|
120
|
use DBI; |
|
13
|
|
|
|
|
56
|
|
|
13
|
|
|
|
|
623
|
|
7
|
13
|
|
|
13
|
|
130
|
use Log::Log4perl qw( get_logger ); |
|
13
|
|
|
|
|
41
|
|
|
13
|
|
|
|
|
127
|
|
8
|
13
|
|
|
13
|
|
876
|
use Workflow::Exception qw( persist_error ); |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
686
|
|
9
|
13
|
|
|
13
|
|
209
|
use English qw( -no_match_vars ); |
|
13
|
|
|
|
|
142
|
|
|
13
|
|
|
|
|
361
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$Workflow::Persister::DBI::SequenceId::VERSION = '1.62'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @FIELDS = qw( log sequence_name sequence_select ); |
14
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(@FIELDS); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
2
|
|
|
2
|
1
|
6
|
my ( $class, $params ) = @_; |
19
|
2
|
|
50
|
|
|
6
|
$params ||= {}; |
20
|
2
|
|
|
|
|
6
|
$params->{log} = get_logger( $class ); |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
537
|
return bless { %$params }, $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub pre_fetch_id { |
26
|
0
|
|
|
0
|
1
|
|
my ( $self, $dbh ) = @_; |
27
|
0
|
|
|
|
|
|
my $full_select = sprintf $self->sequence_select, $self->sequence_name; |
28
|
0
|
|
|
|
|
|
$self->log->debug("SQL to fetch sequence: ", $full_select); |
29
|
0
|
|
|
|
|
|
my ($row); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
local $EVAL_ERROR = undef; |
32
|
0
|
|
|
|
|
|
eval { |
33
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare($full_select); |
34
|
0
|
|
|
|
|
|
$sth->execute; |
35
|
0
|
|
|
|
|
|
$row = $sth->fetchrow_arrayref; |
36
|
0
|
|
|
|
|
|
$sth->finish; |
37
|
|
|
|
|
|
|
}; |
38
|
0
|
0
|
|
|
|
|
if ($EVAL_ERROR) { |
39
|
0
|
|
|
|
|
|
persist_error "Failed to retrieve sequence: $EVAL_ERROR"; |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
|
return $row->[0]; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
1
|
|
sub post_fetch_id {return} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Workflow::Persister::DBI::SequenceId - Persister to fetch ID from a sequence |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 VERSION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This documentation describes version 1.62 of this package |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SYNOPSIS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
<persister |
63
|
|
|
|
|
|
|
name="MyPersister" |
64
|
|
|
|
|
|
|
workflow_sequence="wf_seq" |
65
|
|
|
|
|
|
|
history_sequence="wf_history_seq" |
66
|
|
|
|
|
|
|
... |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Implementation for DBI persister to fetch an ID value from a sequence. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 Properties |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
B<sequence_name> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Name of the sequence to select the next id value from. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
B<sequence_select> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
C<sprintf> template string with a single placeholder (C<%s>) used to |
81
|
|
|
|
|
|
|
interpolate the sequence name. The resulting string is used as the SQL |
82
|
|
|
|
|
|
|
statement to retrieve the next sequence value. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head3 log |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Contains the logger object associated with this instance. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 METHODS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head3 new ( \%params ) |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This method instantiates a class for retrieval of sequence ids from a |
95
|
|
|
|
|
|
|
L<DBI> based persistance entity. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
It takes a hashref containing keys matching the properties outlines in the |
98
|
|
|
|
|
|
|
section above or throws L<Workflow::Exception>s if these are not defined. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns instantiated object upon success. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head3 pre_fetch_id |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns a unique sequence id from a database. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Takes a single parameter, a L<DBI> database handle. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Returns a single value, a integer representing a sequence id from the provided |
109
|
|
|
|
|
|
|
database handle. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head3 post_fetch_id |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This is a I<dummy> method, use L</pre_fetch_id> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 COPYRIGHT |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Copyright (c) 2003-2023 Chris Winters. All rights reserved. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
120
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Please see the F<LICENSE> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHORS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Please see L<Workflow> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |