6 Controller for experiment page.
15 This is a controller script to show the web_page using MASON
21 Aureliano Bombarely Gomez
30 use CXGN
::MasonFactory
;
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`;
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'});
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',
84 experiment
=> $experiment,
85 target_list
=> \
@target_list );
87 $m->exec('/gem/gem_page_error.mas',
89 object
=> $experiment );