5 package CXGN
::Publication
;
6 use base qw
/CXGN::Search::DBI::Simple CXGN::Search::WWWSearch/;
8 __PACKAGE__
->creates_result('CXGN::Publication::Result');
9 __PACKAGE__
->uses_query('CXGN::Publication::Query');
13 package CXGN
::Publication
::Result
;
14 use base qw
/CXGN::Search::BasicResult/;
18 package CXGN
::Publication
::Query
;
19 use CXGN
::Page
::FormattingHelpers
23 hierarchical_selectboxes_html
24 conditional_like_input_html
28 use base qw
/CXGN::Search::DBI::Simple::WWWQuery/;
31 sub _cached_dbh
() { our $_cached_dbc ||= CXGN
::DB
::Connection
->new('public') }
32 my $public = 'public';
33 my $sgn_people= 'sgn_people';
34 my $phenome= 'phenome';
35 __PACKAGE__
->selects_data("$public.pub.pub_id","$public.pub.title","$public.pub.series_name", "$public.pub.pyear","$phenome.pub_curator.assigned_to","$phenome.pub_curator.date_curated", "$phenome.pub_curator.curated_by", "$phenome.pub_curator.status", "$phenome.pub_curator.date_stored" );
38 __PACKAGE__
->join_root("$public.pub");
40 __PACKAGE__
->uses_joinpath('authorpath',
41 ["$public.pubauthor", "$public.pubauthor.pub_id = $public.pub.pub_id"],
44 __PACKAGE__
->uses_joinpath('curatorpath',
45 [ "$phenome.pub_curator", "$phenome.pub_curator.pub_id=$public.pub.pub_id" ],
46 [ "$sgn_people.sp_person", "$phenome.pub_curator.assigned_to = $sgn_people.sp_person.sp_person_id" ],
50 __PACKAGE__
->has_parameter(name
=>'author',
51 columns
=>["$public.pubauthor.surname",
52 "$public.pubauthor.givennames"],
53 sqlexpr
=>"$public.pubauthor.surname || $public.pubauthor.givennames",
56 __PACKAGE__
->has_parameter(name
=>'title',
57 columns
=>"$public.pub.title",
59 __PACKAGE__
->has_parameter(name
=>'pyear',
60 columns
=>"$public.pub.pyear",
62 __PACKAGE__
->has_parameter(name
=>'series',
63 columns
=>"$public.pub.series_name",
66 __PACKAGE__
->has_parameter(name
=>'assigned_to',
67 columns
=>["$sgn_people.sp_person.first_name",
68 "$sgn_people.sp_person.last_name",
69 "$sgn_people.sp_person.sp_person_id"],
70 sqlexpr
=>"$sgn_people.sp_person.last_name || $sgn_people.sp_person.first_name
71 || $sgn_people.sp_person.sp_person_id",
74 __PACKAGE__
->has_parameter(name
=>'status',
75 columns
=>"$phenome.pub_curator.status",
77 __PACKAGE__
->has_parameter(name
=>'is_curated',
78 columns
=>"$phenome.pub_curator.curated_by",
79 #sqlexpr=>"(count pub_curator.curated_by)",
83 __PACKAGE__
->has_parameter(name
=>'date_stored',
84 columns
=>["$phenome.pub_curator.date_stored"],
88 __PACKAGE__
->has_complex_parameter( name
=> 'any_name',
89 uses
=> [qw
/ title series /],
91 my ($self, @args) = @_;
95 $self->compound('&t OR &t' ,'title', 'series');
99 ###### NOW WWW STUFF ###
101 sub request_to_params
{
102 my($self, %params) = @_;
104 #sanitize all the parameters
105 foreach my $key (keys %params) {
106 if( $params{$key} ) {
107 $params{$key} =~ s/[;\'\",]//g;
111 if($params{any_name
}) {
112 $self->any_name('ILIKE ?',"%$params{any_name}%");
115 #if ($params{editor} =~ m/^\d/) {
116 # $self->editor('= ?', "$params{editor}");
117 if ($params{assigned_to
}) {
118 $self->assigned_to('ILIKE ?', "%$params{assigned_to}%");
121 if ($params{is_curated
}) {
122 $self->is_curated('IS NOT NULL');
125 if ($params{author
}) {
126 $self->author('ILIKE ?', "%$params{author}%");
128 if ($params{date_stored
}) {
129 $self->date_stored('> ?', "$params{date_stored}");
131 if($params{status
}) {
132 $self->status('ILIKE ?', "$params{status}");
136 if( defined($params{page
}) ) {
137 $self->page($params{page
});
146 no warnings
'uninitialized';
148 #this part defines the mapping from get/post data to search params
150 ($params{any_name
}) = $self->param_bindvalues('any_name');
151 $params{any_name
} =~ s/%//g;
153 ($params{author
}) = $self->param_bindvalues('author');
154 $params{author
} =~ s/%//g;
156 ($params{assigned_to
}) = $self->param_bindvalues('assigned_to');
157 $params{assigned_to
} =~ s/%//g;
159 ($params{date_stored
}) = $self->param_bindvalues('date_stored');
160 $params{date_stored
} =~ s/%//g;
162 ($params{status
}) = $self->param_bindvalues('status');
164 $params{is_curated
} = $self->pattern_match_parameter('is_curated', /IS NOT NULL/);
171 my $search = 'advanced';
172 my %scalars = $self->_to_scalars($search);
174 #make %pname, a tied hash that uniqifies names the make_pname
175 # function is in CXGN::Page::WebForm, which is a parent of
176 # CXGN::Search::DBI::Simple::WWWQuery
180 my $dbh=_cached_dbh
();
182 my @stat_list= ("", "pending", "curated", "rejected", "no gene");
183 my $stats = simple_selectbox_html
( choices
=> \
@stat_list,
184 name
=> $pname{status
},
185 selected
=> $scalars{status
},
188 my $is_curated= $self->uniqify_name('is_curated');
189 my $any_name = $self->uniqify_name('any_name');
190 my $author = $self->uniqify_name('author');
191 my $assigned_to = $self->uniqify_name('assigned_to');
192 my $date_stored = $self->uniqify_name('date_stored');
196 @scalars{qw
/ is_curated is_assigned /} =
197 map {$_ ?
'checked="checked" ' : undef} @scalars{qw
/ is_curated is_assigned /};
201 'Title'=>qq|<input name
="$pname{any_name}" value
="$scalars{any_name}" size
="60" />|,
204 'Author' => qq|<input name
= "$pname{author}" value
="$scalars{author}" size
="20" />|,
205 'Date stored' =>qq|<input name
="$pname{date_stored}" value
="$scalars{date_stored}" size
="10"/>|,
206 'SGN curator'=> qq|<input name
="$pname{assigned_to}" value
="$scalars{assigned_to}" size
="20" />|,
208 'Curated' => qq|<input type
="checkbox" name
="$is_curated" $scalars{is_curated
} /><br />|,
211 __tableattrs
=> 'width="100%"',
214 #$scalars{is_curated} ||= '';
216 my $html_ret = <<EOHTML;
218 <tr><td>$a_search</td></tr>
219 <tr><td><a href="/chado/publication.pl?action=new">[Submit new publication]</a> </td>
222 <div align="center"><input type="submit" value="Search"/></div>
227 my ($self,$term) = @_;
228 $self->any_name('ILIKE ?', "%$term%");