3 SGN::Controller::BreedingProgram - Catalyst controller for the Breeding Program page
8 package SGN
::Controller
::BreedingProgram
;
13 use CXGN
::BreedingProgram
; # the BP object
14 use SGN
::Model
::Cvterm
; # maybe need this for the projectprop.type_id breeding_program
15 use URI
::FromHash
'uri';
18 ##use CXGN::People::Roles;
21 BEGIN { extends
'Catalyst::Controller' }
22 with
'Catalyst::Component::ApplicationAttribute';
26 isa
=> 'DBIx::Class::Schema',
30 shift->_app->dbic_schema( 'Bio::Chado::Schema', 'sgn_chado' )
33 sub get_breeding_program
: Chained
('/') PathPart
('breeders/program') CaptureArgs
(1) {
34 my ($self, $c, $program_id) = @_;
36 my $schema = $self->schema;
40 $program = CXGN
::BreedingProgram
->new( { schema
=> $schema , program_id
=> $program_id } );
43 $c->stash->{template
} = 'system_message.txt';
44 $c->stash->{message
} = "The requested breeding program ($program_id) does not exist";
47 $c->stash->{user
} = $c->user();
48 $c->stash->{program
} = $program;
52 sub program_info
: Chained
('get_breeding_program') PathPart
('') Args
(0) {
55 #my $user = $c->user();
57 #$c->stash->{user_can_modify} = ($user->check_roles("submitter") || $user->check_roles("curator")) ;
59 my $program = $c->stash->{program
};
62 $c->stash->{message
} = "The requested breeding program does not exist or has been deleted.";
63 $c->stash->{template
} = 'generic_message.mas';
66 $c->stash->{template
} = '/breeders_toolbox/breeding_program.mas';
71 sub profile_detail
: Path
('/profile') Args
(1) {
74 my $profile_id = shift;
75 my $schema = $self->schema;
76 my $profile_json_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($c->dbic_schema("Bio::Chado::Schema"), 'product_profile_json', 'project_property')->cvterm_id();
77 my $profile_rs = $schema->resultset("Project::Projectprop")->search({ projectprop_id
=> $profile_id, type_id
=> $profile_json_type_id });
80 $c->stash->{message
} = 'The requested profile does not exist.';
83 my $profile_row = $profile_rs->next();
84 my $profile_detail_string = $profile_row->value();
86 my $profile_detail_hash = decode_json
$profile_detail_string;
87 my $profile_name = $profile_detail_hash->{'product_profile_name'};
89 $c->stash->{profile_name
} = $profile_name;
90 $c->stash->{user_id
} = $c->user ?
$c->user->get_object()->get_sp_person_id() : undef;
91 $c->stash->{profile_id
} = $profile_id;
92 $c->stash->{template
} = '/breeders_toolbox/program/profile_detail.mas';
98 __PACKAGE__
->meta->make_immutable;