2 package SGN
::Controller
::Cvterm
;
4 #use CXGN::Chado::Cvterm; #DEPRECATE this !!
9 BEGIN { extends
'Catalyst::Controller' };
10 with
'Catalyst::Component::ApplicationAttribute';
14 isa
=> 'DBIx::Class::Schema',
18 shift->_app->dbic_schema( 'Bio::Chado::Schema', 'sgn_chado' )
24 Public path: /cvterm/<cvterm_id>/view
26 View a cvterm detail page.
28 Chained off of L</get_cvterm> below.
32 sub view_cvterm
: Chained
('get_cvterm') PathPart
('view') Args
(0) {
33 my ( $self, $c, $action) = @_;
34 my $cvterm = $c->stash->{cvterm
};
35 my $cvterm_id = $cvterm ?
$cvterm->cvterm_id : undef ;
37 my $bcs_cvterm = $cvterm->cvterm;
39 my ($person_id, $user_role, $curator, $submitter, $sequencer);
40 my $logged_user = $c->user;
41 $person_id = $logged_user->get_object->get_sp_person_id if $logged_user;
42 $user_role = 1 if $logged_user;
43 $curator = $logged_user->check_roles('curator') if $logged_user;
44 $submitter = $logged_user->check_roles('submitter') if $logged_user;
45 $sequencer = $logged_user->check_roles('sequencer') if $logged_user;
46 my $props = $self->_cvtermprops($cvterm);
47 my $editable_cvterm_props = "trait_format,trait_default_value,trait_minimum,trait_maximum,trait_details,trait_categories";
51 template
=> '/chado/cvterm.mas',
52 cvterm
=> $cvterm, #deprecate this maybe?
54 cvterm
=> $bcs_cvterm,
56 submitter
=> $submitter,
57 sequencer
=> $sequencer,
58 person_id
=> $person_id,
60 editable_cvterm_props
=> $editable_cvterm_props,
69 Chain root for fetching a cvterm object to operate on.
71 Path part: /cvterm/<cvterm_id>
75 sub get_cvterm
: Chained
('/') PathPart
('cvterm') CaptureArgs
(1) {
76 my ($self, $c, $cvterm_id) = @_;
78 my $identifier_type = $c->stash->{identifier_type
}
79 || $cvterm_id =~ /[^-\d]/ ?
'accession' : 'cvterm_id';
82 if( $identifier_type eq 'cvterm_id' ) {
83 $cvterm = CXGN
::Cvterm
->new({ schema
=>$self->schema, cvterm_id
=> $cvterm_id } );
84 } elsif ( $identifier_type eq 'accession' ) {
85 $cvterm = CXGN
::Cvterm
->new({ schema
=>$self->schema, accession
=>$cvterm_id } ) ;
87 my $found_cvterm = $cvterm->cvterm
88 or $c->throw_404( "Cvterm $cvterm_id not found" );
90 $c->stash->{cvterm
} = $cvterm;
98 my ($self,$cvterm) = @_;
102 my $bcs_cvterm = $cvterm->cvterm;
103 if (!$bcs_cvterm) { return; }
104 my $cvtermprops = $bcs_cvterm->search_related("cvtermprops");
105 while ( my $prop = $cvtermprops->next ) {
106 push @
{ $properties->{$prop->type->name} } , $prop->value ;