6 my $allele_synonym_detail_page = CXGN
::Phenome
::AlleleSynonymDetailPage
->new();
8 package CXGN
::Phenome
::AlleleSynonymDetailPage
;
12 use CXGN
::Page
::FormattingHelpers qw
/ info_section_html page_title_html /;
13 use CXGN
::Phenome
::AlleleSynonym
;
14 use CXGN
::Phenome
::Allele
;
15 use CXGN
::Phenome
::Locus
;
17 use base qw
/ CXGN::Page::Form::SimpleFormPage /;
21 my $self = $class->SUPER::new
(@_);
22 $self->set_script_name("allele_synonym.pl");
31 # call set_object_id, set_object and set_primary_key here
32 # with the appropriate parameters.
34 my %args = $self->get_args();
35 my $allele_alias_id= $args{allele_alias_id
};
37 $self->set_object_id($allele_alias_id);
38 $self->set_object(CXGN
::Phenome
::AlleleSynonym
->new($self->get_dbh(), $self->get_object_id())
40 $self->set_primary_key("allele_alias_id");
44 # override store to check if an allele synonym with the submitted name already exists
49 my $allele_synonym = $self->get_object();
51 my $allele_synonym_id = $self->get_object_id();
52 my %args = $self->get_args();
55 my $not_new_allele_synonym = "";
56 # print STDERR "*** STORING ALLELE SYNONYM ***\n";
57 my $existing_id = CXGN
::Phenome
::AlleleSynonym
::exists_allele_synonym_named
($self->get_dbh(), $args{allele_alias
}, $args{allele_id
});
59 print STDERR
"**Allele Synonym already exists...\n";
61 $self->get_page()->header();
62 print $not_new_allele_synonym = "Allele synonym '".$args{allele_alias
}. "' already exists <br />";
63 print qq { <a href
="javascript:history.back(1)">back to allele synonyms
</a
> };
64 $self->get_page()->footer();
68 $self->SUPER::store
(1);
73 my $allele_id= $self->get_object()->get_allele_id();
75 $allele = CXGN
::Phenome
::Allele
->new($self->get_dbh(), $args{allele_id
});
76 $allele->add_allele_aliases($allele_synonym);
78 $self->get_page()->client_redirect("/phenome/allele_synonym.pl?allele_id=$allele_id&action=new");
89 my %args = $self->get_args();
91 $self->check_modify_privileges();
93 my ($allele, $allele_name, $allele_symbol);
95 my $allele_synonym_name = $self->get_object()->get_allele_alias();
97 if ($args{allele_id
}) {
98 $allele = CXGN
::Phenome
::Allele
->new($self->get_dbh(), $args{allele_id
});
99 $allele_name = $allele->get_allele_name();
100 $allele_symbol= $allele->get_allele_symbol();
101 $allele->remove_allele_alias($args{allele_alias_id
});
105 $self->get_page()->header();
108 print qq { Removed allele synonym
"$allele_synonym_name" association from allele
"$allele_symbol" ($allele_name).<br
/> };
109 print qq { <a href
="allele_synonym.pl?allele_id=$args{allele_id}&action=new">Back to allele synonyms page
</a
> };
112 $self->get_page()->footer();
119 my %args = $self->get_args();
120 my $allele_synonym = $self->get_object();
121 my $allele_synonym_id = $self->get_object_id();
126 # generate the form with the appropriate values filled in.
127 # if we view, then take the data straight out of the database
128 # if we edit, take data from database and override with what's
129 # in the submitted form parameters.
130 # if we store, only take the form parameters into account.
131 # for new, we don't do anything - we present an empty form.
136 $self->get_form()->add_field(display_name
=>"Allele synonym: ",
137 field_name
=>"allele_alias",
139 object
=>$allele_synonym,
140 getter
=>"get_allele_alias",
141 setter
=>"set_allele_alias",
146 $self->get_form()->add_hidden( field_name
=>"action", contents
=>"store" );
147 $self->get_form()->add_hidden( field_name
=>"allele_alias_id", contents
=>$allele_synonym_id );
149 $self->get_form()->add_hidden( field_name
=>"allele_id",
150 contents
=>$args{allele_id
},
151 object
=>$allele_synonym,
152 getter
=>"get_allele_id",
153 setter
=>"set_allele_id"
156 $self->get_form()->add_hidden (
157 field_name
=> "sp_person_id",
158 contents
=>$self->get_user()->get_sp_person_id(),
159 object
=> $allele_synonym,
160 setter
=>"set_sp_person_id",
164 # (do nothing here because synonyms cannot be edited).
165 #if ($self->get_action()=~/view|edit/i) {
166 # $self->get_form()->from_database();
168 if ($self->get_action()=~/store/i) {
169 $args{allele_alias
}=lc($args{allele_alias
}); # somehow this doesn't work -- would like to lowercase all tags...
170 $self->get_form()->from_request(%args);
178 my %args = $self->get_args();
180 # generate an appropriate edit link
182 my $script_name = $self->get_script_name();
184 # generate some locus and/or image information
190 my @allele_synonyms = ();
194 $self->get_page()->header();
196 print page_title_html
( qq { <h3
>SGN
<a href
="/search/direct_search.pl?search=loci">genes
</a
> database
} );
198 print qq { <b
>Allele synonyms
</b
> };
200 if ($args{allele_id
}) {
201 $allele = CXGN
::Phenome
::Allele
->new($self->get_dbh(), $args{allele_id
});
202 @allele_synonyms=$allele->get_allele_aliases();
203 $allele_id = $allele->get_allele_id();
204 $locus_id= $allele->get_locus_id();
205 print "for allele ".$allele->get_allele_symbol()." (".$allele->get_allele_name().")<br /><br />\n";
206 foreach my $as (@allele_synonyms) {
207 my $allele_synonym_id = $as->get_allele_alias_id();
208 print $as->get_allele_alias(). qq { \n <a href
="allele_synonym.pl?allele_id=$allele_id&allele_alias_id=$allele_synonym_id&locus_id=$locus_id&action=confirm_delete">[Remove
]</a> <br />\n };
213 if (!@allele_synonyms) { print "<b>None found</b><br /><br />\n"; }
215 print qq { <br
/><br /><b
>Add another allele synonym
</b
>: };
217 print qq { <center
> };
219 $self->get_form()->as_table();
221 print qq { </center
> };
223 print qq { <a href
= "/phenome/allele.pl?allele_id=$allele_id&action=view">back to allele page
</a
><br
> };
224 print qq { <a href
="/locus/$locus_id/view">back to locus page
</a
> };
225 $self->get_page()->footer();