| 1 | #$Id: Registration.pm,v 1.2 2008/09/02 13:11:40 kawas Exp $ | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | MOBY::Client::Registration - an object to wrap the registration XML from MOBY Central | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | =cut | ||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | my $reg = $Central->registerService(%args); | ||||||||||||||||||||||||||||||||
| 12 | if ($reg->success){ | ||||||||||||||||||||||||||||||||
| 13 | print "registered successfully ",$reg->registration_id,"\n"; | ||||||||||||||||||||||||||||||||
| 14 | } else { | ||||||||||||||||||||||||||||||||
| 15 | print "registration failed ",$reg->message,"\n"; | ||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | simply turns the registration XML into a hash | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | Mark Wilkinson (markw@illuminae.com) | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | BioMOBY Project: http://www.biomoby.org | ||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | =head1 METHODS | ||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | =head2 new | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | Title : new | ||||||||||||||||||||||||||||||||
| 38 | Usage : my $MOBY = MOBY::Client::Registration->new(%args) | ||||||||||||||||||||||||||||||||
| 39 | Function : | ||||||||||||||||||||||||||||||||
| 40 | Returns : MOBY::Client::Registration object | ||||||||||||||||||||||||||||||||
| 41 | Args : registration_id => $id | ||||||||||||||||||||||||||||||||
| 42 | message => $message | ||||||||||||||||||||||||||||||||
| 43 | success => $success | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | =head2 success | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | get/set the value | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | =head2 registration_id | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | get/set the value | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | =head2 id (same as registration_id) | ||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | get/set the value | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | =head2 message | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | get/set the value | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | =head2 RDF | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | get/set the value | ||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | package MOBY::Client::Registration; | ||||||||||||||||||||||||||||||||
| 70 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 71 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 72 | 5 | ▶ | use vars qw($AUTOLOAD); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 5 | ▶ | use vars qw /$VERSION/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 75 | 5 | $VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /: (\d+)\.(\d+)/; | |||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | #Encapsulated class data | ||||||||||||||||||||||||||||||||
| 80 | #___________________________________________________________ | ||||||||||||||||||||||||||||||||
| 81 | #ATTRIBUTES | ||||||||||||||||||||||||||||||||
| 82 | 5 | my %_attr_data = # DEFAULT ACCESSIBILITY | |||||||||||||||||||||||||||||||
| 83 | ( | ||||||||||||||||||||||||||||||||
| 84 | success => [ 0, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 85 | message => [ "OK", 'read/write' ], | ||||||||||||||||||||||||||||||||
| 86 | registration_id => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 87 | RDF => [ undef, 'read/write' ], | ||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | #_____________________________________________________________ | ||||||||||||||||||||||||||||||||
| 91 | # METHODS, to operate on encapsulated class data | ||||||||||||||||||||||||||||||||
| 92 | # Is a specified object attribute accessible in a given mode | ||||||||||||||||||||||||||||||||
| 93 | 4 | ▶ | sub _accessible { | ||||||||||||||||||||||||||||||
|
Subroutine
_accessible: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 94 | 4 | my ( $self, $attr, $mode ) = @_; | |||||||||||||||||||||||||||||||
| 95 | 4 | $_attr_data{$attr}[1] =~ /$mode/; | |||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | # Classwide default value for a specified object attribute | ||||||||||||||||||||||||||||||||
| 99 | 4 | ▶ | sub _default_for { | ||||||||||||||||||||||||||||||
|
Subroutine
_default_for: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 100 | 4 | my ( $self, $attr ) = @_; | |||||||||||||||||||||||||||||||
| 101 | 4 | $_attr_data{$attr}[0]; | |||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | # List of names of all specified object attributes | ||||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | sub _standard_keys { | ||||||||||||||||||||||||||||||
|
Subroutine
_standard_keys: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 106 | 1 | keys %_attr_data; | |||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | 5 | ▶ | sub id { | ||||||||||||||||||||||||||||||
|
Subroutine
id: not called CC=2 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 111 | 0 | my ( $self, $val ) = @_; | |||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $self->registration_id( $val ) if defined $val; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 113 | 0 | return $self->registration_id; | |||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 117 | 1 | my ( $caller, %args ) = @_; | |||||||||||||||||||||||||||||||
| 118 | 1 | my $caller_is_obj = ref( $caller ); | |||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | 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
| |||||||||||||||||||||||||||||||||
| 120 | 1 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||
| 121 | 1 | foreach my $attrname ( $self->_standard_keys ) { | |||||||||||||||||||||||||||||||
| 122 | 4 | ▶ | if ( exists $args{$attrname} && defined $args{$attrname} ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
exists $args{$attrname} and defined $args{$attrname}
MC/DC0%0/2
exists $args{$attrname} and defined $args{$attrname}
exists $args{$attrname}
defined $args{$attrname}
Truth table33%1/3
A and B
A= exists $args{$attrname}B= defined $args{$attrname}
| |||||||||||||||||||||||||||||||||
| 123 | 0 | $self->{$attrname} = $args{$attrname}; | |||||||||||||||||||||||||||||||
| 124 | } elsif ( $caller_is_obj ) { | ||||||||||||||||||||||||||||||||
| 125 | 0 | $self->{$attrname} = $caller->{$attrname}; | |||||||||||||||||||||||||||||||
| 126 | } else { | ||||||||||||||||||||||||||||||||
| 127 | 4 | $self->{$attrname} = $self->_default_for( $attrname ); | |||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||
| 130 | 1 | return $self; | |||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub DESTROY { } | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | 4 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=4 SCAR=18.7
| |||||||||||||||||||||||||||||||||
| 135 | 5 | ▶ | no strict "refs"; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 136 | 4 | my ( $self, $newval ) = @_; | |||||||||||||||||||||||||||||||
| 137 | 4 | $AUTOLOAD =~ /.*::(\w+)/; | |||||||||||||||||||||||||||||||
| 138 | 4 | my $attr = $1; | |||||||||||||||||||||||||||||||
| 139 | 4 | ▶ | if ( $self->_accessible( $attr, 'write' ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 140 | 4 | ▶ | *{$AUTOLOAD} = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.6
| |||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ( defined $_[1] ) { $_[0]->{$attr} = $_[1] } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 142 | 0 | return $_[0]->{$attr}; | |||||||||||||||||||||||||||||||
| 143 | 4 | }; ### end of created subroutine | |||||||||||||||||||||||||||||||
| 144 | ### this is called first time only | ||||||||||||||||||||||||||||||||
| 145 | 4 | ▶ | if ( defined $newval ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | 0 | $self->{$attr} = $newval; | |||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | 4 | return $self->{$attr}; | |||||||||||||||||||||||||||||||
| 149 | } elsif ( $self->_accessible( $attr, 'read' ) ) { | ||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | *{$AUTOLOAD} = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 151 | 0 | return $_[0]->{$attr}; | |||||||||||||||||||||||||||||||
| 152 | 0 | }; ### end of created subroutine | |||||||||||||||||||||||||||||||
| 153 | 0 | return $self->{$attr}; | |||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | # Must have been a mistake then... | ||||||||||||||||||||||||||||||||
| 157 | 0 | croak "No such method: $AUTOLOAD"; | |||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||
| 159 | 5 | 1; | |||||||||||||||||||||||||||||||