| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################################## |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Copyright (C) 2012 Agile Business Group sagl () |
|
4
|
|
|
|
|
|
|
# Copyright (C) 2012 Domsense srl () |
|
5
|
|
|
|
|
|
|
# Copyright (C) 2012 Associazione OpenERP Italia |
|
6
|
|
|
|
|
|
|
# (). |
|
7
|
|
|
|
|
|
|
# Copyright (C) 2022 Res Binaria Di Paolo Capaldo() |
|
8
|
|
|
|
|
|
|
# All Rights Reserved |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify |
|
11
|
|
|
|
|
|
|
# it under the terms of the GNU Affero General Public License as published |
|
12
|
|
|
|
|
|
|
# by the Free Software Foundation, either version 3 of the License, or |
|
13
|
|
|
|
|
|
|
# (at your option) any later version. |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
16
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
|
|
|
|
# GNU Affero General Public License for more details. |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
# You should have received a copy of the GNU Affero General Public License |
|
21
|
|
|
|
|
|
|
# along with this program. If not, see . |
|
22
|
|
|
|
|
|
|
# |
|
23
|
|
|
|
|
|
|
############################################################################## |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package CBI::Wrapper::Disposal; |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
28
|
|
|
28
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
16
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# ABSTRACT: CBI Disposal. |
|
31
|
|
|
|
|
|
|
# 1 disposal <=> n records. |
|
32
|
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
|
4
|
use CBI::Wrapper::Record; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
14
|
|
|
34
|
1
|
|
|
1
|
|
4
|
use CBI::Wrapper::RecordMapping; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
13
|
|
|
35
|
|
|
|
|
|
|
# libscalar-list-utils-perl in debian. |
|
36
|
1
|
|
|
1
|
|
4
|
use Scalar::Util; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
37
|
|
|
|
|
|
|
# croak. |
|
38
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
335
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new { |
|
41
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
42
|
0
|
|
|
|
|
|
my $self = { |
|
43
|
|
|
|
|
|
|
_records => shift, # arrayref (see Record.pm). |
|
44
|
|
|
|
|
|
|
}; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
bless $self, $class; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
$self->set_records([]) unless defined $self->get_records(); |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $self; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Getters and Setters |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub set_records { |
|
56
|
0
|
|
|
0
|
0
|
|
my ( $self, $records) = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$self->{_records} = $records; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub get_records { |
|
62
|
0
|
|
|
0
|
0
|
|
my ( $self) = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $self->{_records}; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub set_record { |
|
68
|
0
|
|
|
0
|
0
|
|
my( $self, $key, $item) = @_; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Type check. |
|
71
|
0
|
0
|
|
|
|
|
unless (Scalar::Util::blessed($item) eq 'CBI::Wrapper::Record') { |
|
72
|
0
|
|
|
|
|
|
croak('[TypeError] You can only write Record objects'); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
for my $record (@{$self->get_records()}) { |
|
|
0
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
$record = $item if $record->get_field_content('tipo_record') eq $key; |
|
77
|
0
|
|
|
|
|
|
croak('[IndexError] Impossible to find field with key ' . $key); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub get_record { |
|
82
|
0
|
|
|
0
|
0
|
|
my( $self, $key) = @_; |
|
83
|
0
|
|
|
|
|
|
for my $record (@{$self->get_records()}) { |
|
|
0
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
return $record if $record->get_field_content('tipo_record') eq $key; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
0
|
|
|
|
|
|
croak('[IndexError] Impossible to find record ' . $key); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Add record to disposal. |
|
90
|
|
|
|
|
|
|
sub append_record { |
|
91
|
0
|
|
|
0
|
0
|
|
my( $self, $item) = @_; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Type check. |
|
94
|
0
|
0
|
|
|
|
|
unless (Scalar::Util::blessed($item) eq 'CBI::Wrapper::Record') { |
|
95
|
0
|
|
|
|
|
|
croak('[TypeError] You can only write Record objects'); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $records = $self->get_records(); |
|
99
|
0
|
|
|
|
|
|
push(@$records, $item); |
|
100
|
0
|
|
|
|
|
|
$self->set_records($records); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |