6 Controller to show the web_page for platform using MASON.
12 This is the controller script to show the web_page using MASON
18 Aureliano Bombarely Gomez
27 use CXGN
::MasonFactory
;
30 use CXGN
::DB
::Connection
;
31 use CXGN
::DB
::DBICFactory
;
32 use CXGN
::GEM
::Schema
;
33 use CXGN
::GEM
::Platform
;
34 use CXGN
::GEM
::Target
;
37 ## Create mason object
39 my $m = CXGN
::MasonFactory
->new();
42 ## Create the schema object
44 my $psqlv = `psql --version`;
47 my @schema_list = ('gem', 'biosource', 'metadata', 'public');
48 if ($psqlv =~ /8\.1/) {
49 push @schema_list, 'tsearch2';
52 my $schema = CXGN
::DB
::DBICFactory
->open_schema( 'CXGN::GEM::Schema', search_path
=> \
@schema_list, );
54 ## Also it will create a dbi-connection object ($dbh) for all the methods that do not use schemas
55 ## (as CXGN::People::Person) to not interfere with them
57 my $dbh = CXGN
::DB
::Connection
->new();
59 ## Use of CXGN::Page to take the arguments from the URL
61 my %args = CXGN
::Page
->new()->get_all_encoded_arguments();
63 ## Now it will create a platform object (by default it will create an empty platform object)
65 my $platform = CXGN
::GEM
::Platform
->new($schema);
67 if (exists $args{'id'} && $args{'id'} =~ m/^\d+$/) {
68 $platform = CXGN
::GEM
::Platform
->new($schema, $args{'id'});
69 } elsif (exists $args{'name'}) {
70 $platform = CXGN
::GEM
::Platform
->new_by_name($schema, $args{'name'});
74 ## Other data that the controller will suply will be:
76 #### 1) @target_list with CXGN::GEM::Target objects for hybridizations
80 if (defined $platform->get_platform_id() ) {
81 my @hyb_rows = $schema->resultset('GeHybridization')
82 ->search({ platform_id
=> $platform->get_platform_id() });
84 foreach my $hyb_row (@hyb_rows) {
85 my $target_id = $hyb_row->get_column('target_id');
86 my $target = CXGN
::GEM
::Target
->new($schema, $target_id);
87 push @target_list, $target;
91 #### 2) @template_list with template_rows for templates (use CXGN::GEM::Template is slow because template object get other data)
93 my @template_row_list = ();
95 if (defined $platform->get_platform_id() ) {
97 @template_row_list = $schema->resultset('GeTemplate')
98 ->search( { platform_id
=> $platform->get_platform_id() } );
101 #### 3) @pub_id_list, a list of pub ids to show the publications associated with this platform
103 my @pub_id_list = ();
105 if (defined $platform->get_platform_id() ) {
107 @pub_id_list = $platform->get_publication_list();
111 ## There are two ways to access to the page, using id=int or name=something. If use other combinations give an error message
113 if (defined $platform->get_platform_id() ) {
114 $m->exec('/gem/platform_detail.mas',
117 platform
=> $platform,
118 target_list
=> \
@target_list,
119 template_list
=> \
@template_row_list,
120 pub_list
=> \
@pub_id_list );
122 $m->exec('/gem/gem_page_error.mas',
124 object
=> $platform );