Browse Source

updated property API calls

Stephen Ficklin 10 years ago
parent
commit
141b6d0654

+ 46 - 8
tripal_analysis/api/tripal_analysis.DEPRECATED.inc

@@ -66,8 +66,17 @@ function tripal_analysis_get_property($analysis_id, $property, $cv_name = 'tripa
       '%new_function' => 'chado_get_property'
     )
   );
+  
+  $record = array(
+    'table' => 'analysis',
+    'id' => $analysis_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+  );
 
-  return chado_get_property('analysis', $analysis_id, $property, $cv_name);
+  return chado_get_property($record, $property);
 }
 
 /**
@@ -89,7 +98,19 @@ function tripal_analysis_insert_property($analysis_id, $property, $value, $updat
     )
   );
 
-  return chado_insert_property('analysis', $analysis_id, $property, $cv_name, $value, $update_if_present);
+  $record = array(
+    'table' => 'analysis',
+    'id' => $analysis_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value,
+  );
+  $options = array(
+    'update_if_present' => $update_if_present,
+  );
+  return chado_insert_property($record, $property, $options);
 }
 
 /**
@@ -111,7 +132,19 @@ function tripal_analysis_update_property($analysis_id, $property, $value, $inser
     )
   );
 
-  return chado_update_property('analysis', $analysis_id, $property, $cv_name, $value, $insert_if_missing);
+  $record = array(
+    'table' => 'analysis',
+    'id' => $analysis_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value,
+  );
+  $options = array(
+    'insert_if_missing' => $insert_if_missing,
+  );
+  return chado_update_property($record, $property, $options);
 }
 
 /**
@@ -123,17 +156,22 @@ function tripal_analysis_update_property($analysis_id, $property, $value, $inser
  */
 function tripal_analysis_delete_property($analysis_id, $property, $cv_name = 'tripal') {
 
-  tripal_report_error(
-    'tripal_deprecated',
-    TRIPAL_NOTICE,
+  tripal_report_error('tripal_deprecated', TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
     array(
       '%old_function'=>'tripal_analysis_delete_property',
       '%new_function' => 'chado_delete_property'
     )
   );
-
-  return chado_delete_property('analysis', $analysis_id, $property, $cv_name);
+  $record = array(
+    'table' => 'analysis',
+    'id' => $analysis_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+  );
+  return chado_delete_property($record, $property);
 }
 
 /**

+ 7 - 4
tripal_analysis/api/tripal_analysis.api.inc

@@ -84,7 +84,7 @@ function tripal_get_analysis($identifier, $options) {
       'tripal_stock_api',
       TRIPAL_ERROR,
       "chado_get_stock: The identifier passed in is expected to be an array with the key
-        matching a column name in the stock table (ie: stock_id or name). You passed in %identifier.",
+        matching a column name in the analysis table (ie: analysis_id or name). You passed in %identifier.",
       array(
         '%identifier'=> print_r($identifiers, TRUE)
       )
@@ -94,8 +94,8 @@ function tripal_get_analysis($identifier, $options) {
     tripal_report_error(
       'tripal_stock_api',
       TRIPAL_ERROR,
-      "chado_get_stock: You did not pass in anything to identify the stock you want. The identifier
-        is expected to be an array with the key matching a column name in the stock table
+      "chado_get_stock: You did not pass in anything to identify the analysis you want. The identifier
+        is expected to be an array with the key matching a column name in the analysis table
         (ie: stock_id or name). You passed in %identifier.",
       array(
         '%identifier'=> print_r($identifiers, TRUE)
@@ -107,7 +107,10 @@ function tripal_get_analysis($identifier, $options) {
   if (isset($identifiers['property'])) {
     $property = $identifiers['property'];
     unset($identifiers['property']);
-    $analysis = chado_get_record_with_property('analysis', $property, $identifiers, $options);
+    $analysis = chado_get_record_with_property(
+      array('table' => 'analysis', 'base_records' => $identifiers), 
+      array('type_name' => $property)
+    );
   }
 
   // Else we have a simple case and we can just use chado_generate_var to get the analysis

+ 45 - 6
tripal_contact/api/tripal_contact.DEPRECATED.inc

@@ -22,8 +22,17 @@ function tripal_contact_get_property($contact_id, $property) {
       '%new_function' => 'chado_get_property'
     )
   );
+  
+  $record = array(
+    'table' => 'contact',
+    'id' => $contact_id
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'contact_property',
+  );
 
-  return chado_get_property('contact', $contact_id, $property, 'tripal_contact');;
+  return chado_get_property($record, $property);
 }
 
 /**
@@ -45,7 +54,19 @@ function tripal_contact_insert_property($contact_id, $property, $value, $update_
     )
   );
 
-  return chado_insert_property('contact', $contact_id, $property, 'tripal_contact', $value, $update_if_present);
+  $record = array(
+    'table' => 'contact',
+    'id' => $contact_id
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'contact_property',
+    'value' => $value,
+  );
+  $options = array(
+    'update_if_present' => $update_if_present
+  );
+  return chado_insert_property($record, $property, $options);
 }
 
 /**
@@ -66,8 +87,19 @@ function tripal_contact_update_property($contact_id, $property, $value, $insert_
       '%new_function' => 'chado_update_property'
     )
   );
-
-  return chado_update_property('contact', $contact_id, $property, 'tripal_contact', $value, $insert_if_missing);
+  $record = array(
+    'table' => 'contact',
+    'id' => $contact_id
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'contact_property',
+    'value' => $value,
+  );
+  $options = array(
+    'insert_if_missing' => $insert_if_missing
+  );
+  return chado_update_property($record, $property, $options);
 }
 
 /**
@@ -88,8 +120,15 @@ function tripal_contact_delete_property($contact_id, $property) {
       '%new_function' => 'chado_delete_property'
     )
   );
-
-  return chado_delete_property('contact', $contact_id, $property, 'tripal_contact');
+  $record = array(
+    'table' => 'contact',
+    'id' => $contact_id
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'contact_property',
+  );
+  return chado_delete_property($record, $property);
 }
 
 /**

+ 20 - 12
tripal_contact/api/tripal_contact.api.inc

@@ -75,25 +75,33 @@ function tripal_insert_contact($values) {
   // field because it is only 255 characters long and may not be enough
   if ($description) {
     chado_insert_property(
-      'contact',
-      $contact['contact_id'],
-      'contact_description',
-      'tripal_contact',
-      $description,
-      TRUE
+      array(
+        'table' => 'contact',
+        'id' => $contact['contact_id'],
+      ),
+      array(
+        'type_name' => 'contact_description',
+        'cv_name' => 'tripal_contact',
+        'value' => $description,
+      ),
+      array(
+        'update_if_present' => TRUE,
+      )
     );
   }
 
   // add in the other properties provided
   foreach ($properties as $key => $value) {
     $success = chado_insert_property(
-      'contact',
-      $contact['contact_id'],
-      $key,
-      'tripal_contact',
-      $value,
-      TRUE
+      array('table' => 'contact', 'id' => $contact['contact_id']),
+      array(
+        'type_name' => $key,
+        'cv_name' => 'tripal_contact',
+        'value' => $value,
+      ),
+      array('update_if_present' => TRUE)
     );
+
     if (!$success) {
       tripal_report_error('tripal_contact', TRIPAL_ERROR,
         "Could not add the contact property '%prop'", array('%prop' => $key));

+ 2 - 4
tripal_contact/includes/tripal_contact.chado_node.inc

@@ -96,10 +96,8 @@ function chado_contact_form(&$node, $form_state) {
     }
     if (!$description) {
       $contactprop = chado_get_property(
-        'contact',
-        $contact->contact_id,
-        'contact_description',
-        'tripal_contact'
+        array('table' => 'contact', 'id' => $contact->contact_id),
+        array('type_name' => 'contact_description', 'cv_name' => 'tripal_contact')
       );
       $description = (isset($contactprop->value)) ? $contactprop->value : '';
     }

+ 61 - 11
tripal_core/api/tripal_core.DEPRECATED.inc

@@ -949,8 +949,17 @@ function tripal_core_delete_property($basetable, $record_id, $property, $cv_name
     )
   );
 
+  $record = array(
+    'table' => $basetable,
+    'id' => $record_id
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+  );
+  
   //New API Function
-  return chado_delete_property($basetable, $record_id, $property, $cv_name);
+  return chado_delete_property($record, $property);
 }
 
 /**
@@ -970,9 +979,18 @@ function tripal_core_get_property($basetable, $record_id, $property, $cv_name) {
       '%new_function' => 'chado_get_property'
     )
   );
+  
+  $record = array(
+    'table' => $basetable,
+    'id' => $record_id
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+  );
 
   //New API Function
-  return chado_get_property($basetable, $record_id, $property, $cv_name);
+  return chado_get_property($record, $property);
 }
 
 /**
@@ -1028,7 +1046,7 @@ function get_max_chado_rank($tablename, $where_options) {
  * @see chado_insert_property().
  */
 function tripal_core_insert_property($basetable, $record_id, $property,
-$cv_name, $value, $update_if_present = 0) {
+    $cv_name, $value, $update_if_present = 0) {
   tripal_report_error(
     'tripal_deprecated',
     TRIPAL_NOTICE,
@@ -1038,9 +1056,20 @@ $cv_name, $value, $update_if_present = 0) {
       '%new_function' => 'chado_insert_property'
     )
   );
-
+  $record = array(
+    'table' => $basetable,
+    'id' => $record_id
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value,
+  );
+  $options = array(
+    'update_if_present' => $update_if_present
+  );
   //New API Function
-  return chado_insert_property($basetable, $record_id, $property, $cv_name, $value, $update_if_present);
+  return chado_insert_property($record, $property, $options);
 }
 
 /**
@@ -1051,7 +1080,7 @@ $cv_name, $value, $update_if_present = 0) {
  * @see chado_update_property().
  */
 function tripal_core_update_property_by_id($basetable, $record_id, $property,
-$cv_name, $value) {
+  $cv_name, $value) {
   tripal_report_error(
     'tripal_deprecated',
     TRIPAL_NOTICE,
@@ -1062,9 +1091,18 @@ $cv_name, $value) {
       '%new_function' => 'chado_update_property'
     )
   );
-
-  //New API Function
-  return chado_update_property($basetable, FALSE, $property, $cv_name, $value, FALSE, $record_id);
+  $record = array(
+    'table' => $basetable,
+    'prop_id' => $record_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value,
+  );
+  
+  // New API Function.
+  return chado_update_property($record, $property);
 }
 
 /**
@@ -1086,8 +1124,20 @@ $cv_name, $value, $insert_if_missing = 0) {
     )
   );
 
-  //New API Function
-  return chado_update_property($basetable, $record_id, $property, $cv_name, $value, $insert_if_missing);
+  $record = array(
+    'table' => $basetable,
+    'id' => $record_id
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value,
+  );
+  $options = array(
+    'insert_if_missing' => $insert_if_missing,
+  );
+  // New API Function.
+  return chado_update_property($record, $property, $options);
 }
 
 /**

+ 9 - 8
tripal_core/api/tripal_core.chado_general.api.inc

@@ -427,8 +427,7 @@ function chado_update_property($property, $options) {
     }
   }
   
-  // Build the values array for checking if the CVterm exists and for
-  // inserting the term as a property.
+  // Build the values array for checking if the CVterm exists.
   $type = array();
   if ($cv_id) {
     $type['cv_id'] = $cv_id;
@@ -452,13 +451,14 @@ function chado_update_property($property, $options) {
     tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_update_property: " .
         "Cannot find the term described by: %property.",
         array('%property' => print_r($property, TRUE)));
-        return FALSE;
+    return FALSE;
   }
   if (count($term) > 1) {
     tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_update_property: " .
         "Multiple terms found. Cannot add the property. Property was described " .
         "by: %property.",
-        array('%property' => print_r($property, TRUE)));    return FALSE;
+        array('%property' => print_r($property, TRUE)));    
+    return FALSE;
   }
   
 
@@ -466,7 +466,6 @@ function chado_update_property($property, $options) {
   $table_desc = chado_get_schema($base_table . 'prop');
   $fkcol = key($table_desc['foreign keys'][$base_table]['columns']);
 
-  
   // construct the array that will match the exact record to update
   $match = array(
     $fkcol => $record_id,
@@ -620,13 +619,16 @@ function chado_delete_property($record, $property) {
  *     -cv_name: The name of the CV that contains the term.
  *     -value: The specific value for the property.
  *     -rank: The specific rank for the property.
+ * @param $options
+ *   An array of options supported by chado_generate_var(). These keys
+ *   are used for generating the cvterm objects returned by this function.
  *
  * @return
  *   An array of chado variables with the given property
  *
  * @ingroup tripal_chado_api
  */
-function chado_get_record_with_property($record, $property) {
+function chado_get_record_with_property($record, $property, $options = array()) {
   
   $base_table  = array_key_exists('table', $record) ? $record['table'] : '';
   $base_records= array_key_exists('base_records', $record) ? $record['base_records'] : array();
@@ -660,8 +662,7 @@ function chado_get_record_with_property($record, $property) {
   }
   
   // Make sure the CV term exists;
-  $options = array();
-  $term = chado_select_record('cvterm', array('cvterm_id'), $type, $options);
+  $term = chado_select_record('cvterm', array('cvterm_id'), $type);
   if (!$term or count($term) == 0) {
     tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_update_property: " .
         "Cannot find the term described by: %property.",

+ 5 - 1
tripal_cv/api/tripal_cv.api.inc

@@ -225,7 +225,11 @@ function tripal_get_cvterm($identifiers, $options = array()) {
   if (isset($identifiers['property'])) {
     $property = $identifiers['property'];
     unset($identifiers['property']);
-    $cvterm = chado_get_record_with_property('cvterm', $property, $identifiers, $options);
+    $cvterm = chado_get_record_with_property(
+      array('table' => 'cvterm', 'base_records' => $identifiers), 
+      array('type_name' => $property),
+      $options
+    );
   }
 
   // Else we have a simple case and we can just use chado_generate_var to get the cvterm

+ 8 - 12
tripal_db/api/tripal_db.api.inc

@@ -239,27 +239,23 @@ function tripal_get_dbxref($identifiers, $options = array()) {
   if (isset($identifiers['property'])) {
     $property = $identifiers['property'];
     unset($identifiers['property']);
-    $dbxref = chado_get_record_with_property('dbxref', $property, $identifiers, $options);
+    $dbxref = chado_get_record_with_property(
+      array('table' => 'dbxref', 'base_records' => $identifiers), 
+      array('type_name' => $property),
+      $options
+    );
   }
 
   // Else we have a simple case and we can just use chado_generate_var to get the analysis
   else {
-    $dbxref = chado_generate_var(
-      'dbxref',
-      $identifiers,
-      $options
-    );
+    $dbxref = chado_generate_var('dbxref', $identifiers, $options);
   }
 
   // Ensure the dbxref is singular. If it's an array then it is not singular
   if (is_array($dbxref)) {
-    tripal_report_error(
-      'tripal_db_api',
-      TRIPAL_ERROR,
+    tripal_report_error('tripal_db_api', TRIPAL_ERROR,
       "tripal_get_dbxref: The identifiers you passed in were not unique. You passed in %identifier.",
-      array(
-        '%identifier'=> print_r($identifiers, TRUE)
-      )
+      array('%identifier'=> print_r($identifiers, TRUE))
     );
   }
 

+ 118 - 15
tripal_feature/api/tripal_feature.DEPRECATED.inc

@@ -25,7 +25,7 @@ function tripal_feature_analysis_get_property($analysis_id = NULL, $feature_id =
 
   // check that the incoming arguments are correct
   if (($analysis_id and !$feature_id) or
-    (!$analysis_id and $feature_id)) {
+      (!$analysis_id and $feature_id)) {
       tripal_report_error('tripal_feature', TRIPAL_WARNING,
       'tripal_feature_analysis_get_property: Both an analysis ID and feature ID should be specified',
       array());
@@ -39,8 +39,17 @@ function tripal_feature_analysis_get_property($analysis_id = NULL, $feature_id =
     $analysisfeature_id = $result[0]->analysisfeature_id;
   }
 
+  $record = array(
+    'table' => 'analysisfeature',
+    'id' => $analysisfeature_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+  );
+
   // get the property.
-  return chado_get_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
+  return chado_get_property($record, $property);
 }
 
 /**
@@ -78,9 +87,21 @@ function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_i
     $analysisfeature_id = $result[0]->analysisfeature_id;
   }
 
+  $record = array(
+    'table' => 'analysisfeature',
+    'id' => $analysisfeature_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value
+  );
+  $options = array(
+    'update_if_present' => $update_if_present,
+  );
+  
   // insert the property.
-  return chado_insert_property('analysisfeature', $analysisfeature_id,
-    $property, $cv_name, $value, $update_if_present);
+  return chado_insert_property($record, $property, $options);
 
 }
 
@@ -119,8 +140,21 @@ function tripal_feature_analysis_update_property($analysis_id = NULL, $feature_i
     $analysisfeature_id = $result[0]->analysisfeature_id;
   }
 
+  $record = array(
+    'table' => 'analysisfeature',
+    'id' => $analysisfeature_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value
+  );
+  $options = array(
+    'insert_if_missing' => $insert_if_missing,
+  );
+  
   // update the property.
-  return chado_update_property('analysisfeature', $analysisfeature_id, $property, $cv_name, $value, $insert_if_missing);
+  return chado_update_property($record, $property, $options);
 }
 
 /**
@@ -142,8 +176,17 @@ function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
     )
   );
 
+  $record = array(
+    'table' => 'analysisfeature',
+    'prop_id' => $analysisfeatureprop_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value
+  );
   // update the property.
-  return chado_update_property('analysisfeature', NULL, $property, $cv_name, $value, FALSE, $analysisfeatureprop_id);
+  return chado_update_property($record, $property);
 }
 
 /**
@@ -180,9 +223,18 @@ function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_i
     $result = chado_select_record('analysisfeature', $columns, $values);
     $analysisfeature_id = $result[0]->analysisfeature_id;
   }
+  
+  $record = array(
+    'table' => 'analysisfeature',
+    'id' => $analysisfeature_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+  );
 
   // get the property.
-  return chado_delete_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
+  return chado_delete_property($record, $property);
 
 }
 
@@ -201,7 +253,7 @@ function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id)
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
     array(
       '%old_function'=>'tripal_feature_analysis_delete_property_by_id',
-      '%new_function' => 'chado_delete_property'
+      '%new_function' => 'chado_delete_record'
     )
   );
 
@@ -231,8 +283,17 @@ function tripal_feature_get_property($feature_id, $property, $cv_name='tripal')
       '%new_function' => 'chado_get_property'
     )
   );
+  
+  $record = array(
+    'table' => 'feature',
+    'id' => $feature_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+  );
 
-  return chado_get_property('feature', $feature_id, $property, $cv_name);
+  return chado_get_property($record, $property);
 }
 
 /**
@@ -254,8 +315,20 @@ function tripal_feature_insert_property($feature_id, $property, $value, $update_
     )
   );
 
-  return chado_insert_property('feature', $feature_id, $property,
-    $cv_name, $value, $update_if_present);
+  $record = array(
+    'table' => 'feature',
+    'id' => $feature_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value,
+  );
+  $options = array(
+    'update_if_present' => $update_if_present,
+  );
+  
+  return chado_insert_property($record, $property, $options);
 }
 
 /**
@@ -277,7 +350,19 @@ function tripal_feature_update_property($feature_id, $property, $value, $insert_
     )
   );
 
-  return chado_update_property('feature', $feature_id, $property, $cv_name, $value, $insert_if_missing);
+  $record = array(
+    'table' => 'feature',
+    'id' => $feature_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value,
+  );
+  $options = array(
+    'insert_if_missing' => insert_if_missing,
+  );
+  return chado_update_property($record, $property, $options);
 }
 
 /**
@@ -299,7 +384,16 @@ function tripal_feature_update_property_by_id($featureprop_id, $property, $value
     )
   );
 
-  return chado_update_property('feature', NULL, $property, $cv_name, $value, FALSE, $featureprop_id);
+  $record = array(
+    'table' => 'feature',
+    'prop_id' => $featureprop_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+    'value' => $value,
+  );
+  return chado_update_property($record, $property);
 }
 
 /**
@@ -320,8 +414,17 @@ function tripal_feature_delete_property($feature_id, $property, $cv_name='tripal
       '%new_function' => 'chado_delete_property'
     )
   );
+  
+  $record = array(
+    'table' => 'feature',
+    'id' => $feature_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => $cv_name,
+  );
 
-  return chado_delete_property('feature', $feature_id, $property, $cv_name);
+  return chado_delete_property($record, $property);
 }
 
 /**
@@ -339,7 +442,7 @@ function tripal_feature_delete_property_by_id($featureprop_id) {
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
     array(
       '%old_function'=>'tripal_feature_delete_property_by_id',
-      '%new_function' => 'chado_delete_property'
+      '%new_function' => 'chado_delete_record'
     )
   );
 

+ 45 - 7
tripal_featuremap/api/tripal_featuremap.DEPRECATED.inc

@@ -22,8 +22,15 @@ function tripal_featuremap_get_property($featuremap_id, $property) {
       '%new_function' => 'chado_get_property'
     )
   );
-
-  return chado_get_property('featuremap', $featuremap_id, $property, 'featuremap_property');
+  $record = array(
+    'table' => 'featuremap',
+    'id' => $featuremap_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'featuremap_property',
+  );
+  return chado_get_property($record, $property);
 }
 
 /**
@@ -44,8 +51,19 @@ function tripal_featuremap_insert_property($featuremap_id, $property, $value, $u
       '%new_function' => 'chado_insert_property'
     )
   );
-
-  return chado_insert_property('featuremap', $featuremap_id, $property, 'featuremap_property', $value, $update_if_present);
+  $record = array(
+    'table' => 'featuremap',
+    'id' => $featuremap_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'featuremap_property',
+    'value' => $value,
+  );
+  $options = array(
+    'update_if_present' => $update_if_present,
+  );
+  return chado_insert_property($record, $property, $options);
 }
 
 /**
@@ -66,8 +84,19 @@ function tripal_featuremap_update_property($featuremap_id, $property, $value, $i
       '%new_function' => 'chado_update_property'
     )
   );
-
-  return chado_update_property('featuremap', $featuremap_id, $property, 'featuremap_property', $value, $insert_if_missing);
+  $record = array(
+    'table' => 'featuremap',
+    'id' => $featuremap_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'featuremap_property',
+    'value' => $value,
+  );
+  $options = array(
+    'insert_if_missing' => $insert_if_missing,
+  );
+  return chado_update_property($record, $property, $options);
 }
 
 /**
@@ -88,8 +117,17 @@ function tripal_featuremap_delete_property($featuremap_id, $property) {
       '%new_function' => 'chado_delete_property'
     )
   );
+  
+  $record = array(
+    'table' => 'featuremap',
+    'id' => $featuremap_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'featuremap_property',
+  );
 
-  return chado_delete_property('featuremap', $featuremap_id, $property, 'featuremap_property');
+  return chado_delete_property($record, $property);
 }
 
 /**

+ 44 - 6
tripal_library/api/tripal_library.DEPRECATED.inc

@@ -23,7 +23,15 @@ function tripal_library_get_property($library_id, $property) {
     )
   );
 
-  return chado_get_property('library', $library_id, $property, 'library_property');
+  $record = array(
+    'table' => 'library',
+    'id' => $library_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'library_property'
+  );
+  return chado_get_property($record, $property);
 }
 
 /**
@@ -45,7 +53,19 @@ function tripal_library_insert_property($library_id, $property, $value, $update_
     )
   );
 
-  return chado_insert_property('library', $library_id, $property, 'library_property', $value, $update_if_present);
+  $record = array(
+    'table' => 'library',
+    'id' => $library_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'library_property',
+    'value' => $value,
+  );
+  $options = array(
+    'update_if_present' => $update_if_present,
+  );
+  return chado_insert_property($record, $property, $options);
 }
 
 /**
@@ -66,8 +86,19 @@ function tripal_library_update_property($library_id, $property, $value, $insert_
       '%new_function' => 'chado_update_property'
     )
   );
-
-  return chado_update_property('library', $library_id, $property, 'library_property', $value, $insert_if_missing);
+  $record = array(
+    'table' => 'library',
+    'id' => $library_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'library_property',
+    'value' => $value,
+  );
+  $options = array(
+    'insert_if_missing' => $insert_if_missing,
+  );
+  return chado_update_property($record, $property, $options);
 }
 
 /**
@@ -88,6 +119,13 @@ function tripal_library_delete_property($library_id, $property) {
       '%new_function' => 'chado_delete_property'
     )
   );
-
-  return chado_delete_property('library', $library_id, $property, 'library_property');
+  $record = array(
+    'table' => 'library',
+    'id' => $library_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'library_property',
+  );
+  return chado_delete_property($record, $property);
 }

+ 2 - 4
tripal_library/includes/tripal_library.chado_node.inc

@@ -74,10 +74,8 @@ function chado_library_form($node, &$form_state) {
     $organism_id  = $library->organism_id->organism_id;
 
     $libprop = chado_get_property(
-      'library',
-      $library->library_id,
-      'Library Description',
-      'library_property'
+      array('table' => 'library', 'id' => $library->library_id),
+      array('type_name' => 'Library Description', 'cv_name' => 'library_property')
     );
     $description = $libprop->value;
 

+ 9 - 1
tripal_library/theme/templates/tripal_library_base.tpl.php

@@ -3,7 +3,15 @@
 $library  = $variables['node']->library;
 
 // get the library description. IT uses a tern name of 'Library Description'
-$libprop = chado_get_property('library', $library->library_id, 'Library Description', 'library_property');
+$record = array(
+  'table' => 'library',
+  'id' => $library->library_id
+);
+$property = array(
+  'type_name' => 'Library Description',
+  'cv_name' => 'library_property'
+);
+$libprop = chado_get_property($record, $property);
 $description = $libprop->value; ?>
 
 <div class="tripal_library-data-block-desc tripal-data-block-desc"></div> <?php 

+ 9 - 1
tripal_library/theme/templates/tripal_library_teaser.tpl.php

@@ -3,7 +3,15 @@ $node    = $variables['node'];
 $library = $variables['node']->library;
 
 // get the library description. IT uses a tern name of 'Library Description'
-$libprop = chado_get_property('library', $library->library_id, 'Library Description', 'library_property');
+$record = array(
+  'table' => 'library',
+  'id' => $library->library_id
+);
+$property = array(
+  'type_name' => 'Library Description',
+  'cv_name' => 'library_property'
+);
+$libprop = chado_get_property($record, $property);
 $description = $libprop->value; ?>
 
 <div class="tripal_library-teaser tripal-teaser"> 

+ 5 - 1
tripal_organism/api/tripal_organism.api.inc

@@ -76,7 +76,11 @@ function tripal_get_organism($identifiers, $options = array()) {
   if (isset($identifiers['property'])) {
     $property = $identifiers['property'];
     unset($identifiers['property']);
-    $organism = chado_get_record_with_property('organism', $property, $identifiers, $options);
+    $organism = chado_get_record_with_property(
+      array('table' => 'organism', 'base_records' => $identifiers), 
+      array('type_name' => $property), 
+      $options
+    );
   }
 
   // Else we have a simple case and we can just use chado_generate_var to get the analysis

+ 44 - 6
tripal_project/api/tripal_project.DEPRECATED.inc

@@ -23,7 +23,15 @@ function tripal_project_get_property($project_id, $property) {
     )
   );
 
-  return chado_get_property('project', $project_id, $property, 'project_property');
+  $record = array(
+    'table' => 'project',
+    'id' => $project_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'project_property',
+  );
+  return chado_get_property($record, $property);
 }
 
 /**
@@ -45,7 +53,19 @@ function tripal_project_insert_property($project_id, $property, $value, $update_
     )
   );
 
-  return chado_insert_property('project', $project_id, $property, 'project_property', $value, $update_if_present);
+  $record = array(
+    'table' => 'project',
+    'id' => $project_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'project_property',
+    'value' => $value,
+  );
+  $options = array(
+    'update_if_present' => $update_if_present,
+  );
+  return chado_insert_property($record, $property, $options);
 }
 
 /**
@@ -66,8 +86,19 @@ function tripal_project_update_property($project_id, $property, $value, $insert_
       '%new_function' => 'chado_update_property'
     )
   );
-
-  return chado_update_property('project', $project_id, $property, 'project_property', $value, $insert_if_missing);
+  $record = array(
+    'table' => 'project',
+    'id' => $project_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'project_property',
+    'value' => $value,
+  );
+  $options = array(
+    'insert_if_missing' => $insert_if_missing,
+  );
+  return chado_update_property($record, $property, $options);
 }
 
 /**
@@ -88,6 +119,13 @@ function tripal_project_delete_property($project_id, $property) {
       '%new_function' => 'chado_delete_property'
     )
   );
-
-  return chado_delete_property('project', $project_id, $property, 'project_property');
+  $record = array(
+    'table' => 'project',
+    'id' => $project_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'project_property',
+  );
+  return chado_delete_property($record, $property);
 }

+ 2 - 4
tripal_project/includes/tripal_project.chado_node.inc

@@ -92,10 +92,8 @@ function chado_project_form(&$node, $form_state) {
     }
     if (!$description) {
       $projectprop = chado_get_property(
-        'project',
-        $project->project_id,
-        'Project Description',
-        'project_property'
+        array('table' => 'project', 'id' => $project->project_id),
+        array('type_name' => 'Project Description', 'cv_name' =>'project_property')
       );
       $description = $projectprop->value;
     }

+ 9 - 1
tripal_project/theme/templates/tripal_project_base.tpl.php

@@ -18,7 +18,15 @@ if ($project->description) {
   $description = $project->description;
 }
 else {
-  $projectprop = chado_get_property('project', $project->project_id, 'Project Description', 'project_property');
+  $record = array(
+    'table' => 'project',
+    'id' => $project->project_id,
+  );
+  $property = array(
+    'type_name' => 'Project Description',
+    'cv_name' => 'project_property',
+  );
+  $projectprop = chado_get_property($record, $property);
   $description = $projectprop->value;
 } ?>
 

+ 9 - 1
tripal_project/theme/templates/tripal_project_teaser.tpl.php

@@ -19,7 +19,15 @@ if (property_exists($node, 'description')) {
   $description = $project->description;
 }
 else {
-  $projectprop = chado_get_property('property', $project->project_id, 'Project Description', 'project_property');
+  $record = array(
+    'table' => 'project',
+    'id' => $project->project_id,
+  );
+  $property = array(
+    'type_name' => 'Project Description',
+    'cv_name' => 'project_property',
+  );
+  $projectprop = chado_get_property($record, $property);
   $description = $projectprop->value;
 } ?>
 

+ 44 - 8
tripal_pub/api/tripal_pub.DEPRECATED.inc

@@ -355,8 +355,15 @@ function tripal_pub_get_property($pub_id, $property) {
       '%new_function' => 'chado_get_property'
     )
   );
-
-  return chado_get_property('pub', $pub_id, $property, 'tripal_pub');
+  $record = array(
+    'table' => 'pub',
+    'id' => $pub_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'tripal_pub',
+  );
+  return chado_get_property($record, $property);
 }
 
 /**
@@ -377,8 +384,19 @@ function tripal_pub_insert_property($pub_id, $property, $value, $update_if_prese
       '%new_function' => 'chado_insert_property'
     )
   );
-
-  return chado_insert_property('pub', $pub_id, $property, 'tripal_pub', $value, $update_if_present);
+  $record = array(
+    'table' => 'pub',
+    'id' => $pub_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'tripal_pub',
+    'value' => $value,
+  );
+  $options = array(
+    'insert_if_missing' => $insert_if_missing,
+  );
+  return chado_insert_property($record, $property, $options);
 }
 
 /**
@@ -399,8 +417,19 @@ function tripal_pub_update_property($pub_id, $property, $value, $insert_if_missi
       '%new_function' => 'chado_update_property'
     )
   );
-
-  return chado_update_property('pub', $pub_id, $property, 'tripal_pub', $value, $insert_if_missing);
+  $record = array(
+    'table' => 'pub',
+    'id' => $pub_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'tripal_pub',
+    'value' => $value,
+  );
+  $options = array(
+    'update_if_present' => $update_if_present,
+  );
+  return chado_update_property($record, $property, $options);
 }
 
 /**
@@ -421,6 +450,13 @@ function tripal_pub_delete_property($pub_id, $property) {
       '%new_function' => 'chado_delete_property'
     )
   );
-
-  return chado_delete_property('pub', $pub_id, $property, 'tripal_pub');
+  $record = array(
+    'table' => 'pub',
+    'id' => $pub_id,
+  );
+  $property = array(
+    'type_name' => $property,
+    'cv_name' => 'tripal_pub',
+  );
+  return chado_delete_property($record, $property);
 }

+ 5 - 1
tripal_pub/api/tripal_pub.api.inc

@@ -73,7 +73,11 @@ function tripal_get_publication($identifiers, $options = array()) {
   if (array_key_exists('property', $identifiers)) {
     $property = $identifiers['property'];
     unset($identifiers['property']);
-    $pub = chado_get_record_with_property('pub', $property, $identifiers, $options);
+    $pub = chado_get_record_with_property(
+      array('table' => 'pub', 'base_records' => $identifiers),
+      array('type_name' => $property), 
+      $options
+    );
   }
   elseif (array_key_exists('dbxref', $identifiers)) {
     if(preg_match('/^(.*?):(.*?)$/', $identifiers['dbxref'], $matches)) {

+ 13 - 3
tripal_pub/includes/tripal_pub.pub_importers.inc

@@ -1113,15 +1113,25 @@ function tripal_pub_add_publication($pub_details, &$action, $do_contact = FALSE,
         // if the key is an integer then this array is a simple list and
         // we will insert using the primary key. Otheriwse, use the new key
         if(is_int($subkey)) {
-          $success = chado_insert_property('pub', $pub_id, $key, 'tripal_pub', $subvalue, FALSE);
+          $success = chado_insert_property(
+            array('table' => 'pub', 'id' => $pub_id),
+            array('type_name' => $key, 'cv_name' => 'tripal_pub', 'value' => $subvalue)
+          );
         }
         else {
-          $success = chado_insert_property('pub', $pub_id, $subkey, 'tripal_pub', $subvalue, FALSE);
+          $success = chado_insert_property(
+            array('table' => 'pub', 'id' => $pub_id),
+            array('type_name' => $subkey, 'cv_name' => 'tripal_pub', 'value' => $subvalue)
+          );
         }
       }
     }
     else {
-      $success = chado_insert_property('pub', $pub_id, $key, 'tripal_pub', $value, TRUE);
+      $success = chado_insert_property(
+        array('table' => 'pub', 'id' => $pub_id),
+        array('type_name' => $key, 'cv_name' => 'tripal_pub', 'value' => $value),
+        array('update_if_present' => TRUE)
+      );
     }
     if (!$success) {
       tripal_report_error('tripal_pub', TRIPAL_ERROR, "Cannot add property '%prop' to publication. Skipping.",

+ 10 - 2
tripal_stock/api/tripal_stock.api.inc

@@ -76,7 +76,11 @@ function tripal_get_stock($identifiers, $options = array()) {
   if (isset($identifiers['property'])) {
     $property = $identifiers['property'];
     unset($identifiers['property']);
-    $stock = chado_get_record_with_property('stock', $property, $identifiers, $options);
+    $stock = chado_get_record_with_property(
+      array('table' => 'stock', 'base_records' => $identifiers),
+      array('type_name' => $property), 
+      $options
+    );
   }
 
   // Else we have a simple case and we can just use chado_generate_var to get the stock
@@ -176,7 +180,11 @@ function tripal_get_multiple_stocks($identifiers, $options = array()) {
   if (isset($identifiers['property'])) {
     $property = $identifiers['property'];
     unset($identifiers['property']);
-    $stock = chado_get_record_with_property('stock', $property, $identifiers, $options);
+    $stock = chado_get_record_with_property(
+      array('table' => 'stock', 'base_records' => $identifiers),
+      array('type_name' => $property), 
+      $options
+    );
   }
 
   // Else we have a simple case and we can just use chado_generate_var to get the stock