line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::NewsML_G2::Writer::Event_Item; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
135
|
use Moose; |
|
18
|
|
|
|
|
45
|
|
|
18
|
|
|
|
|
154
|
|
4
|
18
|
|
|
18
|
|
117136
|
use Carp; |
|
18
|
|
|
|
|
46
|
|
|
18
|
|
|
|
|
1238
|
|
5
|
18
|
|
|
18
|
|
131
|
use namespace::autoclean; |
|
18
|
|
|
|
|
44
|
|
|
18
|
|
|
|
|
168
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'XML::NewsML_G2::Writer::Concept_Item'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'event_item', |
10
|
|
|
|
|
|
|
isa => 'XML::NewsML_G2::Event_Item', |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
required => 1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _build__root_item { |
15
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
16
|
2
|
|
|
|
|
54
|
return $self->event_item; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _create_id_element { |
20
|
2
|
|
|
2
|
|
25
|
my ($self) = @_; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
4
|
my $result = $self->create_element('conceptId'); |
23
|
2
|
|
|
|
|
47
|
$self->scheme_manager->add_qcode( $result, 'eventid', |
24
|
|
|
|
|
|
|
$self->event_item->event_id ); |
25
|
2
|
|
|
|
|
12
|
return $result; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _create_type_element { |
29
|
2
|
|
|
2
|
|
38
|
my ($self) = @_; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
5
|
my $result = $self->create_element( 'type', qcode => 'cpnat:event' ); |
32
|
2
|
|
|
|
|
12
|
return $result; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _create_location { |
36
|
2
|
|
|
2
|
|
4
|
my ($self) = @_; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
52
|
my $loc = $self->event_item->location; |
39
|
2
|
|
|
|
|
6
|
my $result = $self->create_element('location'); |
40
|
2
|
|
|
|
|
52
|
$result->appendChild( |
41
|
|
|
|
|
|
|
$self->create_element( 'name', _text => $loc->name ) ); |
42
|
2
|
50
|
33
|
|
|
5
|
if ( $loc->latitude && $loc->longitude ) { |
43
|
2
|
|
|
|
|
7
|
$result->appendChild( my $details = |
44
|
|
|
|
|
|
|
$self->create_element('POIDetails') ); |
45
|
2
|
|
|
|
|
6
|
$details->appendChild( |
46
|
|
|
|
|
|
|
$self->create_element( |
47
|
|
|
|
|
|
|
'position', |
48
|
|
|
|
|
|
|
latitude => $loc->latitude, |
49
|
|
|
|
|
|
|
longitude => $loc->longitude |
50
|
|
|
|
|
|
|
) |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
21
|
return $result; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _create_dates { |
58
|
2
|
|
|
2
|
|
3
|
my ($self) = @_; |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
14
|
my $result = $self->create_element('dates'); |
61
|
2
|
|
|
|
|
58
|
$result->appendChild( |
62
|
|
|
|
|
|
|
$self->create_element( |
63
|
|
|
|
|
|
|
'start', |
64
|
|
|
|
|
|
|
_text => $self->_formatter->format_datetime( |
65
|
|
|
|
|
|
|
$self->event_item->start |
66
|
|
|
|
|
|
|
) |
67
|
|
|
|
|
|
|
) |
68
|
|
|
|
|
|
|
); |
69
|
2
|
|
|
|
|
7
|
$result->appendChild( |
70
|
|
|
|
|
|
|
$self->create_element( |
71
|
|
|
|
|
|
|
'end', |
72
|
|
|
|
|
|
|
_text => |
73
|
|
|
|
|
|
|
$self->_formatter->format_datetime( $self->event_item->end ) |
74
|
|
|
|
|
|
|
) |
75
|
|
|
|
|
|
|
); |
76
|
2
|
|
|
|
|
5
|
return $result; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _create_coverage { |
80
|
1
|
|
|
1
|
|
5
|
my ($self) = @_; |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
5
|
my $result = $self->create_element('newsCoverageStatus'); |
83
|
1
|
|
|
|
|
114
|
$self->scheme_manager->add_qcode( $result, 'ncostat', 'int' ); |
84
|
1
|
|
|
|
|
27
|
my $coverage = join '/', $self->event_item->all_coverage; |
85
|
1
|
|
|
|
|
5
|
$result->appendChild( |
86
|
|
|
|
|
|
|
$self->create_element( 'name', _text => $coverage ) ); |
87
|
1
|
|
|
|
|
3
|
return $result; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _create_multilang_elements { |
91
|
4
|
|
|
4
|
|
10
|
my ( $self, $name, $text, %attrs ) = @_; |
92
|
4
|
|
|
|
|
5
|
my @result; |
93
|
4
|
|
|
|
|
100
|
push @result, |
94
|
|
|
|
|
|
|
$self->create_element( $name, _text => $text->text, %attrs ); |
95
|
4
|
|
|
|
|
137
|
foreach my $lang ( $text->languages ) { |
96
|
2
|
|
|
|
|
65
|
my $trans = $text->get_translation($lang); |
97
|
2
|
|
|
|
|
8
|
push @result, |
98
|
|
|
|
|
|
|
$self->create_element( |
99
|
|
|
|
|
|
|
$name, |
100
|
|
|
|
|
|
|
_text => $trans, |
101
|
|
|
|
|
|
|
'xml:lang' => $lang, |
102
|
|
|
|
|
|
|
%attrs |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
4
|
|
|
|
|
30
|
return @result; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _create_inner_content { |
110
|
2
|
|
|
2
|
|
41
|
my ( $self, $parent ) = @_; |
111
|
2
|
|
|
|
|
52
|
$parent->appendChild( $self->doc->createComment('event information') ); |
112
|
|
|
|
|
|
|
$parent->appendChild($_) |
113
|
2
|
|
|
|
|
55
|
foreach $self->_create_multilang_elements( 'name', |
114
|
|
|
|
|
|
|
$self->event_item->title ); |
115
|
|
|
|
|
|
|
|
116
|
2
|
100
|
|
|
|
31
|
if ( my $subtitle = $self->event_item->subtitle ) { |
117
|
|
|
|
|
|
|
$parent->appendChild($_) |
118
|
1
|
|
|
|
|
4
|
foreach $self->_create_multilang_elements( 'definition', |
119
|
|
|
|
|
|
|
$subtitle, role => 'definitionrole:short' ); |
120
|
|
|
|
|
|
|
} |
121
|
2
|
100
|
|
|
|
46
|
if ( my $summary = $self->event_item->summary ) { |
122
|
|
|
|
|
|
|
$parent->appendChild($_) |
123
|
1
|
|
|
|
|
4
|
foreach $self->_create_multilang_elements( 'definition', |
124
|
|
|
|
|
|
|
$summary, role => 'definitionrole:long' ); |
125
|
|
|
|
|
|
|
} |
126
|
2
|
|
|
|
|
15
|
$parent->appendChild( my $details = |
127
|
|
|
|
|
|
|
$self->create_element('eventDetails') ); |
128
|
2
|
|
|
|
|
6
|
$details->appendChild( $self->doc->createComment('dates') ); |
129
|
2
|
|
|
|
|
13
|
$details->appendChild( $self->_create_dates() ); |
130
|
2
|
100
|
|
|
|
40
|
if ( $self->event_item->has_coverage ) { |
131
|
1
|
|
|
|
|
33
|
$details->appendChild( $self->doc->createComment('coverage') ); |
132
|
1
|
|
|
|
|
90
|
$details->appendChild( $self->_create_coverage() ); |
133
|
|
|
|
|
|
|
} |
134
|
2
|
|
|
|
|
42
|
$details->appendChild( $self->doc->createComment('location') ); |
135
|
2
|
|
|
|
|
12
|
$details->appendChild( $self->_create_location() ); |
136
|
|
|
|
|
|
|
|
137
|
2
|
|
|
|
|
48
|
return; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__END__ |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 NAME |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
XML::NewsML_G2::Writer::Event_Item - create DOM tree conforming to |
149
|
|
|
|
|
|
|
NewsML-G2 for Event Concept Items |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=for test_synopsis |
152
|
|
|
|
|
|
|
my ($ei, $sm); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 SYNOPSIS |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
my $w = XML::NewsML_G2::Writer::Event_Item->new |
157
|
|
|
|
|
|
|
(event_item => $ei, scheme_manager => $sm); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $dom = $w->create_dom(); |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 DESCRIPTION |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This module implements the creation of a DOM tree conforming to |
164
|
|
|
|
|
|
|
NewsML-G2 for Event Concept Items. Depending on the version of the standard |
165
|
|
|
|
|
|
|
specified, a version-dependent role will be applied. For the API of |
166
|
|
|
|
|
|
|
this module, see the documentation of the superclass L<XML::NewsML_G2::Writer>. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=over 4 |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item event_item |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L<XML::NewsML_G2::Event_Item> instance used to create the output document |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=back |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 AUTHOR |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Christian Eder C<< <christian.eder@apa.at> >> |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Copyright (c) 2019, APA-IT. All rights reserved. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
See L<XML::NewsML_G2> for the license. |