Plot Order Download: simplify download function
[sgn.git] / cgi-bin / gem / experiment.pl
blob4b92ef4725b038401d70de81d024ed390525e6c9
1 #!/usr/bin/perl
3 =head1 NAME
5 experiment.pl
6 Controller for experiment page.
8 =cut
10 =head1 SYNOPSIS
13 =head1 DESCRIPTION
15 This is a controller script to show the web_page using MASON
17 =cut
19 =head1 AUTHORS
21 Aureliano Bombarely Gomez
22 (ab782@cornell.edu)
24 =cut
27 use strict;
28 use warnings;
30 use CXGN::MasonFactory;
31 use CXGN::Page;
32 use CXGN::DB::Connection;
33 use CXGN::DB::DBICFactory;
34 use CXGN::GEM::Schema;
35 use CXGN::GEM::Experiment;
38 my $m = CXGN::MasonFactory->new();
40 ## Create the schema object
42 my $psqlv = `psql --version`;
43 chomp($psqlv);
45 my @schema_list = ('gem', 'biosource', 'metadata', 'public');
46 if ($psqlv =~ /8\.1/) {
47 push @schema_list, 'tsearch2';
50 my $schema = CXGN::DB::DBICFactory->open_schema( 'CXGN::GEM::Schema', search_path => \@schema_list, );
52 ## Also it will create a dbi-connection object ($dbh) for all the methods that do not use schemas
53 ## (as CXGN::People::Person) to not interfiere with them
55 my $dbh = CXGN::DB::Connection->new();
57 ## Use of CXGN::Page to take the arguments from the URL
59 my %args = CXGN::Page->new()
60 ->get_all_encoded_arguments();
63 ## Get the experiment object (by default it will create an empty object without any id)
65 my $experiment = CXGN::GEM::Experiment->new($schema);;
66 if (exists $args{'id'} && $args{'id'} =~ m/^\d+$/) {
67 $experiment = CXGN::GEM::Experiment->new($schema, $args{'id'});
68 } elsif (exists $args{'name'}) {
69 $experiment = CXGN::GEM::Experiment->new_by_name($schema, $args{'name'});
72 my @target_list;
73 if (defined $experiment->get_experiment_id() ) {
74 @target_list = $experiment->get_target_list();
78 ## There are two ways to access to the page, using id=int or name=something. If use other combinations give an error message
80 if (defined $experiment->get_experiment_id or defined $experiment->get_experiment_name) {
81 $m->exec('/gem/experiment_detail.mas',
82 dbh => $dbh,
83 schema => $schema,
84 experiment => $experiment,
85 target_list => \@target_list );
86 } else {
87 $m->exec('/gem/gem_page_error.mas',
88 schema => $schema,
89 object => $experiment );