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