| 1 | package MOBY::Client::SecondaryArticle; | ||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use MOBY::MobyXMLConstants; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use vars qw($AUTOLOAD @ISA); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use vars qw /$VERSION/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 5 | $VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /: (\d+)\.(\d+)/; | |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | MOBY::Client::SecondaryArticle - a small object describing the Simple articles from the findService Response message of MOBY Central | ||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | Can be used either in this way: | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | use MOBY::CommonSubs qw{:all}; | ||||||||||||||||||||||||||||||||
| 21 | foreach my $queryID(keys %$inputs){ | ||||||||||||||||||||||||||||||||
| 22 | my $this_invocation = $inputs->{$queryID}; # this is the <mobyData> block with this queryID | ||||||||||||||||||||||||||||||||
| 23 | my $invocation_output = ""; | ||||||||||||||||||||||||||||||||
| 24 | if (my $input = $this_invocation->{'This_articleName'}){ | ||||||||||||||||||||||||||||||||
| 25 | # $input contains a MOBY::Client::SimpleArticle, ::CollectionArticle or ::SecondaryArticle | ||||||||||||||||||||||||||||||||
| 26 | next unless $input->isSecondary; # make sure it is a ::SecondaryArticle | ||||||||||||||||||||||||||||||||
| 27 | $prameter_value = $input->value; # get the value of the secondary parameter | ||||||||||||||||||||||||||||||||
| 28 | # do your business here and fill $invocation_output | ||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | $MOBY_RESPONSE .= simpleResponse( # create an empty response for this queryID | ||||||||||||||||||||||||||||||||
| 32 | $invocation_output # response for this query | ||||||||||||||||||||||||||||||||
| 33 | , "myOutput" # the article name of that output object | ||||||||||||||||||||||||||||||||
| 34 | , $queryID); # the queryID of the input that we are responding to | ||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||
| 36 | return SOAP::Data->type('base64' => (responseHeader("illuminae.com") . $MOBY_RESPONSE . responseFooter)); | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | or to construct a representation of a Secondary article from a findService call | ||||||||||||||||||||||||||||||||
| 39 | to MOBY::Central | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | A module used to describe secondary articles in moby | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | =cut | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | Mark Wilkinson (markw at illuminae dot com) | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | =head1 METHODS | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | =head2 new | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | Usage : my $SA = MOBY::Client::SecondaryArticle->new(%args) | ||||||||||||||||||||||||||||||||
| 62 | Function : create SecondaryArticle object | ||||||||||||||||||||||||||||||||
| 63 | Returns : MOBY::Client::SecondaryArticle object | ||||||||||||||||||||||||||||||||
| 64 | Args : articleName => "NameOfArticle" | ||||||||||||||||||||||||||||||||
| 65 | datatype => Integer|Float|String|DateTime, | ||||||||||||||||||||||||||||||||
| 66 | default => $some_default_value, | ||||||||||||||||||||||||||||||||
| 67 | max => $maximum_value, | ||||||||||||||||||||||||||||||||
| 68 | min => $minimum_value, | ||||||||||||||||||||||||||||||||
| 69 | description => $free_text, | ||||||||||||||||||||||||||||||||
| 70 | enum => \@valid_values | ||||||||||||||||||||||||||||||||
| 71 | XML_DOM => $XML_DOM node of the Secondary article (optional) | ||||||||||||||||||||||||||||||||
| 72 | XML => $XML XML string representing the Secondary article (optional) | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | =head2 articleName | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | Usage : $name = $SA->articleName($name) | ||||||||||||||||||||||||||||||||
| 77 | Function : get/set articleName | ||||||||||||||||||||||||||||||||
| 78 | Returns : string | ||||||||||||||||||||||||||||||||
| 79 | Arguments : (optional) string representing articleName to set | ||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | =head2 datatype | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | Usage : $name = $SA->datatype($type) | ||||||||||||||||||||||||||||||||
| 84 | Function : get/set datatype: Integer, Float, DateTime, Boolean, String | ||||||||||||||||||||||||||||||||
| 85 | Returns : the datatype | ||||||||||||||||||||||||||||||||
| 86 | Arguments : | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | =head2 min | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | Usage : $name = $SA->min($value) | ||||||||||||||||||||||||||||||||
| 91 | Function : get/set the minimum value of a datatype | ||||||||||||||||||||||||||||||||
| 92 | Returns : min value | ||||||||||||||||||||||||||||||||
| 93 | Arguments : | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | =head2 max | ||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | Usage : $name = $SA->max($value) | ||||||||||||||||||||||||||||||||
| 98 | Function : get/set maximum value of the datatype | ||||||||||||||||||||||||||||||||
| 99 | Returns : max value | ||||||||||||||||||||||||||||||||
| 100 | Arguments : | ||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | =head2 default | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | Usage : $name = $SA->default($value) | ||||||||||||||||||||||||||||||||
| 105 | Function : get/set the default value of parameter | ||||||||||||||||||||||||||||||||
| 106 | Returns : default value | ||||||||||||||||||||||||||||||||
| 107 | Arguments : | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | =head2 enum | ||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | Usage : $name = $SA->enum(\@possible_values) | ||||||||||||||||||||||||||||||||
| 113 | Function : get/set the enumerated values for discreet variables | ||||||||||||||||||||||||||||||||
| 114 | Returns : listref of string values | ||||||||||||||||||||||||||||||||
| 115 | Arguments : | ||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | =head2 addEnum | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | Usage : $name = $SA->addEnum($new_possible_values) | ||||||||||||||||||||||||||||||||
| 121 | Function : add to the list of enumerated values for discreet variables | ||||||||||||||||||||||||||||||||
| 122 | Returns : new listref of string values | ||||||||||||||||||||||||||||||||
| 123 | Arguments : | ||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | =head2 description | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | Usage : $namespaces = $SA->description("text description here") | ||||||||||||||||||||||||||||||||
| 129 | Function : get/set description of the parameter | ||||||||||||||||||||||||||||||||
| 130 | Returns : string | ||||||||||||||||||||||||||||||||
| 131 | Arguments : (optional) string description | ||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | =head2 XML | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | Usage : $SA = $SA->XML($XML) | ||||||||||||||||||||||||||||||||
| 137 | Function : set/reset all parameters for this object from the XML | ||||||||||||||||||||||||||||||||
| 138 | Returns : MOBY::Client::SecondaryArticle | ||||||||||||||||||||||||||||||||
| 139 | Arguments : (optional) XML fragment from and including <Simple>...</Simple> | ||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | =head2 XML_DOM | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | Usage : $namespaces = $SA->XML_DOM($XML_DOM_NODE) | ||||||||||||||||||||||||||||||||
| 144 | Function : set/reset all parameters for this object from the XML::DOM node for <Simple> | ||||||||||||||||||||||||||||||||
| 145 | Returns : MOBY::Client::SecondaryArticle | ||||||||||||||||||||||||||||||||
| 146 | Arguments : (optional) an $XML::DOM node from the <Simple> article of a DOM | ||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | =head2 isSecondary | ||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||
| 150 | Usage : $boolean = $IN->isSecondary() | ||||||||||||||||||||||||||||||||
| 151 | Function : is this a SecondaryArticle type? (yes, I know this is obvious) | ||||||||||||||||||||||||||||||||
| 152 | Returns : 1 (true) | ||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | =head2 isSimple | ||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | Usage : $boolean = $IN->isSimple() | ||||||||||||||||||||||||||||||||
| 157 | Function : is this a SimpleArticle type | ||||||||||||||||||||||||||||||||
| 158 | Returns : 0 (false) | ||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||
| 160 | =head2 isCollection | ||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | Usage : $boolean = $IN->isCollection() | ||||||||||||||||||||||||||||||||
| 163 | Function : is this a CollectionArticle type | ||||||||||||||||||||||||||||||||
| 164 | Returns : 0 for false | ||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||
| 166 | =cut | ||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | # Encapsulated: | ||||||||||||||||||||||||||||||||
| 171 | # DATA | ||||||||||||||||||||||||||||||||
| 172 | #___________________________________________________________ | ||||||||||||||||||||||||||||||||
| 173 | #ATTRIBUTES | ||||||||||||||||||||||||||||||||
| 174 | 5 | my %_attr_data = # DEFAULT ACCESSIBILITY | |||||||||||||||||||||||||||||||
| 175 | ( | ||||||||||||||||||||||||||||||||
| 176 | articleName => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 177 | objectType => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 178 | namespaces => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 179 | XML_DOM => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 180 | XML => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 181 | isSecondary => [ 1, 'read' ], | ||||||||||||||||||||||||||||||||
| 182 | isSimple => [ 0, 'read' ], | ||||||||||||||||||||||||||||||||
| 183 | isCollection => [ 0, 'read' ], | ||||||||||||||||||||||||||||||||
| 184 | datatype => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 185 | default => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 186 | max => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 187 | min => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 188 | enum => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 189 | description => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 190 | value => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | #_____________________________________________________________ | ||||||||||||||||||||||||||||||||
| 194 | # METHODS, to operate on encapsulated class data | ||||||||||||||||||||||||||||||||
| 195 | # Is a specified object attribute accessible in a given mode | ||||||||||||||||||||||||||||||||
| 196 | 18 | ▶ | sub _accessible { | ||||||||||||||||||||||||||||||
|
Subroutine
_accessible: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 197 | 18 | my ( $self, $attr, $mode ) = @_; | |||||||||||||||||||||||||||||||
| 198 | 18 | $_attr_data{$attr}[1] =~ /$mode/; | |||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||
| 201 | # Classwide default value for a specified object attribute | ||||||||||||||||||||||||||||||||
| 202 | 86 | ▶ | sub _default_for { | ||||||||||||||||||||||||||||||
|
Subroutine
_default_for: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 203 | 86 | my ( $self, $attr ) = @_; | |||||||||||||||||||||||||||||||
| 204 | 86 | $_attr_data{$attr}[0]; | |||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||
| 207 | # List of names of all specified object attributes | ||||||||||||||||||||||||||||||||
| 208 | 6 | ▶ | sub _standard_keys { | ||||||||||||||||||||||||||||||
|
Subroutine
_standard_keys: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 209 | 6 | keys %_attr_data; | |||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||
| 212 | 12 | ▶ | sub addEnum { | ||||||||||||||||||||||||||||||
|
Subroutine
addEnum: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 213 | # No return value necessary | ||||||||||||||||||||||||||||||||
| 214 | 12 | my ( $self, $enum ) = @_; | |||||||||||||||||||||||||||||||
| 215 | 12 | ▶ | $self->{enum} = [] unless $self->{enum}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 216 | 12 | ▶ | return() unless defined ($enum); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 217 | 12 | push @{ $self->{enum} }, $enum; | |||||||||||||||||||||||||||||||
| 218 | 12 | return $self->enum; | |||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | 5 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=13 SCAR=28.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 223 | 6 | my ( $caller, %args ) = @_; | |||||||||||||||||||||||||||||||
| 224 | 6 | my $caller_is_obj = ref( $caller ); | |||||||||||||||||||||||||||||||
| 225 | 6 | ▶ | return $caller if $caller_is_obj; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 226 | 6 | ▶ | my $class = $caller_is_obj || $caller; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$caller_is_obj || $caller
MC/DC0%0/2
$caller_is_obj || $caller
$caller_is_obj
$caller
Truth table33%1/3
A || B
A= $caller_is_objB= $caller
| |||||||||||||||||||||||||||||||||
| 227 | 6 | my $proxy; | |||||||||||||||||||||||||||||||
| 228 | 6 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||
| 229 | 6 | foreach my $attrname ( $self->_standard_keys ) { | |||||||||||||||||||||||||||||||
| 230 | 90 | ▶ | if ( exists $args{$attrname} ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 231 | 4 | $self->{$attrname} = $args{$attrname}; | |||||||||||||||||||||||||||||||
| 232 | } elsif ( $caller_is_obj ) { | ||||||||||||||||||||||||||||||||
| 233 | 0 | $self->{$attrname} = $caller->{$attrname}; | |||||||||||||||||||||||||||||||
| 234 | } else { | ||||||||||||||||||||||||||||||||
| 235 | 86 | $self->{$attrname} = $self->_default_for( $attrname ); | |||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||
| 238 | 6 | ▶ | $self->{enum} = [] unless $self->enum; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 239 | 6 | ▶ | if ( $self->XML && ref( $self->XML ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$self->XML and ref $self->XML
MC/DC0%0/2
$self->XML and ref $self->XML
$self->XML
ref $self->XML
Truth table66%2/3
A and B
A= $self->XMLB= ref $self->XML
| |||||||||||||||||||||||||||||||||
| 240 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 241 | ▶ | } elsif ( $self->XML_DOM && !( ref( $self->XML_DOM ) =~ /libxml/i ) ) { | |||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->XML_DOM and not ref($self->XML_DOM) =~ /libxml/i
MC/DC0%0/2
$self->XML_DOM and not ref($self->XML_DOM) =~ /libxml/i
$self->XML_DOM
not ref($self->XML_DOM) =~ /libxml/i
Truth table66%2/3
A and not(B)
A= $self->XML_DOMB= not ref($self->XML_DOM) =~ /libxml/i
| |||||||||||||||||||||||||||||||||
| 242 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||
| 244 | 6 | ▶ | $self->createFromXML if ( $self->XML ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 245 | 6 | ▶ | $self->createFromDOM( $self->XML_DOM ) if ( $self->XML_DOM ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 246 | 6 | return $self; | |||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | 2 | ▶ | sub createFromXML { | ||||||||||||||||||||||||||||||
|
Subroutine
createFromXML: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 250 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||
| 251 | 2 | my $p = XML::LibXML->new; | |||||||||||||||||||||||||||||||
| 252 | 2 | my $doc = $p->parse_string( $self->XML ); | |||||||||||||||||||||||||||||||
| 253 | 2 | my $root = $doc->getDocumentElement; | |||||||||||||||||||||||||||||||
| 254 | 2 | ▶ | return 0 unless ( $root && ( $root->localname eq "Parameter" ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$root and $root->localname eq "Parameter"
MC/DC0%0/2
$root and $root->localname eq "Parameter"
$root
$root->localname eq "Parameter"
Truth table33%1/3
A and B
A= $rootB= $root->localname eq "Parameter"
| |||||||||||||||||||||||||||||||||
| 255 | 2 | return $self->createFromDOM( $root ); | |||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||
| 258 | 4 | ▶ | sub createFromDOM { | ||||||||||||||||||||||||||||||
|
Subroutine
createFromDOM: called CC=6 SCAR=18.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 259 | 4 | my ( $self, $dom ) = @_; | |||||||||||||||||||||||||||||||
| 260 | 4 | ▶ | return 0 unless ( $dom && ( $dom->localname eq "Parameter" ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$dom and $dom->localname eq "Parameter"
MC/DC0%0/2
$dom and $dom->localname eq "Parameter"
$dom
$dom->localname eq "Parameter"
Truth table33%1/3
A and B
A= $domB= $dom->localname eq "Parameter"
| |||||||||||||||||||||||||||||||||
| 261 | 4 | $self->XML( $dom->toString ); # set the string version of the DOM | |||||||||||||||||||||||||||||||
| 262 | 4 | $self->namespaces( [] ); # reset! | |||||||||||||||||||||||||||||||
| 263 | 4 | $self->articleName( "" ); | |||||||||||||||||||||||||||||||
| 264 | 4 | $self->objectType( "" ); | |||||||||||||||||||||||||||||||
| 265 | 4 | my $attr = $dom->getAttributeNode( 'articleName' ); | |||||||||||||||||||||||||||||||
| 266 | 4 | ▶ | $attr ||= $dom->getAttributeNode( 'moby:articleName' ); | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$attr ||= $dom->getAttributeNode("moby:articleName")
MC/DC0%0/2
$attr ||= $dom->getAttributeNode("moby:articleName")
$attr
$dom->getAttributeNode("moby:articleName")
Truth table33%1/3
A ||= B
A= $attrB= $dom->getAttributeNode("moby:articleName")
| |||||||||||||||||||||||||||||||||
| 267 | 4 | ▶ | $self->articleName( $attr ? $attr->getValue : "" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 268 | 4 | ▶ | if ( @{ $dom->getElementsByLocalName( 'Value' ) }[0] ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 269 | 2 | return $self->_createInstantiatedArticle( $dom ); | |||||||||||||||||||||||||||||||
| 270 | } else { | ||||||||||||||||||||||||||||||||
| 271 | 2 | return $self->_createTemplateArticle( $dom ); | |||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||
| 275 | 2 | ▶ | sub _createTemplateArticle { | ||||||||||||||||||||||||||||||
|
Subroutine
_createTemplateArticle: called CC=11 SCAR=24.3
| |||||||||||||||||||||||||||||||||
| 276 | 2 | my ( $self, $dom ) = @_; | |||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||
| 278 | #datatype => [undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 279 | #description => [undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 280 | #default => [undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 281 | #max => [undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 282 | #min => [undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 283 | #enum => [[], 'read/write' ], | ||||||||||||||||||||||||||||||||
| 284 | 2 | my @single_valued = qw/datatype default max min description/; | |||||||||||||||||||||||||||||||
| 285 | 2 | my $objects; | |||||||||||||||||||||||||||||||
| 286 | 2 | foreach my $param (@single_valued) { | |||||||||||||||||||||||||||||||
| 287 | 10 | $objects = $dom->getElementsByTagName( $param ); | |||||||||||||||||||||||||||||||
| 288 | 10 | ▶ | if ( $objects->get_node( 1 ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 289 | 10 | my $data; | |||||||||||||||||||||||||||||||
| 290 | 10 | foreach my $child ( $objects->get_node( 1 )->childNodes ) { | |||||||||||||||||||||||||||||||
| 291 | 10 | ▶ | next unless $child->nodeType == TEXT_NODE; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 292 | 10 | $data .= $child->toString; | |||||||||||||||||||||||||||||||
| 293 | 10 | ▶ | ($data =~ s/\s//g) unless ($param eq "description"); # Trim all whitespace except from description | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||
| 295 | 10 | $self->$param( $data ); | |||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||
| 298 | # Since it is (array)multi-valued, 'enum' is a little different from the others. | ||||||||||||||||||||||||||||||||
| 299 | 2 | $objects = $dom->getElementsByTagName( "enum" ); | |||||||||||||||||||||||||||||||
| 300 | 2 | ▶ | if ( $objects->get_node( 1 ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 301 | 2 | foreach ( 1 .. $objects->size() ) { | |||||||||||||||||||||||||||||||
| 302 | 12 | foreach my $child ( $objects->get_node( $_ )->childNodes ) { | |||||||||||||||||||||||||||||||
| 303 | 12 | my $val; | |||||||||||||||||||||||||||||||
| 304 | 12 | ▶ | next unless $child->nodeType == TEXT_NODE; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 305 | 12 | $val = $child->toString; | |||||||||||||||||||||||||||||||
| 306 | 12 | ▶ | next unless defined( $val ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 307 | # Trim space from front and back, but leave alone in middle....? | ||||||||||||||||||||||||||||||||
| 308 | 12 | $val =~ s/^\s//; | |||||||||||||||||||||||||||||||
| 309 | 12 | $val =~ s/\s$//; | |||||||||||||||||||||||||||||||
| 310 | 12 | $self->addEnum( $val ); | |||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||
| 314 | 2 | return $self; | |||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||
| 317 | 2 | ▶ | sub _createInstantiatedArticle { | ||||||||||||||||||||||||||||||
|
Subroutine
_createInstantiatedArticle: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 318 | 2 | my ( $self, $dom ) = @_; | |||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | #<Parameter articleName='foo'><Value>43764</Value></Parameter> | ||||||||||||||||||||||||||||||||
| 321 | 2 | my $values = $dom->getElementsByLocalName( 'Value' ); | |||||||||||||||||||||||||||||||
| 322 | 2 | $self->value( "" ); # Initialize to 1) avoid Perl warnings 2) be good. | |||||||||||||||||||||||||||||||
| 323 | 2 | foreach my $child ( $values->get_node( 1 )->childNodes ) { | |||||||||||||||||||||||||||||||
| 324 | 2 | ▶ | next unless $child->nodeType == TEXT_NODE; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 325 | # Would we *really* want to catenate values like this? | ||||||||||||||||||||||||||||||||
| 326 | 2 | $self->value( $self->value . $child->toString ); | |||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||
| 330 | 15 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||
| 331 | 5 | ▶ | no strict "refs"; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 332 | 15 | my ( $self, $newval ) = @_; | |||||||||||||||||||||||||||||||
| 333 | 15 | $AUTOLOAD =~ /.*::(\w+)/; | |||||||||||||||||||||||||||||||
| 334 | 15 | my $attr = $1; | |||||||||||||||||||||||||||||||
| 335 | 15 | ▶ | if ( $self->_accessible( $attr, 'write' ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 336 | 12 | ▶ | *{$AUTOLOAD} = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 337 | 120 | ▶ | if ( defined $_[1] ) { $_[0]->{$attr} = $_[1] } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 338 | 120 | return $_[0]->{$attr}; | |||||||||||||||||||||||||||||||
| 339 | 12 | }; ### end of created subroutine | |||||||||||||||||||||||||||||||
| 340 | ### this is called first time only | ||||||||||||||||||||||||||||||||
| 341 | 12 | ▶ | if ( defined $newval ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 342 | 0 | $self->{$attr} = $newval; | |||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||
| 344 | 12 | return $self->{$attr}; | |||||||||||||||||||||||||||||||
| 345 | } elsif ( $self->_accessible( $attr, 'read' ) ) { | ||||||||||||||||||||||||||||||||
| 346 | 3 | ▶ | *{$AUTOLOAD} = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 347 | 3 | return $_[0]->{$attr}; | |||||||||||||||||||||||||||||||
| 348 | 3 | }; ### end of created subroutine | |||||||||||||||||||||||||||||||
| 349 | 3 | return $self->{$attr}; | |||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||
| 352 | # Must have been a mistake then... | ||||||||||||||||||||||||||||||||
| 353 | 0 | croak "No such method: $AUTOLOAD"; | |||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | sub DESTROY { } | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 356 | 5 | 1; | |||||||||||||||||||||||||||||||