update empty fixture to something that is more up to date.
[sgn.git] / cgi-bin / phenome / merge_locus.pl
blob8782fb0ac2a4d792f7f93f3260e2399258a49521
1 use strict;
2 use warnings;
4 use CXGN::Scrap::AjaxPage;
5 use CXGN::Login;
6 use CXGN::People::Person;
7 use CXGN::Phenome::Locus;
8 use CXGN::Feed;
9 use CXGN::Contact;
10 use CatalystX::GlobalContext '$c';
12 use JSON;
14 my %error = ();
15 my $json = JSON->new();
17 my $dbh = $c->dbc->dbh;
18 my($login_person_id,$login_user_type)=CXGN::Login->new($dbh)->verify_session();
20 #print STDERR "merge_locus.pl:login_person_id= $login_person_id\n";
22 if ($login_user_type eq 'curator') {
23 my $doc = CXGN::Scrap::AjaxPage->new();
24 $doc->send_http_header();
25 my ($merged_locus_id, $locus_id) = $doc->get_encoded_arguments("merged_locus_id", "locus_id");
26 print STDERR "merge_locus.pl:merged_locus_id=$merged_locus_id, locus_id = $locus_id\n ";
28 my $locus= CXGN::Phenome::Locus->new($dbh, $locus_id);
30 if ($merged_locus_id && $locus_id ) {
32 my $fail = $locus->merge_locus($merged_locus_id, $login_person_id);
34 if ($fail) {
35 warn "merging locus failed! . $fail";
36 my $message= "merging locus failed!\n $fail ";
37 CXGN::Contact::send_email('Merging locus failed' ,$message, 'sgn-bugs@sgn.cornell.edu');
38 $error{"error"} = $message;
42 else {
43 $error{reload} = 1;
44 my $subject="[New locus merged] locus $locus_id";
45 my $person= CXGN::People::Person->new($dbh, $login_person_id);
46 my $user=$person->get_first_name()." ".$person->get_last_name();
47 my $user_link = qq |http://www.sgn.cornell.edu/solpeople/personal-info.pl?sp_person_id=$login_person_id|;
48 my $locus_link = qq |http://www.sgn.cornell.edu/phenome/locus_display.pl?locus_id=$locus_id|;
50 my $fdbk_body="curator $user ($user_link) merged locus $merged_locus_id with locus $locus_id ($locus_link) \n ";
51 CXGN::Contact::send_email($subject,$fdbk_body, 'sgn-db-curation@sgn.cornell.edu');
52 CXGN::Feed::update_feed($subject,$fdbk_body);
55 my $jobj = $json->encode(\%error);
56 print $jobj;