blib/lib/MOBY/Client/ServiceInstance.pm

filter: Statementstmt 86.6% 52 / 60 Branchbran 54.5% 12 / 22 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 12 / 14 Podpod 100% 1 / 1 totaltotal 76.4% 78 / 102 CC 14 SCAR 17.8
CC
14
Cov
76%
new
12.5
AUTOLOAD
4.7
__ANON__
2.0
CRAP 5.9
« blib/lib/MOBY/Client/CollectionArticle.pm ↑ Summary blib/lib/MOBY/Adaptor/moby/DataAccessI.pm »
1 package MOBY::Client::ServiceInstance;
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 vars qw($AUTOLOAD @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use MOBY::Client::MobyUnitTest;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use vars qw /$VERSION/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 $VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /: (\d+)\.(\d+)/;
9  
10 =head1 NAME
11  
12 MOBY::Client::ServiceInstance - a small object describing a MOBY service
13  
14 =head1 SYNOPSIS
15  
16 use MOBY::Client::ServiceInstance;
17 my $Instance = MOBY::Client::ServiceInstance->new(
18 authority => 'bioinfo.pbi.nrc.ca',
19 authoritative => 0,
20 URL => http://bioinfo.pbi.nrc.ca/runMe.pl,
21 contactEmail => markw@illumin.com,
22 name => 'marksFabulousService',
23 type => 'Retrieve',
24 input => [$SimpleArticle],
25 category => 'moby',
26 output => [$CollectionArticle, $SecondaryArticle],
27 description => 'retrieves random sequences from a database',
28 XML => $xml, # the XML from MOBY::Central::findService
29 );
30  
31 =cut
32  
33 =head1 DESCRIPTION
34  
35 a simple get/set object to hold information about a service instance.
36  
37 This object is created by MOBY::Client::Central, and is not particularly
38 useful for anyone else to create it... it is meant to be read-only
39  
40 =head1 AUTHORS
41  
42 Mark Wilkinson (markw at illuminae dot com)
43  
44 BioMOBY Project: http://www.biomoby.org
45  
46  
47 =cut
48  
49 =head1 METHODS
50  
51  
52 =head2 new
53  
54 Title : new
55 Usage : my $MOBY = MOBY::Client::ServiceInstance->new(%args)
56 Function : create ServiceInstance object
57 Returns : MOBY::Client::ServiceInstance object
58 Args : authority : required : string : default NULL
59 the URI of the service provider
60 name : required : string : default NULL
61 the name of the service
62 type : required : string : default NULL
63 the type of service from ontology
64 input : optional : listref : default empty listref
65 the SimpleArticle and CollectionArticle inputs for the service
66 secondary : optional : listref : default empty listref
67 the SecondaryArticle inputs for the service
68 output : optional : listref : default empty listref
69 the SimpleArticle and CollectionArticle outputs for the service
70 description : required : string : default NULL
71 human-readable description of service
72  
73 =cut
74  
75 =head2 authority
76  
77 Title : authority
78 Usage : $URI = $Service->authority($arg)
79 Args : (optional) scalar string with authority URI
80 Function : get/set authority
81 Returns : string
82  
83 =cut
84  
85 =head2 name
86  
87 Title : name
88 Usage : $name = $Service->name($arg)
89 Args : (optional) scalar string with service name
90 Function : get/set name
91 Returns : string
92  
93 =cut
94  
95 =head2 type
96  
97 Title : type
98 Usage : $type = $Service->type($arg)
99 Args : (optional) scalar string with servivce type ontology term
100 Function : get/set type
101 Returns : string
102  
103 =cut
104  
105 =head2 category
106  
107 Title : category
108 Usage : $category = $Service->category($arg)
109 Args : (optional) scalar string with moby service category ['moby' | 'post' | 'moby-async']
110 Function : get/set category
111 Returns : string
112  
113 =cut
114  
115  
116 =head2 input
117  
118 Title : input
119 Usage : $input = $Service->input($args)
120 Args : (optional) listref of SimpleArticle, and/or CollectionArticles
121 Function : get/set input
122 Returns : listref of MOBY::Client::SimpleArticle
123 and/or MOBY::Client::CollectionArticle objects
124  
125 =cut
126  
127 =head2 output
128  
129 Title : output
130 Usage : $output = $Service->output($args)
131 Args : (optional) listref of SimpleArticle,
132 CollectionArticle, or SecondaryArticle objects
133 Function : get/set output
134 Returns : listref of MOBY::Client::SimpleArticle
135 and/or MOBY::Client::CollectionArticle objects
136  
137 =cut
138  
139  
140 =head2 secondary
141  
142 Title : secondary
143 Usage : $output = $Service->secondary($args)
144 Args : (optional) listref of SecondaryArticle objects
145 Function : get/set secondary inputs
146 Returns : listref of MOBY::Client::SecondaryArticle
147  
148 =cut
149  
150 =head2 description
151  
152 Title : description
153 Usage : $description = $Service->description($arg)
154 Args : (optional) scalar string with description
155 Function : get/set description
156 Returns : string
157  
158 =cut
159  
160 =head2 authoritative
161  
162 Title : authoritative
163 Usage : $auth = $Service->authoritative(1|0)
164 Args : (optional) boolean 1 or 0
165 Function : get/set authoritative flag
166 Returns : current value
167  
168 =cut
169  
170 =head2 URL
171  
172 Title : URL
173 Usage : $URL = $Service->URL($url)
174 Args : (optional) string representing a URL
175 Function : get/set service URL endpoint
176 Returns : current value
177  
178 =cut
179  
180 =head2 contactEmail
181  
182 Title : contactEmail
183 Usage : $email = $Service->contactEmail($email)
184 Args : (optional) string representing an email address
185 Function : get/set service email address
186 Returns : current value
187  
188 =cut
189  
190  
191 =head2 LSID
192  
193 Title : LSID
194 Usage : $lsid = $Service->LSID()
195 Args : none
196 Function : get (readonly) service instance LSID
197 Returns : current value as scalar string
198  
199 =cut
200  
201 =head2 signatureURL
202  
203 Title : signatureURL
204 Usage : $sig = $Service->signatureURL()
205 Args : (optional) string representing a URL
206 Function : get/set the location of the RDF document that describes this service
207 Returns : current value as scalar string
208  
209 =cut
210  
211 =head2 registry
212  
213 Title : registry
214 Usage : $regname = $Service->registry([$description])
215 Function : get/set registry
216 Returns : string
217  
218 =cut
219  
220 =head2 unitTests
221  
222 Title : unitTests
223 Usage : $test = $Service->unitTests()
224 Function : get/set the MobyUnitTests for this service
225 Returns : a listref of MOBY::Client::MobyUnitTest objects for this service
226  
227 =cut
228  
229 {
230  
231 # Encapsulated:
232 # DATA
233 #___________________________________________________________
234 #ATTRIBUTES
235 5 my %_attr_data = # DEFAULT ACCESSIBILITY
236 (
237 authority => [ undef, 'read/write' ],
238 signatureURL => [ undef, 'read/write' ],
239 name => [ undef, 'read/write' ],
240 type => [ undef, 'read/write' ],
241 input => [ undef, 'read/write' ], # listref of Simple and Collection articles
242 output => [ undef, 'read/write' ], # listref of Simple and Collection articles
243 secondary => [ undef, 'read/write' ], # listref of SecondaryArticles
244 category => [ undef, 'read/write' ],
245 description => [ undef, 'read/write' ],
246 registry => [ 'MOBY_Central', 'read/write' ],
247 XML => [ undef, 'read/write' ],
248 authoritative => [ undef, 'read/write' ],
249 URL => [ undef, 'read/write' ],
250 contactEmail => [ undef, 'read/write' ],
251 LSID => [ undef, 'read/write'],
252 unitTests => [ undef, 'read/write'], # listref to a MobyUnitTest objects
253 );
254  
255 #_____________________________________________________________
256 # METHODS, to operate on encapsulated class data
257 # Is a specified object attribute accessible in a given mode
258 15 ▶ sub _accessible {
Subroutine _accessible: called CC=1 SCAR=0.0
259 15 my ( $self, $attr, $mode ) = @_;
260 15 $_attr_data{$attr}[1] =~ /$mode/;
261 }
262  
263 # Classwide default value for a specified object attribute
264 16 ▶ sub _default_for {
Subroutine _default_for: called CC=1 SCAR=0.0
265 16 my ( $self, $attr ) = @_;
266 16 $_attr_data{$attr}[0];
267 }
268  
269 # List of names of all specified object attributes
270 1 ▶ sub _standard_keys {
Subroutine _standard_keys: called CC=1 SCAR=0.0
271 1 keys %_attr_data;
272 }
273 }
274  
275 5 ▶sub new {
Subroutine new: called CC=10 SCAR=25.3
Pod documented
276 2 my ( $caller, %args ) = @_;
277 2 my $caller_is_obj = ref( $caller );
278 2 ▶ return $caller if $caller_is_obj;
Branch: 1 branch
BranchTrueFalseTotal
if $caller_is_obj 1 1 2
279 1 ▶ my $class = $caller_is_obj || $caller;
Condition33%1/3
$caller_is_obj || $caller
l!l&&r!l&&!r
010
MC/DC0%0/2
$caller_is_obj || $caller
$caller_is_obj $caller
Truth table33%1/3
A || B
A= $caller_is_objB= $caller
ABresult
1X1
011
000
280 1 my $proxy;
281 1 my $self = bless {}, $class;
282 1 foreach my $attrname ( $self->_standard_keys ) {
283 16 ▶ if ( exists $args{$attrname} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $args{$attrname}) { } 0 16 16
elsif ($caller_is_obj) { } 0 16 16
284 0 $self->{$attrname} = $args{$attrname};
285 } elsif ( $caller_is_obj ) {
286 0 $self->{$attrname} = $caller->{$attrname};
287 } else {
288 16 $self->{$attrname} = $self->_default_for( $attrname );
289 }
290 }
291 1 ▶ $self->input( [] ) unless $self->input;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->input 1 0 1
292 1 ▶ $self->output( [] ) unless $self->output;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->output 1 0 1
293 1 ▶ $self->secondary( [] ) unless $self->secondary;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->secondary 1 0 1
294 1 ▶ $self->unitTests ( [] ) unless $self->unitTests;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->unitTests 1 0 1
295 1 return $self;
296 }
297  
298 15 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=4 SCAR=15.5
299 5 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
300 15 my ( $self, $newval ) = @_;
301 15 $AUTOLOAD =~ /.*::(\w+)/;
302 15 my $attr = $1;
303 15 ▶ if ( $self->_accessible( $attr, 'write' ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_accessible($attr, 'write')) { } 15 0 15
elsif ($self->_accessible($attr, 'read')) { } 0 0 0
304 15 ▶ *{$AUTOLOAD} = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
305 7 ▶ if ( defined $_[1] ) { $_[0]->{$attr} = $_[1] }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) 4 3 7
306 7 return $_[0]->{$attr};
307 15 }; ### end of created subroutine
308 ### this is called first time only
309 15 ▶ if ( defined $newval ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newval) 0 15 15
310 0 $self->{$attr} = $newval;
311 }
312 15 return $self->{$attr};
313 } elsif ( $self->_accessible( $attr, 'read' ) ) {
314 0 ▶ *{$AUTOLOAD} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
315 0 return $_[0]->{$attr};
316 0 }; ### end of created subroutine
317 0 return $self->{$attr};
318 }
319  
320 # Must have been a mistake then...
321 0 croak "No such method: $AUTOLOAD";
322 }
323 0 ▶sub DESTROY { }
Subroutine DESTROY: not called CC=1 SCAR=0.0
324 5 1;
« blib/lib/MOBY/Client/CollectionArticle.pm ↑ Summary blib/lib/MOBY/Adaptor/moby/DataAccessI.pm »