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