소스 검색

Fixed issues with error reporting in bulk loader, and warnings when syncing organisms

Stephen Ficklin 10 년 전
부모
커밋
db0da648ee

+ 1 - 1
tripal_bulk_loader/includes/tripal_bulk_loader.chado_node.inc

@@ -63,7 +63,7 @@ function tripal_bulk_loader_form($node, $form_state) {
 
   $form['loader']['loader_name'] = array(
     '#type'          => 'textfield',
-    '#title'         => t('Loading Job Name'),
+    '#title'         => t('Job Name'),
     '#weight'        => -10,
     '#required'      => TRUE,
     '#default_value' => (isset($node->loader_name)) ? $node->loader_name : ''

+ 16 - 4
tripal_bulk_loader/includes/tripal_bulk_loader.loader.inc

@@ -576,13 +576,19 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
 
   // skip optional fields
   if ($skip_optional) {
-    tripal_bulk_loader_throw_error('Skipping an optional record (%record)',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
+    // SPF -- Commented out the following line.  This state is intentional due
+    // to the loader setup and and is not an error.  If informational it 
+    // prints too much to the terminal.
+    // tripal_bulk_loader_throw_error('Skipping an optional record (%record)',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
     return $no_errors;
   }
 
   // check if it is already inserted
   if (array_key_exists('inserted', $table_data) and $table_data['inserted']) {
-    tripal_bulk_loader_throw_error('Skipping %record since it is already inserted',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
+    // SPF -- Commented out the following line.  This state is intentional due
+    // to the loader setup and and is not an error.  If informational it 
+    // prints too much to the terminal.
+    // tripal_bulk_loader_throw_error('Skipping %record since it is already inserted',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
     return $no_errors;
   }
 
@@ -590,7 +596,10 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
   // the default_data array
   if (array_key_exists('selected', $table_data) and $table_data['selected']) {
     $data[$priority]['values_array'] = $default_data[$priority]['values_array'];
-    tripal_bulk_loader_throw_error('%record was already selected thus we are just returning the values previously selected.',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
+    // SPF -- Commented out the following line.  This state is intentional due
+    // to the loader setup and and is not an error.  If informational it 
+    // prints too much to the terminal.
+    // tripal_bulk_loader_throw_error('%record was already selected thus we are just returning the values previously selected.',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
     return $no_errors;
   }
 
@@ -641,7 +650,10 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
       }
       // return if this is a select_if_duplicate
       if ($table_data['select_if_duplicate'] == 1) {
-        tripal_bulk_loader_throw_error('Simply returning values for %record since it was already inserted',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
+        // SPF -- Commented out the following line.  This state is intentional due
+        // to the loader setup and and is not an error.  If informational it 
+        // prints too much to the terminal.
+        // tripal_bulk_loader_throw_error('Simply returning values for %record since it was already inserted',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
         return $no_errors;
       }
     }

+ 9 - 6
tripal_core/api/tripal_core.chado_nodes.api.inc

@@ -582,15 +582,18 @@ function chado_node_sync_records($base_table, $max_sync = FALSE, $organism_id =
 
   $i = 0;
   $transaction = db_transaction();
+  print "\nNOTE: Syncing is performed using a database transaction. \n" .
+      "If the sync fails or is terminated prematurely then the entire set of \n" .
+      "synced items is rolled back and will not be found in the database\n\n";
   try {
     foreach ($results as $record) {
 
-      print "\nLoading $base_table " . ($i + 1) . " of $count ($base_table_id=" . $record->{$base_table_id} . ")...";
+      //print "\nLoading $base_table " . ($i + 1) . " of $count ($base_table_id=" . $record->{$base_table_id} . ")...";
 
       // update the job status every 1% features
       if ($job_id and $i % $interval == 0) {
-        $percent = sprintf("%.2f", ($i / $count) * 100);
-        print "Parsing Line $line_num (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes.\n";
+        $percent = sprintf("%.2f", (($i + 1) / $count) * 100);
+        print "Syncing $base_table " . ($i + 1) . " of $count (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes.\r";
         tripal_set_job_progress($job_id, intval(($i/$count)*100));
       }
 
@@ -602,7 +605,7 @@ function chado_node_sync_records($base_table, $max_sync = FALSE, $organism_id =
         ->fetchObject();
 
       if (!empty($result)) {
-        print " Previously Sync'd";
+        //print " Previously Sync'd";
       }
       else {
 
@@ -628,7 +631,7 @@ function chado_node_sync_records($base_table, $max_sync = FALSE, $organism_id =
         if (!form_get_errors()) {
           $node = node_submit($new_node);
           node_save($node);
-          print " Node Created (nid=".$node->nid.")";
+          //print " Node Created (nid=".$node->nid.")";
         }
         else {
           watchdog('trp-fsync', "Failed to insert $base_table: %title", array('%title' => $new_node->title), WATCHDOG_ERROR);
@@ -636,9 +639,9 @@ function chado_node_sync_records($base_table, $max_sync = FALSE, $organism_id =
       }
       $i++;
     }
-
     print "\n\nComplete!\n";
   }
+  
   catch (Exception $e) {
     $transaction->rollback();
     print "\n"; // make sure we start errors on new line

+ 3 - 1
tripal_organism/includes/tripal_organism.chado_node.inc

@@ -343,7 +343,9 @@ function chado_organism_insert($node) {
   }
 
   // add the image
-  chado_organism_add_image($node);
+  if (property_exists($node, organism_image)) {
+    chado_organism_add_image($node);
+  }
 }
 
 /**