Эх сурвалжийг харах

Stock: Implemented relationships api for stock node forms

Lacey Sanderson 11 жил өмнө
parent
commit
b0e47784e3

+ 7 - 0
tripal_core/tripal_core.module

@@ -44,6 +44,7 @@ require_once "api/tripal_core_jobs.api.inc";
 require_once "api/tripal_core_mviews.api.inc";
 require_once "api/tripal_core_properties.api.inc";
 require_once "api/tripal_core.database_references.api.inc";
+require_once "api/tripal_core.relationships.api.inc";
 
 require_once "includes/jobs.inc";
 require_once "includes/mviews.inc";
@@ -424,6 +425,12 @@ function tripal_core_theme($existing, $type, $theme, $path) {
       'function' => 'theme_tripal_core_additional_dbxrefs_form_table',
       'render element' => 'element',
     ),
+
+    // relationships form theme
+    'tripal_core_relationships_form_table' => array(
+      'function' => 'theme_tripal_core_relationships_form_table',
+      'render element' => 'element',
+    ),
   );
 }
 

+ 33 - 4
tripal_stock/includes/tripal_stock.chado_node.inc

@@ -344,6 +344,19 @@ function chado_stock_form($node, $form_state) {
   );
   tripal_core_additional_dbxrefs_form($form, $form_state, $details);
 
+  // RELATIONSHIPS FORM
+  //---------------------------------------------
+
+  $details = array(
+    'relationship_table' => 'stock_relationship',
+    'base_table' => 'stock',
+    'base_foreign_key' => 'stock_id',
+    'base_key_value' => $stock_id,
+    'nodetype' => 'stock',
+    'cv_id' => variable_get('chado_stock_relationship_cv', 0)
+  );
+  tripal_core_relationships_form($form, $form_state, $details);
+
   return $form;
 }
 
@@ -593,13 +606,22 @@ function chado_stock_insert($node) {
 
     // Now add the additional references
     if ($stock_added) {
-      tripal_core_additional_dbxrefs_form_update_dbxrefs(
+      tripal_core_relationships_form_update_relationships(
         $node,
         'stock_dbxref',
         'stock_id',
         $stock_id
       );
     }
+
+    // Now add in relationships
+    if ($stock_added) {
+      tripal_core_relationships_form_update_dbxrefs(
+        $node,
+        'stock_relationship',
+        $stock_id
+      );
+    }
   } //end of adding stock to chado
   else {
     // stock already exists since this is a sync
@@ -780,13 +802,20 @@ function chado_stock_update($node) {
 
   // now update the additional dbxrefs
   if ($node->stock_id > 0) {
-    $stock_id = $node->stock_id;
-
     tripal_core_additional_dbxrefs_form_update_dbxrefs(
       $node,
       'stock_dbxref',
       'stock_id',
-      $stock_id
+      $node->stock_id
+    );
+  }
+
+  // now update relationships
+  if ($node->stock_id > 0) {
+    tripal_core_relationships_form_update_relationships(
+      $node,
+      'stock_relationship',
+      $node->stock_id
     );
   }
 }