| 1 | package XML::NewsML_G2::Writer::News_Item; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 21 | ▶ | use Scalar::Util qw(looks_like_number); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 21 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 21 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 21 | extends 'XML::NewsML_G2::Writer::Substancial_Item'; | |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | 21 | has 'news_item', | |||||||||||||||||||||||||||||||||
| 10 | isa => 'XML::NewsML_G2::News_Item', | ||||||||||||||||||||||||||||||||||
| 11 | is => 'ro', | ||||||||||||||||||||||||||||||||||
| 12 | required => 1; | ||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | 64 | ▶ | sub _build__root_item { | ||||||||||||||||||||||||||||||||
|
Subroutine
_build__root_item: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 64 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 16 | 64 | return $self->news_item; | |||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 57 | ▶ | sub _create_rights_info { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_rights_info: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||
| 20 | 57 | my ( $self, $root ) = @_; | |||||||||||||||||||||||||||||||||
| 21 | 57 | ▶ | return unless $self->news_item->copyright_holder; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | 48 | my $ri = $self->create_element('rightsInfo'); | |||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||
| 25 | 48 | $ri->appendChild( | |||||||||||||||||||||||||||||||||
| 26 | my $crh = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 27 | 'copyrightHolder', | ||||||||||||||||||||||||||||||||||
| 28 | _name_text => $self->news_item->copyright_holder | ||||||||||||||||||||||||||||||||||
| 29 | ) | ||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||
| 31 | 48 | ▶ | $crh->setAttribute( 'uri', $self->news_item->copyright_holder->uri ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 32 | if $self->news_item->copyright_holder->uri; | ||||||||||||||||||||||||||||||||||
| 33 | 48 | ▶ | if ( my $qcode = $self->news_item->copyright_holder->qcode ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 34 | 48 | $self->scheme_manager->add_qcode_or_literal( $crh, | |||||||||||||||||||||||||||||||||
| 35 | 'copyright_holder', $qcode ); | ||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||
| 38 | 48 | $self->_create_copyright_holder_remoteinfo($crh); | |||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | 48 | my $notice = $self->news_item->copyright_holder->notice; | |||||||||||||||||||||||||||||||||
| 41 | 48 | ▶ | $ri->appendChild( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 42 | $self->create_element( 'copyrightNotice', _text => $notice ) ) | ||||||||||||||||||||||||||||||||||
| 43 | if $notice; | ||||||||||||||||||||||||||||||||||
| 44 | 48 | ▶ | $ri->appendChild( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 45 | $self->create_element( | ||||||||||||||||||||||||||||||||||
| 46 | 'usageTerms', _text => $self->news_item->usage_terms | ||||||||||||||||||||||||||||||||||
| 47 | ) | ||||||||||||||||||||||||||||||||||
| 48 | ) if $self->news_item->usage_terms; | ||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | 48 | $root->appendChild($ri); | |||||||||||||||||||||||||||||||||
| 51 | 48 | return; | |||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | 188 | ▶ | sub _create_hierarchy { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_hierarchy: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | # my ($self, $node, $schema) = @_; | ||||||||||||||||||||||||||||||||||
| 57 | # code moved to Writer_2_9 | ||||||||||||||||||||||||||||||||||
| 58 | 188 | return; | |||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | 55 | ▶ | sub _create_icon { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_icon: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | #overwrite me | ||||||||||||||||||||||||||||||||||
| 64 | 55 | return; | |||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | 64 | ▶ | sub _create_subjects_desk { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_subjects_desk: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 68 | 64 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 69 | 64 | my @res; | |||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | 64 | ▶ | push @res, $self->doc->createComment('desks') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 72 | if $self->news_item->has_desks; | ||||||||||||||||||||||||||||||||||
| 73 | 0 | foreach ( sort { $a->qcode cmp $b->qcode } @{ $self->news_item->desks } ) | |||||||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||||||||
| 75 | 53 | push @res, | |||||||||||||||||||||||||||||||||
| 76 | my $s = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 77 | 'subject', | ||||||||||||||||||||||||||||||||||
| 78 | type => 'cpnat:abstract', | ||||||||||||||||||||||||||||||||||
| 79 | _name_text => $_ | ||||||||||||||||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||||||||||||||||
| 81 | 53 | $self->scheme_manager->add_qcode_or_literal( $s, 'desk', $_->qcode ); | |||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||
| 83 | 64 | return @res; | |||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||
| 86 | 64 | ▶ | sub _create_subjects_storytypes { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_subjects_storytypes: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||
| 87 | 64 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 88 | 64 | my @res; | |||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | push @res, $self->doc->createComment('storytypes') | ||||||||||||||||||||||||||||||||||
| 91 | 64 | ▶ | if ( @{ $self->news_item->storytypes } ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||
| 93 | 0 | foreach ( sort { $a->qcode cmp $b->qcode } | |||||||||||||||||||||||||||||||||
| 94 | 64 | @{ $self->news_item->storytypes } ) { | |||||||||||||||||||||||||||||||||
| 95 | 0 | push @res, | |||||||||||||||||||||||||||||||||
| 96 | my $s = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 97 | 'subject', | ||||||||||||||||||||||||||||||||||
| 98 | type => 'cpnat:abstract', | ||||||||||||||||||||||||||||||||||
| 99 | _name_text => $_ | ||||||||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->scheme_manager->add_qcode_or_literal( $s, 'storytype', | |||||||||||||||||||||||||||||||||
| 102 | $_->qcode ); | ||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||
| 104 | 64 | return @res; | |||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | 159 | ▶ | sub _sort_subjects_locations { | ||||||||||||||||||||||||||||||||
|
Subroutine
_sort_subjects_locations: called CC=9 SCAR=35.5
| |||||||||||||||||||||||||||||||||||
| 108 | 159 | ▶ | if ( looks_like_number($a) && looks_like_number($b) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&looks_like_number($a) and &looks_like_number($b)
MC/DC0%0/2
&looks_like_number($a) and &looks_like_number($b)
&looks_like_number($a)
&looks_like_number($b)
Truth table33%1/3
A and B
A= &looks_like_number($a)B= &looks_like_number($b)
| |||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return ( $b->relevance // 0 ) <=> ( $a->relevance // 0 ) | ||||||||||||||||||||||||||||||||
|
Condition0%0/7
($b->relevance // 0) <=> ($a->relevance // 0) || $a->qcode <=> $b->qcode
$b->relevance // 0
$a->relevance // 0
MC/DC0%0/2
($b->relevance // 0) <=> ($a->relevance // 0) || $a->qcode <=> $b->qcode
$b->relevance
$a->qcode <=> $b->qcode
MC/DC0%0/1
$a->relevance // 0
$a->relevance
Truth table0%0/3
A || B
A= $b->relevanceB= $a->qcode <=> $b->qcode
Truth table0%0/2
A
A= $a->relevance
| |||||||||||||||||||||||||||||||||||
| 110 | || $a->qcode <=> $b->qcode; | ||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||
| 112 | else { | ||||||||||||||||||||||||||||||||||
| 113 | 159 | ▶ | return ( $b->relevance // 0 ) <=> ( $a->relevance // 0 ) | ||||||||||||||||||||||||||||||||
|
Condition42%3/7
($b->relevance // 0) <=> ($a->relevance // 0) || $a->qcode cmp $b->qcode
$b->relevance // 0
$a->relevance // 0
MC/DC0%0/2
($b->relevance // 0) <=> ($a->relevance // 0) || $a->qcode cmp $b->qcode
$b->relevance
$a->qcode cmp $b->qcode
MC/DC0%0/1
$a->relevance // 0
$a->relevance
Truth table33%1/3
A || B
A= $b->relevanceB= $a->qcode cmp $b->qcode
Truth table50%1/2
A
A= $a->relevance
| |||||||||||||||||||||||||||||||||||
| 114 | || $a->qcode cmp $b->qcode; | ||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||
| 118 | 60 | ▶ | sub _create_subjects_location { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_subjects_location: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||
| 119 | 60 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 120 | 60 | my @res; | |||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||
| 122 | 60 | ▶ | push @res, $self->doc->createComment('locations') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 123 | if $self->news_item->has_locations; | ||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||
| 125 | 60 | foreach my $l ( | |||||||||||||||||||||||||||||||||
| 126 | 60 | sort _sort_subjects_locations values %{ $self->news_item->locations } | |||||||||||||||||||||||||||||||||
| 127 | ) { | ||||||||||||||||||||||||||||||||||
| 128 | 159 | ▶ | my $why = $l->direct ? 'why:direct' : 'why:ancestor'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 129 | 159 | push @res, | |||||||||||||||||||||||||||||||||
| 130 | my $s = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 131 | 'subject', | ||||||||||||||||||||||||||||||||||
| 132 | type => 'cpnat:geoArea', | ||||||||||||||||||||||||||||||||||
| 133 | why => $why, | ||||||||||||||||||||||||||||||||||
| 134 | _name_text => $l | ||||||||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||||||||
| 136 | 159 | ▶ | $s->setAttribute( 'relevance', $l->relevance ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 137 | if defined $l->relevance; | ||||||||||||||||||||||||||||||||||
| 138 | 159 | $self->scheme_manager->add_qcode_or_literal( $s, 'geo', $l->qcode ); | |||||||||||||||||||||||||||||||||
| 139 | 159 | ▶ | if ( $l->iso_code ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 140 | 53 | $s->appendChild( my $sa = $self->create_element('sameAs') ); | |||||||||||||||||||||||||||||||||
| 141 | 53 | $self->scheme_manager->add_qcode_or_literal( $sa, 'iso3166_1a2', | |||||||||||||||||||||||||||||||||
| 142 | $l->iso_code ); | ||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||
| 144 | 159 | ▶ | if ( $l->parent ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 145 | 106 | $s->appendChild( my $b = $self->create_element('broader') ); | |||||||||||||||||||||||||||||||||
| 146 | 106 | $self->scheme_manager->add_qcode_or_literal( $b, 'geo', | |||||||||||||||||||||||||||||||||
| 147 | $l->parent->qcode ); | ||||||||||||||||||||||||||||||||||
| 148 | 106 | my $hierarchy = $self->_create_hierarchy( $l, 'geo' ); | |||||||||||||||||||||||||||||||||
| 149 | 106 | ▶ | $b->appendChild($hierarchy) if $hierarchy; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||
| 152 | 60 | return @res; | |||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||
| 155 | 60 | ▶ | sub _create_subjects_organisation { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_subjects_organisation: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 156 | 60 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 157 | 60 | my @res; | |||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||
| 159 | 60 | ▶ | push @res, $self->doc->createComment('organisations') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 160 | if $self->news_item->has_organisations; | ||||||||||||||||||||||||||||||||||
| 161 | 60 | foreach my $org ( @{ $self->news_item->organisations } ) { | |||||||||||||||||||||||||||||||||
| 162 | 56 | push @res, | |||||||||||||||||||||||||||||||||
| 163 | my $o = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 164 | 'subject', | ||||||||||||||||||||||||||||||||||
| 165 | type => 'cpnat:organisation', | ||||||||||||||||||||||||||||||||||
| 166 | _name_text => $org | ||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||
| 168 | 56 | $self->scheme_manager->add_qcode_or_literal( $o, 'org', $org->qcode ); | |||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||
| 170 | 60 | return @res; | |||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||
| 173 | 60 | ▶ | sub _create_subjects_topic { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_subjects_topic: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 174 | 60 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 175 | 60 | my @res; | |||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||
| 177 | 60 | ▶ | push @res, $self->doc->createComment('topics') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 178 | if $self->news_item->has_topics; | ||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||
| 180 | 60 | foreach my $topic ( @{ $self->news_item->topics } ) { | |||||||||||||||||||||||||||||||||
| 181 | 53 | push @res, | |||||||||||||||||||||||||||||||||
| 182 | my $t = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 183 | 'subject', | ||||||||||||||||||||||||||||||||||
| 184 | type => 'cpnat:abstract', | ||||||||||||||||||||||||||||||||||
| 185 | _name_text => $topic | ||||||||||||||||||||||||||||||||||
| 186 | ); | ||||||||||||||||||||||||||||||||||
| 187 | 53 | $self->scheme_manager->add_qcode_or_literal( $t, 'topic', | |||||||||||||||||||||||||||||||||
| 188 | $topic->qcode ); | ||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||
| 191 | 60 | return @res; | |||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||
| 194 | 60 | ▶ | sub _create_subjects_product { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_subjects_product: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||
| 195 | 60 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 196 | 60 | my @res; | |||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||
| 198 | 60 | ▶ | push @res, $self->doc->createComment('products') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 199 | if $self->news_item->has_products; | ||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||
| 201 | 60 | foreach my $product ( @{ $self->news_item->products } ) { | |||||||||||||||||||||||||||||||||
| 202 | 53 | push @res, | |||||||||||||||||||||||||||||||||
| 203 | my $p = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 204 | 'subject', | ||||||||||||||||||||||||||||||||||
| 205 | type => 'cpnat:object', | ||||||||||||||||||||||||||||||||||
| 206 | _name_text => $product | ||||||||||||||||||||||||||||||||||
| 207 | ); | ||||||||||||||||||||||||||||||||||
| 208 | 53 | ▶ | if ( $product->isbn ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 209 | 53 | $self->scheme_manager->add_qcode_or_literal( $p, 'isbn', | |||||||||||||||||||||||||||||||||
| 210 | $product->isbn ); | ||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||
| 212 | elsif ( $product->ean ) { | ||||||||||||||||||||||||||||||||||
| 213 | 0 | $self->scheme_manager->add_qcode_or_literal( $p, 'ean', | |||||||||||||||||||||||||||||||||
| 214 | $product->ean ); | ||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||
| 218 | 60 | return @res; | |||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||
| 221 | 64 | ▶ | sub _create_subjects_event_refs { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_subjects_event_refs: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 222 | 64 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||
| 224 | 64 | my @res; | |||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||
| 226 | 64 | ▶ | push @res, $self->doc->createComment('events') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 227 | if $self->news_item->has_event_references; | ||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | 64 | foreach my $event_ref ( @{ $self->news_item->event_references } ) { | |||||||||||||||||||||||||||||||||
| 230 | 1 | push @res, | |||||||||||||||||||||||||||||||||
| 231 | my $p = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 232 | 'subject', | ||||||||||||||||||||||||||||||||||
| 233 | type => 'cpnat:event', | ||||||||||||||||||||||||||||||||||
| 234 | _name_text => $event_ref->name | ||||||||||||||||||||||||||||||||||
| 235 | ); | ||||||||||||||||||||||||||||||||||
| 236 | 1 | $self->scheme_manager->add_qcode_or_literal( $p, 'eventid', | |||||||||||||||||||||||||||||||||
| 237 | $event_ref->event_id ); | ||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||
| 239 | 64 | return @res; | |||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||
| 242 | 64 | ▶ | sub _create_subjects { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_subjects: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 243 | 64 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 244 | 64 | my @res; | |||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||
| 246 | 64 | push @res, $self->_create_subjects_storytypes(); | |||||||||||||||||||||||||||||||||
| 247 | 64 | push @res, $self->_create_subjects_desk(); | |||||||||||||||||||||||||||||||||
| 248 | 64 | push @res, $self->_create_subjects_event_refs(); | |||||||||||||||||||||||||||||||||
| 249 | 64 | push @res, $self->_create_subjects_media_topic(); | |||||||||||||||||||||||||||||||||
| 250 | 64 | ▶ | push @res, $self->_create_subjects_concepts() | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 251 | if ( $self->news_item->has_concepts ); | ||||||||||||||||||||||||||||||||||
| 252 | 60 | push @res, $self->_create_subjects_location(); | |||||||||||||||||||||||||||||||||
| 253 | 60 | push @res, $self->_create_subjects_organisation(); | |||||||||||||||||||||||||||||||||
| 254 | 60 | push @res, $self->_create_subjects_topic(); | |||||||||||||||||||||||||||||||||
| 255 | 60 | push @res, $self->_create_subjects_product(); | |||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||
| 257 | 60 | return @res; | |||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||
| 260 | 50 | ▶ | sub _create_company_data { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_company_data: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||
| 261 | 50 | my ( $self, $org, $root ) = @_; | |||||||||||||||||||||||||||||||||
| 262 | 50 | ▶ | return unless ( $self->scheme_manager->crel ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||
| 264 | 38 | my $crel_alias = $self->scheme_manager->crel->alias; | |||||||||||||||||||||||||||||||||
| 265 | $root->appendChild( | ||||||||||||||||||||||||||||||||||
| 266 | $self->create_element( | ||||||||||||||||||||||||||||||||||
| 267 | 'related', | ||||||||||||||||||||||||||||||||||
| 268 | rel => "$crel_alias:index", | ||||||||||||||||||||||||||||||||||
| 269 | _name_text => $_ | ||||||||||||||||||||||||||||||||||
| 270 | ) | ||||||||||||||||||||||||||||||||||
| 271 | 38 | ) foreach ( @{ $org->indices } ); | |||||||||||||||||||||||||||||||||
| 272 | $root->appendChild( | ||||||||||||||||||||||||||||||||||
| 273 | $self->create_element( | ||||||||||||||||||||||||||||||||||
| 274 | 'related', | ||||||||||||||||||||||||||||||||||
| 275 | rel => "$crel_alias:exchange", | ||||||||||||||||||||||||||||||||||
| 276 | _name_text => $_ | ||||||||||||||||||||||||||||||||||
| 277 | ) | ||||||||||||||||||||||||||||||||||
| 278 | 38 | ) foreach ( @{ $org->stock_exchanges } ); | |||||||||||||||||||||||||||||||||
| 279 | 38 | return; | |||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||
| 282 | 60 | ▶ | sub _create_asserts_organisation { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_asserts_organisation: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 283 | 60 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||
| 285 | 60 | my @res; | |||||||||||||||||||||||||||||||||
| 286 | 60 | ▶ | push @res, $self->doc->createComment('organisations') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 287 | if $self->news_item->has_organisations; | ||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||
| 289 | 60 | foreach my $org ( @{ $self->news_item->organisations } ) { | |||||||||||||||||||||||||||||||||
| 290 | 56 | push @res, | |||||||||||||||||||||||||||||||||
| 291 | my $a = $self->create_element( 'assert', _name_text => $org ); | ||||||||||||||||||||||||||||||||||
| 292 | 56 | $self->scheme_manager->add_qcode_or_literal( $a, 'org', $org->qcode ); | |||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||
| 294 | 56 | foreach ( @{ $org->isins } ) { | |||||||||||||||||||||||||||||||||
| 295 | 53 | $a->appendChild( my $sa = $self->create_element('sameAs') ); | |||||||||||||||||||||||||||||||||
| 296 | 53 | $self->scheme_manager->add_qcode_or_literal( $sa, 'isin', $_ ); | |||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||
| 298 | 56 | ▶ | if ( $org->has_websites ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 299 | 56 | $a->appendChild( my $od = | |||||||||||||||||||||||||||||||||
| 300 | $self->create_element('organisationDetails') ); | ||||||||||||||||||||||||||||||||||
| 301 | 56 | $od->appendChild( my $ci = $self->create_element('contactInfo') ); | |||||||||||||||||||||||||||||||||
| 302 | $ci->appendChild( $self->create_element( 'web', _text => $_ ) ) | ||||||||||||||||||||||||||||||||||
| 303 | 56 | foreach @{ $org->websites }; | |||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||
| 305 | 56 | $self->_create_company_data( $org, $a ); | |||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||
| 307 | 60 | return @res; | |||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||
| 310 | 60 | ▶ | sub _create_asserts_location { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_asserts_location: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||
| 311 | 60 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 312 | 60 | my @res; | |||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||
| 314 | 60 | foreach my $loc_k ( sort keys %{ $self->news_item->locations } ) { | |||||||||||||||||||||||||||||||||
| 315 | 159 | my $location = $self->news_item->locations->{$loc_k}; | |||||||||||||||||||||||||||||||||
| 316 | next | ||||||||||||||||||||||||||||||||||
| 317 | 159 | ▶ | unless ( defined $location->longitude | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $location->longitude and defined $location->latitude
MC/DC50%1/2
defined $location->longitude and defined $location->latitude
defined $location->longitude
defined $location->latitude
Truth table66%2/3
A and B
A= defined $location->longitudeB= defined $location->latitude
| |||||||||||||||||||||||||||||||||||
| 318 | && defined $location->latitude ); | ||||||||||||||||||||||||||||||||||
| 319 | 53 | push @res, my $l = $self->create_element('assert'); | |||||||||||||||||||||||||||||||||
| 320 | 53 | $self->scheme_manager->add_qcode_or_literal( $l, 'geo', | |||||||||||||||||||||||||||||||||
| 321 | $location->qcode ); | ||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||
| 323 | 53 | $l->appendChild( my $geo_area_details = | |||||||||||||||||||||||||||||||||
| 324 | $self->create_element('geoAreaDetails') ); | ||||||||||||||||||||||||||||||||||
| 325 | 53 | $geo_area_details->appendChild( my $pos = | |||||||||||||||||||||||||||||||||
| 326 | $self->create_element('position') ); | ||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||
| 328 | 53 | $pos->setAttribute( $_, $location->$_ ) for qw/latitude longitude/; | |||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||
| 331 | 60 | return @res; | |||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||
| 334 | 60 | ▶ | sub _create_asserts { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_asserts: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 335 | 60 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 336 | 60 | my @res; | |||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||
| 338 | 60 | push @res, $self->_create_asserts_organisation(); | |||||||||||||||||||||||||||||||||
| 339 | 60 | push @res, $self->_create_asserts_location(); | |||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||
| 341 | 60 | return @res; | |||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||
| 344 | 57 | ▶ | sub _create_infosources { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_infosources: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 345 | 57 | my ( $self, $root ) = @_; | |||||||||||||||||||||||||||||||||
| 346 | 57 | foreach ( @{ $self->news_item->sources } ) { | |||||||||||||||||||||||||||||||||
| 347 | 94 | ▶ | next if $_ eq uc $self->news_item->provider->qcode; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 348 | 47 | $root->appendChild( my $i = | |||||||||||||||||||||||||||||||||
| 349 | $self->create_element( 'infoSource', _name_text => $_ ) ); | ||||||||||||||||||||||||||||||||||
| 350 | 47 | $self->scheme_manager->add_role( $i, 'isrol', 'originfo' ); | |||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||
| 352 | 57 | return; | |||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||
| 355 | 64 | ▶ | sub _create_authors { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_authors: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 356 | 64 | my ( $self, $root ) = @_; | |||||||||||||||||||||||||||||||||
| 357 | 64 | foreach ( @{ $self->news_item->authors } ) { | |||||||||||||||||||||||||||||||||
| 358 | 211 | $root->appendChild( $self->_create_creator($_) ); | |||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||
| 360 | 64 | return; | |||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||
| 363 | 64 | ▶ | sub _create_content_meta { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_content_meta: called CC=20 SCAR=31.7
| |||||||||||||||||||||||||||||||||||
| 364 | 64 | my ( $self, $root ) = @_; | |||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||
| 366 | 64 | my $cm = $self->create_element('contentMeta'); | |||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||
| 368 | 64 | $self->_create_icon($cm); | |||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||
| 370 | 64 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 371 | $self->create_element( | ||||||||||||||||||||||||||||||||||
| 372 | 'urgency', _text => $self->news_item->priority | ||||||||||||||||||||||||||||||||||
| 373 | ) | ||||||||||||||||||||||||||||||||||
| 374 | ); | ||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||
| 376 | 64 | ▶ | if ( $self->news_item->content_created ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 377 | 64 | my $t = | |||||||||||||||||||||||||||||||||
| 378 | $self->_formatter->format_datetime( | ||||||||||||||||||||||||||||||||||
| 379 | $self->news_item->content_created ); | ||||||||||||||||||||||||||||||||||
| 380 | 64 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 381 | $self->create_element( 'contentCreated', _text => $t ) ); | ||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||
| 383 | 64 | ▶ | if ( $self->news_item->content_modified | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->news_item->content_modified and $self->news_item->content_created != $self->news_item->content_modified
MC/DC50%1/2
$self->news_item->content_modified and $self->news_item->content_created != $self->news_item->content_modified
$self->news_item->content_modified
$self->news_item->content_created != $self->news_item->content_modified
Truth table66%2/3
A and B
A= $self->news_item->content_modifiedB= $self->news_item->content_created != $self->news_item->content_modified
| |||||||||||||||||||||||||||||||||||
| 384 | and $self->news_item->content_created != | ||||||||||||||||||||||||||||||||||
| 385 | $self->news_item->content_modified ) { | ||||||||||||||||||||||||||||||||||
| 386 | 53 | my $t = | |||||||||||||||||||||||||||||||||
| 387 | $self->_formatter->format_datetime( | ||||||||||||||||||||||||||||||||||
| 388 | $self->news_item->content_modified ); | ||||||||||||||||||||||||||||||||||
| 389 | 53 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 390 | $self->create_element( 'contentModified', _text => $t ) ); | ||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||
| 393 | 64 | foreach ( @{ $self->news_item->cities } ) { | |||||||||||||||||||||||||||||||||
| 394 | 53 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 395 | $self->create_element( 'located', _name_text => $_ ) ); | ||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||
| 398 | 64 | ▶ | if ( my $electiondistrict = $self->news_item->electiondistrict ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 399 | 0 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 400 | my $ed = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 401 | 'located', _text => $electiondistrict->name | ||||||||||||||||||||||||||||||||||
| 402 | ) | ||||||||||||||||||||||||||||||||||
| 403 | ); | ||||||||||||||||||||||||||||||||||
| 404 | 0 | $self->scheme_manager->add_qcode( $ed, 'electiondistrict', | |||||||||||||||||||||||||||||||||
| 405 | $electiondistrict->qcode ); | ||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if ( my $electionprovince = $electiondistrict->province ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 408 | 0 | my $ep = $self->create_element( 'located', | |||||||||||||||||||||||||||||||||
| 409 | _text => $electionprovince->name ); | ||||||||||||||||||||||||||||||||||
| 410 | 0 | $self->scheme_manager->add_qcode( $ep, 'electionprovince', | |||||||||||||||||||||||||||||||||
| 411 | $electionprovince->qcode ); | ||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||
| 413 | 0 | $ed->appendChild($ep); | |||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||
| 417 | 64 | $self->_create_infosources($cm); | |||||||||||||||||||||||||||||||||
| 418 | 64 | $self->_create_authors($cm); | |||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||
| 420 | 64 | ▶ | if ( $self->news_item->message_id ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 421 | 59 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 422 | $self->create_element( | ||||||||||||||||||||||||||||||||||
| 423 | 'altId', _text => $self->news_item->message_id | ||||||||||||||||||||||||||||||||||
| 424 | ) | ||||||||||||||||||||||||||||||||||
| 425 | ); | ||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||
| 428 | 64 | ▶ | if ( $self->news_item->byline ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 429 | 0 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 430 | $self->create_element( 'by', _text => $self->news_item->byline ) | ||||||||||||||||||||||||||||||||||
| 431 | ); | ||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||
| 434 | 64 | ▶ | if ( $self->news_item->dateline ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 435 | 0 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 436 | $self->create_element( | ||||||||||||||||||||||||||||||||||
| 437 | 'dateline', _text => $self->news_item->dateline | ||||||||||||||||||||||||||||||||||
| 438 | ) | ||||||||||||||||||||||||||||||||||
| 439 | ); | ||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||
| 442 | $cm->appendChild( | ||||||||||||||||||||||||||||||||||
| 443 | 64 | $self->create_element( | |||||||||||||||||||||||||||||||||
| 444 | 'language', tag => $self->news_item->language | ||||||||||||||||||||||||||||||||||
| 445 | ) | ||||||||||||||||||||||||||||||||||
| 446 | ); | ||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||
| 448 | 64 | foreach ( @{ $self->news_item->genres } ) { | |||||||||||||||||||||||||||||||||
| 449 | 106 | $cm->appendChild( my $gn = | |||||||||||||||||||||||||||||||||
| 450 | $self->create_element( 'genre', _name_text => $_ ) ); | ||||||||||||||||||||||||||||||||||
| 451 | 106 | $self->scheme_manager->add_qcode_or_literal( $gn, 'genre', | |||||||||||||||||||||||||||||||||
| 452 | $_->qcode ); | ||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||
| 455 | 64 | my @subjects = $self->_create_subjects(); | |||||||||||||||||||||||||||||||||
| 456 | 60 | $cm->appendChild($_) foreach (@subjects); | |||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||
| 458 | 60 | ▶ | if ( $self->news_item->slugline ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 459 | 53 | my $slug = | |||||||||||||||||||||||||||||||||
| 460 | $self->create_element( 'slugline', | ||||||||||||||||||||||||||||||||||
| 461 | _text => $self->news_item->slugline ); | ||||||||||||||||||||||||||||||||||
| 462 | 53 | ▶ | if ( $self->news_item->slugline_sep ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 463 | 53 | $slug->setAttribute( 'separator', | |||||||||||||||||||||||||||||||||
| 464 | $self->news_item->slugline_sep ); | ||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||
| 466 | 53 | $cm->appendChild($slug); | |||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||
| 469 | $cm->appendChild( | ||||||||||||||||||||||||||||||||||
| 470 | 60 | my $hl1 = $self->create_element( | |||||||||||||||||||||||||||||||||
| 471 | 'headline', _text => $self->news_item->title | ||||||||||||||||||||||||||||||||||
| 472 | ) | ||||||||||||||||||||||||||||||||||
| 473 | ); | ||||||||||||||||||||||||||||||||||
| 474 | 60 | $self->scheme_manager->add_role( $hl1, 'hltype', 'title' ); | |||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||
| 476 | 60 | ▶ | if ( $self->news_item->subtitle ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 477 | 53 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 478 | my $hl2 = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 479 | 'headline', _text => $self->news_item->subtitle | ||||||||||||||||||||||||||||||||||
| 480 | ) | ||||||||||||||||||||||||||||||||||
| 481 | ); | ||||||||||||||||||||||||||||||||||
| 482 | 53 | $self->scheme_manager->add_role( $hl2, 'hltype', 'subtitle' ); | |||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||
| 485 | 60 | ▶ | if ( $self->news_item->credit ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 486 | 53 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 487 | $self->create_element( | ||||||||||||||||||||||||||||||||||
| 488 | 'creditline', _text => $self->news_item->credit | ||||||||||||||||||||||||||||||||||
| 489 | ) | ||||||||||||||||||||||||||||||||||
| 490 | ); | ||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||
| 493 | 60 | foreach ( @{ $self->news_item->keywords } ) { | |||||||||||||||||||||||||||||||||
| 494 | 265 | $cm->appendChild( $self->create_element( 'keyword', _text => $_ ) ); | |||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||
| 497 | 60 | ▶ | if ( $self->news_item->caption ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 498 | 14 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 499 | my $desc = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 500 | 'description', _text => $self->news_item->caption | ||||||||||||||||||||||||||||||||||
| 501 | ) | ||||||||||||||||||||||||||||||||||
| 502 | ); | ||||||||||||||||||||||||||||||||||
| 503 | 14 | $self->scheme_manager->add_role( $desc, 'drol', 'caption' ); | |||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||
| 506 | 60 | ▶ | if ( $self->news_item->summary ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 507 | 0 | $cm->appendChild( | |||||||||||||||||||||||||||||||||
| 508 | my $smry = $self->create_element( | ||||||||||||||||||||||||||||||||||
| 509 | 'description', _text => $self->news_item->summary | ||||||||||||||||||||||||||||||||||
| 510 | ) | ||||||||||||||||||||||||||||||||||
| 511 | ); | ||||||||||||||||||||||||||||||||||
| 512 | 0 | $self->scheme_manager->add_role( $smry, 'drol', 'summary' ); | |||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||
| 515 | 60 | $self->_create_teaser($cm); | |||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||
| 517 | 60 | $root->appendChild($cm); | |||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||
| 519 | 60 | my @asserts = $self->_create_asserts(); | |||||||||||||||||||||||||||||||||
| 520 | 60 | $root->appendChild($_) foreach @asserts; | |||||||||||||||||||||||||||||||||
| 521 | 60 | return; | |||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||
| 524 | 60 | ▶ | sub _create_content { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create_content: called CC=8 SCAR=22.9
| |||||||||||||||||||||||||||||||||||
| 525 | 60 | my ( $self, $root ) = @_; | |||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||
| 527 | 60 | $root->appendChild( my $cs = $self->create_element('contentSet') ); | |||||||||||||||||||||||||||||||||
| 528 | 60 | my $inlinexml = $self->create_element( 'inlineXML', | |||||||||||||||||||||||||||||||||
| 529 | contenttype => 'application/xhtml+xml' ); | ||||||||||||||||||||||||||||||||||
| 530 | 60 | my $html = $self->create_element( 'html', _ns => $self->xhtml_ns ); | |||||||||||||||||||||||||||||||||
| 531 | 60 | $html->appendChild( my $head = | |||||||||||||||||||||||||||||||||
| 532 | $self->create_element( 'head', _ns => $self->xhtml_ns ) ); | ||||||||||||||||||||||||||||||||||
| 533 | 60 | $head->appendChild( | |||||||||||||||||||||||||||||||||
| 534 | $self->create_element( | ||||||||||||||||||||||||||||||||||
| 535 | 'title', | ||||||||||||||||||||||||||||||||||
| 536 | _ns => $self->xhtml_ns, | ||||||||||||||||||||||||||||||||||
| 537 | _text => $self->news_item->title | ||||||||||||||||||||||||||||||||||
| 538 | ) | ||||||||||||||||||||||||||||||||||
| 539 | ); | ||||||||||||||||||||||||||||||||||
| 540 | 60 | $inlinexml->appendChild($html); | |||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||
| 542 | 60 | $html->appendChild( my $body = | |||||||||||||||||||||||||||||||||
| 543 | $self->create_element( 'body', _ns => $self->xhtml_ns ) ); | ||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||
| 545 | 60 | $body->appendChild( | |||||||||||||||||||||||||||||||||
| 546 | $self->create_element( | ||||||||||||||||||||||||||||||||||
| 547 | 'h1', | ||||||||||||||||||||||||||||||||||
| 548 | _ns => $self->xhtml_ns, | ||||||||||||||||||||||||||||||||||
| 549 | _text => $self->news_item->title | ||||||||||||||||||||||||||||||||||
| 550 | ) | ||||||||||||||||||||||||||||||||||
| 551 | ); | ||||||||||||||||||||||||||||||||||
| 552 | 60 | ▶ | $body->appendChild( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 553 | $self->create_element( | ||||||||||||||||||||||||||||||||||
| 554 | 'h2', | ||||||||||||||||||||||||||||||||||
| 555 | _ns => $self->xhtml_ns, | ||||||||||||||||||||||||||||||||||
| 556 | _text => $self->news_item->subtitle | ||||||||||||||||||||||||||||||||||
| 557 | ) | ||||||||||||||||||||||||||||||||||
| 558 | ) if $self->news_item->subtitle; | ||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||
| 560 | 60 | ▶ | my @paras = | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 561 | $self->news_item->paragraphs | ||||||||||||||||||||||||||||||||||
| 562 | ? $self->news_item->paragraphs->getChildNodes() | ||||||||||||||||||||||||||||||||||
| 563 | : (); | ||||||||||||||||||||||||||||||||||
| 564 | 60 | $body->appendChild($_) foreach (@paras); | |||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||
| 566 | 60 | $cs->appendChild($inlinexml); | |||||||||||||||||||||||||||||||||
| 567 | 60 | foreach ( sort keys %{ $self->news_item->remotes } ) { | |||||||||||||||||||||||||||||||||
| 568 | 56 | my $rc = $self->create_element( 'remoteContent', href => $_ ); | |||||||||||||||||||||||||||||||||
| 569 | 56 | $self->_create_remote_content( $rc, $self->news_item->remotes->{$_} ); | |||||||||||||||||||||||||||||||||
| 570 | 56 | $cs->appendChild($rc); | |||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||
| 572 | 60 | foreach ( @{ $self->news_item->inlinedata } ) { | |||||||||||||||||||||||||||||||||
| 573 | 0 | my %args; | |||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | if ( $_->isa('XML::NewsML_G2::Inline_CData') ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 575 | 0 | $args{_cdata} = $_->data; | |||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||
| 577 | else { | ||||||||||||||||||||||||||||||||||
| 578 | 0 | $args{_text} = $_->data; | |||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | $args{contenttype} = $_->mimetype if $_->mimetype; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 581 | 0 | my $data = $self->create_element( 'inlineData', %args ); | |||||||||||||||||||||||||||||||||
| 582 | 0 | $cs->appendChild($data); | |||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||
| 584 | 60 | return; | |||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||
| 587 | 21 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||
| 589 | 21 | 1; | |||||||||||||||||||||||||||||||||
| 590 | __END__ | ||||||||||||||||||||||||||||||||||