blib/lib/MOBY/Client/Service.pm

filter: Statementstmt 16.5% 37 / 223 Branchbran 1.2% 1 / 82 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 39.2% 11 / 28 Podpod 100% 5 / 5 totaltotal 15.3% 54 / 352 CC 51 SCAR 46.2
CC
51
Cov
12%
execute
240.0
enumerated_execute
210.0
new
103.2
CRAP 101.9
« blib/lib/MOBY/RDF/Ontologies/Cache/ServiceCache.pm ↑ Summary blib/lib/MOBY/Adaptor/moby/Impl/FetaQueryAdaptor.pm »
1 #$Id: Service.pm,v 1.4 2009/02/12 19:03:32 kawas Exp $
2  
3 =head1 NAME
4  
5 MOBY::Client::Service - an object for communicating with MOBY Services
6  
7 =head1 SYNOPSIS
8  
9 use MOBY::Client::Service;
10  
11 my $Service = MOBY::Client::Service->new(service => $WSDL);
12 my $result = $Service->execute(@args);
13  
14 =head1 DESCRIPTION
15  
16 Deals with all SOAPy rubbish required to communicate with a MOBY Service.
17 The object is created using the WSDL file returned from a
18 MOBY::Client::Central->retrieveService() call. The only useful method call
19 in this module is "execute", which executes the service.
20  
21 =head1 AUTHORS
22  
23 Mark Wilkinson (markw@illuminae.com)
24  
25 BioMOBY Project: http://www.biomoby.org
26  
27 =head1 METHODS
28  
29 =head2 new
30  
31 Usage : $Service = MOBY::Client::Service->new(@args)
32 Function : create a service connection
33 Returns : MOBY::Client::Service object, undef if no wsdl.
34 Args : service : string ; required
35 a WSDL file defining a MOBY service
36 uri : string ; optional ; default NULL
37 if the URI of the soap call needs to be personalized
38 this should almost never happen...
39  
40 =cut
41  
42 package MOBY::Client::Service;
43 1 ▶use SOAP::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 #use SOAP::Lite + 'trace';
46 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 1 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 1 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 1 ▶use vars qw($AUTOLOAD @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 1 ▶use vars qw /$VERSION/;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 $VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /: (\d+)\.(\d+)/;
54  
55 1 my $debug = 0;
56 1 ▶if ( $debug ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 1 1
57 0 ▶ open( OUT, ">/tmp/ServiceCallLogOut.txt" ) || die "cant open logfile\n";
Branch: 1 branch
BranchTrueFalseTotal
open OUT, ">/tmp/ServiceCallLogOut.txt" or die "cant open logfile\n" 0 0 0
58 0 close OUT;
59 }
60  
61 1 ▶sub BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
62 }
63 {
64  
65 #Encapsulated class data
66 #___________________________________________________________
67 #ATTRIBUTES
68 1 my %_attr_data = # DEFAULT ACCESSIBILITY
69 (
70 service => [ undef, 'read/write' ],
71 uri => [ undef, 'read/write' ],
72 serviceName => [ undef, 'read/write' ],
73 _soapService => [ undef, 'read/write' ],
74 smessageVersion => ['0.88', 'read' ],
75 category => ['moby', 'read/write'],
76 );
77  
78 #_____________________________________________________________
79 # METHODS, to operate on encapsulated class data
80 # Is a specified object attribute accessible in a given mode
81 0 ▶ sub _accessible {
Subroutine _accessible: not called CC=1 SCAR=6.9
82 0 my ( $self, $attr, $mode ) = @_;
83 0 $_attr_data{$attr}[1] =~ /$mode/;
84 }
85  
86 # Classwide default value for a specified object attribute
87 0 ▶ sub _default_for {
Subroutine _default_for: not called CC=1 SCAR=6.9
88 0 my ( $self, $attr ) = @_;
89 0 $_attr_data{$attr}[0];
90 }
91  
92 # List of names of all specified object attributes
93 0 ▶ sub _standard_keys {
Subroutine _standard_keys: not called CC=1 SCAR=6.9
94 0 keys %_attr_data;
95 }
96 1 my $queryID = 0;
97  
98 0 ▶ sub _nextQueryID {
Subroutine _nextQueryID: not called CC=1 SCAR=6.9
99 0 return ++$queryID;
100 }
101 }
102  
103 1 ▶sub new {
Subroutine new: not called CC=10 SCAR=46.4
Pod documented
104 0 my ( $caller, %args ) = @_;
105 0 my $caller_is_obj = ref( $caller );
106 0 ▶ my $class = $caller_is_obj || $caller;
Condition0%0/3
$caller_is_obj || $caller
l!l&&r!l&&!r
000
MC/DC0%0/2
$caller_is_obj || $caller
$caller_is_obj $caller
Truth table0%0/3
A || B
A= $caller_is_objB= $caller
ABresult
1X1
011
000
107 0 my $self = bless {}, $class;
108 0 foreach my $attrname ( $self->_standard_keys ) {
109 0 ▶ if ( exists $args{$attrname} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $args{$attrname}) { } 0 0 0
elsif ($caller_is_obj) { } 0 0 0
110 0 $self->{$attrname} = $args{$attrname};
111 } elsif ( $caller_is_obj ) {
112 0 $self->{$attrname} = $caller->{$attrname};
113 } else {
114 0 $self->{$attrname} = $self->_default_for( $attrname );
115 }
116 }
117 0 my $wsdl = $self->service;
118 0 ▶ return undef unless $wsdl;
Branch: 1 branch
BranchTrueFalseTotal
unless $wsdl 0 0 0
119  
120 0 ▶ if ($wsdl =~ /<http:binding verb=['"]POST['"]\/>/){
Branch: 1 branch
BranchTrueFalseTotal
if ($wsdl =~ m[<http:binding verb=['"]POST['"]/>]) 0 0 0
121 0 $self->category('post');
122 }
123  
124 # TODO - added to make old WSDL compliant with soap lite 0.69
125 0 ▶ if ( $wsdl =~ /element="xsd1:NOT_YET_DEFINED_INPUTS"/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wsdl =~ /element="xsd1:NOT_YET_DEFINED_INPUTS"/) 0 0 0
126 0 $wsdl =~ s/name="body" element="xsd1:NOT_YET_DEFINED_INPUTS"/name="data" type="xsd:string"/g;
127 0 $wsdl =~ s/element="xsd1:NOT_YET_DEFINED_OUTPUTS"/type="xsd:string"/g;
128 }
129
130 0 $wsdl = URI::Escape::uri_escape( $self->service ); # this seems to fix the bug
131
132 0 my $soap = SOAP::Lite->service( "data:,$wsdl" );
133 0 $soap->soapversion('1.1');
134 0 $self->_soapService( $soap );
135 0 ▶ if ( $self->uri ) { $soap->uri( $self->uri ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->uri) 0 0 0
136 0 $self->serviceName( $self->_getServiceName() );
137 0 ▶ return undef unless $self->serviceName; # servicename could not be determined, so no methods can be called
Branch: 1 branch
BranchTrueFalseTotal
unless $self->serviceName 0 0 0
138 0 return $self;
139 }
140  
141 =head2 execute
142  
143 Usage : $result = $Service->execute(%args)
144 Function : execute the MOBY service
145 Returns : whatever the Service provides as output
146 Args : XMLinputlist => \@data
147 Comment : @data is a list of single invocation inputs; the XML goes between the
148 <queryInput> tags of a servce invocation XML.
149 Each element of @data is itself a listref of [articleName, $XML].
150 articleName may be undef if it isn't required.
151 $XML is the actual XML of the Input object
152  
153 =head3 Examples
154  
155 There are several ways in which you can execute a service. You may
156 wish to invoke the service on several objects, and get the response
157 back in a single message. You may wish to pass in a collection of
158 objects, which should be treated as a single entity. Or you may wish
159 to pass in parameters, along with data. In each case, you're passing in
160  
161 XMLinputlist => [ ARGS ]
162  
163 The structure of @ARGS helps MOBY to figure out what you want.
164  
165 =over 4
166  
167 =item Iterate over multiple Simples
168  
169 To have the service iterate over multiple equivalent objects, and
170 return all the results in a single message, use this syntax (ARGS =
171 ([...], [...], ...). Here, the articleName of the input parameter is
172 "input1":
173  
174 $Service->execute(XMLinputlist => [
175 ['input1', '<Object namespace="blah" id="123"/>'],
176 ['input1', '<Object namespace="blah" id="234"/>']
177 ]);
178  
179 This would invoke the service twice (in a single message) the first
180 time with an object "123" and the second time with object "234".
181  
182 =item Process a Collection
183  
184 To pass in a Collection, you need this syntax (ARGS = [ '', [..., ..., ...] ]).
185 Here, the articleName of the input is "input1".
186  
187 $Service->execute(XMLinputlist => [
188 ['input1', [
189 '<Object namespace="blah" id="123"/>',
190 '<Object namespace="blah" id="234"/>']
191 ]);
192  
193 This would invoke the service once with a collection of inputs that
194 are not required to be named ('').
195  
196 =item Process multiple Simple inputs
197  
198 To pass in multiple inputs, to be considered neither a Collection nor sequentially
199 evaluated, use this syntax (ARGS = [..., ..., ...]). Here, the service consumes
200 two inputs with articleName input1 and input2
201  
202 $Service->execute(XMLinputlist => [
203 [
204 'input1', '<Object namespace="blah" id="123"/>',
205 'input2', '<Object namespace="blah" id="234"/>',
206 ]
207 ]);
208  
209 This would cause a single invocation of a service.
210  
211 =item Parameters
212  
213 Finally, MOBY will recognize parameters by virtue of their having been
214 declared when the service was registered. You need to specify the name
215 correctly.
216  
217 $Service->execute(XMLinputlist => [
218 [
219 'input1', '<Object namespace="blah" id="123"/>',
220 'input2', '<Object namespace="blah" id="234"/>',
221 'param1', '<Value>0.001</Value>',
222 ]
223 ]);
224  
225 This would cause a single invocation of a service requiring two input
226 parameters named "input1" and "input2", and a parameter named 'param1'
227 with a value of 0.001
228  
229 =back
230  
231 =cut
232  
233 0 ▶sub execute {
Subroutine execute: not called CC=15 SCAR=54.8
Pod documented
234 # The biggest unanswered question for this subroutine is how it should respond in the event
235 # that there is a problem with the service.
236 # It should probably die() rather than just return strings as error messages.
237 0 my ( $self, %args ) = @_;
238 die "ERROR: expected listref for XMLinputlist"
239 0 ▶ unless ( ref( $args{XMLinputlist} ) eq 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"XMLinputlist"} eq "ARRAY" 0 0 0
240 0 my @inputs = @{ $args{XMLinputlist} };
241 0 my $data;
242 0 foreach ( @inputs ) {
243 0 ▶ die "ERROR: expected listref [articleName, XML] for data element"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_ eq "ARRAY" 0 0 0
244 unless ( ref( $_ ) eq 'ARRAY' );
245 0 my $qID = $self->_nextQueryID;
246 0 $data .= "<moby:mobyData queryID='$qID'>";
247 0 ▶ while ( my ( $articleName, $XML ) = splice( @{$_}, 0, 2 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@{$_;}, 0, 2)) 0 0 0
248 0 ▶ $articleName ||= "";
Condition0%0/2
$articleName ||= ""
l!l
00
MC/DC0%0/1
$articleName ||= ""
$articleName
Truth table0%0/2
A
A= $articleName
Aresult
11
00
249 0 ▶ if ( ref( $XML ) ne 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $XML ne 'ARRAY') { } 0 0 0
elsif (ref $XML eq 'ARRAY') { } 0 0 0
250 0 ▶ $XML ||= "";
Condition0%0/2
$XML ||= ""
l!l
00
MC/DC0%0/1
$XML ||= ""
$XML
Truth table0%0/2
A
A= $XML
Aresult
11
00
251 0 ▶ if ( $XML =~ /\<(moby\:|)Value\>/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($XML =~ /\<(moby\:|)Value\>/) { } 0 0 0
252 {
253 0 $data .=
254 "<moby:Parameter moby:articleName='$articleName'>$XML</moby:Parameter>";
255 } else {
256 0 $data .=
257 "<moby:Simple moby:articleName='$articleName'>\n$XML\n</moby:Simple>\n";
258 }
259
260 # need to do this for collections also!!!!!!
261 } elsif ( ref( $XML ) eq 'ARRAY' ) {
262 0 my @objs = @{$XML};
263 0 $data .= "<moby:Collection moby:articleName='$articleName'>\n";
264 0 foreach ( @objs ) {
265 0 $data .= "<moby:Simple>$_</moby:Simple>\n";
266 }
267 0 $data .= "</moby:Collection>\n";
268 }
269 }
270 0 $data .= "</moby:mobyData>\n";
271 }
272 ###################
273 # this was added on January 19th, 2005 and may not work!
274 ###################
275 ###################
276 0 my $version = $self->smessageVersion();
277 0 $data = "<?xml version='1.0' encoding='UTF-8'?>
278 <moby:MOBY xmlns:moby='http://www.biomoby.org/moby' moby:smessageVersion='$version'>
279 <moby:mobyContent>
280 $data
281 </moby:mobyContent>
282 </moby:MOBY>";
283 # $data =~ s"&"&amp;"g; # encode content in case it has CDATA
284 # $data =~ s"\<"&lt;"g;
285 # $data =~ s"\]\]\>"\]\]&gt;"g;
286
287 ####################
288 ####################
289 ### BEFORE IT WAS JUST THIS
290
291 #$data = "<![CDATA[<?xml version='1.0' encoding='UTF-8'?>
292 #<moby:MOBY xmlns:moby='http://www.biomoby.org/moby-s'>
293 # <moby:mobyContent>
294 # $data
295 # </moby:mobyContent>
296 #</moby:MOBY>]]>";
297 0 my $METHOD = $self->serviceName;
298 0 &_LOG( %args, $METHOD );
299 0 my $response;
300  
301 0 ▶ if ($self->category eq 'moby'){
Branch: 2 branches
BranchTrueFalseTotal
if ($self->category eq 'moby') { } 0 0 0
elsif ($self->category eq 'post') { } 0 0 0
302 0 eval { ( $response ) = $self->_soapService->$METHOD( $data ) };
303 0 ▶ if ($@) { die "Service execution failed: $@"}
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
304 0 else {return $response;} # the service execution failed then pass back ""
305 } elsif ($self->category eq 'post'){
306 0 my $response = $self->_executePOSTService(data => $data, method => $METHOD);
307 # currently SOAP::Lite does not execute POST WSDL, so we need to
308 # use LWP or something like that in the executePOSTService method
309 #eval { ( $response ) = $self->_soapService->$METHOD( $data ) };
310 0 ▶ unless ($response){ die "Service execution failed: $@"}
Branch: 1 branch
BranchTrueFalseTotal
if ($response) { } 0 0 0
311 0 else {return $response;} # the service execution failed then pass back ""
312 }
313 }
314  
315  
316 =head2 raw_execute
317  
318 Usage : $result = $Service->raw_execute(inputXML => "<../>")
319 Function : execute the MOBY service using a raw MOBY input block
320 Returns : whatever the Service provides as output
321 Args : inputXML => "<moby:MOBY>.....</moby:MOBY>"
322  
323 =cut
324  
325 0 ▶sub raw_execute {
Subroutine raw_execute: not called CC=5 SCAR=34.0
Pod documented
326 0 my ( $self, %args ) = @_;
327 0 my $data = $args{inputXML};
328  
329 0 my $METHOD = $self->serviceName;
330 0 my $response;
331  
332 0 ▶ if ($self->category eq 'moby'){
Branch: 2 branches
BranchTrueFalseTotal
if ($self->category eq 'moby') { } 0 0 0
elsif ($self->category eq 'cgi') { } 0 0 0
333 0 eval { ( $response ) = $self->_soapService->$METHOD( $data ) };
334 0 ▶ if ($@) { die "Service execution failed: $@"}
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
335 0 else {return $response;} # the service execution failed then pass back ""
336 } elsif ($self->category eq 'cgi'){
337 0 my $response = $self->_executePOSTService(data => $data, method => $METHOD);
338 # currently SOAP::Lite does not execute POST WSDL, so we need to
339 # use LWP or something like that in the executePOSTService method
340 #eval { ( $response ) = $self->_soapService->$METHOD( $data ) };
341 0 ▶ unless ($response){ die "Service execution failed: $@"}
Branch: 1 branch
BranchTrueFalseTotal
if ($response) { } 0 0 0
342 0 else {return $response;} # the service execution failed then pass back ""
343 }
344
345
346 }
347 0 ▶sub _executePOSTService {
Subroutine _executePOSTService: not called CC=2 SCAR=15.3
348 0 my ($self, %args) = @_;
349 0 my $serviceName = $args{method};
350 0 my $data = $args{data};
351 0 my $wsdl = $self->service;
352 0 $wsdl =~ /address\slocation=['"]([^'"]+)/s;
353 0 my $location = $1;
354 0 $wsdl =~/operation\slocation=['"]([^'"]+)/s;
355 0 my $path = $1;
356 1 ▶ use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
357 0 my $ua = LWP::UserAgent->new;
358
359 # Create a request
360 0 my $req = HTTP::Request->new(POST => "$location/$path");
361 0 $req->content_type('application/x-www-form-urlencoded');
362 0 $req->content('data=$data');
363
364 # Pass request to the user agent and get a response back
365 0 my $res = $ua->request($req);
366 0 my $result;
367 # Check the outcome of the response
368 0 ▶ if ($res->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->is_success) { } 0 0 0
369 0 $result = $res->content;
370 }
371 else {
372 0 $result = "";
373 }
374 0 return $result;
375 }
376  
377  
378 =head2 enumerated_execute
379  
380 Usage : $result = $Service->enumerated_execute(%args)
381 Function : execute the MOBY service using self-enumerated inputs
382 Returns : whatever the Service provides as output
383 Args : Input => %data
384 Comment : %data is a hash of single invocation inputs
385 the structure of %data is:
386  
387 $data{$queryID} = {articleName => $inputXML1, # for simples and parameters
388 articleNmae => [$inputXML2, $inputXML3], # for collections
389 }
390 $inputXML is the actual XML of the Input object
391 for example <Object namespace="NCBI_gi" id="163483"/>
392  
393 a full example might be:
394  
395 $data{invocation1} = {id_to_match => "<Object namespace="GO" id="0003875"/>",
396 id_list => ["<Object namespace="GO" id="0003875"/>,
397 "<Object namespace="GO" id="0009984"/>,...
398 ]
399 cutoff => "<Value>10</Value>"
400 }
401  
402  
403 =cut
404  
405  
406  
407 0 ▶sub enumerated_execute {
Subroutine enumerated_execute: not called CC=14 SCAR=53.5
Pod documented
408 0 my ( $self, %args ) = @_;
409 die "ERROR: expected Input to be a HASH ref "
410 0 ▶ unless ( ref( $args{Input} ) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"Input"} eq "HASH" 0 0 0
411 0 my %inputs = %{$args{Input}};
412 # structure of %input is:
413 #$input{qid} = {articleName => "<XML>", # for simples
414 # articleName2 => ["<XML>", "<XML>"], # for collections
415 # }
416  
417 0 my $data;
418 0 foreach my $qID( keys %inputs ) {
419 0 ▶ die "ERROR: expected hashref {articleName => XML} for each queryID" unless ( ref($inputs{$qID}) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $inputs{$qID} eq "HASH" 0 0 0
420 0 my %articles = %{$inputs{$qID}};
421 0 $data .= "<moby:mobyData queryID='$qID'>";
422 0 foreach my $articleName(keys %articles){
423 0 my $XML = $articles{$articleName};
424 0 ▶ if ( ref( $XML ) ne 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $XML ne 'ARRAY') { } 0 0 0
elsif (ref $XML eq 'ARRAY') { } 0 0 0
425 0 ▶ $XML ||= "";
Condition0%0/2
$XML ||= ""
l!l
00
MC/DC0%0/1
$XML ||= ""
$XML
Truth table0%0/2
A
A= $XML
Aresult
11
00
426 0 ▶ if ( $XML =~ /\<(moby\:|)Value\>/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($XML =~ /\<(moby\:|)Value\>/) { } 0 0 0
427 0 $data .= "<moby:Parameter moby:articleName='$articleName'>$XML</moby:Parameter>";
428 } else {
429 0 $data .= "<moby:Simple moby:articleName='$articleName'>\n$XML\n</moby:Simple>\n";
430 }
431 } elsif ( ref( $XML ) eq 'ARRAY' ) {
432 0 my @objs = @{$XML};
433 0 $data .= "<moby:Collection moby:articleName='$articleName'>\n";
434 0 foreach ( @objs ) {
435 0 $data .= "<moby:Simple>$_</moby:Simple>\n";
436 }
437 0 $data .= "</moby:Collection>\n";
438 }
439 }
440 0 $data .= "</moby:mobyData>\n";
441 }
442 ###################
443 # this was added on January 19th, 2005 and may not work!
444 ###################
445 ###################
446 0 my $version = $self->smessageVersion();
447 0 $data = "<?xml version='1.0' encoding='UTF-8'?>
448 <moby:MOBY xmlns:moby='http://www.biomoby.org/moby' moby:smessageVersion='$version'>
449 <moby:mobyContent>
450 $data
451 </moby:mobyContent>
452 </moby:MOBY>";
453 0 my $METHOD = $self->serviceName;
454 0 &_LOG( %args, $METHOD );
455 0 my $response;
456  
457 0 ▶ if ($self->category eq 'moby'){
Branch: 2 branches
BranchTrueFalseTotal
if ($self->category eq 'moby') { } 0 0 0
elsif ($self->category eq 'post') { } 0 0 0
458 0 eval { ( $response ) = $self->_soapService->$METHOD( $data ) };
459 0 ▶ if ($@) { die "Service execution failed: $@"}
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
460 0 else {return $response;} # the service execution failed then pass back ""
461 } elsif ($self->category eq 'post'){
462 0 my $response = $self->_executePOSTService(data => $data, method => $METHOD);
463 # currently SOAP::Lite does not execute POST WSDL, so we need to
464 # use LWP or something like that in the executePOSTService method
465 #eval { ( $response ) = $self->_soapService->$METHOD( $data ) };
466 0 ▶ unless ($response){ die "Service execution failed: $@"}
Branch: 1 branch
BranchTrueFalseTotal
if ($response) { } 0 0 0
467 0 else {return $response;} # the service execution failed then pass back ""
468 }
469 }
470  
471  
472  
473  
474 =head2 methods
475  
476 Usage : $name = $Service->methods()
477 Function : retrieve all possible method calls for a given service
478 Returns : listref of method names as strings
479 Args : none
480  
481 =cut
482  
483 0 ▶sub methods {
Subroutine methods: not called CC=1 SCAR=2.2
Pod documented
484 0 my ($self) = @_;
485 0 my $service = $self->_soapService;
486 1 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
487 0 my @methods = @{ join '::', ref $service, 'EXPORT_OK' };
488 return \@methods
489 0 }
490  
491  
492 =head2 serviceName
493  
494 Usage : $name = $Service->serviceName()
495 Function : get the name of the service
496 Returns : string
497 Args : none
498  
499 =cut
500  
501 =head2 _getServiceName
502  
503 Usage : $name = $Service->_getServiceName()
504 Function : Internal method to retrieve the name of the service from the SOAP object
505 In the case of Asynchronous services it will return the base name of
506 the service (i.e. myService, rather than myService_submit). This base name
507 is not guaranteed to give you any output if you call it!
508 Returns : string
509 Args : none
510  
511 =cut
512  
513 0 ▶sub _getServiceName {
Subroutine _getServiceName: not called CC=4 SCAR=30.0
514 0 my ( $self ) = @_;
515 0 my @methods = @{$self->methods};
516 0 ▶ return shift @methods if scalar @methods <=1; # in case of non-asynch services it is the only one there.
Branch: 1 branch
BranchTrueFalseTotal
if scalar @methods <= 1 0 0 0
517 0 foreach (@methods){
518 0 ▶ next unless m/^(\S+)_submit/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^(\S+)_submit/ 0 0 0
519 0 return $1;
520 }
521 return undef
522 0 }
523  
524  
525  
526 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=4 SCAR=27.3
527 1 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
528 0 my ( $self, $newval ) = @_;
529 0 $AUTOLOAD =~ /.*::(\w+)/;
530 0 my $attr = $1;
531 0 ▶ if ( $self->_accessible( $attr, 'write' ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_accessible($attr, 'write')) { } 0 0 0
elsif ($self->_accessible($attr, 'read')) { } 0 0 0
532 0 ▶ *{$AUTOLOAD} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
533 0 ▶ if ( defined $_[1] ) { $_[0]->{$attr} = $_[1] }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) 0 0 0
534 0 return $_[0]->{$attr};
535 0 }; ### end of created subroutine
536 ### this is called first time only
537 0 ▶ if ( defined $newval ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newval) 0 0 0
538 0 $self->{$attr} = $newval;
539 }
540 0 return $self->{$attr};
541 } elsif ( $self->_accessible( $attr, 'read' ) ) {
542 0 ▶ *{$AUTOLOAD} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
543 0 return $_[0]->{$attr};
544 0 }; ### end of created subroutine
545 0 return $self->{$attr};
546 }
547  
548 # Must have been a mistake then...
549 0 croak "No such method: $AUTOLOAD";
550 }
551 0 ▶sub DESTROY { }
Subroutine DESTROY: not called CC=1 SCAR=0.0
552  
553 0 ▶sub SOAP::Transport::HTTP::Client::get_basic_credentials {
Subroutine get_basic_credentials: not called CC=1 SCAR=6.9
554 0 my ( $username, $password );
555 0 print "ENTER USERNAME: ";
556 0 $username = <STDIN>;
557 0 chomp $username;
558 0 print "ENTER PASSWORD: ";
559 0 $password = <STDIN>;
560 0 chomp $password;
561 0 return $username => $password;
562 }
563  
564 0 ▶sub _LOG {
Subroutine _LOG: not called CC=3 SCAR=24.8
565 0 ▶ return unless $debug;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug 0 0 0
566 0 ▶ open LOG, ">>/tmp/ServiceCallLogOut.txt" or die "can't open logfile $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open LOG, ">>/tmp/ServiceCallLogOut.txt" or die "can't open logfile $!\n" 0 0 0
567 0 print LOG join "\n", @_;
568 0 print LOG "\n---\n";
569 0 close LOG;
570 }
571  
572 #
573 #
574 # --------------------------------------------------------------------------------------------------------
575 #
576 ##
577 ##
578 1 1;
« blib/lib/MOBY/RDF/Ontologies/Cache/ServiceCache.pm ↑ Summary blib/lib/MOBY/Adaptor/moby/Impl/FetaQueryAdaptor.pm »