Browse Source

Fixed bugs from PR review

Stephen Ficklin 6 years ago
parent
commit
4229d8b98f

+ 1 - 1
tripal_chado/api/tripal_chado.api.inc

@@ -106,7 +106,7 @@ function chado_publish_records($values, $job = NULL) {
   }
 
   // Load the term for use in setting the alias for each entity created.
-  $term = entity_load('TripalTerm', array('id' => $entity->term_id));
+  $term = entity_load('TripalTerm', array('id' => $bundle->term_id));
   $cache['term'] = $term;
 
   $table = $chado_bundle->data_table;

+ 23 - 13
tripal_chado/includes/loaders/tripal_chado.pub_importers.inc

@@ -961,7 +961,9 @@ function tripal_pub_add_publications($pubs, $do_contact, $update = FALSE, $job =
 }
 
 /**
- * Adds a new publication to the Chado, along with all properties and
+ * Adds a new publication to Chado.
+ * 
+ * In addition, all properties and
  * database cross-references. If the publication does not already exist
  * in Chado then it is added.  If it does exist nothing is done.  If
  * the $update parameter is TRUE then the publication is updated if it exists.
@@ -972,23 +974,25 @@ function tripal_pub_add_publications($pubs, $do_contact, $update = FALSE, $job =
  *   This variable will get set to a text value indicating the action that was
  *   performed. The values include 'skipped', 'inserted', 'updated' or 'error'.
  * @param $do_contact
- *   Optional. Set to TRUE if a contact entry should be added to the Chado contact table
- *   for authors of the publication.
+ *   Optional. Set to TRUE if a contact entry should be added to the Chado 
+ *   contact table for authors of the publication.
  * @param $update_if_exists
- *   Optional.  If the publication already exists then this function will return
- *   without adding a new publication.  However, set this value to TRUE to force
- *   the function to pudate the publication using the $pub_details that are provided.
+ *   Optional.  If the publication already exists then this function will 
+ *   return without adding a new publication.  However, set this value to 
+ *   TRUE to force the function to pudate the publication using the 
+ *   $pub_details that are provided.   
  * @param $job
  *   The jobs management object for the job if this function is run as a job. 
  *   This argument is added by Tripal during a job run and is not needed if
  *   this function is run directly.
  * @return
- *   If the publication already exists, is inserted or updated then the publication
- *   ID is returned, otherwise FALSE is returned. If the publication already exists
- *   and $update_if_exists is not TRUE then the $action variable is set to 'skipped'.
- *   If the publication already exists and $update_if_exists is TRUE and if the update
- *   was successful then $action is set to 'updated'.  Otherwise on successful insert
- *   the $action variable is set to 'inserted'.  If the function failes then the
+ *   If the publication already exists, is inserted or updated then the 
+ *   publication ID is returned, otherwise FALSE is returned. If the 
+ *   publication already exists and $update_if_exists is not TRUE then the 
+ *   $action variable is set to 'skipped'. If the publication already exists 
+ *   and $update_if_exists is TRUE and if the update was successful then 
+ *   $action is set to 'updated'.  Otherwise on successful insert the 
+ *   $action variable is set to 'inserted'.  If the function failes then the
  *   $action variable is set to 'error'
  *
  * @ingroup tripal_pub
@@ -1157,6 +1161,12 @@ function tripal_pub_add_publication($pub_details, &$action, $do_contact = FALSE,
     if($key == 'raw') {
       continue;
     }
+    
+    // Since we're not updating the 'Publication Dbxref' on an update
+    // skip this property.
+    if ($update_if_exists and $key == 'Publication Dbxref') {
+      continue;
+    }
 
     // Get the cvterm by name.
     $identifiers = array(
@@ -1222,7 +1232,7 @@ function tripal_pub_add_publication($pub_details, &$action, $do_contact = FALSE,
     }
     if (!$success) {
       tripal_report_error($message_type, TRIPAL_ERROR, 
-        "Cannot add property '%prop' to publication. Skipping.",
+        "Cannot add property '%prop' to pubprop table. Skipping.",
         ['%prop' => $key], $error_opts);
       continue;
     }

+ 6 - 5
tripal_chado/tripal_chado.drush.inc

@@ -152,18 +152,19 @@ function drush_tripal_chado_trp_import_pubs() {
     $update = FALSE;
   }
   
+  
   if ($publish == 'Y' and $sync == 'Y' ) {
     $publish = 'both';
   }
-  elseif ($publish  != 'Y' and $sync == 'Y' ) {
+  elseif ($publish != 'Y' and $sync == 'Y') {
     $publish = 'sync';
   }
-  elseif ($publish  == 'Y'  and $sync  != 'Y' ) {
+  elseif ($publish == 'Y' and $sync != 'Y') {
     $publish = TRUE;
   }
   else {
-    $publish = TRUE;
-  } 
+    $publish = FALSE;
+  }
 
   module_load_include('inc', 'tripal_chado', 'includes/loaders/tripal_chado.pub_importers');
   if ($dbxref) {
@@ -199,7 +200,7 @@ function drush_tripal_chado_trp_update_pubs() {
     $publish = TRUE;
   }
   else {
-    $publish = TRUE;
+    $publish = FALSE;
   }
 
   module_load_include('inc', 'tripal_chado', 'includes/loaders/tripal_chado.pub_importers');