2 package SGN
::Controller
::Seedlot
;
6 BEGIN { extends
'Catalyst::Controller'; }
8 use CXGN
::Stock
::Seedlot
;
12 sub seedlots
:Path
('/breeders/seedlots') :Args
(0) {
15 my $schema = $c->dbic_schema("Bio::Chado::Schema", "sgn_chado");
17 $c->stash->{preferred_species
} = $c->config->{preferred_species
};
18 $c->stash->{timestamp
} = localtime;
20 my @editable_stock_props = split ',', $c->config->{editable_stock_props
};
21 my %editable_stock_props = map { $_=>1 } @editable_stock_props;
22 $c->stash->{editable_stock_props
} = \
%editable_stock_props;
24 my $projects = CXGN
::BreedersToolbox
::Projects
->new( { schema
=> $schema } );
25 my $breeding_programs = $projects->get_breeding_programs();
26 $c->stash->{crossing_trials
} = $projects->get_crossing_trials();
27 $c->stash->{locations
} = JSON
::XS
->new->decode($projects->get_location_geojson());
28 $c->stash->{programs
} = $breeding_programs;
29 $c->stash->{template
} = '/breeders_toolbox/seedlots.mas';
32 sub seedlot_detail
:Path
('/breeders/seedlot') Args
(1) {
35 my $seedlot_id = shift;
36 my $schema = $c->dbic_schema("Bio::Chado::Schema", "sgn_chado");
37 my $phenome_schema = $c->dbic_schema("CXGN::Phenome::Schema");
38 my $people_schema = $c->dbic_schema("CXGN::People::Schema");
40 my $sl = CXGN
::Stock
::Seedlot
->new(
42 phenome_schema
=> $phenome_schema,
43 seedlot_id
=> $seedlot_id
45 my @content_accession_names;
46 my @content_cross_names;
47 my $accessions = $sl->accession();
48 my $accessions_html = '';
50 $accessions_html .= '<a href="/stock/'.$accessions->[0].'/view">'.$accessions->[1].'</a> (accession)';
51 push @content_accession_names, $accessions->[1];
53 my $crosses = $sl->cross();
54 my $crosses_html = '';
56 $crosses_html .= '<a href="/cross/'.$crosses->[0].'">'.$crosses->[1].'</a> (cross)';
57 push @content_cross_names, $crosses->[1];
59 my $populations = $sl->populations();
60 my $populations_html = '';
61 foreach (@
$populations){
62 $populations_html .= '<a href="/stock/'.$_->[0].'/view">'.$_->[1].'</a> ';
64 my $owners = $sl->owners;
65 my $owners_string = '';
67 my $p = $people_schema->resultset("SpPerson")->find({sp_person_id
=>$_});
68 $owners_string .= ' <a href="/solpeople/personal-info.pl?sp_person_id='.$p->sp_person_id.'">'.$p->username.'</a>';
70 $c->stash->{seedlot_id
} = $seedlot_id;
71 $c->stash->{uniquename
} = $sl->uniquename();
72 $c->stash->{organization_name
} = $sl->organization_name();
73 $c->stash->{box_name
} = $sl->box_name();
74 $c->stash->{population_name
} = $populations_html;
75 $c->stash->{content_html
} = $accessions_html ?
$accessions_html : $crosses_html;
76 $c->stash->{content_accession_name
} = $content_accession_names[0];
77 $c->stash->{content_cross_name
} = $content_cross_names[0];
78 $c->stash->{current_count
} = $sl->get_current_count_property();
79 $c->stash->{current_weight
} = $sl->get_current_weight_property();
80 $c->stash->{owners_string
} = $owners_string;
81 $c->stash->{timestamp
} = localtime();
82 $c->stash->{template
} = '/breeders_toolbox/seedlot_details.mas';