improve debug output of 404 errors
[sgn.git] / cgi-bin / gem / target.pl
blob011457f46c204f2e6ebefa10e316242c87b5909f
1 #!/usr/bin/perl
3 =head1 NAME
5 target.pl
6 Controller to show the web_page for target information using MASON.
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;
33 use CXGN::DB::Connection;
34 use CXGN::DB::DBICFactory;
35 use CXGN::GEM::Schema;
36 use CXGN::GEM::Target;
38 ## Call the mason object
40 my $m = CXGN::MasonFactory->new();
43 ## Create the schema object for gem (and gem related searches)
45 my $psqlv = `psql --version`;
46 chomp($psqlv);
48 my @schema_list = ('gem','biosource','metadata','public');
49 if ($psqlv =~ /8\.1/) {
50 push @schema_list, 'tsearch2';
53 my $schema = CXGN::DB::DBICFactory->open_schema( 'CXGN::GEM::Schema', search_path => \@schema_list, );
56 ## Use of CXGN::Page to take the arguments from the URL
58 my %args = CXGN::Page->new()
59 ->get_all_encoded_arguments();
62 ## Create the target object (by default it will create an empty object)
64 my $target = CXGN::GEM::Target->new($schema);
66 if (exists $args{'id'} && $args{'id'} =~ m/^\d+$/) {
67 $target = CXGN::GEM::Target->new($schema, $args{'id'});
68 } elsif (exists $args{'name'}) {
69 $target = CXGN::GEM::Target->new_by_name($schema, $args{'name'});
73 ## There are two ways to access to the page, using id=int or name=something. If use other combinations give an error message
75 if (defined $target->get_target_id or defined $target->get_target_name ) {
76 $m->exec('/gem/target_detail.mas',
77 schema => $schema,
78 target => $target );
79 } else {
80 $m->exec('/gem/gem_page_error.mas',
81 schema => $schema,
82 object => $target );