| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#------------------------------------------------------------------------------------------------------ |
|
2
|
|
|
|
|
|
|
# OBJET : "Classe abstraite" des sous-modules ou sous-classes de CTM::ReadEM::* |
|
3
|
|
|
|
|
|
|
# APPLICATION : Control-M |
|
4
|
|
|
|
|
|
|
# AUTEUR : Yoann Le Garff |
|
5
|
|
|
|
|
|
|
# DATE DE CREATION : 09/05/2014 |
|
6
|
|
|
|
|
|
|
#------------------------------------------------------------------------------------------------------ |
|
7
|
|
|
|
|
|
|
# USAGE / AIDE |
|
8
|
|
|
|
|
|
|
# perldoc CTM::Base::SubClass |
|
9
|
|
|
|
|
|
|
#------------------------------------------------------------------------------------------------------ |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#-> BEGIN |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----> ** initialisation ** |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package CTM::Base::SubClass; |
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
45
|
|
|
18
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
61
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
65
|
use base qw/ |
|
21
|
|
|
|
|
|
|
CTM::Base |
|
22
|
1
|
|
|
1
|
|
6
|
/; |
|
|
1
|
|
|
|
|
1
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
52
|
use Carp qw/ |
|
25
|
|
|
|
|
|
|
carp |
|
26
|
1
|
|
|
1
|
|
5
|
/; |
|
|
1
|
|
|
|
|
1
|
|
|
27
|
1
|
|
|
|
|
54
|
use String::Util qw/ |
|
28
|
|
|
|
|
|
|
crunch |
|
29
|
1
|
|
|
1
|
|
4
|
/; |
|
|
1
|
|
|
|
|
1
|
|
|
30
|
1
|
|
|
|
|
7
|
use Hash::Util qw/ |
|
31
|
|
|
|
|
|
|
lock_hash |
|
32
|
|
|
|
|
|
|
unlock_hash |
|
33
|
1
|
|
|
1
|
|
4
|
/; |
|
|
1
|
|
|
|
|
1
|
|
|
34
|
1
|
|
|
|
|
1082
|
use Storable qw/ |
|
35
|
|
|
|
|
|
|
dclone |
|
36
|
1
|
|
|
1
|
|
633
|
/; |
|
|
1
|
|
|
|
|
2545
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#----> ** variables de classe ** |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our $VERSION = 0.181; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#----> ** methodes privees ** |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $_clone = sub { |
|
45
|
|
|
|
|
|
|
my $self = shift; |
|
46
|
|
|
|
|
|
|
my $clone = { |
|
47
|
|
|
|
|
|
|
CTM::Base::_rootClassEMPrivate => $self->getParentClass(), |
|
48
|
|
|
|
|
|
|
CTM::Base::_subClassDatasObjProperty => dclone($self->getItems()), |
|
49
|
|
|
|
|
|
|
CTM::Base::_paramsObjProperty => dclone($self->getParams()), |
|
50
|
|
|
|
|
|
|
CTM::Base::_errorsObjProperty => dclone($self->getErrors()), |
|
51
|
|
|
|
|
|
|
CTM::Base::_workingObjProperty => 0 |
|
52
|
|
|
|
|
|
|
}; |
|
53
|
|
|
|
|
|
|
return bless $clone, ref $self; |
|
54
|
|
|
|
|
|
|
}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#----> ** methodes protegees ** |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _resetAndRefresh { |
|
59
|
0
|
|
|
0
|
|
|
my ($self, $workMethod) = @_; |
|
60
|
0
|
0
|
|
|
|
|
if (caller->isa(__PACKAGE__)) { |
|
61
|
0
|
|
|
|
|
|
sleep 1 while ($self->_isWorking()); |
|
62
|
0
|
|
|
|
|
|
my $selfTemp = $self->getParentClass()->$workMethod( |
|
63
|
0
|
|
|
|
|
|
%{$self->getParams()} |
|
64
|
|
|
|
|
|
|
); |
|
65
|
0
|
|
|
|
|
|
my $_errorsTemp = $self->getErrors(); |
|
66
|
0
|
|
|
|
|
|
$self = $selfTemp; |
|
67
|
0
|
|
|
|
|
|
unlock_hash(%{$self}); |
|
|
0
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$self->{CTM::Base::_errorsObjProperty} = $_errorsTemp; |
|
69
|
0
|
|
|
|
|
|
lock_hash(%{$self}); |
|
|
0
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return 1; |
|
71
|
|
|
|
|
|
|
} else { |
|
72
|
0
|
|
|
|
|
|
carp(CTM::Base::_myErrorMessage((caller 0)[3], "tentative d'utilisation d'une methode protegee.")); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
0
|
|
|
|
|
|
return 0; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#-> methodes en rapport avec les alarmes/alertes |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _setSerials { |
|
80
|
0
|
|
|
0
|
|
|
my ($self, $childSub, $sqlRequest, $sqlRequestArgs, $serialID) = @_; |
|
81
|
0
|
|
|
|
|
|
my $subName = (caller 0)[3]; |
|
82
|
0
|
0
|
|
|
|
|
if (caller->isa(__PACKAGE__)) { |
|
83
|
0
|
|
|
|
|
|
$self->_tagAtWork; |
|
84
|
0
|
|
|
|
|
|
$self->unshiftError(); |
|
85
|
0
|
0
|
|
|
|
|
if ($self->getParentClass()->isSessionSeemAlive()) { |
|
86
|
0
|
0
|
|
|
|
|
$serialID = [keys %{$self->getItems()}] unless (ref $serialID eq 'ARRAY'); |
|
|
0
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
if (@{$serialID}) { |
|
|
0
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my $sth = $self->getParentClass()->_DBI()->prepare($sqlRequest . ' WHERE serial IN (' . join(', ', ('?') x @{$serialID}) . ')'); |
|
|
0
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$self->getParentClass()->_invokeVerbose($subName, "\n". $sth->{Statement} . "\n"); |
|
90
|
0
|
0
|
|
|
|
|
if ($sth->execute(@{$serialID})) { |
|
|
0
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
unlock_hash(%{$self->getItems()}); |
|
|
0
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
if (%{$sqlRequestArgs}) { |
|
|
0
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
for my $currentID (@{$serialID}) { |
|
|
0
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
while (my ($field, $value) = each %{$sqlRequestArgs}) { |
|
|
0
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
$self->getItems()->{$currentID}->{$field} = $value; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} else { |
|
99
|
0
|
|
|
|
|
|
delete $self->getItems()->{$_} for (@{$serialID}); |
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
|
101
|
0
|
|
|
|
|
|
lock_hash(%{$self->getItems()}); |
|
|
0
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$self->_tagAtRest; |
|
103
|
0
|
|
|
|
|
|
return 1; |
|
104
|
|
|
|
|
|
|
} else { |
|
105
|
0
|
|
|
|
|
|
$self->_addError(CTM::Base::_myErrorMessage($childSub, "la connexion est etablie mais la methode DBI 'do()' a echouee : '" . crunch($self->getParentClass()->_DBI()->errstr()) . "'.")); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} else { |
|
109
|
0
|
|
|
|
|
|
$self->_addError(CTM::Base::_myErrorMessage($childSub, "impossible de continuer car la connexion au SGBD n'est pas active.")); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
0
|
|
|
|
|
|
$self->_tagAtRest; |
|
112
|
|
|
|
|
|
|
} else { |
|
113
|
0
|
|
|
|
|
|
carp(CTM::Base::_myErrorMessage($subName, "tentative d'utilisation d'une methode protegee.")); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
0
|
|
|
|
|
|
return 0; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#----> ** methodes publiques ** |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub clone { |
|
121
|
0
|
|
|
0
|
0
|
|
my $selfClone = shift->$_clone(); |
|
122
|
0
|
|
|
|
|
|
lock_hash(%{$selfClone}); |
|
|
0
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
return $selfClone; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub countItems { |
|
127
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
128
|
0
|
|
|
|
|
|
return scalar keys %{$self->getItems()}; |
|
|
0
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
#-> accesseurs/mutateurs |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub getParentClass { |
|
134
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
135
|
0
|
|
|
|
|
|
return $self->{CTM::Base::_rootClassEMPrivate}; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub getParams { |
|
139
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
140
|
0
|
|
|
|
|
|
return $self->{CTM::Base::_paramsObjProperty}; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub getItems { |
|
144
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
145
|
0
|
0
|
|
|
|
|
return ref $self->{CTM::Base::_subClassDatasObjProperty} eq 'HASH' ? $self->{CTM::Base::_subClassDatasObjProperty} : {}; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub keepItemsWithAnd { |
|
149
|
0
|
|
|
0
|
0
|
|
my ($self, $properties) = @_; |
|
150
|
0
|
|
|
|
|
|
my $subName = (caller 0)[3]; |
|
151
|
0
|
0
|
0
|
|
|
|
if (ref $properties eq 'HASH' && ! grep { ref $_ ne 'CODE' } values %{$properties}) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
while (my ($itemId, $item) = each %{$self->getItems()}) { |
|
|
0
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
while (my ($property, $expr) = each %{$properties}) { |
|
|
0
|
|
|
|
|
|
|
|
154
|
0
|
0
|
|
|
|
|
if (defined $item->{$property}) { |
|
155
|
0
|
0
|
|
|
|
|
delete $self->getItems()->{$itemId} unless $expr->($item->{$property}); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
} else { |
|
160
|
0
|
|
|
|
|
|
croak(CTM::Base::_myErrorMessage($subName, CTM::Base::_myUsageMessage('$obj->' . $subName, "{ 'property' => \&codeRef }"))); |
|
161
|
|
|
|
|
|
|
} |
|
162
|
0
|
|
|
|
|
|
return $self; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub keepItemsWithOr { |
|
166
|
0
|
|
|
0
|
0
|
|
my ($self, $properties) = @_; |
|
167
|
0
|
|
|
|
|
|
my $subName = (caller 0)[3]; |
|
168
|
0
|
0
|
0
|
|
|
|
if (ref $properties eq 'HASH' && ! grep { ref $_ ne 'CODE' } values %{$properties}) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
my %test; |
|
170
|
0
|
|
|
|
|
|
while (my ($itemId, $item) = each %{$self->getItems()}) { |
|
|
0
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
$test{$itemId} = {}; |
|
172
|
0
|
|
|
|
|
|
while (my ($property, $expr) = each %{$properties}) { |
|
|
0
|
|
|
|
|
|
|
|
173
|
0
|
0
|
|
|
|
|
if (defined $item->{$property}) { |
|
174
|
0
|
|
|
|
|
|
$test{$itemId}->{$property} = $expr->($item->{$property}); |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
} |
|
178
|
0
|
|
|
|
|
|
for (keys %test) { |
|
179
|
0
|
0
|
|
|
|
|
delete $self->getItems()->{$_} unless (grep $_, values %{$test{$_}}); |
|
|
0
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
} else { |
|
182
|
0
|
|
|
|
|
|
croak(CTM::Base::_myErrorMessage($subName, CTM::Base::_myUsageMessage('$obj->' . $subName, "{ 'property' => \&codeRef }"))); |
|
183
|
|
|
|
|
|
|
} |
|
184
|
0
|
|
|
|
|
|
return $self; |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
#-> Perl BuiltIn |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
BEGIN { |
|
190
|
1
|
|
|
1
|
|
23
|
*AUTOLOAD = \&CTM::Base::AUTOLOAD; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
1; |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
#-> END |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
__END__ |