line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package |
2
|
|
|
|
|
|
|
Net::FileMaker::XML::ResultSet; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
13
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
6
|
1
|
|
|
1
|
|
63
|
use Net::FileMaker::XML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::FileMaker::XML::ResultSet |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This module handles the hash returned by the Net::FileMaker::XML search methods. |
15
|
|
|
|
|
|
|
Don't call this module directly, instead use L. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
my($class, %args) = @_; |
24
|
|
|
|
|
|
|
my @rows; |
25
|
|
|
|
|
|
|
my $self = { |
26
|
|
|
|
|
|
|
result_hash => $args{rs}, # complete result hash provided by Net::FileMaker::XML search methods |
27
|
|
|
|
|
|
|
db => $args{db}, # ref to the db, it is useful to add an $row->update method later |
28
|
|
|
|
|
|
|
fields_def => undef, # fields definition |
29
|
|
|
|
|
|
|
rows => \@rows, # resultset's rows |
30
|
|
|
|
|
|
|
next_index => 0, # index used by the "next" method |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
bless $self , $class; |
33
|
|
|
|
|
|
|
# let's begin the parsing |
34
|
|
|
|
|
|
|
$self->_parse; |
35
|
|
|
|
|
|
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 fields_definition |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Returns an hash with the fields' definition. See |
41
|
|
|
|
|
|
|
L. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub fields_definition |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
return $self->{fields_def}->fields; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 http_response |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Returns the http response for this call. Returns an L object. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=begin text |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# let's print the request url for debugging purposes |
60
|
|
|
|
|
|
|
print $rs->http_response->base; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=end text |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub http_response |
67
|
|
|
|
|
|
|
{ |
68
|
|
|
|
|
|
|
my $self = shift; |
69
|
|
|
|
|
|
|
return $self->{result_hash}{http_response}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 datasource |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Return an hash with useful information about the datasource. You don't need to |
75
|
|
|
|
|
|
|
use this information to parse the date, time or timestamp fields as it is |
76
|
|
|
|
|
|
|
already done by the C methods of each row returned by the I |
77
|
|
|
|
|
|
|
method. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
the hash contains: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over 4 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * database |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
database file name |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item * layout |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
kind of layout, eg. 'List |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * timestamp-format |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
eg. 'MM/dd/yyyy HH:mm:ss' |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item * date-format |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
eg. 'MM/dd/yyyy' |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * time-format |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
eg. 'HH:mm:ss' |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * table |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
name of the selected database table |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * total-count |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
total count of the records in the selected table |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub datasource |
117
|
|
|
|
|
|
|
{ |
118
|
|
|
|
|
|
|
my $self = shift; |
119
|
|
|
|
|
|
|
return $self->{result_hash}{datasource}; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 xmlns |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Returns the XML namespace of the response. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub xmlns |
129
|
|
|
|
|
|
|
{ |
130
|
|
|
|
|
|
|
my $self = shift; |
131
|
|
|
|
|
|
|
return $self->{result_hash}{xmlns}; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 version |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns the XML version of the response. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub version |
142
|
|
|
|
|
|
|
{ |
143
|
|
|
|
|
|
|
my $self = shift; |
144
|
|
|
|
|
|
|
return $self->{result_hash}{version}; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 product |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Returns an hash with information about the FileMaker Server. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub product |
154
|
|
|
|
|
|
|
{ |
155
|
|
|
|
|
|
|
my $self = shift; |
156
|
|
|
|
|
|
|
return { |
157
|
|
|
|
|
|
|
version => $self->{result_hash}{product}{'FileMaker Web Publishing Engine'}{version}, |
158
|
|
|
|
|
|
|
build => $self->{result_hash}{product}{'FileMaker Web Publishing Engine'}{build}, |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 total_count |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Returns an integer representing the total number of rows that match the research |
165
|
|
|
|
|
|
|
but B take into account the limit clause. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub total_count |
170
|
|
|
|
|
|
|
{ |
171
|
|
|
|
|
|
|
my $self = shift; |
172
|
|
|
|
|
|
|
return $self->{result_hash}{resultset}{count}; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 fetch_size |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Returns an integer representing the total number of rows of the resultset, but |
178
|
|
|
|
|
|
|
does take into account the limit clause. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub fetch_size |
183
|
|
|
|
|
|
|
{ |
184
|
|
|
|
|
|
|
my $self = shift; |
185
|
|
|
|
|
|
|
return $self->{result_hash}{resultset}{'fetch-size'}; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 rows |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Returns all the rows of the resultset as L |
192
|
|
|
|
|
|
|
objects. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub rows |
197
|
|
|
|
|
|
|
{ |
198
|
|
|
|
|
|
|
my $self = shift; |
199
|
|
|
|
|
|
|
return $self->{rows}; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 next_row |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Returns the next L if available, if not |
206
|
|
|
|
|
|
|
returns an undefined value. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=cut |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub next_row |
211
|
|
|
|
|
|
|
{ |
212
|
|
|
|
|
|
|
my $self = shift; |
213
|
|
|
|
|
|
|
# if next row exists let's return it, otherwise undefined |
214
|
|
|
|
|
|
|
if( $self->{next_index} < scalar @{$self->{rows}} ) |
215
|
|
|
|
|
|
|
{ |
216
|
|
|
|
|
|
|
my $index = $self->{next_index}; |
217
|
|
|
|
|
|
|
$self->{next_index}++; |
218
|
|
|
|
|
|
|
return @{$self->{rows}}[$index]; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
else |
221
|
|
|
|
|
|
|
{ |
222
|
|
|
|
|
|
|
return; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head2 reset_index |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Resets the index for the next method to the first value |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub reset_index |
234
|
|
|
|
|
|
|
{ |
235
|
|
|
|
|
|
|
my $self = shift; |
236
|
|
|
|
|
|
|
$self->{next_index} = 0; |
237
|
|
|
|
|
|
|
return; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# _parse |
242
|
|
|
|
|
|
|
# calls all the methods that parse the single blocks of the response |
243
|
|
|
|
|
|
|
sub _parse |
244
|
|
|
|
|
|
|
{ |
245
|
|
|
|
|
|
|
my $self = shift; |
246
|
|
|
|
|
|
|
# parse the resultset |
247
|
|
|
|
|
|
|
$self->_parse_field_definition; |
248
|
|
|
|
|
|
|
$self->_parse_rows; |
249
|
|
|
|
|
|
|
return; |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
# _parse_field_definition |
253
|
|
|
|
|
|
|
# parses the field definition instantiating a N::F::X::D::FieldDefinition |
254
|
|
|
|
|
|
|
sub _parse_field_definition |
255
|
|
|
|
|
|
|
{ |
256
|
|
|
|
|
|
|
my ($self) = @_; |
257
|
|
|
|
|
|
|
require Net::FileMaker::XML::ResultSet::FieldsDefinition; |
258
|
|
|
|
|
|
|
$self->{fields_def} = Net::FileMaker::XML::ResultSet::FieldsDefinition->new( |
259
|
|
|
|
|
|
|
$self->{result_hash}{metadata}{'field-definition'} |
260
|
|
|
|
|
|
|
); |
261
|
|
|
|
|
|
|
return; |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# _parse_rows |
265
|
|
|
|
|
|
|
sub _parse_rows |
266
|
|
|
|
|
|
|
{ |
267
|
|
|
|
|
|
|
my $self = shift; |
268
|
|
|
|
|
|
|
require Net::FileMaker::XML::ResultSet::Row; |
269
|
|
|
|
|
|
|
my $cd = $self->fields_definition; # column definition, I need it for the inflater |
270
|
|
|
|
|
|
|
my $ds = $self->datasource; |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
# If the fetch size is 1 it returns an hash with the row, if more it returns an array |
273
|
|
|
|
|
|
|
if($self->fetch_size == 1) |
274
|
|
|
|
|
|
|
{ |
275
|
|
|
|
|
|
|
push @{$self->{rows}} , Net::FileMaker::XML::ResultSet::Row->new( |
276
|
|
|
|
|
|
|
$self->{result_hash}{resultset}{record},$self |
277
|
|
|
|
|
|
|
); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
else |
280
|
|
|
|
|
|
|
{ |
281
|
|
|
|
|
|
|
for my $row (@{$self->{result_hash}{resultset}{record}}) |
282
|
|
|
|
|
|
|
{ |
283
|
|
|
|
|
|
|
push @{$self->{rows}} , Net::FileMaker::XML::ResultSet::Row->new($row,$self); |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
return; |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
1; |