line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::AutoCRUD::ConfigDomain; |
2
|
1
|
|
|
1
|
|
437
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
615
|
use Data::Domain 1.05 qw/:all/; |
|
1
|
|
|
|
|
25273
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub Config { |
9
|
1
|
|
|
1
|
0
|
3
|
Struct( |
10
|
|
|
|
|
|
|
app => Struct( |
11
|
|
|
|
|
|
|
name => String(-optional => 1), |
12
|
|
|
|
|
|
|
title => String(-optional => 1), |
13
|
|
|
|
|
|
|
default => Struct(-optional => 1), |
14
|
|
|
|
|
|
|
), |
15
|
|
|
|
|
|
|
datasources => Struct( |
16
|
|
|
|
|
|
|
-values => List(-min_size => 1, |
17
|
|
|
|
|
|
|
-all => DataSource()), |
18
|
|
|
|
|
|
|
) |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub DataSource { |
23
|
1
|
|
|
1
|
0
|
935
|
Struct ( |
24
|
|
|
|
|
|
|
dbh => Struct( |
25
|
|
|
|
|
|
|
connect => One_of( |
26
|
|
|
|
|
|
|
List(String(-name => "connect string"), |
27
|
|
|
|
|
|
|
String(-name => "connect username"), |
28
|
|
|
|
|
|
|
String(-name => "connect password"), |
29
|
|
|
|
|
|
|
Struct(-name => "connect options", -optional => 1)), |
30
|
|
|
|
|
|
|
Whatever(-does => 'CODE', -name => "coderef for connection"), |
31
|
|
|
|
|
|
|
String(-name => "eval code for connection"), |
32
|
|
|
|
|
|
|
), |
33
|
|
|
|
|
|
|
db_catalog => String(-optional => 1), |
34
|
|
|
|
|
|
|
db_schema => String(-optional => 1), |
35
|
|
|
|
|
|
|
), |
36
|
|
|
|
|
|
|
descr => String(-optional => 1), |
37
|
|
|
|
|
|
|
require => String(-optional => 1), |
38
|
|
|
|
|
|
|
schema_class => String(-optional => 1), |
39
|
|
|
|
|
|
|
tablegroups => List(-all => Tablegroup(), -optional => 1), |
40
|
|
|
|
|
|
|
tables => Struct(-values => List(-all => Table()), -optional => 1), |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub Tablegroup { |
45
|
1
|
|
|
1
|
0
|
837
|
Struct ( |
46
|
|
|
|
|
|
|
name => String, |
47
|
|
|
|
|
|
|
descr => String(-optional => 1), |
48
|
|
|
|
|
|
|
node => Node(-optional => 1), |
49
|
|
|
|
|
|
|
tables => List(-all => String, -min_size => 1), |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub Table { |
56
|
1
|
|
|
1
|
0
|
547
|
Struct ( |
57
|
|
|
|
|
|
|
descr => String(-optional => 1), |
58
|
|
|
|
|
|
|
colgroups => List( |
59
|
|
|
|
|
|
|
-optional => 1, |
60
|
|
|
|
|
|
|
-all => Struct( |
61
|
|
|
|
|
|
|
name => String, |
62
|
|
|
|
|
|
|
descr => String(-optional => 1), |
63
|
|
|
|
|
|
|
node => Node(-optional => 1), |
64
|
|
|
|
|
|
|
columns => List(-all => Struct( |
65
|
|
|
|
|
|
|
name => String, |
66
|
|
|
|
|
|
|
descr => String(-optional => 1), |
67
|
|
|
|
|
|
|
)) |
68
|
|
|
|
|
|
|
)), |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub Node { |
74
|
2
|
|
|
2
|
0
|
225
|
Enum(-values => [qw/open closed/], @_); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=encoding ISO-8859-1 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 NAME |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
App::AutoCRUD::ConfigDomain - checking configuration data |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SYNOPSIS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 Using the module |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
use App::AutoCRUD::ConfigDomain; |
92
|
|
|
|
|
|
|
use YAML qw/LoadFile Dump/; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $config = LoadFile $config_file; |
95
|
|
|
|
|
|
|
my $domain = App::AutoCRUD::ConfigDomain->Config(); |
96
|
|
|
|
|
|
|
my $errors = $domain->inspect($config); |
97
|
|
|
|
|
|
|
die Dump($errors) if $errors; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 Configuration example |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
TODO |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
app: |
104
|
|
|
|
|
|
|
# global settings for the application |
105
|
|
|
|
|
|
|
# maybe application name, stuff for the homepage, etc. |
106
|
|
|
|
|
|
|
name: Demo |
107
|
|
|
|
|
|
|
default: |
108
|
|
|
|
|
|
|
page_size : 50 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
datasources : |
111
|
|
|
|
|
|
|
DEVCI : |
112
|
|
|
|
|
|
|
dbh: |
113
|
|
|
|
|
|
|
connect: |
114
|
|
|
|
|
|
|
- "dbi:SQLite:dbname=D:/Temp/DEVCI_MINI_unicode.sqlite" |
115
|
|
|
|
|
|
|
- "" |
116
|
|
|
|
|
|
|
- "" |
117
|
|
|
|
|
|
|
- RaiseError: 1 |
118
|
|
|
|
|
|
|
sqlite_unicode: 1 |
119
|
|
|
|
|
|
|
structure: DM |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
DEVPJ : |
122
|
|
|
|
|
|
|
dbh: |
123
|
|
|
|
|
|
|
connect: |
124
|
|
|
|
|
|
|
- "dbi:SQLite:dbname=D:/Temp/DEVPJ_MINI_unicode.sqlite" |
125
|
|
|
|
|
|
|
- "" |
126
|
|
|
|
|
|
|
- "" |
127
|
|
|
|
|
|
|
- RaiseError: 1 |
128
|
|
|
|
|
|
|
sqlite_unicode: 1 |
129
|
|
|
|
|
|
|
structure: DM |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 DESCRIPTION |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This package builds a L<Data::Domain> for checking configuration data. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The L<App::AutoCRUD> application uses this domain at startup time |
139
|
|
|
|
|
|
|
to check if the configuration is correct. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 DATASTRUCTURE |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
<config> : { |
144
|
|
|
|
|
|
|
app => <app>, |
145
|
|
|
|
|
|
|
datasources => [ <datasource>+ ] |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
<app> : { |
150
|
|
|
|
|
|
|
name => <string>, |
151
|
|
|
|
|
|
|
title => <string>, |
152
|
|
|
|
|
|
|
default => <hashref>, |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
<datasource> : { |
156
|
|
|
|
|
|
|
dbh => { |
157
|
|
|
|
|
|
|
connect => ( [ <string>, <string>, <string>, <hashref>? ] |
158
|
|
|
|
|
|
|
| <coderef> ), |
159
|
|
|
|
|
|
|
db_catalog => <string>, |
160
|
|
|
|
|
|
|
db_schema => <string>, |
161
|
|
|
|
|
|
|
}, |
162
|
|
|
|
|
|
|
descr => <string>, |
163
|
|
|
|
|
|
|
require => <string>, |
164
|
|
|
|
|
|
|
schema_class => <string>, |
165
|
|
|
|
|
|
|
tablegroups => [ <tablegroup>+ ], |
166
|
|
|
|
|
|
|
tables => [ <table>+ ], |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 CONFIGURATION SECTIONS |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 app |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Basic information about the application : |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item name |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Short name (will be displayed in most pages). |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item title |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Long name (will be displayed in home page). |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item default |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Hashref of various default values that may be used by inner modules. |
188
|
|
|
|
|
|
|
Currently there is only one example : C<page_size>, used by |
189
|
|
|
|
|
|
|
L<App::AutoCRUD::Controller::Table> to decide how many |
190
|
|
|
|
|
|
|
records per page will be displayed. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=back |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 datasources |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
datasources : |
197
|
|
|
|
|
|
|
Chinook : |
198
|
|
|
|
|
|
|
dbh: |
199
|
|
|
|
|
|
|
connect: |
200
|
|
|
|
|
|
|
- "dbi:SQLite:dbname=/path/to/Chinook_Sqlite_AutoIncrementPKs.sqlite" |
201
|
|
|
|
|
|
|
- "" # username |
202
|
|
|
|
|
|
|
- "" # password |
203
|
|
|
|
|
|
|
- RaiseError: 1 # DBI options |
204
|
|
|
|
|
|
|
sqlite_unicode: 1 |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
A hashref describing the various databases served by this application. |
208
|
|
|
|
|
|
|
Each key in the hashref is a short name for accessing the corresponding |
209
|
|
|
|
|
|
|
datasource; that name will be part of URLs. Each value is a hashref |
210
|
|
|
|
|
|
|
with the following keys : |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=over |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item dbh |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
A hashref containing instructions for connecting to the database. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
The main key is C<connect>, which contains a list of arguments |
219
|
|
|
|
|
|
|
to L<DBI/connect>, i.e. a connection string, username, password, |
220
|
|
|
|
|
|
|
and possibly a hashref of additional options. Alternatively, C<connect> |
221
|
|
|
|
|
|
|
could also contain a coderef, or even just a string of Perl code, |
222
|
|
|
|
|
|
|
which will be C<eval>ed to get the connection. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Optional keys C<db_catalog> and C<db_schema> may specify the values to |
225
|
|
|
|
|
|
|
be passed to L<DBI/table_info>, L<DBI/column_info>, etc. This will be |
226
|
|
|
|
|
|
|
necessary if your database contains several catalogs and/or schemata. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item descr |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
A string for describing the database; this will be displayed on the |
231
|
|
|
|
|
|
|
home page. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item require |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
The name of a Perl module to load before accessing this datasource |
236
|
|
|
|
|
|
|
(optional). |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item schema_class |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
The name of the L<DBIx::DataModel::Schema> subclass for this datasource. |
241
|
|
|
|
|
|
|
This is optional, and defaults to the value of C<require>; if none is |
242
|
|
|
|
|
|
|
supplied, the class will be constructed dynamically. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=item tablegroups |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
tablegroups : |
247
|
|
|
|
|
|
|
- name: Music |
248
|
|
|
|
|
|
|
descr: Tables describing music content |
249
|
|
|
|
|
|
|
node: open |
250
|
|
|
|
|
|
|
tables : |
251
|
|
|
|
|
|
|
- Artist |
252
|
|
|
|
|
|
|
- Album |
253
|
|
|
|
|
|
|
- Track |
254
|
|
|
|
|
|
|
- name: Reference |
255
|
|
|
|
|
|
|
descr: Lists of codes |
256
|
|
|
|
|
|
|
node: closed |
257
|
|
|
|
|
|
|
tables : |
258
|
|
|
|
|
|
|
- MediaType |
259
|
|
|
|
|
|
|
- Genre |
260
|
|
|
|
|
|
|
... |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Datastructure for organising how database tables will be presented. |
263
|
|
|
|
|
|
|
In absence of groups, the default presentation is alphabetical order, |
264
|
|
|
|
|
|
|
which is good enough for small databases, but is no longer appropriate |
265
|
|
|
|
|
|
|
when the number of tables becomes large. I<Tablegroups> is a list of |
266
|
|
|
|
|
|
|
subsets of tables; each group may contain : |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=over |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=item name |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Short name for this group |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=item descr |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
Longer description for this group |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=item node |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Either C<open> or C<closed>, depending on how you want this group |
281
|
|
|
|
|
|
|
to be presented in the home page. By default groups are C<open>, which |
282
|
|
|
|
|
|
|
means that the list of tables within the group is immediately visible. |
283
|
|
|
|
|
|
|
The choice C<closed> is more appropriate for tables which contain technical |
284
|
|
|
|
|
|
|
information and are not immediately useful to the user. |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=item tables |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
The ordered list of tables within this group. |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=back |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=back |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
|