Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
used stored_procedure for annotated_image table
authorlingutln <lingutln@localhost>
Fri, 10 May 2013 23:24:29 +0000 (23:24 +0000)
committerlingutln <lingutln@localhost>
Fri, 10 May 2013 23:24:29 +0000 (23:24 +0000)
svn path=/; revision=476

image_annotation_db/ia_upload/annotation_data_importer.pl
image_annotation_db/ia_upload/stored_procedures.sql

index 80b972ff1c203c38f38819fb595e1eb25c466b0a..20c509270b12bba16e81fa9cfe5481a7e38d6752 100644 (file)
@@ -107,12 +107,7 @@ sub insert_image_data_into_database
   my $image_path = trim($image_data_fields[1]) . trim($image_data_fields[0]);
 
   # preprocessing ip_comment data
-  my $ip_comment = trim($image_data_fields[12]);
-
-  if(undef $ip_comment){
-    $ip_comment = ""
-  }
-
+  my $ip_comment     = trim($image_data_fields[12]);
   my $source_db      = trim($image_data_fields[14]);
   my $source_db_name = "";
   my $source_db_id   = "";
@@ -126,9 +121,16 @@ sub insert_image_data_into_database
   my $collection_date     = trim($image_data_fields[11]);
   my $comments                   = trim($image_data_fields[15]);
 
-  $dbh->do('INSERT INTO annotated_image (curator_id, taxon_id, image_path, collection_location, collection_date, ip_comment, doi, source_db_name, source_db_id, comments) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
-           undef, $curator_id, $taxon_id, $image_path, $collection_location, $collection_date, $ip_comment, $doi, $source_db_name, $source_db_id, $comments);
-  my $annotated_image_id = $dbh->{'mysql_insertid'};
+  #$dbh->do('INSERT INTO annotated_image (curator_id, taxon_id, image_path, collection_location, collection_date, ip_comment, doi, source_db_name, source_db_id, comments) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
+#          undef, $curator_id, $taxon_id, $image_path, $collection_location, $collection_date, $ip_comment, $doi, $source_db_name, $source_db_id, $comments);
+  #my $annotated_image_id = $dbh->{'mysql_insertid'};
+
+  my $annotated_image_id;
+  my $sth = $dbh->prepare("call import_annotated_image('$curator_id', '$taxon_id', '$image_path', '$collection_location', '$collection_date', '$ip_comment', '$doi', '$source_db_name', '$source_db_id', '$comments');");
+  $sth->execute();
+  $sth->bind_col(1, \$annotated_image_id);
+  $sth->fetch();
+
 
   my @keywords                 = split(/\|/, trim($image_data_fields[2]));
   my @ontology_term_ids = split(/\|/, trim($image_data_fields[3]));
index 513f10c9bf741c0fdf182495698eb523c14dd169..acacc1a8dda89ab8c1ff6527e78169c5e23f0adb 100644 (file)
@@ -39,4 +39,12 @@ insert into taxon (species_id, species_name, genus) values (species_id, species_
 select last_insert_id();
 end //
 
+-- create(drop and create if exists) stored procedure for importing data into annotated_image table
 
+DROP procedure if exists import_annotated_image;
+delimiter //
+create procedure import_annotated_image (curator_id int(11), taxon_id int(11), image_path varchar(255), collection_location varchar(255), collection_date date, ip_comment varchar(255), doi varchar(45), source_db_name varchar(45), source_db_id varchar(30), comments varchar(255))
+begin
+insert into annotated_image (curator_id, taxon_id, image_path, collection_location, collection_date, ip_comment, doi, source_db_name, source_db_id, comments) values (curator_id, taxon_id, image_path, collection_location, collection_date, ip_comment, doi, source_db_name, source_db_id, comments);
+select last_insert_id();
+end //
\ No newline at end of file