clean
[sgn.git] / lib / SGN / Controller / Cvterm.pm
blob4f47c251c2a73054be02cc54aea6b0c280169b4b
2 package SGN::Controller::Cvterm;
4 use CXGN::Chado::Cvterm;
6 use Moose;
8 BEGIN { extends 'Catalyst::Controller' };
9 with 'Catalyst::Component::ApplicationAttribute';
12 =head2 view_cvterm
14 Public path: /cvterm/<cvterm_id>/view
16 View a cvterm detail page.
18 Chained off of L</get_cvterm> below.
20 =cut
22 sub view_cvterm : Chained('get_cvterm') PathPart('view') Args(0) {
23 my ( $self, $c, $action) = @_;
24 my $cvterm = $c->stash->{cvterm};
26 $c->stash(
27 template => '/chado/cvterm.mas',
28 cvterm => $cvterm,
34 =head2 get_cvterm
36 Chain root for fetching a cvterm object to operate on.
38 Path part: /cvterm/<cvterm_id>
40 =cut
42 sub get_cvterm : Chained('/') PathPart('cvterm') CaptureArgs(1) {
43 my ($self, $c, $cvterm_id) = @_;
45 my $identifier_type = $c->stash->{identifier_type}
46 || $cvterm_id =~ /[^-\d]/ ? 'accession' : 'cvterm_id';
48 my $cvterm;
49 if( $identifier_type eq 'cvterm_id' ) {
50 $cvterm = CXGN::Chado::Cvterm->new($c->dbc->dbh, $cvterm_id);
51 } elsif ( $identifier_type eq 'accession' ) {
52 $cvterm = CXGN::Chado::Cvterm->new_with_accession ($c->dbc->dbh , $cvterm_id) ;
54 my $found_cvterm_id = $cvterm->get_cvterm_id
55 or $c->throw_404( "Cvterm not found" );
57 $c->stash->{cvterm} = CXGN::Chado::Cvterm->new($c->dbc->dbh, $found_cvterm_id);
59 return 1;