4 my $locus_synonym_detail_page = CXGN
::Phenome
::LocusSynonymDetailPage
->new();
6 package CXGN
::Phenome
::LocusSynonymDetailPage
;
10 use CXGN
::Page
::FormattingHelpers qw
/ info_section_html page_title_html /;
11 use CXGN
::Phenome
::LocusSynonym
;
12 use CXGN
::Phenome
::Locus
;
15 use base qw
/ CXGN::Page::Form::SimpleFormPage /;
19 my $self = $class->SUPER::new
(@_);
20 $self->set_script_name("locus_synonym.pl");
29 # call set_object_id, set_object and set_primary_key here
30 # with the appropriate parameters.
32 my %args = $self->get_args();
33 $self->set_object_id($args{locus_alias_id
});
34 $self->set_object(CXGN
::Phenome
::LocusSynonym
->new($self->get_dbh(), $self->get_object_id())
36 $self->set_primary_key("locus_alias_id");
40 # override store to check if a locus synonym with the submitted name already exists
45 my $locus_synonym = $self->get_object();
47 my $locus_synonym_id = $self->get_object_id();
48 my %args = $self->get_args();
51 my $not_new_locus_synonym = "";
52 # print STDERR "*** STORING LOCUS SYNONYM ***\n";
53 my ($existing_id, $obsolete) = CXGN
::Phenome
::LocusSynonym
::exists_locus_synonym_named
($self->get_dbh(), $args{locus_alias
}, $args{locus_id
});
54 print STDERR
"******$existing_id, $obsolete\n";
55 if ($existing_id && $obsolete == 0) {
56 print STDERR
"**Locus Synonym already exists...\n";
58 $self->get_page()->header();
59 print $not_new_locus_synonym = "Locus synonym '".$args{locus_alias
}. "' already exists <br />";
60 print qq { <a href
="javascript:history.back(1)">back to locus synonyms
</a
> };
61 $self->get_page()->footer();
64 $self->SUPER::store
(1);
65 $self->send_synonym_email();
68 my $locus_id= $args{locus_id
};
69 $self->get_page()->client_redirect("/phenome/locus_synonym.pl?locus_id=$locus_id&action=new");
79 my %args = $self->get_args();
81 $self->check_modify_privileges();
88 my $locus_synonym_name = $self->get_object()->get_locus_alias();
90 if ($args{locus_id
}) {
91 $locus = CXGN
::Phenome
::Locus
->new($self->get_dbh(), $args{locus_id
});
92 $locus_name = $locus->get_locus_name();
93 $locus->remove_locus_alias($args{locus_alias_id
});
94 $self->send_synonym_email('delete');
99 my $locus_id= $args{locus_id
};
100 $self->get_page()->client_redirect("/phenome/locus_synonym.pl?locus_id=$locus_id&action=new");
107 my %args = $self->get_args();
108 my $locus_synonym = $self->get_object();
109 my $locus_synonym_id = $self->get_object_id();
113 # generate the form with the appropriate values filled in.
114 # if we view, then take the data straight out of the database
115 # if we edit, take data from database and override with what's
116 # in the submitted form parameters.
117 # if we store, only take the form parameters into account.
118 # for new, we don't do anything - we present an empty form.
123 $self->get_form()->add_field(display_name
=>"Locus synonym: ",
124 field_name
=>"locus_alias",
126 object
=>$locus_synonym,
127 getter
=>"get_locus_alias",
128 setter
=>"set_locus_alias",
133 $self->get_form()->add_hidden( field_name
=>"action", contents
=>"store" );
134 $self->get_form()->add_hidden( field_name
=>"locus_alias_id", contents
=>$locus_synonym_id );
136 $self->get_form()->add_hidden( field_name
=>"locus_id",
137 contents
=>$args{locus_id
},
138 object
=>$locus_synonym,
139 getter
=>"get_locus_id",
140 setter
=>"set_locus_id"
142 $self->get_form()->add_hidden (
143 field_name
=> "sp_person_id",
144 contents
=>$self->get_user()->get_sp_person_id(),
145 object
=> $locus_synonym,
146 setter
=>"set_sp_person_id",
150 # (do nothing here because synonyms cannot be edited).
151 #if ($self->get_action()=~/view|edit/i) {
152 # $self->get_form()->from_database();
154 if ($self->get_action()=~/store/i) {
155 $args{locus_alias
}=lc($args{locus_alias
}); # somehow this doesn't work -- would like to lowercase all tags...
156 $self->get_form()->from_request(%args);
164 my %args = $self->get_args();
166 # generate an appropriate edit link
168 my $script_name = $self->get_script_name();
170 # generate some locus and/or image information
177 my @locus_synonyms = ();
179 my @experiment_tags = ();
183 $self->get_page()->header();
185 print page_title_html
( qq { SGN
<a href
="/search/direct_search.pl?search=loci">genes
</a
> database
} );
187 print qq { <b
>Locus synonyms
</b
> };
189 if ($args{locus_id
}) {
190 $locus = CXGN
::Phenome
::Locus
->new($self->get_dbh(), $args{locus_id
});
191 @locus_synonyms=$locus->get_locus_aliases('f', 'f');
192 my $locus_id = $locus->get_locus_id();
193 print "for locus ".$locus->get_locus_name()."<br /><br />\n";
194 foreach my $ls (@locus_synonyms) {
195 my $locus_synonym_id = $ls->get_locus_alias_id();
196 print $ls->get_locus_alias(). qq { \n <a href
="locus_synonym.pl?locus_id=$locus_id&locus_alias_id=$locus_synonym_id&action=confirm_delete">[Remove
]</a> <br />\n };
201 if (!@locus_synonyms && !@image_tags) { print "<b>None found</b><br /><br />\n"; }
203 print qq { <br
/><br /><b
>Add another locus synonym
</b
>: };
205 print qq { <center
> };
207 $self->get_form()->as_table();
209 print qq { </center
> };
211 print qq { <a href
="locus_display.pl?locus_id=$args{locus_id}&action=view">back to locus page
</a
> };
213 $self->get_page()->footer();
219 sub send_synonym_email
{
222 my %args = $self->get_args();
223 my $locus_id= $args{locus_id
};
225 my $locus_synonym_id=$self->get_object()->get_locus_alias_id();
226 my $locus_synonym_name= $self->get_object->get_locus_alias();
228 my $username= $self->get_user()->get_first_name()." ".$self->get_user()->get_last_name();
229 my $sp_person_id=$self->get_user()->get_sp_person_id();
230 my $usermail=$self->get_user()->get_private_email();
231 my $locus_link= qq |http
://www
.sgn
.cornell
.edu
/phenome/locus_display
.pl?locus_id
=$locus_id|;
232 my $user_link = qq |http
://www
.sgn
.cornell
.edu
/solpeople/personal
-info
.pl?sp_person_id
=$sp_person_id|;
236 if ($action eq 'delete') {
237 $subject="[A locus synonym deleted] locus $locus_id";
238 $fdbk_body="$username ($user_link)\n has deleted locus synonym $locus_synonym_name \n from locus ($locus_link)\n"; }
240 $subject="[New locus synonym stored] locus $locus_id";
241 $fdbk_body="$username ($user_link)\n has submitted a new synonym $locus_synonym_name \n for locus ($locus_link)\n"; }
244 CXGN
::Contact
::send_email
($subject,$fdbk_body, 'sgn-db-curation@sgn.cornell.edu');
245 CXGN
::Feed
::update_feed
($subject,$fdbk_body);