spficklin 14 anos atrás
pai
commit
c45f61069e

+ 1 - 1
theme_tripal/node-chado_organism.tpl.php

@@ -94,7 +94,7 @@ if (Drupal.jsEnabled) {
    <div id="tripal_organism_toc_title" class="tripal_toc_title">Resources</i></div>
    <span id="tripal_organism_toc_desc" class="tripal_toc_desc"></span>
    <ul id="tripal_organism_toc_list" class="tripal_toc_list">
-
+   <?php // ADD CUSTOMIZED LINKS HERE ?>
    </ul>
 </div>
 

+ 4 - 81
tripal_analysis/tripal_analysis.api.inc

@@ -113,107 +113,30 @@ function tripal_analysis_chado_analysisprop_schema() {
   return $description;
 }
 /**
-* Adds a single property to an existing analysis record.
 *
 * @ingroup tripal_api
 */
 function tripal_analysis_get_property($analysis_id,$property){
-   // construct the array of values to be inserted  
-   $values = array (
-      'analysis_id' => $analysis_id,
-      'type_id' => array ( 
-         'cv_id' => array (
-            'name' => 'tripal',
-         ),
-         'name' => $property,
-         'is_obsolete' => 0
-      ),
-   );
-   $results = tripal_core_generate_chado_var('analysisprop',$values);
-   $results = tripal_core_expand_chado_vars($results,'field','analysisprop.value');
-   return $results;
+   return tripal_core_get_property('analysis',$analysis_id,$property,'tripal');
 }
 /**
-* Adds a single property to an existing analysis record.
 *
 * @ingroup tripal_api
 */
 function tripal_analysis_insert_property($analysis_id,$property,$value,$update_if_present = 0){
-   // first see if the property already exists, if so we can't insert
-   $prop = tripal_analysis_get_property($analysis_id,$property);
-   if(count($prop)>0){
-      if($update_if_present){
-        return tripal_analysis_update_property($analysis_id,$property,$value) ;
-      } else {
-        return FALSE;
-      }
-   }
-
-   // construct the array of values to be inserted  
-   $values = array (
-      'analysis_id' => $analysis_id,
-      'type_id' => array ( 
-         'cv_id' => array (
-            'name' => 'tripal',
-         ),
-         'name' => $property,
-         'is_obsolete' => 0
-      ),
-      'value' => $value, 
-      'rank' => 0,
-   );
-   return tripal_core_chado_insert('analysisprop',$values);
+    return tripal_core_insert_property('analysis',$analysis_id,$property,'tripal',$value,$update_if_present);
 }
 /**
-* Adds a single property to an existing analysis record.
 *
 * @ingroup tripal_api
 */
 function tripal_analysis_update_property($analysis_id,$property,$value,$insert_if_missing = 0){
-
-   // first see if the property is missing (we can't update a missing property
-   $prop = tripal_analysis_get_property($analysis_id,$property);
-   if(count($prop)==0){
-      if($insert_if_missing){
-        return tripal_analysis_insert_property($analysis_id,$property,$value);
-      } else {
-        return FALSE;
-      }
-   }
-
-   // construct the array that will match the exact record to update
-   $match = array (
-      'analysis_id' => $analysis_id,
-      'type_id' => array ( 
-         'cv_id' => array (
-            'name' => 'tripal',
-         ),
-         'name' => $property,
-      ),
-   );
-   // construct the array of values to be updated
-   $values = array (      
-      'value' => $value, 
-   );
-   return tripal_core_chado_update('analysisprop',$match,$values);
+   return tripal_core_update_property('analysis',$analysis_id,$property,'tripal',$value, $insert_if_missing);
 }
 /**
-* Adds a single property to an existing analysis record.
 *
 * @ingroup tripal_api
 */
 function tripal_analysis_delete_property($analysis_id,$property){
-
-
-   // construct the array that will match the exact record to update
-   $match = array (
-      'analysis_id' => $analysis_id,
-      'type_id' => array ( 
-         'cv_id' => array (
-            'name' => 'tripal',
-         ),
-         'name' => $property,
-      ),
-   );
-   return tripal_core_chado_delete('analysisprop',$match);
+   return tripal_core_delete_property('analysis',$analysis_id,$property,'tripal');
 }

+ 44 - 23
tripal_core/tripal_core.api.inc

@@ -490,12 +490,12 @@ function tripal_core_chado_select($table,$columns,$values,$options = null){
     if (!$options['order_by']) { $options['order_by'] = array(); }
     
    if (!is_array($columns)){
-      watchdog('tripal_feature', 'the $columns argument for tripal_core_chado_select must be an array.');
+      watchdog('tripal_core', 'the $columns argument for tripal_core_chado_select must be an array.');
       return false;
    }
 
    if (!is_array($values)){
-      watchdog('tripal_feature', 'the $values argument for tripal_core_chado_select must be an array.');
+      watchdog('tripal_core', 'the $values argument for tripal_core_chado_select must be an array.');
       return false;
    }
 
@@ -687,7 +687,11 @@ function tripal_core_chado_get_foreign_key($table_desc,$field,$values, $options
       // TODO: what do we do if we get to this point and we have a fk 
       // relationship expected but we don't have any definition for one in the
       // table schema??
-      $message = "There is no foreign key relationship defined for ".$field.". To define a foreign key relationship, determine the table this foreign key referrs to (<foreign table>) and then implement hook_chado_<foreign table>_schema(). See tripal_feature_chado_feature_schema for an example.";
+      $message = "There is no foreign key relationship defined for ".$field.". 
+         To define a foreign key relationship, determine the table this foreign 
+         key referrs to (<foreign table>) and then implement 
+         hook_chado_<foreign table>_schema(). See 
+         tripal_feature_chado_feature_schema for an example.";
       watchdog('tripal_core', $message);
       drupal_set_message($message,'error');      
    }
@@ -1269,10 +1273,12 @@ function chado_get_node_id ($table, $id) {
 *
 * @ingroup tripal_api
 */
-function tripal_core_get_property($basetable, $record_id, $property,$cv_name){
+function tripal_core_get_property($basetable, $record_id, $property, $cv_name){
 
+   // get the foreign key for this property table
    $table_desc = module_invoke_all('chado_'.$basetable.'prop_schema');
    $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
+
    // construct the array of values to be inserted  
    $values = array (
       $fkcol => $record_id,
@@ -1293,23 +1299,29 @@ function tripal_core_get_property($basetable, $record_id, $property,$cv_name){
 *
 * @ingroup tripal_core.api
 */
-function tripal_core_insert_property($proptable, $feature_id,$property,$value,$update_if_present = 0){
+function tripal_core_insert_property($basetable, $record_id, $property, 
+   $cv_name, $value, $update_if_present = 0)
+{
    // first see if the property already exists, if so we can't insert
-   $prop = tripal_feature_get_property($feature_id,$property);
-   if(count($prop)>0){
+   $prop = tripal_core_get_property($basetable,$record_id,$property,$cv_name);
+   if(count($prop)>0){ 
       if($update_if_present){
-        return tripal_feature_update_property($feature_id,$property,$value) ;
+        return tripal_core_update_property($basetable,$record_id,$property,$cv_name,$value) ;
       } else {
         return FALSE;
       }
    }
 
+   // get the foreign key for this property table
+   $table_desc = module_invoke_all('chado_'.$basetable.'prop_schema');
+   $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
+
    // construct the array of values to be inserted  
    $values = array (
-      'feature_id' => $feature_id,
+      $fkcol => $record_id,
       'type_id' => array ( 
          'cv_id' => array (
-            'name' => 'tripal',
+            'name' => $cv_name,
          ),
          'name' => $property,
          'is_obsolete' => 0
@@ -1317,31 +1329,37 @@ function tripal_core_insert_property($proptable, $feature_id,$property,$value,$u
       'value' => $value, 
       'rank' => 0,
    );
-   return tripal_core_chado_insert('featureprop',$values);
+   return tripal_core_chado_insert($basetable.'prop',$values);
 }
 /**
-* Adds a single property to an existing feature record.
+* Adds a single property to an existing record.
 *
 * @ingroup tripal_api
 */
-function tripal_core_update_property($proptable, $feature_id,$property,$value,$insert_if_missing = 0){
+function tripal_core_update_property($basetable, $record_id,$property,$cv_name,
+   $value,$insert_if_missing = 0)
+{
 
    // first see if the property is missing (we can't update a missing property
-   $prop = tripal_feature_get_property($feature_id,$property);
+   $prop = tripal_core_get_property($basetable,$record_id,$property,$cv_name);
    if(count($prop)==0){
       if($insert_if_missing){
-        return tripal_feature_insert_property($feature_id,$property,$value);
+        return tripal_core_insert_property($basetable,$record_id,$property,$cv_name,$value);
       } else {
         return FALSE;
       }
    }
 
+   // get the foreign key for this property table
+   $table_desc = module_invoke_all('chado_'.$basetable.'prop_schema');
+   $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
+
    // construct the array that will match the exact record to update
    $match = array (
-      'feature_id' => $feature_id,
+      $fkcol => $record_id,
       'type_id' => array ( 
          'cv_id' => array (
-            'name' => 'tripal',
+            'name' => $cv_name,
          ),
          'name' => $property,
       ),
@@ -1350,24 +1368,27 @@ function tripal_core_update_property($proptable, $feature_id,$property,$value,$i
    $values = array (      
       'value' => $value, 
    );
-   return tripal_core_chado_update('featureprop',$match,$values);
+   return tripal_core_chado_update($basetable.'prop',$match,$values);
 }
 /**
-* Adds a single property to an existing feature record.
+* Adds a single property to an existing record.
 *
 * @ingroup tripal_api
 */
-function tripal_core_delete_property($proptable, $feature_id,$property){
+function tripal_core_delete_property($basetable, $record_id,$property,$cv_name){
+   // get the foreign key for this property table
+   $table_desc = module_invoke_all('chado_'.$basetable.'prop_schema');
+   $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
 
    // construct the array that will match the exact record to update
    $match = array (
-      'feature_id' => $feature_id,
+      $fkcol => $record_id,
       'type_id' => array ( 
          'cv_id' => array (
-            'name' => 'tripal',
+            'name' => $cv_name,
          ),
          'name' => $property,
       ),
    );
-   return tripal_core_chado_delete('featureprop',$match);
+   return tripal_core_chado_delete($basetable.'prop',$match);
 }

+ 4 - 77
tripal_library/tripal_library.api.inc

@@ -109,20 +109,7 @@ function tripal_library_chado_libraryprop_schema() {
 * @ingroup tripal_api
 */
 function tripal_library_get_property($library_id,$property){
-   // construct the array of values to be inserted  
-   $values = array (
-      'library_id' => $library_id,
-      'type_id' => array ( 
-         'cv_id' => array (
-            'name' => 'tripal',
-         ),
-         'name' => $property,
-         'is_obsolete' => 0
-      ),
-   );
-   $results = tripal_core_generate_chado_var('libraryprop',$values);
-   $results = tripal_core_expand_chado_vars($results,'field','libraryprop.value');
-   return $results;
+   return tripal_core_get_property('library',$library_id,$property,'tripal');
 }
 /**
 * Adds a single property to an existing library record.
@@ -130,30 +117,7 @@ function tripal_library_get_property($library_id,$property){
 * @ingroup tripal_api
 */
 function tripal_library_insert_property($library_id,$property,$value,$update_if_present = 0){
-   // first see if the property already exists, if so we can't insert
-   $prop = tripal_library_get_property($library_id,$property);
-   if(count($prop)>0){
-      if($update_if_present){
-        return tripal_library_update_property($library_id,$property,$value) ;
-      } else {
-        return FALSE;
-      }
-   }
-
-   // construct the array of values to be inserted  
-   $values = array (
-      'library_id' => $library_id,
-      'type_id' => array ( 
-         'cv_id' => array (
-            'name' => 'tripal',
-         ),
-         'name' => $property,
-         'is_obsolete' => 0
-      ),
-      'value' => $value, 
-      'rank' => 0,
-   );
-   return tripal_core_chado_insert('libraryprop',$values);
+   return tripal_core_insert_property('library',$library_id,$property,'tripal',$value,$update_if_present);
 }
 /**
 * Adds a single property to an existing library record.
@@ -161,32 +125,7 @@ function tripal_library_insert_property($library_id,$property,$value,$update_if_
 * @ingroup tripal_api
 */
 function tripal_library_update_property($library_id,$property,$value,$insert_if_missing = 0){
-
-   // first see if the property is missing (we can't update a missing property
-   $prop = tripal_library_get_property($library_id,$property);
-   if(count($prop)==0){
-      if($insert_if_missing){
-        return tripal_library_insert_property($library_id,$property,$value);
-      } else {
-        return FALSE;
-      }
-   }
-
-   // construct the array that will match the exact record to update
-   $match = array (
-      'library_id' => $library_id,
-      'type_id' => array ( 
-         'cv_id' => array (
-            'name' => 'tripal',
-         ),
-         'name' => $property,
-      ),
-   );
-   // construct the array of values to be updated
-   $values = array (      
-      'value' => $value, 
-   );
-   return tripal_core_chado_update('libraryprop',$match,$values);
+   return tripal_core_update_property('library',$library_id,$property,'tripal',$value, $insert_if_missing);
 }
 /**
 * Adds a single property to an existing library record.
@@ -194,17 +133,5 @@ function tripal_library_update_property($library_id,$property,$value,$insert_if_
 * @ingroup tripal_api
 */
 function tripal_library_delete_property($library_id,$property){
-
-
-   // construct the array that will match the exact record to update
-   $match = array (
-      'library_id' => $library_id,
-      'type_id' => array ( 
-         'cv_id' => array (
-            'name' => 'tripal',
-         ),
-         'name' => $property,
-      ),
-   );
-   return tripal_core_chado_delete('libraryprop',$match);
+   return tripal_core_delete_property('library',$library_id,$property,'tripal');
 }

+ 1 - 1
tripal_library/tripal_library.module

@@ -813,7 +813,7 @@ function chado_library_update($node){
       );
       $status = tripal_core_chado_update('library', $match,$values); 
 
-      tripal_library_insert_property($library_id,'library_description',$node->library_description);
+      tripal_library_update_property($library_id,'library_description',$node->library_description);
    }
 }