line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ODS::Table; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
71
|
|
4
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
54
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1152
|
use YAOO; |
|
3
|
|
|
|
|
84973
|
|
|
3
|
|
|
|
|
16
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
1725
|
use ODS::Utils qw/clone/; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
29
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
226
|
use ODS::Utils qw/load build_temp_class/; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
9
|
|
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
215
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1569
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
auto_build; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has storage_class => isa(string); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has storage => isa(object); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has table_class => isa(string); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has resultset_class => isa(string); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has resultset => isa(object); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has name => isa(string); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has columns => isa(ordered_hash), default(1); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has row_class => isa(string); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has rows => isa(array); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has options => isa(hash); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has keyfield => isa(string); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub add_column { |
39
|
36
|
|
|
36
|
0
|
70
|
my ($self, @args) = @_; |
40
|
|
|
|
|
|
|
|
41
|
36
|
|
|
|
|
41
|
my $name = shift @args; |
42
|
|
|
|
|
|
|
|
43
|
36
|
50
|
|
|
|
58
|
if ($self->columns->{$name}) { |
44
|
0
|
|
|
|
|
0
|
croak sprintf "Column %s is already defined in the %s table", |
45
|
|
|
|
|
|
|
$name, $self->name; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
36
|
50
|
|
|
|
413
|
if (scalar @args % 2) { |
49
|
0
|
|
|
|
|
0
|
croak "The column definition for %s does not contain an even number of key/values in the %s table.", |
50
|
|
|
|
|
|
|
$name, $self->name; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
36
|
|
|
|
|
86
|
my %column = @args; |
54
|
36
|
|
|
|
|
48
|
$column{name} = $name; |
55
|
36
|
100
|
|
|
|
65
|
if (! $column{type}) { |
56
|
16
|
|
|
|
|
22
|
$column{type} = 'string'; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
36
|
100
|
|
|
|
48
|
if ($column{keyfield}) { |
60
|
2
|
|
|
|
|
4
|
$self->keyfield($name); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
36
|
|
|
|
|
121
|
my $module = 'ODS::Table::Column::' . ucfirst($column{type}); |
64
|
|
|
|
|
|
|
|
65
|
36
|
|
|
|
|
71
|
load $module; |
66
|
|
|
|
|
|
|
|
67
|
36
|
|
|
|
|
92
|
my $column = $module->new(\%column); |
68
|
|
|
|
|
|
|
|
69
|
36
|
|
|
|
|
3517
|
$self->columns->{$name} = $column; |
70
|
|
|
|
|
|
|
|
71
|
36
|
|
|
|
|
742
|
return $self; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub connect { |
75
|
4
|
|
|
4
|
0
|
14
|
my ($self, $package, $storage, $connect) = (shift, shift, shift, shift); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
4
|
50
|
|
|
|
13
|
if (ref $storage) { |
79
|
0
|
|
|
|
|
0
|
$connect = $storage; |
80
|
0
|
|
|
|
|
0
|
$storage = undef; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
4
|
|
|
|
|
13
|
$self->table_class($package); |
84
|
|
|
|
|
|
|
|
85
|
4
|
|
|
|
|
110
|
(my $resultset = $package) =~ s/Table/ResultSet2/g; |
86
|
|
|
|
|
|
|
|
87
|
4
|
|
|
|
|
8
|
eval { |
88
|
4
|
|
|
|
|
16
|
load $resultset |
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
4
|
50
|
|
|
|
22
|
if ($@) { |
92
|
4
|
|
|
|
|
7
|
$resultset = 'ODS::Table::ResultSet'; |
93
|
4
|
|
|
|
|
11
|
load $resultset; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
4
|
|
|
|
|
15
|
$self->resultset_class($resultset); |
97
|
|
|
|
|
|
|
|
98
|
4
|
|
|
|
|
92
|
(my $row = $package) =~ s/Table/Row/g; |
99
|
|
|
|
|
|
|
|
100
|
4
|
|
|
|
|
7
|
eval { |
101
|
4
|
|
|
|
|
7
|
load $row |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
|
104
|
4
|
50
|
|
|
|
24
|
if ($@) { |
105
|
4
|
|
|
|
|
12
|
$row = build_temp_class('ODS::Table::Row'); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
4
|
|
|
|
|
14
|
$self->row_class($row); |
109
|
|
|
|
|
|
|
|
110
|
4
|
50
|
|
|
|
130
|
$self->storage_class($storage) if $storage; |
111
|
|
|
|
|
|
|
|
112
|
4
|
|
|
|
|
82
|
$storage = $self->storage_class; |
113
|
|
|
|
|
|
|
|
114
|
4
|
|
|
|
|
28
|
my $module = 'ODS::Storage::' . $storage; |
115
|
|
|
|
|
|
|
|
116
|
4
|
|
|
|
|
12
|
load $module; |
117
|
|
|
|
|
|
|
|
118
|
4
|
50
|
|
|
|
7
|
$self->storage($module->connect(%{$connect || {}}, table => $self)); |
|
4
|
|
|
|
|
40
|
|
119
|
|
|
|
|
|
|
|
120
|
4
|
|
|
|
|
103
|
return $self->resultset($self->resultset_class->new(table => $self, @_)); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__ |