4 use CXGN
::Scrap
::AjaxPage
;
5 use CXGN
::DB
::Connection
;
9 my $dbh = CXGN
::DB
::Connection
->new();
11 my ( $person_id, $user_type ) =
12 CXGN
::Login
->new($dbh)->has_session();
14 if ( grep { /^$user_type$/ } ('curator', 'submitter', 'sequencer') ) {
15 my $doc = CXGN
::Scrap
::AjaxPage
->new();
16 $doc->send_http_header();
20 my ( $registry_symbol, $registry_name, $registry_description, $sp_person_id,
22 = $doc->get_encoded_arguments(
23 "registry_symbol", "registry_name",
24 "registry_description", "sp_person_id",
28 #query to make sure we can't insert 2 of the same registries. There is a constraint on the database but this is required to give user feedback
29 #I've changed the query to search only for existing registered symbols. There may be multiple symbols in the database, but users shouldn't be allowed to store more duplicates.
30 my $registry_exists = $dbh->prepare(
31 "SELECT symbol, name FROM phenome.registry WHERE symbol ilike '$registry_symbol' "
33 $registry_exists->execute();
35 if ( !$registry_exists->fetchrow_array() ) {
36 my $registry_query = $dbh->prepare(
37 "INSERT INTO phenome.registry (symbol, name, description, sp_person_id, status) VALUES (?, ?, ?, ?, 'registered')"
40 $registry_query->execute(
41 $registry_symbol, $registry_name,
42 $registry_description, $sp_person_id
45 my $registry_id = $dbh->last_insert_id( 'registry', 'phenome' );
47 my $locus_registry_insert = $dbh->prepare(
48 "INSERT INTO phenome.locus_registry (locus_id, registry_id, sp_person_id) VALUES (?, ?, ?)"
50 $locus_registry_insert->execute( $locus_id, $registry_id,
52 $response = "success";
55 else { $response = "already exists"; }