|
@@ -20,15 +20,15 @@
|
|
|
*
|
|
|
* @return
|
|
|
* An array in the same format as that generated by the function
|
|
|
- * tripal_api_chado_generate_chado_var(). If only one record is returned it
|
|
|
+ * tripal_core_generate_chado_var(). If only one record is returned it
|
|
|
* is a single object. If more than one record is returned then it is an array
|
|
|
* of objects
|
|
|
*
|
|
|
* @ingroup tripal_properties_api
|
|
|
*/
|
|
|
-function tripal_api_chado_get_property($basetable, $record_id, $property, $cv_name) {
|
|
|
+function tripal_api_get_property($basetable, $record_id, $property, $cv_name) {
|
|
|
// get the foreign key for this property table
|
|
|
- $table_desc = tripal_api_chado_get_chado_table_schema($basetable . 'prop');
|
|
|
+ $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
|
|
|
$fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
|
|
|
|
|
|
// construct the array of values to be selected
|
|
@@ -42,9 +42,9 @@ function tripal_api_chado_get_property($basetable, $record_id, $property, $cv_na
|
|
|
'is_obsolete' => 0
|
|
|
),
|
|
|
);
|
|
|
- $results = tripal_api_chado_generate_chado_var($basetable . 'prop', $values);
|
|
|
+ $results = tripal_core_generate_chado_var($basetable . 'prop', $values);
|
|
|
if ($results) {
|
|
|
- $results = tripal_api_chado_expand_chado_vars($results, 'field', $basetable . 'prop.value');
|
|
|
+ $results = tripal_core_expand_chado_vars($results, 'field', $basetable . 'prop.value');
|
|
|
}
|
|
|
|
|
|
return $results;
|
|
@@ -77,13 +77,13 @@ function tripal_api_chado_get_property($basetable, $record_id, $property, $cv_na
|
|
|
*
|
|
|
* @ingroup tripal_properties_api
|
|
|
*/
|
|
|
-function tripal_api_chado_insert_property($basetable, $record_id, $property,
|
|
|
+function tripal_api_insert_property($basetable, $record_id, $property,
|
|
|
$cv_name, $value, $update_if_present = 0) {
|
|
|
|
|
|
// first see if the property already exists, if the user want's to update
|
|
|
// then we can do that, but otherwise we want to increment the rank and
|
|
|
// insert
|
|
|
- $props = tripal_api_chado_get_property($basetable, $record_id, $property, $cv_name);
|
|
|
+ $props = tripal_api_get_property($basetable, $record_id, $property, $cv_name);
|
|
|
if (!is_array($props) and $props) {
|
|
|
$props = array($props);
|
|
|
}
|
|
@@ -91,7 +91,7 @@ $cv_name, $value, $update_if_present = 0) {
|
|
|
$rank = 0;
|
|
|
if (count($props) > 0) {
|
|
|
if ($update_if_present) {
|
|
|
- return tripal_api_chado_update_property($basetable, $record_id, $property, $cv_name, $value);
|
|
|
+ return tripal_api_update_property($basetable, $record_id, $property, $cv_name, $value);
|
|
|
}
|
|
|
else {
|
|
|
// iterate through the properties returned and check to see if the
|
|
@@ -120,15 +120,15 @@ $cv_name, $value, $update_if_present = 0) {
|
|
|
);
|
|
|
|
|
|
$options = array();
|
|
|
- $term = tripal_api_chado_chado_select('cvterm', array('cvterm_id'), $values, $options);
|
|
|
+ $term = tripal_core_chado_select('cvterm', array('cvterm_id'), $values, $options);
|
|
|
if (!$term or count($term) == 0) {
|
|
|
- watchdog('tripal_api_chado', "Cannot find property '%prop_name' in vocabulary '%cvname'.",
|
|
|
+ watchdog('tripal_core', "Cannot find property '%prop_name' in vocabulary '%cvname'.",
|
|
|
array('%prop_name' => $property, '%cvname' => $cv_name), WATCHDOG_ERROR);
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
|
// get the foreign key for this property table
|
|
|
- $table_desc = tripal_api_chado_get_chado_table_schema($basetable . 'prop');
|
|
|
+ $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
|
|
|
$fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
|
|
|
|
|
|
// construct the array of values to be inserted
|
|
@@ -145,7 +145,7 @@ $cv_name, $value, $update_if_present = 0) {
|
|
|
);
|
|
|
|
|
|
$options = array();
|
|
|
- $result = tripal_api_chado_chado_insert($basetable . 'prop', $values, $options);
|
|
|
+ $result = tripal_core_chado_insert($basetable . 'prop', $values, $options);
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
@@ -153,7 +153,7 @@ $cv_name, $value, $update_if_present = 0) {
|
|
|
* Update a property for a given base table record and property name. This
|
|
|
* function should be used only if one record of the property will be present.
|
|
|
* If the property name can have multiple entries (with increasing rank) then
|
|
|
- * use the function named tripal_api_chado_update_property_by_id
|
|
|
+ * use the function named tripal_api_update_property_by_id
|
|
|
*
|
|
|
* @param $basetable
|
|
|
* The base table for which the property should be updated. The property table
|
|
@@ -179,14 +179,14 @@ $cv_name, $value, $update_if_present = 0) {
|
|
|
*
|
|
|
* @ingroup tripal_properties_api
|
|
|
*/
|
|
|
-function tripal_api_chado_update_property($basetable, $record_id, $property,
|
|
|
+function tripal_api_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_api_chado_get_property($basetable, $record_id, $property, $cv_name);
|
|
|
+ $prop = tripal_api_get_property($basetable, $record_id, $property, $cv_name);
|
|
|
if (count($prop)==0) {
|
|
|
if ($insert_if_missing) {
|
|
|
- return tripal_api_chado_insert_property($basetable, $record_id, $property, $cv_name, $value);
|
|
|
+ return tripal_api_insert_property($basetable, $record_id, $property, $cv_name, $value);
|
|
|
}
|
|
|
else {
|
|
|
return FALSE;
|
|
@@ -194,7 +194,7 @@ $cv_name, $value, $insert_if_missing = 0) {
|
|
|
}
|
|
|
|
|
|
// get the foreign key for this property table
|
|
|
- $table_desc = tripal_api_chado_get_chado_table_schema($basetable . 'prop');
|
|
|
+ $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
|
|
|
$fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
|
|
|
|
|
|
// construct the array that will match the exact record to update
|
|
@@ -213,7 +213,7 @@ $cv_name, $value, $insert_if_missing = 0) {
|
|
|
'value' => $value,
|
|
|
);
|
|
|
|
|
|
- return tripal_api_chado_chado_update($basetable . 'prop', $match, $values);
|
|
|
+ return tripal_core_chado_update($basetable . 'prop', $match, $values);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -240,11 +240,11 @@ $cv_name, $value, $insert_if_missing = 0) {
|
|
|
*
|
|
|
* @ingroup tripal_properties_api
|
|
|
*/
|
|
|
-function tripal_api_chado_update_property_by_id($basetable, $record_id, $property,
|
|
|
+function tripal_api_update_property_by_id($basetable, $record_id, $property,
|
|
|
$cv_name, $value) {
|
|
|
|
|
|
// get the primary key for this property table
|
|
|
- $table_desc = tripal_api_chado_get_chado_table_schema($basetable . 'prop');
|
|
|
+ $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
|
|
|
$pkcol = $table_desc['primary key'][0];
|
|
|
|
|
|
// construct the array that will match the exact record to update
|
|
@@ -263,7 +263,7 @@ $cv_name, $value) {
|
|
|
'value' => $value,
|
|
|
);
|
|
|
|
|
|
- return tripal_api_chado_chado_update($basetable . 'prop', $match, $values);
|
|
|
+ return tripal_core_chado_update($basetable . 'prop', $match, $values);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -286,10 +286,10 @@ $cv_name, $value) {
|
|
|
*
|
|
|
* @ingroup tripal_properties_api
|
|
|
*/
|
|
|
-function tripal_api_chado_delete_property($basetable, $record_id, $property, $cv_name) {
|
|
|
+function tripal_api_delete_property($basetable, $record_id, $property, $cv_name) {
|
|
|
|
|
|
// get the foreign key for this property table
|
|
|
- $table_desc = tripal_api_chado_get_chado_table_schema($basetable . 'prop');
|
|
|
+ $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
|
|
|
$fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
|
|
|
|
|
|
// construct the array that will match the exact record to update
|
|
@@ -303,7 +303,7 @@ function tripal_api_chado_delete_property($basetable, $record_id, $property, $cv
|
|
|
),
|
|
|
);
|
|
|
|
|
|
- return tripal_api_chado_chado_delete($basetable . 'prop', $match);
|
|
|
+ return tripal_core_chado_delete($basetable . 'prop', $match);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -320,10 +320,10 @@ function tripal_api_chado_delete_property($basetable, $record_id, $property, $cv
|
|
|
*
|
|
|
* @ingroup tripal_properties_api
|
|
|
*/
|
|
|
-function tripal_api_chado_delete_property_by_id($basetable, $record_id) {
|
|
|
+function tripal_api_delete_property_by_id($basetable, $record_id) {
|
|
|
|
|
|
// get the foreign key for this property table
|
|
|
- $table_desc = tripal_api_chado_get_chado_table_schema($basetable . 'prop');
|
|
|
+ $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
|
|
|
$pkcol = $table_desc['primary key'][0];
|
|
|
|
|
|
// construct the array that will match the exact record to update
|
|
@@ -331,5 +331,5 @@ function tripal_api_chado_delete_property_by_id($basetable, $record_id) {
|
|
|
$pkcol => $record_id,
|
|
|
);
|
|
|
|
|
|
- return tripal_api_chado_chado_delete($basetable . 'prop', $match);
|
|
|
+ return tripal_core_chado_delete($basetable . 'prop', $match);
|
|
|
}
|