line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bigtop::Backend::Model::GantryCDBI; |
2
|
1
|
|
|
1
|
|
1202
|
use strict; use warnings; |
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
|
|
62
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
569
|
use Bigtop::Backend::Model; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
6
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
6
|
1
|
|
|
1
|
|
4
|
use Inline; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
37
|
use Bigtop; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
430
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
10
|
|
|
|
|
|
|
# The Default Template |
11
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $template_is_setup = 0; |
14
|
|
|
|
|
|
|
our $default_template_text = <<'EO_TT_blocks'; |
15
|
|
|
|
|
|
|
[% BLOCK stub_table_module %] |
16
|
|
|
|
|
|
|
package [% package_name %]; |
17
|
|
|
|
|
|
|
use strict; use warnings; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use base '[% base_class || base_class_default %]', 'Exporter'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use [% gen_package_name %]; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $[% package_alias %] = '[% package_name %]'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT_OK = ( '$[% package_alias %]' ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
[% package_name %] - model for [% table_name %] table (stub part) |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This model inherits from [% base_class || base_class_default %] and uses its generated |
36
|
|
|
|
|
|
|
helper [% gen_package_name %]. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
It was generated by Bigtop, but is NOT subject to regeneration. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
[% END %] |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
[% BLOCK gen_table_module %] |
44
|
|
|
|
|
|
|
# NEVER EDIT this file. It was generated and will be overwritten without |
45
|
|
|
|
|
|
|
# notice upon regeneration of this application. You have been warned. |
46
|
|
|
|
|
|
|
package [% package_name %]; |
47
|
|
|
|
|
|
|
use strict; use warnings; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
[% package_name %]->table ( '[% real_table_name %]' ); |
50
|
|
|
|
|
|
|
[% IF sequence_name %] |
51
|
|
|
|
|
|
|
[% package_name %]->sequence( '[% sequence_name %]' ); |
52
|
|
|
|
|
|
|
[% END %] |
53
|
|
|
|
|
|
|
[% IF primary_key %] |
54
|
|
|
|
|
|
|
[% package_name %]->columns ( Primary => qw/ |
55
|
|
|
|
|
|
|
[% IF primary_key.0 %] |
56
|
|
|
|
|
|
|
[% primary_key.join( ' ' ) +%] |
57
|
|
|
|
|
|
|
[% ELSE %] |
58
|
|
|
|
|
|
|
[% primary_key +%] |
59
|
|
|
|
|
|
|
[% END -%] |
60
|
|
|
|
|
|
|
/ ); |
61
|
|
|
|
|
|
|
[% END -%] |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
[% package_name %]->columns ( All => qw/ |
64
|
|
|
|
|
|
|
[% FOREACH column IN all_columns %] |
65
|
|
|
|
|
|
|
[% column +%] |
66
|
|
|
|
|
|
|
[% END %] |
67
|
|
|
|
|
|
|
/ ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
[% package_name %]->columns ( Essential => qw/ |
70
|
|
|
|
|
|
|
[% FOREACH essential_column IN essential_columns %] |
71
|
|
|
|
|
|
|
[% essential_column +%] |
72
|
|
|
|
|
|
|
[% END %] |
73
|
|
|
|
|
|
|
/ ); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
[% FOREACH has_a IN has_a_list %] |
76
|
|
|
|
|
|
|
[% package_name %]->has_a( [% has_a.column %] => '[% base_package_name %]::[% has_a.table %]' ); |
77
|
|
|
|
|
|
|
[% END +%] |
78
|
|
|
|
|
|
|
sub get_foreign_display_fields { |
79
|
|
|
|
|
|
|
return [ qw( [% foreign_display_columns %] ) ]; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub get_foreign_tables { |
83
|
|
|
|
|
|
|
return qw( |
84
|
|
|
|
|
|
|
[% FOREACH foreign_table IN foreign_tables %] |
85
|
|
|
|
|
|
|
[% base_package_name %]::[% foreign_table +%] |
86
|
|
|
|
|
|
|
[% END %] |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub foreign_display { |
91
|
|
|
|
|
|
|
my $self = shift; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
[% foreign_display_body %] |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
[% gen_package_name %] - model for [% table_name %] table (generated part) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 DESCRIPTION |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This model mixes into [% package_name %], |
105
|
|
|
|
|
|
|
because Class::DBI bindings don't really allow a choice. |
106
|
|
|
|
|
|
|
It was generated by Bigtop, and IS subject to regeneration. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 METHODS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
You may use all normal Class::DBI::Sweet methods and the ones listed here: |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over 4 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item get_foreign_display_fields |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item get_foreign_tables |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item foreign_display |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
[% END %] |
124
|
|
|
|
|
|
|
EO_TT_blocks |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
127
|
|
|
|
|
|
|
# Methods in the Bigtop::Model::GantryCDBI package |
128
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub what_do_you_make { |
131
|
|
|
|
|
|
|
return [ |
132
|
0
|
|
|
0
|
1
|
|
[ 'lib/AppName/Model/*.pm' => |
133
|
|
|
|
|
|
|
'Class::DBI style model stubs [safe to change]' ], |
134
|
|
|
|
|
|
|
[ 'lib/AppName/Model/GEN/*.pm' => |
135
|
|
|
|
|
|
|
'Class::DBI style model specifications [please, do not change]' ], |
136
|
|
|
|
|
|
|
[ 'note' => |
137
|
|
|
|
|
|
|
'This backend is incompatible with other Model backends.' ], |
138
|
|
|
|
|
|
|
]; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub backend_block_keywords { |
142
|
|
|
|
|
|
|
return [ |
143
|
0
|
|
|
0
|
1
|
|
{ keyword => 'no_gen', |
144
|
|
|
|
|
|
|
label => 'No Gen', |
145
|
|
|
|
|
|
|
descr => 'Skip everything for this backend', |
146
|
|
|
|
|
|
|
type => 'boolean' }, |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
{ keyword => 'model_base_class', |
149
|
|
|
|
|
|
|
label => 'Models Inherit From', |
150
|
|
|
|
|
|
|
descr => 'Defaults to Gantry::Utils::CDBI', |
151
|
|
|
|
|
|
|
type => 'text' }, |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
{ keyword => 'template', |
154
|
|
|
|
|
|
|
label => 'Alternate Template', |
155
|
|
|
|
|
|
|
descr => 'A custom TT template.', |
156
|
|
|
|
|
|
|
type => 'text' }, |
157
|
|
|
|
|
|
|
]; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub setup_template { |
161
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
162
|
0
|
|
0
|
|
|
|
my $template_text = shift || $default_template_text; |
163
|
|
|
|
|
|
|
|
164
|
0
|
0
|
|
|
|
|
return if ( $template_is_setup ); |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
Inline->bind( |
167
|
|
|
|
|
|
|
TT => $template_text, |
168
|
|
|
|
|
|
|
POST_CHOMP => 1, |
169
|
|
|
|
|
|
|
TRIM_LEADING_SPACE => 0, |
170
|
|
|
|
|
|
|
TRIM_TRAILING_SPACE => 0, |
171
|
|
|
|
|
|
|
); |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
$template_is_setup = 1; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub gen_Model { |
177
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
178
|
0
|
|
|
|
|
|
my $build_dir = shift; |
179
|
0
|
|
|
|
|
|
my $bigtop_tree = shift; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
# make sure the directories are ready for us |
182
|
0
|
|
|
|
|
|
my $model_name = $bigtop_tree->get_appname() . '::Model'; |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
my ( $module_dir, @sub_dirs ) |
185
|
|
|
|
|
|
|
= Bigtop::make_module_path( $build_dir, $model_name ); |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
my $gen_dir = File::Spec->catdir( $module_dir, 'GEN' ); |
188
|
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
|
mkdir $gen_dir; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# see if there is an alternate default base module |
192
|
0
|
|
|
|
|
|
my $config_block = $bigtop_tree->get_config()->{ Model }; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# build the individual model packages |
195
|
0
|
|
0
|
|
|
|
$bigtop_tree->walk_postorder( |
196
|
|
|
|
|
|
|
'output_model', |
197
|
|
|
|
|
|
|
{ |
198
|
|
|
|
|
|
|
module_dir => $module_dir, |
199
|
|
|
|
|
|
|
model_name => $model_name, |
200
|
|
|
|
|
|
|
lookup => $bigtop_tree->{application}{lookup}, |
201
|
|
|
|
|
|
|
model_base_class => $config_block->{model_base_class} |
202
|
|
|
|
|
|
|
|| 'Gantry::Utils::CDBI', |
203
|
|
|
|
|
|
|
}, |
204
|
|
|
|
|
|
|
); |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
209
|
|
|
|
|
|
|
# Packages named in the grammar |
210
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# table_block |
213
|
|
|
|
|
|
|
package # table_block |
214
|
|
|
|
|
|
|
table_block; |
215
|
1
|
|
|
1
|
|
7
|
use strict; use warnings; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
|
1
|
|
|
|
|
189
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
591
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub output_model { |
218
|
0
|
|
|
0
|
|
|
my $self = shift; |
219
|
0
|
|
|
|
|
|
my $child_output = shift; |
220
|
0
|
|
|
|
|
|
my $data = shift; |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# Skip sequences, etc. |
223
|
0
|
0
|
|
|
|
|
return unless ( $self->{__TYPE__} eq 'tables' ); |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
my $table_lookup = $data->{lookup}{tables}{ $self->{__NAME__} }; |
226
|
|
|
|
|
|
|
|
227
|
0
|
0
|
|
|
|
|
if ( $table_lookup->{not_for} ) { |
228
|
0
|
|
|
|
|
|
foreach my $skipped_type ( @{ $table_lookup->{not_for}{__ARGS__} } ) { |
|
0
|
|
|
|
|
|
|
229
|
0
|
0
|
|
|
|
|
return if ( $skipped_type eq 'Model' ); |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# get columns sets |
234
|
0
|
|
|
|
|
|
my $lookup = $table_lookup->{fields}; |
235
|
|
|
|
|
|
|
|
236
|
0
|
|
|
|
|
|
my $all = $self->walk_postorder( |
237
|
|
|
|
|
|
|
'output_all_fields_cdbi', $lookup |
238
|
|
|
|
|
|
|
); |
239
|
0
|
|
|
|
|
|
my $essentials = $self->walk_postorder( |
240
|
|
|
|
|
|
|
'output_essential_fields_cdbi', $lookup |
241
|
|
|
|
|
|
|
); |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
# deal with foreign keys |
244
|
0
|
|
|
|
|
|
my $foreign_tables = $self->walk_postorder( |
245
|
|
|
|
|
|
|
'output_foreign_tables_cdbi', $lookup |
246
|
|
|
|
|
|
|
); |
247
|
|
|
|
|
|
|
|
248
|
0
|
|
|
|
|
|
my @foreign_table_names; |
249
|
|
|
|
|
|
|
my @has_a_list; |
250
|
|
|
|
|
|
|
|
251
|
0
|
|
|
|
|
|
foreach my $entry ( @{ $foreign_tables } ) { |
|
0
|
|
|
|
|
|
|
252
|
0
|
|
|
|
|
|
my $entry_hash = { @{ $entry } }; |
|
0
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
my $foreign_table = $entry_hash->{ table }; |
255
|
0
|
|
|
|
|
|
$foreign_table =~ s/\./_/; |
256
|
|
|
|
|
|
|
|
257
|
0
|
|
|
|
|
|
push @foreign_table_names, $foreign_table; |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
push @has_a_list, { |
260
|
|
|
|
|
|
|
table => $foreign_table, |
261
|
|
|
|
|
|
|
column => $entry_hash->{ column }, |
262
|
0
|
|
|
|
|
|
}; |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
# Gone Fishing. |
266
|
0
|
|
|
|
|
|
my $table = $self->{__NAME__}; |
267
|
0
|
|
|
|
|
|
$table =~ s/\./_/; |
268
|
0
|
|
|
|
|
|
my $module_name = $data->{model_name} . '::' . $table; |
269
|
0
|
|
|
|
|
|
my $gen_pack_name = $data->{model_name} . '::GEN::' . $table; |
270
|
0
|
|
|
|
|
|
my $alias = uc $table; |
271
|
0
|
|
|
|
|
|
my $sequence = $table_lookup->{sequence}; |
272
|
0
|
|
|
|
|
|
my $foreign_display = $table_lookup->{foreign_display}; |
273
|
|
|
|
|
|
|
|
274
|
0
|
|
|
|
|
|
my $sequence_name; |
275
|
|
|
|
|
|
|
|
276
|
0
|
0
|
|
|
|
|
if ( $sequence ) { |
277
|
0
|
|
|
|
|
|
$sequence_name = $sequence->{__ARGS__}[0]; |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
my $primary_key = $self->find_primary_key( |
281
|
|
|
|
|
|
|
$self->{__NAME__}, |
282
|
|
|
|
|
|
|
$data->{ lookup }, |
283
|
0
|
|
|
|
|
|
); |
284
|
|
|
|
|
|
|
|
285
|
0
|
|
|
|
|
|
my $foreign_display_columns; |
286
|
|
|
|
|
|
|
my $foreign_display_body; |
287
|
|
|
|
|
|
|
|
288
|
0
|
0
|
|
|
|
|
if ( $foreign_display ) { |
289
|
0
|
|
|
|
|
|
my $foreign_display_cols = $foreign_display->{__ARGS__}[0]; |
290
|
|
|
|
|
|
|
|
291
|
0
|
|
|
|
|
|
my @field_names = ( $foreign_display_cols =~ /%([\w\d_]*)/g ); |
292
|
0
|
|
|
|
|
|
$foreign_display_columns = "@field_names"; |
293
|
|
|
|
|
|
|
|
294
|
0
|
|
|
|
|
|
$foreign_display_body = _build_foreign_display_body( |
295
|
|
|
|
|
|
|
$foreign_display_cols, @field_names |
296
|
|
|
|
|
|
|
); |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
0
|
|
|
|
|
|
my $base_class; |
300
|
|
|
|
|
|
|
|
301
|
0
|
0
|
|
|
|
|
if ( defined $table_lookup->{model_base_class} ) { |
302
|
0
|
|
|
|
|
|
$base_class = $table_lookup->{model_base_class}{__ARGS__}[0]; |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
# generate output |
306
|
0
|
|
|
|
|
|
my $stub_content = Bigtop::Backend::Model::GantryCDBI::stub_table_module( |
307
|
|
|
|
|
|
|
{ |
308
|
|
|
|
|
|
|
base_class => $base_class, |
309
|
|
|
|
|
|
|
base_class_default => $data->{model_base_class}, |
310
|
|
|
|
|
|
|
base_package_name => $data->{model_name}, |
311
|
|
|
|
|
|
|
gen_package_name => $gen_pack_name, |
312
|
|
|
|
|
|
|
package_name => $module_name, |
313
|
|
|
|
|
|
|
package_alias => $alias, |
314
|
|
|
|
|
|
|
table_name => $table, |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
); |
317
|
|
|
|
|
|
|
|
318
|
0
|
|
|
|
|
|
my $gen_content = Bigtop::Backend::Model::GantryCDBI::gen_table_module( |
319
|
|
|
|
|
|
|
{ |
320
|
|
|
|
|
|
|
base_package_name => $data->{model_name}, |
321
|
|
|
|
|
|
|
package_name => $module_name, |
322
|
|
|
|
|
|
|
gen_package_name => $gen_pack_name, |
323
|
|
|
|
|
|
|
package_alias => $alias, |
324
|
|
|
|
|
|
|
table_name => $table, |
325
|
|
|
|
|
|
|
real_table_name => $self->{__NAME__}, |
326
|
|
|
|
|
|
|
sequence_name => $sequence_name, |
327
|
|
|
|
|
|
|
primary_key => $primary_key, |
328
|
|
|
|
|
|
|
foreign_display_columns => $foreign_display_columns, |
329
|
|
|
|
|
|
|
foreign_display_body => $foreign_display_body, |
330
|
|
|
|
|
|
|
all_columns => $all, |
331
|
|
|
|
|
|
|
essential_columns => $essentials, |
332
|
|
|
|
|
|
|
has_a_list => \@has_a_list, |
333
|
|
|
|
|
|
|
foreign_tables => \@foreign_table_names, |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
); |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
# store it |
338
|
0
|
|
|
|
|
|
my $module_file = File::Spec->catfile( $data->{module_dir}, "$table.pm" ); |
339
|
0
|
|
|
|
|
|
my $gen_dir = File::Spec->catdir ( $data->{module_dir}, 'GEN' ); |
340
|
0
|
|
|
|
|
|
my $gen_file = File::Spec->catfile( $gen_dir, "$table.pm" ); |
341
|
|
|
|
|
|
|
|
342
|
0
|
|
|
|
|
|
eval { |
343
|
1
|
|
|
1
|
|
5
|
no warnings qw( Bigtop ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
152
|
|
344
|
0
|
|
|
|
|
|
Bigtop::write_file( $module_file, $stub_content, 'no overwrite' ); |
345
|
|
|
|
|
|
|
}; |
346
|
0
|
0
|
|
|
|
|
warn $@ if $@; |
347
|
|
|
|
|
|
|
|
348
|
0
|
|
|
|
|
|
eval { |
349
|
0
|
|
|
|
|
|
Bigtop::write_file( $gen_file, $gen_content ); |
350
|
|
|
|
|
|
|
}; |
351
|
0
|
0
|
|
|
|
|
warn $@ if $@; |
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
# table_element_block |
355
|
|
|
|
|
|
|
package # table_element_block |
356
|
|
|
|
|
|
|
table_element_block; |
357
|
1
|
|
|
1
|
|
4
|
use strict; use warnings; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
312
|
|
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
sub output_all_fields_cdbi { |
360
|
0
|
|
|
0
|
|
|
my $self = shift; |
361
|
0
|
|
|
|
|
|
shift; |
362
|
0
|
|
|
|
|
|
my $data = shift; |
363
|
|
|
|
|
|
|
|
364
|
0
|
0
|
|
|
|
|
return unless ( ref( $self->{__BODY__} ) ); |
365
|
|
|
|
|
|
|
|
366
|
0
|
|
|
|
|
|
my $field = $data->{ $self->{__NAME__} }; |
367
|
|
|
|
|
|
|
|
368
|
0
|
0
|
|
|
|
|
return if ( _not_for_model( $field ) ); |
369
|
|
|
|
|
|
|
|
370
|
0
|
|
|
|
|
|
return [ $self->{__NAME__} ]; |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
sub output_essential_fields_cdbi { |
374
|
0
|
|
|
0
|
|
|
my $self = shift; |
375
|
0
|
|
|
|
|
|
shift; |
376
|
0
|
|
|
|
|
|
my $data = shift; |
377
|
|
|
|
|
|
|
|
378
|
0
|
0
|
|
|
|
|
return unless ( ref( $self->{__BODY__} ) ); |
379
|
|
|
|
|
|
|
|
380
|
0
|
|
|
|
|
|
my $field = $data->{ $self->{__NAME__} }; |
381
|
|
|
|
|
|
|
|
382
|
0
|
0
|
|
|
|
|
if ( $field->{non_essential} ) { |
383
|
0
|
|
|
|
|
|
my $non_essential_value = $field->{non_essential}{args}[0]; |
384
|
|
|
|
|
|
|
|
385
|
0
|
0
|
|
|
|
|
return if ( $non_essential_value ); |
386
|
|
|
|
|
|
|
} |
387
|
|
|
|
|
|
|
|
388
|
0
|
0
|
|
|
|
|
return if ( _not_for_model( $field ) ); |
389
|
|
|
|
|
|
|
|
390
|
0
|
|
|
|
|
|
return [ $self->{__NAME__} ]; |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
sub output_foreign_tables_cdbi { |
394
|
0
|
|
|
0
|
|
|
my $self = shift; |
395
|
0
|
|
|
|
|
|
shift; |
396
|
0
|
|
|
|
|
|
my $data = shift; |
397
|
|
|
|
|
|
|
|
398
|
0
|
0
|
|
|
|
|
return unless ( ref( $self->{__BODY__} ) ); |
399
|
|
|
|
|
|
|
|
400
|
0
|
|
|
|
|
|
my $field = $data->{ $self->{__NAME__} }; |
401
|
|
|
|
|
|
|
|
402
|
0
|
0
|
|
|
|
|
if ( $field->{refers_to} ) { |
403
|
0
|
|
|
|
|
|
my $foreign_table_name = $field->{refers_to}{args}[0]; |
404
|
|
|
|
|
|
|
|
405
|
0
|
0
|
|
|
|
|
if ( ref( $foreign_table_name ) eq 'HASH' ) { |
406
|
0
|
|
|
|
|
|
( $foreign_table_name ) = %{ $foreign_table_name }; |
|
0
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
return [ |
410
|
0
|
|
|
|
|
|
[ column => $self->{__NAME__}, table => $foreign_table_name ] |
411
|
|
|
|
|
|
|
]; |
412
|
|
|
|
|
|
|
} |
413
|
0
|
|
|
|
|
|
return; |
414
|
|
|
|
|
|
|
} |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
1; |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
__END__ |