Parcourir la source

API: Updated contact api to the new function names and enabled DEPRECATED file

Lacey Sanderson il y a 11 ans
Parent
commit
6f83bdbaf6

+ 10 - 5
tripal_contact/api/tripal_contact.DEPRECATED.inc

@@ -23,7 +23,7 @@ function tripal_contact_get_property($contact_id, $property) {
     )
   );
 
-  return FALSE;
+  return chado_get_property('contact', $contact_id, $property, 'tripal_contact');;
 }
 
 /**
@@ -45,7 +45,7 @@ function tripal_contact_insert_property($contact_id, $property, $value, $update_
     )
   );
 
-  return FALSE;
+  return chado_insert_property('contact', $contact_id, $property, 'tripal_contact', $value, $update_if_present);
 }
 
 /**
@@ -67,7 +67,7 @@ function tripal_contact_update_property($contact_id, $property, $value, $insert_
     )
   );
 
-  return FALSE;
+  return chado_update_property('contact', $contact_id, $property, 'tripal_contact', $value, $insert_if_missing);
 }
 
 /**
@@ -89,7 +89,7 @@ function tripal_contact_delete_property($contact_id, $property) {
     )
   );
 
-  return FALSE;
+  return chado_delete_property('contact', $contact_id, $property, 'tripal_contact');
 }
 
 /**
@@ -111,5 +111,10 @@ function tripal_contact_add_contact($name, $description, $type, $properties) {
     )
   );
 
-  return FALSE;
+  return chado_insert_contact(array(
+    'name' => $name,
+    'description' => $description,
+    'type_name' => $type,
+    'properties' => $properties
+  ));
 }

+ 14 - 93
tripal_contact/api/tripal_contact.api.inc

@@ -14,101 +14,17 @@
  * @}
  */
 
-/**
- * Retrieve properties of a given type for a given contact
- *
- * @param $contact_id
- *    The contact_id of the properties you would like to retrieve
- * @param $property
- *    The cvterm name of the properties to retrieve
- *
- * @return
- *    An contact chado variable with the specified properties expanded
- *
- * @ingroup tripal_contact_api
- */
-function tripal_contact_get_property($contact_id, $property) {
-  return chado_get_property('contact', $contact_id, $property, 'tripal_contact');
-}
-
-/**
- * Insert a given property
- *
- * @param $contact_id
- *   The contact_id of the property to insert
- * @param $property
- *   The cvterm name of the property to insert
- * @param $value
- *   The value of the property to insert
- * @param $update_if_present
- *   A boolean indicated whether to update the record if it's already present
- *
- * @return
- *   True of success, False otherwise
- *
- * @ingroup tripal_contact_api
- */
-function tripal_contact_insert_property($contact_id, $property, $value, $update_if_present = 0) {
-  return chado_insert_property('contact', $contact_id, $property, 'tripal_contact', $value, $update_if_present);
-}
-
-/**
- * Update a given property
- *
- * @param $contact_id
- *   The contact_id of the property to update
- * @param $property
- *   The cvterm name of the property to update
- * @param $value
- *   The value of the property to update
- * @param $insert_if_missing
- *   A boolean indicated whether to insert the record if it's absent
- *
- * Note: The property will be identified using the unique combination of the $contact_id and $property
- * and then it will be updated with the supplied value
- *
- * @return
- *   True of success, False otherwise
- *
- * @ingroup tripal_contact_api
- */
-function tripal_contact_update_property($contact_id, $property, $value, $insert_if_missing = 0) {
-  return chado_update_property('contact', $contact_id, $property, 'tripal_contact', $value, $insert_if_missing);
-}
-
-/**
- * Delete a given property
- *
- * @param $contact_id
- *   The contact_id of the property to delete
- * @param $property
- *   The cvterm name of the property to delete
- *
- * Note: The property will be identified using the unique combination of the $contact_id and $property
- * and then it will be deleted
- *
- * @return
- *   True of success, False otherwise
- *
- * @ingroup tripal_contact_api
- */
-function tripal_contact_delete_property($contact_id, $property) {
-  return chado_delete_property('contact', $contact_id, $property, 'tripal_contact');
-}
-
 /**
  * Adds a contact to the Chado contact table
  *
- * @param $name
- *   The name of the contact
- * @param $description
- *   Text describing the contact
- * @param $type
- *   The type of contact.  Must be a term in the tripal_contact vocabulary
- * @param $properties
- *   An associative array containing a list of key value pairs for the properites.
- *   The key's must be valid terms in the tripal_contact vocabulary (e.g. Affiliation,
- *   Address, etc).
+ * @param $values
+ *   An array of values to be inserted. Valid keys include:
+ *   - name: The name of the contact
+ *   - description: Text describing the contact
+ *   - type_name: The type of contact.  Must be a term in the tripal_contact vocabulary
+ *   - properties: An associative array containing a list of key value pairs for the properites.
+ *     The key's must be valid terms in the tripal_contact vocabulary (e.g. Affiliation,
+ *     Address, etc).
  *
  * @return
  *   On success, an array is returned containing the fields of the contact
@@ -117,7 +33,12 @@ function tripal_contact_delete_property($contact_id, $property) {
  *
  * @ingroup tripal_contact_api
  */
-function tripal_contact_add_contact($name, $description, $type, $properties) {
+function chado_insert_contact($values) {
+
+  $name = $values['name'];
+  $description = $values['description'];
+  $type = $values['type_name'];
+  $properties = $values['properties'];
 
   // check to see if this contact name already exists.
   $values =  array('name' => $name);

+ 1 - 1
tripal_contact/tripal_contact.module

@@ -15,7 +15,7 @@
  */
 
 require_once 'api/tripal_contact.api.inc';
-// require_once 'api/tripal_contact.DEPRECATED.inc';
+require_once 'api/tripal_contact.DEPRECATED.inc';
 
 require_once 'theme/tripal_contact.theme.inc';