| 1 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 2 | # MOSES::MOBY::Def::Data | ||||||||||||||||||||
| 3 | # Author: Edward Kawas <edward.kawas@gmail.com>, | ||||||||||||||||||||
| 4 | # Martin Senger <martin.senger@gmail.com> | ||||||||||||||||||||
| 5 | # For copyright and disclaimer see below. | ||||||||||||||||||||
| 6 | # | ||||||||||||||||||||
| 7 | # $Id: Data.pm,v 1.4 2008/04/29 19:41:09 kawas Exp $ | ||||||||||||||||||||
| 8 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 11 | # | ||||||||||||||||||||
| 12 | # MOSES::MOBY::Def::Data | ||||||||||||||||||||
| 13 | # | ||||||||||||||||||||
| 14 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 15 | package MOSES::MOBY::Def::Data; | ||||||||||||||||||||
| 16 | 1 | ▶ | use base qw( MOSES::MOBY::Base ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 1 | ▶ | use XML::LibXML; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | # add versioning to this module | ||||||||||||||||||||
| 21 | 1 | ▶ | use vars qw /$VERSION/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 1 | $VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /: (\d+)\.(\d+)/; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | =head1 NAME | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | MOSES::MOBY::Def::Data - a BioMoby definition of a service input/output | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | =head1 SYNOPSIS | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =head1 DESCRIPTION | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | Each definition of a BioMoby service includes definition of data that | ||||||||||||||||||||
| 35 | the service expects and tha data that the service produces. These | ||||||||||||||||||||
| 36 | definitions are kept in modules in this file. | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | =head1 AUTHORS | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | Edward Kawas (edward.kawas [at] gmail [dot] com) | ||||||||||||||||||||
| 41 | Martin Senger (martin.senger [at] gmail [dot] com) | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | =cut | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 46 | # A list of allowed attribute names. See MOSES::MOBY::Base for details. | ||||||||||||||||||||
| 47 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =head1 ACCESSIBLE ATTRIBUTES | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | Details are in L<MOSES::MOBY::Base>. Here just a list of them: | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | =over | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | =item B<name> | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | =item B<primary> | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | A boolean attribute. Must have true value for primary inputs and | ||||||||||||||||||||
| 60 | outputs. | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =back | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | =cut | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | { | ||||||||||||||||||||
| 67 | my %_allowed = | ||||||||||||||||||||
| 68 | ( | ||||||||||||||||||||
| 69 | name => { type => MOSES::MOBY::Base->STRING, | ||||||||||||||||||||
| 70 | 0 | ▶ | post => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 71 | 0 | my ($self) = shift; | |||||||||||||||||||
| 72 | 0 | $self->{original_name} = $self->{name}; | |||||||||||||||||||
| 73 | $self->{name} = $self->escape_name ($self->{original_name}) | ||||||||||||||||||||
| 74 | 0 | } }, | |||||||||||||||||||
| 75 | 1 | primary => { type => MOSES::MOBY::Base->BOOLEAN }, | |||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | # used internally (but cannot start with underscore - Template would ignore them) | ||||||||||||||||||||
| 78 | original_name => undef, | ||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 0 | ▶ | sub _accessible { | ||||||||||||||||||
|
Subroutine
_accessible: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 82 | 0 | my ($self, $attr) = @_; | |||||||||||||||||||
| 83 | 0 | ▶ | exists $_allowed{$attr} or $self->SUPER::_accessible ($attr); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | 0 | ▶ | sub _attr_prop { | ||||||||||||||||||
|
Subroutine
_attr_prop: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 86 | 0 | my ($self, $attr_name, $prop_name) = @_; | |||||||||||||||||||
| 87 | 0 | my $attr = $_allowed {$attr_name}; | |||||||||||||||||||
| 88 | 0 | ▶ | return ref ($attr) ? $attr->{$prop_name} : $attr if $attr; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 89 | 0 | return $self->SUPER::_attr_prop ($attr_name, $prop_name); | |||||||||||||||||||
| 90 | } | ||||||||||||||||||||
| 91 | } | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 94 | # init | ||||||||||||||||||||
| 95 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 96 | #sub init { | ||||||||||||||||||||
| 97 | # my ($self) = shift; | ||||||||||||||||||||
| 98 | # $self->SUPER::init(); | ||||||||||||||||||||
| 99 | #} | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 102 | # toXML | ||||||||||||||||||||
| 103 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 104 | 1 | ▶ | sub toXML{ | ||||||||||||||||||
|
Subroutine
toXML: not called CC=1 SCAR=2.6
Pod
undocumented
| |||||||||||||||||||||
| 105 | 0 | my $self = shift; | |||||||||||||||||||
| 106 | 0 | $self->throw( "toXML not implemented in the ". ref($self) ." module.\n"); | |||||||||||||||||||
| 107 | } | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 110 | # | ||||||||||||||||||||
| 111 | # MOSES::MOBY::Def::PrimaryData | ||||||||||||||||||||
| 112 | # | ||||||||||||||||||||
| 113 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 114 | package MOSES::MOBY::Def::PrimaryData; | ||||||||||||||||||||
| 115 | 1 | ▶ | use base qw( MOSES::MOBY::Def::Data ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 116 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 119 | # A list of allowed attribute names. See MOSES::MOBY::Base for details. | ||||||||||||||||||||
| 120 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | =head1 ACCESSIBLE ATTRIBUTES | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | Details are in L<MOSES::MOBY::Base>. Here just a list of them: | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | =over | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | =item B<datatype> | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | =back | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | =cut | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | { | ||||||||||||||||||||
| 135 | 1 | my %_allowed = | |||||||||||||||||||
| 136 | ( | ||||||||||||||||||||
| 137 | ); | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | 0 | ▶ | sub _accessible { | ||||||||||||||||||
|
Subroutine
_accessible: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 140 | 0 | my ($self, $attr) = @_; | |||||||||||||||||||
| 141 | 0 | ▶ | exists $_allowed{$attr} or $self->SUPER::_accessible ($attr); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 142 | } | ||||||||||||||||||||
| 143 | 0 | ▶ | sub _attr_prop { | ||||||||||||||||||
|
Subroutine
_attr_prop: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 144 | 0 | my ($self, $attr_name, $prop_name) = @_; | |||||||||||||||||||
| 145 | 0 | my $attr = $_allowed {$attr_name}; | |||||||||||||||||||
| 146 | 0 | ▶ | return ref ($attr) ? $attr->{$prop_name} : $attr if $attr; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 147 | 0 | return $self->SUPER::_attr_prop ($attr_name, $prop_name); | |||||||||||||||||||
| 148 | } | ||||||||||||||||||||
| 149 | } | ||||||||||||||||||||
| 150 | |||||||||||||||||||||
| 151 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 152 | # init | ||||||||||||||||||||
| 153 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 154 | 1 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=3.5
| |||||||||||||||||||||
| 155 | 0 | my ($self) = shift; | |||||||||||||||||||
| 156 | 0 | $self->SUPER::init(); | |||||||||||||||||||
| 157 | 0 | $self->primary (1); | |||||||||||||||||||
| 158 | } | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 161 | # | ||||||||||||||||||||
| 162 | # MOSES::MOBY::Def::PrimaryDataSimple | ||||||||||||||||||||
| 163 | # | ||||||||||||||||||||
| 164 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 165 | package MOSES::MOBY::Def::PrimaryDataSimple; | ||||||||||||||||||||
| 166 | 1 | ▶ | use base qw( MOSES::MOBY::Def::PrimaryData ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 167 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 170 | # A list of allowed attribute names. See MOSES::MOBY::Base for details. | ||||||||||||||||||||
| 171 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 172 | |||||||||||||||||||||
| 173 | =head1 ACCESSIBLE ATTRIBUTES | ||||||||||||||||||||
| 174 | |||||||||||||||||||||
| 175 | Details are in L<MOSES::MOBY::Base>. Here just a list of them: | ||||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | =over | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | =item B<namespaces> | ||||||||||||||||||||
| 180 | |||||||||||||||||||||
| 181 | =back | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | =cut | ||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | { | ||||||||||||||||||||
| 186 | 1 | my %_allowed = | |||||||||||||||||||
| 187 | ( | ||||||||||||||||||||
| 188 | namespaces => {type => 'MOSES::MOBY::Def::Namespace', is_array => 1}, | ||||||||||||||||||||
| 189 | datatype => { type => 'MOSES::MOBY::Def::DataType' }, | ||||||||||||||||||||
| 190 | ); | ||||||||||||||||||||
| 191 | |||||||||||||||||||||
| 192 | 0 | ▶ | sub _accessible { | ||||||||||||||||||
|
Subroutine
_accessible: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 193 | 0 | my ($self, $attr) = @_; | |||||||||||||||||||
| 194 | 0 | ▶ | exists $_allowed{$attr} or $self->SUPER::_accessible ($attr); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 195 | } | ||||||||||||||||||||
| 196 | 0 | ▶ | sub _attr_prop { | ||||||||||||||||||
|
Subroutine
_attr_prop: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 197 | 0 | my ($self, $attr_name, $prop_name) = @_; | |||||||||||||||||||
| 198 | 0 | my $attr = $_allowed {$attr_name}; | |||||||||||||||||||
| 199 | 0 | ▶ | return ref ($attr) ? $attr->{$prop_name} : $attr if $attr; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 200 | 0 | return $self->SUPER::_attr_prop ($attr_name, $prop_name); | |||||||||||||||||||
| 201 | } | ||||||||||||||||||||
| 202 | } | ||||||||||||||||||||
| 203 | |||||||||||||||||||||
| 204 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 205 | |||||||||||||||||||||
| 206 | =head1 SUBROUTINES | ||||||||||||||||||||
| 207 | |||||||||||||||||||||
| 208 | =cut | ||||||||||||||||||||
| 209 | |||||||||||||||||||||
| 210 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 211 | # init | ||||||||||||||||||||
| 212 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 213 | 1 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=4.1
| |||||||||||||||||||||
| 214 | 0 | my ($self) = shift; | |||||||||||||||||||
| 215 | 0 | $self->SUPER::init(); | |||||||||||||||||||
| 216 | 0 | $self->datatype (new MOSES::MOBY::Def::DataType ( name => 'Object')); | |||||||||||||||||||
| 217 | 0 | $self->namespaces ([]); | |||||||||||||||||||
| 218 | } | ||||||||||||||||||||
| 219 | |||||||||||||||||||||
| 220 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 221 | # toXML | ||||||||||||||||||||
| 222 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 223 | 0 | ▶ | sub toXML { | ||||||||||||||||||
|
Subroutine
toXML: not called CC=8 SCAR=42.8
| |||||||||||||||||||||
| 224 | 0 | my $caller = shift; | |||||||||||||||||||
| 225 | 0 | my $useArticleName = 1; | |||||||||||||||||||
| 226 | 0 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 227 | 0 | my $var = shift; | |||||||||||||||||||
| 228 | 0 | ▶ | if ( $var == 0 ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 229 | 0 | $useArticleName = 0; | |||||||||||||||||||
| 230 | } | ||||||||||||||||||||
| 231 | } | ||||||||||||||||||||
| 232 | 0 | my $root = $caller->createXMLElement ('Simple'); | |||||||||||||||||||
| 233 | |||||||||||||||||||||
| 234 | #set the articlename | ||||||||||||||||||||
| 235 | 0 | ▶ | $caller->setXMLAttribute( $root, 'articleName', $caller->original_name ||'' ) if $useArticleName; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$caller->original_name || ''
MC/DC0%0/1
$caller->original_name || ''
$caller->original_name
Truth table0%0/2
A
A= $caller->original_name
| |||||||||||||||||||||
| 236 | |||||||||||||||||||||
| 237 | # set the objectType | ||||||||||||||||||||
| 238 | 0 | my $node = $caller->createXMLElement("objectType"); | |||||||||||||||||||
| 239 | 0 | ▶ | $node->appendTextNode( $caller->datatype->name || ""); | ||||||||||||||||||
|
Condition0%0/2
$caller->datatype->name || ''
MC/DC0%0/1
$caller->datatype->name || ''
$caller->datatype->name
Truth table0%0/2
A
A= $caller->datatype->name
| |||||||||||||||||||||
| 240 | 0 | $root->addChild($node); | |||||||||||||||||||
| 241 | |||||||||||||||||||||
| 242 | # add any namespaces | ||||||||||||||||||||
| 243 | 0 | foreach my $ns ( @{$caller->namespaces} ) { | |||||||||||||||||||
| 244 | 0 | $node = $caller->createXMLElement("Namespace"); | |||||||||||||||||||
| 245 | 0 | ▶ | $node->appendTextNode( $ns->name ) if $ns->name; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 246 | 0 | $root->addChild($node); | |||||||||||||||||||
| 247 | } | ||||||||||||||||||||
| 248 | |||||||||||||||||||||
| 249 | 0 | return $root; | |||||||||||||||||||
| 250 | } | ||||||||||||||||||||
| 251 | |||||||||||||||||||||
| 252 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 253 | # | ||||||||||||||||||||
| 254 | # MOSES::MOBY::Def::PrimaryDataSet | ||||||||||||||||||||
| 255 | # | ||||||||||||||||||||
| 256 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 257 | package MOSES::MOBY::Def::PrimaryDataSet; | ||||||||||||||||||||
| 258 | 1 | ▶ | use base qw( MOSES::MOBY::Def::PrimaryData ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 259 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 260 | |||||||||||||||||||||
| 261 | { | ||||||||||||||||||||
| 262 | 1 | my %_allowed = | |||||||||||||||||||
| 263 | ( | ||||||||||||||||||||
| 264 | elements => {type => 'MOSES::MOBY::Def::PrimaryDataSimple', is_array => 1}, | ||||||||||||||||||||
| 265 | ); | ||||||||||||||||||||
| 266 | |||||||||||||||||||||
| 267 | 0 | ▶ | sub _accessible { | ||||||||||||||||||
|
Subroutine
_accessible: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 268 | 0 | my ($self, $attr) = @_; | |||||||||||||||||||
| 269 | 0 | ▶ | exists $_allowed{$attr} or $self->SUPER::_accessible ($attr); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 270 | } | ||||||||||||||||||||
| 271 | 0 | ▶ | sub _attr_prop { | ||||||||||||||||||
|
Subroutine
_attr_prop: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 272 | 0 | my ($self, $attr_name, $prop_name) = @_; | |||||||||||||||||||
| 273 | 0 | my $attr = $_allowed {$attr_name}; | |||||||||||||||||||
| 274 | 0 | ▶ | return ref ($attr) ? $attr->{$prop_name} : $attr if $attr; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 275 | 0 | return $self->SUPER::_attr_prop ($attr_name, $prop_name); | |||||||||||||||||||
| 276 | } | ||||||||||||||||||||
| 277 | } | ||||||||||||||||||||
| 278 | |||||||||||||||||||||
| 279 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 280 | |||||||||||||||||||||
| 281 | =head1 SUBROUTINES | ||||||||||||||||||||
| 282 | |||||||||||||||||||||
| 283 | =cut | ||||||||||||||||||||
| 284 | |||||||||||||||||||||
| 285 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 286 | # init | ||||||||||||||||||||
| 287 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 288 | 1 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=3.5
| |||||||||||||||||||||
| 289 | 0 | my ($self) = shift; | |||||||||||||||||||
| 290 | 0 | $self->SUPER::init(); | |||||||||||||||||||
| 291 | 0 | $self->elements ([]); | |||||||||||||||||||
| 292 | } | ||||||||||||||||||||
| 293 | |||||||||||||||||||||
| 294 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 295 | # toXML | ||||||||||||||||||||
| 296 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 297 | 0 | ▶ | sub toXML{ | ||||||||||||||||||
|
Subroutine
toXML: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 298 | 0 | my $caller = shift; | |||||||||||||||||||
| 299 | 0 | my $root = $caller->createXMLElement ('Collection'); | |||||||||||||||||||
| 300 | |||||||||||||||||||||
| 301 | #set the articlename | ||||||||||||||||||||
| 302 | 0 | ▶ | $caller->setXMLAttribute($root, 'articleName' , $caller->original_name ||''); | ||||||||||||||||||
|
Condition0%0/2
$caller->original_name || ''
MC/DC0%0/1
$caller->original_name || ''
$caller->original_name
Truth table0%0/2
A
A= $caller->original_name
| |||||||||||||||||||||
| 303 | # add any datatypes | ||||||||||||||||||||
| 304 | 0 | foreach my $dt (@{$caller->elements}) { | |||||||||||||||||||
| 305 | 0 | $root->addChild($dt->toXML(0)); | |||||||||||||||||||
| 306 | } | ||||||||||||||||||||
| 307 | 0 | return $root; | |||||||||||||||||||
| 308 | } | ||||||||||||||||||||
| 309 | |||||||||||||||||||||
| 310 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 311 | # | ||||||||||||||||||||
| 312 | # MOSES::MOBY::Def::SecondaryData | ||||||||||||||||||||
| 313 | # | ||||||||||||||||||||
| 314 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 315 | package MOSES::MOBY::Def::SecondaryData; | ||||||||||||||||||||
| 316 | 1 | ▶ | use base qw( MOSES::MOBY::Def::Data ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 317 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 318 | |||||||||||||||||||||
| 319 | { | ||||||||||||||||||||
| 320 | 1 | my %_allowed = | |||||||||||||||||||
| 321 | ( | ||||||||||||||||||||
| 322 | max => { type => MOSES::MOBY::Base->STRING }, | ||||||||||||||||||||
| 323 | min => { type => MOSES::MOBY::Base->STRING }, | ||||||||||||||||||||
| 324 | default => undef, | ||||||||||||||||||||
| 325 | description => { type => MOSES::MOBY::Base->STRING}, | ||||||||||||||||||||
| 326 | datatype => { type => MOSES::MOBY::Base->STRING}, | ||||||||||||||||||||
| 327 | allowables => {is_array => 1}, | ||||||||||||||||||||
| 328 | ); | ||||||||||||||||||||
| 329 | |||||||||||||||||||||
| 330 | 0 | ▶ | sub _accessible { | ||||||||||||||||||
|
Subroutine
_accessible: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 331 | 0 | my ($self, $attr) = @_; | |||||||||||||||||||
| 332 | 0 | ▶ | exists $_allowed{$attr} or $self->SUPER::_accessible ($attr); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 333 | } | ||||||||||||||||||||
| 334 | 0 | ▶ | sub _attr_prop { | ||||||||||||||||||
|
Subroutine
_attr_prop: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 335 | 0 | my ($self, $attr_name, $prop_name) = @_; | |||||||||||||||||||
| 336 | 0 | my $attr = $_allowed {$attr_name}; | |||||||||||||||||||
| 337 | 0 | ▶ | return ref ($attr) ? $attr->{$prop_name} : $attr if $attr; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 338 | 0 | return $self->SUPER::_attr_prop ($attr_name, $prop_name); | |||||||||||||||||||
| 339 | } | ||||||||||||||||||||
| 340 | } | ||||||||||||||||||||
| 341 | |||||||||||||||||||||
| 342 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 343 | # init | ||||||||||||||||||||
| 344 | #----------------------------------------------------------------- | ||||||||||||||||||||
| 345 | 1 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=4.1
| |||||||||||||||||||||
| 346 | 0 | my ($self) = shift; | |||||||||||||||||||
| 347 | 0 | $self->SUPER::init(); | |||||||||||||||||||
| 348 | 0 | $self->allowables ([]); | |||||||||||||||||||
| 349 | 0 | $self->datatype (new MOSES::MOBY::Def::DataType ( name => 'String')); | |||||||||||||||||||
| 350 | } | ||||||||||||||||||||
| 351 | #sub _verify_datatype_ { | ||||||||||||||||||||
| 352 | # my ($self, $attr) = @_; | ||||||||||||||||||||
| 353 | # $self->throw ("Datatype not set - valid types are: Integer|Float|String|DateTime and not " . $self->datatype) | ||||||||||||||||||||
| 354 | # unless $self->datatype =~ /Integer|Float|String|DateTime/ ; | ||||||||||||||||||||
| 355 | #} | ||||||||||||||||||||
| 356 | |||||||||||||||||||||
| 357 | #sub _verify_max_ { | ||||||||||||||||||||
| 358 | # my ($self, $attr) = @_; | ||||||||||||||||||||
| 359 | # $self->throw ("max value must be a digit") | ||||||||||||||||||||
| 360 | # unless $self->max =~ m/^[+-]?\ *(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/ ; | ||||||||||||||||||||
| 361 | #} | ||||||||||||||||||||
| 362 | |||||||||||||||||||||
| 363 | #sub _verify_min_ { | ||||||||||||||||||||
| 364 | # my ($self, $attr) = @_; | ||||||||||||||||||||
| 365 | # $self->throw ("min value must be a digit") | ||||||||||||||||||||
| 366 | # unless $self->min =~ m/^[+-]?\ *(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/ ; | ||||||||||||||||||||
| 367 | #} | ||||||||||||||||||||
| 368 | |||||||||||||||||||||
| 369 | 0 | ▶ | sub toXML { | ||||||||||||||||||
|
Subroutine
toXML: not called CC=12 SCAR=50.5
| |||||||||||||||||||||
| 370 | 0 | my $caller = shift; | |||||||||||||||||||
| 371 | 0 | my $rootName = "Parameter"; | |||||||||||||||||||
| 372 | 0 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 373 | 0 | ▶ | $rootName = shift || "Parameter"; | ||||||||||||||||||
|
Condition0%0/2
shift() || 'Parameter'
MC/DC0%0/1
shift() || 'Parameter'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||
| 374 | } | ||||||||||||||||||||
| 375 | |||||||||||||||||||||
| 376 | 0 | my $root = $caller->createXMLElement("$rootName"); | |||||||||||||||||||
| 377 | |||||||||||||||||||||
| 378 | #set the articlename | ||||||||||||||||||||
| 379 | 0 | ▶ | $root->setAttribute( 'articleName', $caller->original_name || '' ); | ||||||||||||||||||
|
Condition0%0/2
$caller->original_name || ''
MC/DC0%0/1
$caller->original_name || ''
$caller->original_name
Truth table0%0/2
A
A= $caller->original_name
| |||||||||||||||||||||
| 380 | |||||||||||||||||||||
| 381 | # set the datatype | ||||||||||||||||||||
| 382 | 0 | my $node = $caller->createXMLElement("datatype"); | |||||||||||||||||||
| 383 | 0 | ▶ | $node->appendTextNode( $caller->datatype ) if $caller->datatype; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 384 | 0 | $root->addChild($node); | |||||||||||||||||||
| 385 | |||||||||||||||||||||
| 386 | 0 | ▶ | if ( $caller->max ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 387 | 0 | $node = $caller->createXMLElement("max"); | |||||||||||||||||||
| 388 | 0 | ▶ | $node->appendTextNode( $caller->max ) if $caller->max; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 389 | 0 | $root->addChild($node); | |||||||||||||||||||
| 390 | } | ||||||||||||||||||||
| 391 | 0 | ▶ | if ( $caller->min ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 392 | 0 | $node = $caller->createXMLElement("min"); | |||||||||||||||||||
| 393 | 0 | ▶ | $node->appendTextNode( $caller->min ) if $caller->min; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 394 | 0 | $root->addChild($node); | |||||||||||||||||||
| 395 | } | ||||||||||||||||||||
| 396 | 0 | ▶ | if ( $caller->default ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 397 | 0 | $node = $caller->createXMLElement("default"); | |||||||||||||||||||
| 398 | 0 | ▶ | $node->appendTextNode( $caller->default ) if $caller->default; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 399 | 0 | $root->addChild($node); | |||||||||||||||||||
| 400 | } | ||||||||||||||||||||
| 401 | |||||||||||||||||||||
| 402 | # add any allowables | ||||||||||||||||||||
| 403 | 0 | foreach my $ns ( @{$caller->allowables} ) { | |||||||||||||||||||
| 404 | 0 | $node = $caller->createXMLElement("enum"); | |||||||||||||||||||
| 405 | 0 | $node->appendTextNode($ns); | |||||||||||||||||||
| 406 | 0 | $root->addChild($node); | |||||||||||||||||||
| 407 | } | ||||||||||||||||||||
| 408 | |||||||||||||||||||||
| 409 | 0 | return $root; | |||||||||||||||||||
| 410 | } | ||||||||||||||||||||
| 411 | |||||||||||||||||||||
| 412 | 1 | 1; | |||||||||||||||||||
| 413 | __END__ | ||||||||||||||||||||