debugging
[sgn.git] / cgi-bin / phenome / add_dbxref.pl
blob64e96dcfaf4f05debf57dccc115961244690465a
1 use strict;
2 use warnings;
4 use CXGN::Scrap::AjaxPage;
5 use CXGN::DB::Connection;
6 use CXGN::Login;
7 use CXGN::People::Person;
8 use CXGN::Contact;
10 use CXGN::Chado::Dbxref;
11 use CXGN::Phenome::Locus;
12 use CXGN::Phenome::Locus::LocusRanking;
13 use CXGN::Feed;
15 my $dbh = CXGN::DB::Connection->new();
16 my($login_person_id,$login_user_type)=CXGN::Login->new($dbh)->verify_session();
18 if ($login_user_type eq 'curator' || $login_user_type eq 'submitter' || $login_user_type eq 'sequencer') {
19 my $doc = CXGN::Scrap::AjaxPage->new();
20 my ($type,$object_id,$dbxref_id,$validate)= $doc->get_encoded_arguments("type","object_id","dbxref_id","validate");
22 my $dbxref= CXGN::Chado::Dbxref->new($dbh, $dbxref_id);
23 my $pub_id=$dbxref->get_publication()->get_pub_id();
24 my $link;
25 eval {
26 my ($object, $object_dbxref, $object_dbxref_id);
27 if ($type eq 'locus') {
28 $link= "http://www.sgn.cornell.edu/phenome/locus_display.pl?locus_id=$object_id";
30 $object=CXGN::Phenome::Locus->new($dbh, $object_id);
31 my $pub_rank= CXGN::Phenome::Locus::LocusRanking->new($dbh, $object_id, $pub_id);
32 $pub_rank->set_validate($validate);
33 $pub_rank->store_validate(); #store locus_pub_ranking_validate
34 my $locus_dbxref_id =$object->get_locus_dbxref($dbxref)->get_object_dbxref_id();
35 if ($validate eq 'yes') { $object->add_locus_dbxref($dbxref,$locus_dbxref_id,$login_person_id); }
36 elsif ($validate eq 'no') { $object->get_locus_dbxref($dbxref)->obsolete(); }
39 }elsif ($type eq 'individual') {
40 $object_dbxref_id= CXGN::Phenome::Individual::IndividualDbxref::individual_dbxref_exists($dbh,$object_id, $dbxref_id);
41 $object_dbxref=CXGN::Phenome::Individual::IndividualDbxref->new($dbh, $object_dbxref_id);
42 $object_dbxref->set_individual_id($object_id);
43 $link= "http://www.sgn.cornell.edu/phenome/individual.pl?individual_id=$object_id";
46 #this store should insert a new locus_dbxref if !$locus_dbxref_id
47 #update obsolete to 'f' if $locus_dbxref_id and obsolete ='t'
48 #do nothing if $locus_dbxref_id and obsolete = 'f'
49 #my $obsolete = $object_dbxref->get_obsolete();
50 #if ($obsolete eq 'f' && $object_dbxref_id) {
51 # print STDERR "********associate_ontology_term.pl exiting ***** $obsolete, $object_dbxref_id, $type\n\n";
52 # exit();
56 if ($@) { warn "***********dbxref association failed! \n $@ \n "; }
57 else {
59 my $subject="[New locus_dbxref term loaded] $type $object_id";
60 my $person= CXGN::People::Person->new($dbh, $login_person_id);
61 my $user=$person->get_first_name()." ".$person->get_last_name();
62 my $user_link = qq |http://www.sgn.cornell.edu/solpeople/personal-info.pl?sp_person_id=$login_person_id|;
64 my $fdbk_body="$user ($user_link has submitted a new dbxref (id=$dbxref_id) for $type $object_id \n
65 $link";
66 CXGN::Contact::send_email($subject,$fdbk_body, 'sgn-db-curation@sgn.cornell.edu');
67 CXGN::Feed::update_feed($subject,$fdbk_body);