Merge pull request #5134 from solgenomics/topic/fix_seedlot_search
[sgn.git] / cgi-bin / gem / experimental_design.pl
blob4f33dbcc3df8497498d2835378fc405ef8424fd3
1 #!/usr/bin/perl
3 =head1 NAME
5 experimental_design.pl
6 Controller for experimental design mason components
8 =cut
10 =head1 DESCRIPTION
12 This is the script to show the web_page using MASON
14 =cut
16 =head1 AUTHORS
18 Aureliano Bombarely Gomez
19 (ab782@cornell.edu)
21 =cut
24 use strict;
25 use warnings;
27 use HTML::Mason;
28 use CXGN::Page;
30 use CXGN::MasonFactory;
31 use CXGN::DB::Connection;
32 use CXGN::DB::DBICFactory;
33 use CXGN::GEM::Schema;
34 use CXGN::GEM::ExperimentalDesign;
36 my $m = CXGN::MasonFactory->new();
38 ## Use of CXGN::Page to take the arguments from the URL
40 my %args = CXGN::Page->new()
41 ->get_all_encoded_arguments();
44 ## Create the schema used for all the gem searches
46 my $psqlv = `psql --version`;
47 chomp($psqlv);
49 my @schema_list = ('gem', 'biosource', 'metadata', 'public');
50 if ($psqlv =~ /8\.1/) {
51 push @schema_list, 'tsearch2';
54 my $schema = CXGN::DB::DBICFactory->open_schema( 'CXGN::GEM::Schema', search_path => \@schema_list, );
57 my $expdesign = CXGN::GEM::ExperimentalDesign->new($schema);
58 if (exists $args{'id'} && $args{'id'} =~ m/^\d+$/) {
59 $expdesign = CXGN::GEM::ExperimentalDesign->new($schema, $args{'id'});
60 } elsif (exists $args{'name'}) {
61 $expdesign = CXGN::GEM::ExperimentalDesign->new_by_name($schema, $args{'name'});
64 my @exp_list;
65 if (defined $expdesign->get_experimental_design_id() ) {
66 @exp_list = $expdesign->get_experiment_list();
69 my @pubs = ();
70 if (defined $expdesign->get_experimental_design_id()) {
71 @pubs = $expdesign->get_publication_list();
75 ## There are two ways to access to the page, using id=int or name=something. If use other combinations give an error message
77 if (defined $expdesign->get_experimental_design_id or defined $expdesign->get_experimental_design_name ) {
78 $m->exec('/gem/experimental_design_detail.mas',
79 schema => $schema,
80 expdesign => $expdesign,
81 pub_list => \@pubs,
82 exp_list => \@exp_list );
83 } else {
84 $m->exec('/gem/gem_page_error.mas',
85 schema => $schema,
86 object => $expdesign );