Browse Source

Merge branch '6.x-1.x' of git.drupal.org:sandbox/spficklin/1337878 into 6.x-1.x

spficklin 12 năm trước cách đây
mục cha
commit
b32ef39d05

+ 7 - 3
tripal_bulk_loader/tripal_bulk_loader.constants.inc

@@ -138,7 +138,8 @@ function tripal_bulk_loader_set_constants_form($form_state, $node) {
   );
 
   // Display table of already added constant sets with the ability to re-arrange and delete
-  if (sizeof($node->constants) > 0) {
+  $first_constant = reset($node->constants);
+  if (sizeof($node->constants) > 0 AND !empty($first_constant)) {
     $form['exposed_fields']['explanation-1'] = array(
       '#type' => 'item',
       '#value' => t('You have already added constants to this bulk loading job. Each '
@@ -360,14 +361,16 @@ function theme_tripal_bulk_loader_set_constants_form($form) {
       }
       $row[] = drupal_render($element['delete']);
       $row[] = drupal_render($element['group']) . drupal_render($element['id']);
-      $rows[] = array('data' => $row, 'class' => 'draggable');
+      if (!empty($row[0])) {
+        $rows[] = array('data' => $row, 'class' => 'draggable');
+      }
       $i++;
     }
     //drupal_add_tabledrag('mytable', 'order', 'sibling', 'weight-group');
     // @coder-ignore: no user input thus don't need to filter
     $form['exposed_fields']['existing'] = array(
       '#type' => 'markup',
-      '#value' => filter_xss(theme('table', $header, $rows, array('id' => 'mytable')) . '<br />'),
+      '#value' => theme('table', $header, $rows, array('id' => 'mytable')) . '<br />',
     );
   }
 
@@ -420,6 +423,7 @@ function tripal_bulk_loader_edit_constant_set_form($form_state, $node, $group_id
     foreach ($node->exposed_fields as $exposed_index) {
 
       $record_id = $exposed_index['record_id'];
+      $record = $node->template->template_array[$record_id];
       $field_id = $exposed_index['field_id'];
       $field = $node->template->template_array[$record_id]['fields'][$field_id];
 

+ 15 - 3
tripal_bulk_loader/tripal_bulk_loader.loader.inc

@@ -139,6 +139,7 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
   print "File: " . $node->file . " (" . $total_lines . " lines)\n";
 
   // Prep Work ==================================================================================
+  print "\nPreparing to load...\n";
   $loaded_without_errors = TRUE;
 
   // Generate default values array
@@ -203,6 +204,7 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
   ///////////////////////////////////////////////
   // For each set of constants
   ///////////////////////////////////////////////
+  print "Loading...\n";
   $original_default_data = $default_data;
   $group_index = 0;
   $total_num_groups = sizeof($node->constants);
@@ -251,7 +253,9 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
 
     // Parse File adding records as we go ========================================================
 
+    print "\tPreparing to load the current constant set...\n";
     // Open File
+    print "\t\tOpen File...\n";
     $file_handle = fopen($node->file, 'r');
 
     // Set defaults
@@ -271,11 +275,13 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
       case "none":
         break;
       case "all":
+        print "\t\tStart Transaction...\n";
         tripal_db_start_transaction();
         $transactions = TRUE;
         $savepoint = "";
         break;
       case "row":
+        print "\t\tStart Transaction...\n";
         tripal_db_start_transaction();
         $transactions = TRUE;
         $savepoint = "last_row_complete";
@@ -285,16 +291,22 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
     // Disable triggers
     $triggers_disabled = FALSE;
     if ($transactions AND variable_get('tripal_bulk_loader_disable_triggers', TRUE)) {
+      print "\t\tDefer Constraints...\n";
       $triggers_disabled = TRUE;
       chado_query("SET CONSTRAINTS ALL DEFERRED");
     }
 
     // Acquire Locks
-    $lockmode = variable_get('tripal_bulk_loader_lock', 'ROW EXCLUSIVE');
-    foreach ($tables as $table) {
-      chado_query("LOCK TABLE %s IN %s MODE", $table, $lockmode);
+    if ($transactions) {
+      print "\t\tAcquiring Table Locks...\n";
+      $lockmode = variable_get('tripal_bulk_loader_lock', 'ROW EXCLUSIVE');
+      foreach ($tables as $table) {
+        print "\t\t\t$lockmode for $table\n";
+        chado_query("LOCK TABLE %s IN %s MODE", $table, $lockmode);
+      }
     }
 
+    print "\tLoading the current constant set...\n";
     tripal_bulk_loader_progress_bar(0, $total_lines);
     while (!feof($file_handle)) {
 

+ 1 - 1
tripal_db/tripal_db.api.inc

@@ -352,7 +352,7 @@ function tripal_db_add_dbxref($db_id, $accession, $version='', $description='')
       watchdog('tripal_cv', "Failed to insert the dbxref record $accession", NULL, WATCHDOG_WARNING);
       return 0;
     }
-    print "Added Dbxref accession: $accession\n";
+    drupal_set_message("Added Dbxref accession: $accession");
     $dbxref = db_fetch_object(db_query($dbxsql, $db_id, $accession));
   }
   return $dbxref;