Browse Source

Stock: some bug fixes to the node form

Lacey Sanderson 11 years ago
parent
commit
cc3a5643e7
1 changed files with 24 additions and 19 deletions
  1. 24 19
      tripal_stock/includes/tripal_stock.chado_node.inc

+ 24 - 19
tripal_stock/includes/tripal_stock.chado_node.inc

@@ -315,7 +315,7 @@ function chado_stock_form($node, $form_state) {
     'base_foreign_key' => 'stock_id',
     'base_key_value' => $stock_id
   );
-  tripal_core_additional_dbxrefs_form($form, $form_state, $details);
+  chado_node_additional_dbxrefs_form($form, $form_state, $details);
 
   // RELATIONSHIPS FORM
   //---------------------------------------------
@@ -328,7 +328,7 @@ function chado_stock_form($node, $form_state) {
     'nodetype' => 'stock',
     'cv_id' => variable_get('chado_stock_relationship_cv', 0)
   );
-  tripal_core_relationships_form($form, $form_state, $details);
+  chado_node_relationships_form($form, $form_state, $details);
 
   return $form;
 }
@@ -545,14 +545,14 @@ function chado_stock_insert($node) {
       chado_node_properties_form_update_properties($node, $details);
 
       // Now add the additional references
-      tripal_core_additional_dbxrefs_form_update_dbxrefs(
+      chado_node_additional_dbxrefs_form_update_dbxrefs(
         $node,
         'stock_dbxref',
         'stock_id',
         $stock_id
       );
       // Now add in relationships
-      tripal_core_relationships_form_update_relationships(
+      chado_node_relationships_form_update_relationships(
         $node,
         'stock_relationship',
         $stock_id
@@ -609,7 +609,10 @@ function chado_stock_update($node) {
   }
 
   //update dbxref
+  $dbxref_status = NULL;
+  $dbxref_present = FALSE;
   if ($node->database) {
+    $dbxref_present = TRUE;
     if ($node->accession) {
       $dbxref_mode = '';
       $stock = tripal_core_chado_select(
@@ -659,15 +662,15 @@ function chado_stock_update($node) {
         }
       }
     }
-  }
 
-  if (!$dbxref_status) {
-    watchdog(
-      'tripal_stock',
-      'Stock Update: Unable to %mode main stock dbxref with values: %values',
-      array('%values' => print_r($values, TRUE), '%mode' => $dbxref_mode),
-      WATCHDOG_WARNING
-    );
+    if (!$dbxref_status) {
+      watchdog(
+        'tripal_stock',
+        'Stock Update: Unable to %mode main stock dbxref with values: %values',
+        array('%values' => print_r($values, TRUE), '%mode' => $dbxref_mode),
+        WATCHDOG_WARNING
+      );
+    }
   }
 
   //can't change stock id which is all thats stored in drupal thus only update chado
@@ -678,11 +681,13 @@ function chado_stock_update($node) {
     'description' => $node->stock_description,
     'type_id' => $node->type_id,
   );
-  if ($dbxref_status) {
-    $update_values['dbxref_id'] = array(
-      'db_id' => $node->database,
-      'accession' => $node->accession
-    );
+  if ($dbxref_present) {
+    if ($dbxref_status) {
+      $update_values['dbxref_id'] = array(
+        'db_id' => $node->database,
+        'accession' => $node->accession
+      );
+    }
   }
   $status = tripal_core_chado_update('stock', array('stock_id' => $node->stock_id), $update_values);
 
@@ -717,7 +722,7 @@ function chado_stock_update($node) {
 
   // now update the additional dbxrefs
   if ($node->stock_id > 0) {
-    tripal_core_additional_dbxrefs_form_update_dbxrefs(
+    chado_node_additional_dbxrefs_form_update_dbxrefs(
       $node,
       'stock_dbxref',
       'stock_id',
@@ -727,7 +732,7 @@ function chado_stock_update($node) {
 
   // now update relationships
   if ($node->stock_id > 0) {
-    tripal_core_relationships_form_update_relationships(
+    chado_node_relationships_form_update_relationships(
       $node,
       'stock_relationship',
       $node->stock_id