| 1 | package Lim::Plugin::Zonalizer::DB; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use common::sense; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Log::Log4perl (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Lim (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Lim::Plugin::Zonalizer qw(:status); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =encoding utf8 | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | Lim::Plugin::Zonalizer::DB - The database interface for Zonalizer | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | package Lim::Plugin::Zonalizer::DB::MyDatabase; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | use base qw(Lim::Plugin::Zonalizer::DB); | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head1 METHODS | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =over 4 | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =item $db = Lim::Plugin::Zonalizer::DB->new (...) | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | Create a new database object, arguments are passed to the backend specific | ||||||||||||||||||||||||||||
| 32 | database module via C<Init>. | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 0 | my ( $this, %args ) = @_; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $class = ref( $this ) ? ref( $this ) : $this; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | my $self = { logger => Log::Log4perl->get_logger }; | |||||||||||||||||||||||||||
| 40 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 41 | 0 | weaken( $self->{logger} ); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | $self->Init( %args ); | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # uncoverable branch false | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug( 'new ', __PACKAGE__, ' ', $self ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | return $self; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=2 SCAR=14.6
| |||||||||||||||||||||||||||||
| 51 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # uncoverable branch false | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug( 'destroy ', __PACKAGE__, ' ', $self ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | $self->Destroy; | |||||||||||||||||||||||||||
| 57 | 0 | return; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =item $db->Init (...) | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | Called upon creation of the object, arguments should be handled in the backend | ||||||||||||||||||||||||||||
| 63 | specific database module. | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =cut | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub Init { | ||||||||||||||||||||||||||
|
Subroutine
Init: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =item $db->Destroy | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | Called upon destruction of the object. | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub Destroy { | ||||||||||||||||||||||||||
|
Subroutine
Destroy: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =item $name = $db->Name | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | Return the name of the module, must be overloaded. | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub Name { | ||||||||||||||||||||||||||
|
Subroutine
Name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 0 | confess 'Name is not overloaded'; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =item $db->ReadAnalysis (parameter => value, ...) | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | Read analyze objects from the database and return them via the callback provided. | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | Most arguments are passed through from API calls, see API documentation for | ||||||||||||||||||||||||||||
| 94 | details. | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =over 4 | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =item space => string | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | The space to read from, see Spaces in API documentation. | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =item search => string | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =item limit => number | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =item sort => string | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =item direction => string | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =item after => id | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =item before => id | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =item cb => sub { my ($paging, @analysis) = @_; ... } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | The callback subrutin that will be called upon success or failure, if there | ||||||||||||||||||||||||||||
| 117 | was an error then C<$@> will be set with the error. | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =over 4 | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =item $paging | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | A hash reference with details about the pagination or undef if no pagination | ||||||||||||||||||||||||||||
| 124 | is available (i.e. not enough data). | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =over 4 | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =item previous | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | The identifier for the previous object. | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =item next | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | The identifier for the next object. | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | =back | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =item @analysis | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | An array with all the analyze objects found. | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =back | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | =back | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | =cut | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub ReadAnalysis { | ||||||||||||||||||||||||||
|
Subroutine
ReadAnalysis: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 149 | 0 | confess 'ReadAnalysis is not overloaded'; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =item $db->DeleteAnalysis | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | Delete all analysis from the database. | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =over 4 | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =item space => string | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | The space to delete in, see Spaces in API documentation. | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =item cb => sub { my ($deleted_analysis) = @_; ... } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | The callback subrutin that will be called upon success or failure, if there | ||||||||||||||||||||||||||||
| 165 | was an error then C<$@> will be set with the error. | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =over 4 | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | =item $deleted_analysis | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | The number of delete analyze objects. | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =back | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | =back | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =cut | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 0 | ▶ | sub DeleteAnalysis { | ||||||||||||||||||||||||||
|
Subroutine
DeleteAnalysis: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 180 | 0 | confess 'DeleteAnalysis is not overloaded'; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | =item $db->CreateAnalyze (parameter => value, ...) | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | Create a new analyze object in the database. | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | =over 4 | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | =item space => string | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | The space to create in, see Spaces in API documentation. | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | =item analyze => hash | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | The analyze object to create, see API documentation for details. | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =item cb => sub { my ($analyze) = @_; ... } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | The callback subrutin that will be called upon success or failure, if there | ||||||||||||||||||||||||||||
| 200 | was an error then C<$@> will be set with the error. | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =over 4 | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | =item $analyze | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | The analyze object created. | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | =back | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | =back | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | =cut | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub CreateAnalyze { | ||||||||||||||||||||||||||
|
Subroutine
CreateAnalyze: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 215 | 0 | confess 'CreateAnalyze is not overloaded'; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | =item $db->ReadAnalyze (parameter => value, ...) | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | Read a analyze object from the database and return it via the callback provided. | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | =over 4 | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | =item space => string | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | The space to read from, see Spaces in API documentation. | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | =item id => id | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | The analyze identifier to read. | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | =item cb => sub { my ($analyze) = @_; ... } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | The callback subrutin that will be called upon success or failure, if there | ||||||||||||||||||||||||||||
| 235 | was an error then C<$@> will be set with the error. | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | =over 4 | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | =item $analyze | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | The analyze object read. | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | =back | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | =back | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | =cut | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub ReadAnalyze { | ||||||||||||||||||||||||||
|
Subroutine
ReadAnalyze: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 250 | 0 | confess 'ReadAnalyze is not overloaded'; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | =item $db->UpdateAnalyze (parameter => value, ...) | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | Update a analyze object in the database. | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | =over 4 | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | =item space => string | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | The space to update in, see Spaces in API documentation. | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | =item analyze => hash | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | The updated analyze object, this object must have been read from the database. | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | =item cb => sub { my ($analyze) = @_; ... } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | The callback subrutin that will be called upon success or failure, if there | ||||||||||||||||||||||||||||
| 270 | was an error then C<$@> will be set with the error. | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =over 4 | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | =item $analyze | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | The updated analyze object. | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | =back | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | =back | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | =cut | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub UpdateAnalyze { | ||||||||||||||||||||||||||
|
Subroutine
UpdateAnalyze: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 285 | 0 | confess 'UpdateAnalyze is not overloaded'; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | =item $db->DeleteAnalyze (parameter => value, ...) | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | Delete a analyze object from the database. | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =over 4 | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | =item space => string | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | The space to delete in, see Spaces in API documentation. | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | =item id => id | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | The analyze identifier to delete. | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | =item cb => sub { ... } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | The callback subrutin that will be called upon success or failure, if there | ||||||||||||||||||||||||||||
| 305 | was an error then C<$@> will be set with the error. | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | =back | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | =cut | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | ▶ | sub DeleteAnalyze { | ||||||||||||||||||||||||||
|
Subroutine
DeleteAnalyze: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 312 | 0 | confess 'DeleteAnalyze is not overloaded'; | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | =item $db->ValidateAnalyze ($analyze) | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | Validate a analyze object and confess if there are any problems. | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | =over 4 | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | =item $analyze | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | The analyze object to validate. | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | =back | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | =cut | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | ▶ | sub ValidateAnalyze { | ||||||||||||||||||||||||||
|
Subroutine
ValidateAnalyze: not called CC=47 SCAR=77.2
Pod
documented
| |||||||||||||||||||||||||||||
| 330 | 0 | my ( $self, $analyze ) = @_; | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | ▶ | unless ( ref( $analyze ) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | 0 | confess 'analyze is not HASH'; | |||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | 0 | foreach ( qw(id fqdn status progress created updated ipv4 ipv6) ) { | |||||||||||||||||||||||||||
| 336 | 0 | ▶ | unless ( defined $analyze->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 0 | confess 'analyze->' . $_ . ' is not defined'; | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | 0 | ▶ | unless ( $analyze->{fqdn} =~ /^(?:[a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.$/o ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 341 | 0 | confess 'analyze->fqdn invalid'; | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | 0 | foreach ( qw(progress created updated) ) { | |||||||||||||||||||||||||||
| 344 | 0 | ▶ | unless ( $analyze->{$_} == ( $analyze->{$_} + 0 ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 345 | 0 | confess 'analyze->' . $_ . ' is not a numeric value'; | |||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | 0 | ▶ | unless ( grep { $analyze->{status} eq $_ } ( STATUS_RESERVED, STATUS_QUEUED, STATUS_ANALYZING, STATUS_DONE, STATUS_FAILED, STATUS_STOPPED, STATUS_UNKNOWN ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 349 | 0 | confess 'analyze->status is invalid'; | |||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ( exists $analyze->{policy} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 352 | 0 | ▶ | unless ( ref( $analyze->{policy} ) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 353 | 0 | confess 'analyze->policy is not HASH'; | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | 0 | foreach ( qw(name display) ) { | |||||||||||||||||||||||||||
| 356 | 0 | ▶ | unless ( defined $analyze->{policy}->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 357 | 0 | confess 'analyze->policy->' . $_ . ' is not defined'; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | 0 | foreach ( qw(description) ) { | |||||||||||||||||||||||||||
| 361 | 0 | ▶ | if ( exists $analyze->{policy}->{$_} and !defined $analyze->{policy}->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $analyze->{"policy"}{$_} and not defined $analyze->{"policy"}{$_}
MC/DC0%0/2
exists $analyze->{"policy"}{$_} and not defined $analyze->{"policy"}{$_}
exists $analyze->{"policy"}{$_}
not defined $analyze->{"policy"}{$_}
Truth table0%0/3
A and not(B)
A= exists $analyze->{"policy"}{$_}B= not defined $analyze->{"policy"}{$_}
| |||||||||||||||||||||||||||||
| 362 | 0 | confess 'analyze->policy->' . $_ . ' is not defined'; | |||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if ( exists $analyze->{error} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | 0 | ▶ | unless ( ref( $analyze->{error} ) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | 0 | confess 'analyze->error is not HASH'; | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | 0 | foreach ( qw(code message) ) { | |||||||||||||||||||||||||||
| 371 | 0 | ▶ | unless ( defined $analyze->{error}->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 372 | 0 | confess 'analyze->error->' . $_ . ' is not defined'; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | 0 | ▶ | if ( exists $analyze->{summary} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 377 | 0 | ▶ | unless ( ref( $analyze->{summary} ) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 378 | 0 | confess 'analyze->summary is not HASH'; | |||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | 0 | foreach ( qw(notice warning error critical) ) { | |||||||||||||||||||||||||||
| 381 | 0 | ▶ | unless ( defined $analyze->{summary}->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 382 | 0 | confess 'analyze->summary->' . $_ . ' is not defined'; | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | 0 | ▶ | unless ( $analyze->{summary}->{$_} == ( $analyze->{summary}->{$_} + 0 ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 385 | 0 | confess 'analyze->{summary}->' . $_ . ' is not a numeric value'; | |||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | 0 | ▶ | if ( exists $analyze->{results} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | 0 | eval { $self->ValidateResults( $analyze->{results} ); }; | |||||||||||||||||||||||||||
| 391 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 392 | 0 | confess 'analyze->results is invalid: ' . $@; | |||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if ( exists $analyze->{ns} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | 0 | ▶ | unless ( ref( $analyze->{ns} ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | 0 | confess 'analyze->ns is not ARRAY'; | |||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | 0 | my $count = 1; | |||||||||||||||||||||||||||
| 400 | 0 | foreach my $ns ( @{ $analyze->{ns} } ) { | |||||||||||||||||||||||||||
| 401 | 0 | ▶ | unless ( ref( $ns ) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 402 | 0 | confess 'analyze->ns[' . $count . '] is not HASH'; | |||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | 0 | foreach ( qw(fqdn) ) { | |||||||||||||||||||||||||||
| 405 | 0 | ▶ | unless ( defined $ns->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | 0 | confess 'analyze->ns[' . $count . ']->' . $_ . ' is not defined'; | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | 0 | foreach ( qw(ip) ) { | |||||||||||||||||||||||||||
| 410 | 0 | ▶ | if ( exists $ns->{$_} and !defined $ns->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $ns->{$_} and not defined $ns->{$_}
MC/DC0%0/2
exists $ns->{$_} and not defined $ns->{$_}
exists $ns->{$_}
not defined $ns->{$_}
Truth table0%0/3
A and not(B)
A= exists $ns->{$_}B= not defined $ns->{$_}
| |||||||||||||||||||||||||||||
| 411 | 0 | confess 'analyze->ns[' . $count . ']->' . $_ . ' is not defined'; | |||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | 0 | $count++; | |||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | 0 | ▶ | if ( exists $analyze->{ds} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 418 | 0 | ▶ | unless ( ref( $analyze->{ds} ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 419 | 0 | confess 'analyze->ds is not ARRAY'; | |||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||
| 421 | 0 | my $count = 1; | |||||||||||||||||||||||||||
| 422 | 0 | foreach my $ds ( @{ $analyze->{ds} } ) { | |||||||||||||||||||||||||||
| 423 | 0 | ▶ | unless ( ref( $ds ) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 424 | 0 | confess 'analyze->ds[' . $count . '] is not HASH'; | |||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | 0 | foreach ( qw(keytag algorithm type digest) ) { | |||||||||||||||||||||||||||
| 427 | 0 | ▶ | unless ( defined $ds->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 428 | 0 | confess 'analyze->ds[' . $count . ']->' . $_ . ' is not defined'; | |||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||
| 431 | 0 | $count++; | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | 0 | ▶ | if ( exists $analyze->{meta_data} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 435 | 0 | ▶ | unless ( ref( $analyze->{meta_data} ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 436 | 0 | confess 'analyze->meta_data is not ARRAY'; | |||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||
| 438 | 0 | my $count = 1; | |||||||||||||||||||||||||||
| 439 | 0 | foreach my $meta_data ( @{ $analyze->{meta_data} } ) { | |||||||||||||||||||||||||||
| 440 | 0 | ▶ | unless ( ref( $meta_data ) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 441 | 0 | confess 'analyze->meta_data[' . $count . '] is not HASH'; | |||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | 0 | foreach ( qw(key value) ) { | |||||||||||||||||||||||||||
| 444 | 0 | ▶ | unless ( defined $meta_data->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 445 | 0 | confess 'analyze->meta_data[' . $count . ']->' . $_ . ' is not defined'; | |||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||
| 448 | 0 | $count++; | |||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||
| 451 | 0 | return; | |||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | =item $db->ValidateResults ($results) | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | Validate a set of result objects and confess if there are any problems. | ||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | =over 4 | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | =item $results | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | An array ref with the result objects to validate. | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | =back | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | =cut | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | 0 | ▶ | sub ValidateResults { | ||||||||||||||||||||||||||
|
Subroutine
ValidateResults: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 469 | 0 | my ( $self, $results ) = @_; | |||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | 0 | ▶ | unless ( ref( $results ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 472 | 0 | confess 'results is not ARRAY'; | |||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | 0 | my $count = 1; | |||||||||||||||||||||||||||
| 475 | 0 | foreach ( @$results ) { | |||||||||||||||||||||||||||
| 476 | 0 | eval { $self->ValidateResult( $_ ); }; | |||||||||||||||||||||||||||
| 477 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 478 | 0 | confess 'result[' . $count . '] is invalid: ' . $@; | |||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||
| 480 | 0 | $count++; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | 0 | return; | |||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | =item $db->ValidateResult ($result) | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | Validate a result object and confess if there are any problems. | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | =over 4 | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | =item $result | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | The result object to validate. | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | =back | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | =cut | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | 0 | ▶ | sub ValidateResult { | ||||||||||||||||||||||||||
|
Subroutine
ValidateResult: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 500 | 0 | my ( $self, $result ) = @_; | |||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | 0 | ▶ | unless ( ref( $result ) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 503 | 0 | confess 'result is not HASH'; | |||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||
| 505 | 0 | foreach ( qw(_id level module tag timestamp) ) { | |||||||||||||||||||||||||||
| 506 | 0 | ▶ | unless ( defined $result->{$_} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 507 | 0 | confess 'result->' . $_ . ' is not defined'; | |||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | 0 | foreach ( qw(_id timestamp) ) { | |||||||||||||||||||||||||||
| 511 | 0 | ▶ | unless ( $result->{$_} == ( $result->{$_} + 0 ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 512 | 0 | confess 'result->' . $_ . ' is not a numeric value'; | |||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||
| 515 | 0 | ▶ | if ( exists $result->{args} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 516 | 0 | ▶ | unless ( ref( $result->{args} ) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 517 | 0 | confess 'result->args is not HASH'; | |||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||
| 520 | 0 | return; | |||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | =back | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | Jerry Lundström, C<< <lundstrom.jerry@gmail.com> >> | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | =head1 BUGS | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | Please report any bugs or feature requests to L<https://github.com/jelu/lim-plugin-zonalizer/issues>. | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | perldoc Lim::Plugin::Zonalizer::DB | ||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | You can also look for information at: | ||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | =over 4 | ||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | =item * Lim issue tracker (report bugs here) | ||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | L<https://github.com/jelu/lim-plugin-zonalizer/issues> | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | =back | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||
| 551 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | Copyright 2015-2016 Jerry Lundström | ||||||||||||||||||||||||||||
| 554 | Copyright 2015-2016 IIS (The Internet Foundation in Sweden) | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 557 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||
| 558 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | =cut | ||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||
| 565 | 1 | 1; # End of Lim::Plugin::Zonalizer::DB | |||||||||||||||||||||||||||