on second though, remove post-only restriction on organism tree image cache flushing...
[sgn.git] / cgi-bin / phenome / obsolete_object_ev.pl
blobfbc538832003c453eb17f215a9cc6c07be6150e3
1 use strict;
2 use warnings;
4 use CXGN::Scrap::AjaxPage;
5 use CXGN::DB::Connection;
6 use CXGN::Phenome::Locus::LocusDbxrefEvidence;
7 use CXGN::Phenome::Individual::IndividualDbxrefEvidence;
9 use CXGN::Login;
10 use CXGN::Contact;
11 use CXGN::People::Person;
12 use CXGN::Feed;
14 use JSON;
16 my $dbh = CXGN::DB::Connection->new();
17 my($login_person_id,$login_user_type)=CXGN::Login->new($dbh)->verify_session();
19 if ($login_user_type eq 'curator' || $login_user_type eq 'submitter' || $login_user_type eq 'sequencer') {
20 my $doc = CXGN::Scrap::AjaxPage->new();
21 $doc->send_http_header();
23 my %error = ();
24 my $json = JSON->new();
26 my ($dbxref_ev_id, $type, $action) = $doc->get_encoded_arguments("object_ev_id", "type", "action");
27 my $link;
29 eval {
30 if ($type eq 'locus') {
31 my $locus_ev=CXGN::Phenome::Locus::LocusDbxrefEvidence->new($dbh, $dbxref_ev_id);
32 if ($action eq 'unobsolete' ) {
33 $locus_ev->unobsolete();
34 }else { $locus_ev->obsolete(); }
35 my $locus_id = $locus_ev->get_locus_dbxref()->get_locus_id();
36 $link = "http://www.sgn.cornell.edu/phenome/locus_display.pl?locus_id=$locus_id";
37 }elsif ($type eq 'individual') {
38 my $individual_ev=CXGN::Phenome::Individual::IndividualDbxrefEvidence->new($dbh, $dbxref_ev_id);
39 if ($action eq 'unobsolete' ) { $individual_ev->unobsolete(); }
40 else { $individual_ev->obsolete(); }
42 my $individual_id = $individual_ev->get_individual_dbxref()->get_individual_id();
43 $link = "http://www.sgn.cornell.edu/phenome/individual.pl?individual_id=$individual_id";
46 if ($@) {
47 $error{"error"} = $@;
48 CXGN::Contact::send_email('obsolete_object_ev.pl died',$error{"error"}, 'sgn-bugs@sgn.cornell.edu');
49 warn "Obsoleting ontology term association failed! $@"; }
50 else {
52 my $subject="[Ontology-$type association $action] ";
53 my $person= CXGN::People::Person->new($dbh, $login_person_id);
54 my $user=$person->get_first_name()." ".$person->get_last_name();
55 my $user_link = qq |http://www.sgn.cornell.edu/solpeople/personal-info.pl?sp_person_id=$login_person_id|;
57 my $fdbk_body="$user ($user_link) just $action ontology-$type association from phenome. $type - dbxref\n
58 id=$dbxref_ev_id \n $link";
59 CXGN::Contact::send_email($subject,$fdbk_body, 'sgn-db-curation@sgn.cornell.edu');
60 CXGN::Feed::update_feed($subject,$fdbk_body);
62 my $jobj = $json->encode(\%error);
63 print $jobj;