Merge pull request #5230 from solgenomics/topic/open_pollinated
[sgn.git] / lib / SGN / Controller / Folder.pm
blob17fae75bb63f7450943c0047373230efa47316db
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();
33 my @trials;
34 my @cross_trials;
35 my @genotyping_trials;
36 my @genotyping_projects;
37 my @analyses_trials;
38 my @tracking_activities;
39 my @child_folders;
40 my $has_child_folders;
41 foreach (@$children) {
42 # print STDERR "CHECK FOLDER =".Dumper($_->folder_type." : ".$_->name)."\n";
43 if ($_->folder_type eq 'trial') {
44 push @trials, $_;
46 if ($_->folder_type eq 'cross') {
47 push @cross_trials, $_;
49 if ($_->folder_type eq 'genotyping_trial') {
50 push @genotyping_trials, $_;
52 if ($_->folder_type eq 'genotyping_project') {
53 push @genotyping_projects, $_;
55 if ($_->folder_type eq 'analyses') {
56 push @analyses_trials, $_;
58 if ($_->folder_type eq 'activity_record') {
59 push @tracking_activities, $_;
61 if ($_->folder_type eq 'folder') {
62 $has_child_folders = 1;
63 push @child_folders, $_;
67 $c->stash->{trials} = \@trials;
68 $c->stash->{crossing_trials} = \@cross_trials;
69 $c->stash->{genotyping_trials} = \@genotyping_trials;
70 $c->stash->{genotyping_projects} = \@genotyping_projects;
71 $c->stash->{analyses_trials} = \@analyses_trials;
72 $c->stash->{tracking_activities} = \@tracking_activities;
73 $c->stash->{child_folders} = \@child_folders;
74 $c->stash->{project_parent} = $folder->project_parent();
75 $c->stash->{breeding_program} = $folder->breeding_program();
76 $c->stash->{folder_id} = $folder_id;
77 $c->stash->{folder_name} = $folder_project->name();
78 $c->stash->{folder_for_trials} = $folder->folder_for_trials();
79 $c->stash->{folder_for_crosses} = $folder->folder_for_crosses();
80 $c->stash->{folder_for_genotyping_trials} = $folder->folder_for_genotyping_trials();
81 $c->stash->{folder_for_genotyping_projects} = $folder->folder_for_genotyping_projects();
82 $c->stash->{folder_for_tracking_activities} = $folder->folder_for_tracking_activities();
83 $c->stash->{folder_for_transformations} = $folder->folder_for_transformations();
84 $c->stash->{folder_description} = $folder_project->description();
85 $c->stash->{has_child_folders} = $has_child_folders;
86 if (!$folder->breeding_program) {
87 $c->stash->{message} = "The requested folder does not exist or has been deleted.";
88 $c->stash->{template} = 'generic_message.mas';
89 return;
91 $c->stash->{template} = '/breeders_toolbox/folder/folder.mas';