seedlot upload with accession synonyms. seedlot upload works to update existing seedlots
[sgn.git] / lib / SGN / Controller / Folder.pm
bloba9eb75d28c0a1df0e1fbe2fa47aa8a6846ad5d84
1 package SGN::Controller::Folder;
3 use Moose;
4 use Data::Dumper;
5 use Try::Tiny;
6 use SGN::Model::Cvterm;
7 use Data::Dumper;
8 use CXGN::Trial::Folder;
10 BEGIN { extends 'Catalyst::Controller'; }
12 has 'schema' => (
13 is => 'rw',
14 isa => 'DBIx::Class::Schema',
15 lazy_build => 1,
17 sub _build_schema {
18 shift->_app->dbic_schema( 'Bio::Chado::Schema', 'sgn_chado' )
21 sub folder_page :Path("/folder") Args(1) {
22 my $self = shift;
23 my $c = shift;
24 my $folder_id = shift;
26 #print STDERR Dumper $folder_id;
28 my $folder_project = $self->schema->resultset("Project::Project")->find( { project_id => $folder_id } );
29 my $folder = CXGN::Trial::Folder->new({ bcs_schema => $self->schema, folder_id => $folder_id });
31 my $children = $folder->children();
32 my @crosses;
33 my $cross_type_id = SGN::Model::Cvterm->get_cvterm_row($self->schema(), 'cross', 'stock_type')->cvterm_id();
34 foreach (@$children) {
35 if ($_->folder_type eq 'cross') {
36 my $cross_stock = $self->schema->resultset("Project::Project")->search({ 'me.project_id' => $_->folder_id() })->search_related('nd_experiment_projects')->search_related('nd_experiment')->search_related('nd_experiment_stocks')->search_related('stock', {'stock.type_id'=>$cross_type_id})->first();
37 if ($cross_stock) {
38 push @crosses, [$cross_stock->stock_id(), $cross_stock->uniquename()];
42 #print STDERR Dumper \@crosses;
44 $c->stash->{children} = $children;
45 $c->stash->{crosses} = \@crosses;
46 $c->stash->{project_parent} = $folder->project_parent();
47 $c->stash->{breeding_program} = $folder->breeding_program();
48 $c->stash->{folder_id} = $folder_id;
49 $c->stash->{folder_name} = $folder_project->name();
50 $c->stash->{folder_for_trials} = $folder->folder_for_trials();
51 $c->stash->{folder_for_crosses} = $folder->folder_for_crosses();
52 $c->stash->{folder_description} = $folder_project->description();
53 if (!$folder->breeding_program) {
54 $c->stash->{message} = "The requested folder does not exist or has been deleted.";
55 $c->stash->{template} = 'generic_message.mas';
56 return;
58 $c->stash->{template} = '/breeders_toolbox/folder/folder.mas';