6 Controller to show the web_page for template using MASON.
15 This is the script controller to show the template web_page using MASON
21 Aureliano Bombarely Gomez
30 use CXGN
::MasonFactory
;
33 use CXGN
::DB
::Connection
;
34 use CXGN
::DB
::DBICFactory
;
35 use CXGN
::GEM
::Schema
;
36 use CXGN
::GEM
::Template
;
39 ## Create the mason object
41 my $m = CXGN
::MasonFactory
->new();
44 ## Create the schema object
46 my $psqlv = `psql --version`;
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, );
56 ## Another schema to create is a schema that use sgn as schema
58 my $sgn_schema = CXGN
::DB
::DBICFactory
->open_schema( 'SGN::Schema', search_path
=> ['sgn'], );
61 ## Also it will create a dbi-connection object ($dbh) for all the methods that do not use schemas
62 ## (as CXGN::People::Person) to not interfiere with them
64 my $dbh = CXGN
::DB
::Connection
->new();
67 ## Use of CXGN::Page to take the arguments from the URL
70 my $page = CXGN
::Page
->new();
72 my %args = $page->get_all_encoded_arguments();
75 ## Get template object (by default it will create an empty template object)
77 my $template = CXGN
::GEM
::Template
->new($schema);
79 if (exists $args{'id'}) {
80 $template = CXGN
::GEM
::Template
->new($schema, $args{'id'});
81 } elsif (exists $args{'name'}) {
82 $template = CXGN
::GEM
::Template
->new_by_name($schema, $args{'name'});
85 ## Get the unigene list associated with this template to use with the annotations
88 if (defined $template->get_template_id) {
89 @unigene_ids = $template->get_internal_accessions('unigene');
93 ## There are two ways to access to the page, using id=int or name=something. If use other combinations give an error message
95 if (defined $template->get_template_id() or defined $template->get_template_name() ) {
96 $m->exec( '/gem/template_detail.mas',
99 sgn_schema
=> $sgn_schema,
100 template
=> $template,
101 unigene_list
=> \
@unigene_ids
104 $m->exec('/gem/gem_page_error.mas',
106 object
=> $template );