| 1 | package Bio::Phylo::PhyloWS::Resource::Description; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use base qw'Bio::Phylo::PhyloWS::Resource Bio::Phylo::Listable'; | ||
| 5 | use Bio::Phylo::Util::Exceptions 'throw'; | ||
| 6 | use Bio::Phylo::Util::CONSTANT qw'_DESCRIPTION_ _NONE_'; | ||
| 7 | { | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Bio::Phylo::PhyloWS::Resource::Description - Represents a PhyloWS resource description | ||
| 12 | |||
| 13 | =head1 SYNOPSIS | ||
| 14 | |||
| 15 | # no direct usage | ||
| 16 | |||
| 17 | =head1 DESCRIPTION | ||
| 18 | |||
| 19 | This class represents a resource description for a web resource that implements the PhyloWS | ||
| 20 | recommendations. | ||
| 21 | |||
| 22 | =head1 METHODS | ||
| 23 | |||
| 24 | =head2 CONSTRUCTOR | ||
| 25 | |||
| 26 | =over | ||
| 27 | |||
| 28 | =item new() | ||
| 29 | |||
| 30 | Type : Constructor | ||
| 31 | Title : new | ||
| 32 | Usage : my $desc = Bio::Phylo::PhyloWS::Resource::Description->new( -guid => $guid ); | ||
| 33 | Function: Instantiates Bio::Phylo::PhyloWS::Resource::Description object | ||
| 34 | Returns : a Bio::Phylo::PhyloWS::Resource::Description object | ||
| 35 | Args : Required: -guid => $guid | ||
| 36 | Optional: any number of setters. | ||
| 37 | |||
| 38 | =cut | ||
| 39 | |||
| 40 | sub new { | ||
| 41 | my $self = shift->SUPER::new( | ||
| 42 | @_, | ||
| 43 | '-tag' => 'rdf:RDF', | ||
| 44 | '-attributes' => { | ||
| 45 | 'xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', | ||
| 46 | 'xmlns:dcterms' => 'http://purl.org/dc/terms/', | ||
| 47 | 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', | ||
| 48 | 'xmlns' => 'http://purl.org/rss/1.0/', | ||
| 49 | } | ||
| 50 | ); | ||
| 51 | } | ||
| 52 | |||
| 53 | =back | ||
| 54 | |||
| 55 | =head2 TESTS | ||
| 56 | |||
| 57 | =over | ||
| 58 | |||
| 59 | =item is_identifiable() | ||
| 60 | |||
| 61 | Tests if invocant has an xml id attribute | ||
| 62 | |||
| 63 | Type : Test | ||
| 64 | Title : is_identifiable | ||
| 65 | Usage : if ( $obj->is_identifiable ) { | ||
| 66 | # do something | ||
| 67 | } | ||
| 68 | Function: Tests if invocant has an xml id attribute | ||
| 69 | Returns : FALSE | ||
| 70 | Args : NONE | ||
| 71 | |||
| 72 | =cut | ||
| 73 | |||
| 74 | sub is_identifiable { 0 } | ||
| 75 | |||
| 76 | =back | ||
| 77 | |||
| 78 | =head2 SERIALIZERS | ||
| 79 | |||
| 80 | =over | ||
| 81 | |||
| 82 | =item to_xml() | ||
| 83 | |||
| 84 | Serializes resource to RSS1.0 XML representation | ||
| 85 | |||
| 86 | Type : Serializer | ||
| 87 | Title : to_xml() | ||
| 88 | Usage : print $obj->to_xml(); | ||
| 89 | Function: Serializes object to RSS1.0 XML string | ||
| 90 | Returns : String | ||
| 91 | Args : None | ||
| 92 | Comments: | ||
| 93 | |||
| 94 | =cut | ||
| 95 | |||
| 96 | sub to_xml { | ||
| 97 | my $self = shift; | ||
| 98 | my $link = $self->get_link; | ||
| 99 | my $title = $self->get_name || $self->get_guid || 'Untitled'; | ||
| 100 | my $desc = $self->get_desc || ''; | ||
| 101 | my $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; | ||
| 102 | $xml .= $self->get_xml_tag(0); | ||
| 103 | $xml .= "<channel rdf:about='$link'>"; | ||
| 104 | $xml .= "<title>$title</title>"; | ||
| 105 | $xml .= "<link>$link</link>"; | ||
| 106 | $xml .= "<description>$desc</description>"; | ||
| 107 | $xml .= "<items><rdf:Seq>"; | ||
| 108 | $xml .= "<rdf:li rdf:resource='" . $_->get_link . "'/>" for @{ $self->get_entities }; | ||
| 109 | $xml .= "</rdf:Seq></items></channel>"; | ||
| 110 | $xml .= $_->to_xml for @{ $self->get_entities }; | ||
| 111 | $xml .= sprintf('</%s>', $self->get_tag ); | ||
| 112 | return $xml; | ||
| 113 | } | ||
| 114 | sub _container { _NONE_ } | ||
| 115 | sub _type { _DESCRIPTION_ } | ||
| 116 | |||
| 117 | =back | ||
| 118 | |||
| 119 | =cut | ||
| 120 | |||
| 121 | # podinherit_insert_token | ||
| 122 | |||
| 123 | =head1 SEE ALSO | ||
| 124 | |||
| 125 | There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> | ||
| 126 | for any user or developer questions and discussions. | ||
| 127 | |||
| 128 | Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com> | ||
| 129 | |||
| 130 | =head1 CITATION | ||
| 131 | |||
| 132 | If you use Bio::Phylo in published research, please cite it: | ||
| 133 | |||
| 134 | B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> | ||
| 135 | and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. | ||
| 136 | I<BMC Bioinformatics> B<12>:63. | ||
| 137 | L<http://dx.doi.org/10.1186/1471-2105-12-63> | ||
| 138 | |||
| 139 | =cut | ||
| 140 | |||
| 141 | } | ||
| 142 | 1; |