Browse Source

Renamed Entities to have a Tripal prefix rather than a Chado prefix

Stephen Ficklin 9 years ago
parent
commit
3c8538eab6

+ 49 - 49
tripal_entities/api/tripal_entities.api.inc

@@ -1,133 +1,133 @@
 <?php
 
 /**
- * Menu argument loader; Load a chado data type by string.
+ * Menu argument loader; Load a tripal data type by string.
  *
  * @param $type
- *   The machine-readable name of a chado data type to load.
+ *   The machine-readable name of a tripal data type to load.
  * @return
- *   A chado data type array or FALSE if $type does not exist.
+ *   A tripal data type array or FALSE if $type does not exist.
  */
 
-function chado_data_type_load($type) {
-  $entity = chado_data_get_types($type);
+function tripal_data_type_load($type) {
+  $entity = tripal_data_get_types($type);
   return $entity;
 }
 
 /**
- * Gets an array of all chado_data types, keyed by the type name.
+ * Gets an array of all tripal_data types, keyed by the type name.
  *
  * @param $type_name
  *   If set, the type with the given name is returned.
- * @return ChadoDataType[]
- *   Depending whether $type isset, an array of chado_data types or a single one.
+ * @return TripalDataType[]
+ *   Depending whether $type isset, an array of tripal_data types or a single one.
  */
-function chado_data_get_types($type_name = NULL) {
-  // entity_load will get the Entity controller for our chado_data entity and call the load
+function tripal_data_get_types($type_name = NULL) {
+  // entity_load will get the Entity controller for our tripal_data entity and call the load
   // function of that object - we are loading entities by name here.
-  $types = entity_load_multiple_by_name('chado_data_type', isset($type_name) ? array($type_name) : FALSE);
+  $types = entity_load_multiple_by_name('tripal_data_type', isset($type_name) ? array($type_name) : FALSE);
   return isset($type_name) ? reset($types) : $types;
 }
 
 /**
- * Fetch a chado_data object. Make sure that the wildcard you choose
- * in the chado_data entity definition fits the function name here.
+ * Fetch a tripal_data object. Make sure that the wildcard you choose
+ * in the tripal_data entity definition fits the function name here.
  *
  * @param $entity_id
- *   Integer specifying the chado_data id.
+ *   Integer specifying the tripal_data id.
  * @param $reset
  *   A boolean indicating that the internal cache should be reset.
  * @return
- *   A fully-loaded $chado_data object or FALSE if it cannot be loaded.
+ *   A fully-loaded $tripal_data object or FALSE if it cannot be loaded.
  *
- * @see chado_data_load_multiple()
+ * @see tripal_data_load_multiple()
  */
-function chado_data_load($entity_id, $reset = FALSE) {
-  $chado_datas = chado_data_load_multiple(array($entity_id), array(), $reset);
-  return reset($chado_datas);
+function tripal_data_load($entity_id, $reset = FALSE) {
+  $tripal_datas = tripal_data_load_multiple(array($entity_id), array(), $reset);
+  return reset($tripal_datas);
 }
 
 
 /**
- * Load multiple chado_datas based on certain conditions.
+ * Load multiple tripal_datas based on certain conditions.
  *
  * @param $entity_ids
- *   An array of chado_data IDs.
+ *   An array of tripal_data IDs.
  * @param $conditions
- *   An array of conditions to match against the {chado_data} table.
+ *   An array of conditions to match against the entity table.
  * @param $reset
  *   A boolean indicating that the internal cache should be reset.
  * @return
- *   An array of chado_data objects, indexed by entity_id.
+ *   An array of tripal_data objects, indexed by entity_id.
  *
  * @see entity_load()
- * @see chado_data_load()
+ * @see tripal_data_load()
  */
-function chado_data_load_multiple($entity_ids = array(), $conditions = array(), $reset = FALSE) {
-  return entity_load('chado_data', $entity_ids, $conditions, $reset);
+function tripal_data_load_multiple($entity_ids = array(), $conditions = array(), $reset = FALSE) {
+  return entity_load('tripal_data', $entity_ids, $conditions, $reset);
 }
 
 
 /**
- * Deletes a chado_data.
+ * Deletes a tripal_data.
  */
-function chado_data_delete(ChadoData $chado_data) {
-  $chado_data->delete();
+function tripal_data_delete(TripalData $tripal_data) {
+  $tripal_data->delete();
 }
 
 
 /**
- * Delete multiple chado_datas.
+ * Delete multiple tripal_datas.
  *
  * @param $entity_ids
- *   An array of chado_data IDs.
+ *   An array of tripal_data IDs.
  */
-function chado_data_delete_multiple(array $entity_ids) {
-  entity_get_controller('chado_data')->delete($entity_ids);
+function tripal_data_delete_multiple(array $entity_ids) {
+  entity_get_controller('tripal_data')->delete($entity_ids);
 }
 
 
 /**
- * Create a chado_data object.
+ * Create a tripal_data object.
  */
-function chado_data_create($values = array()) {
-  return entity_get_controller('chado_data')->create($values);
+function tripal_data_create($values = array()) {
+  return entity_get_controller('tripal_data')->create($values);
 }
-function chado_data_type_create($values = array()) {
-  return entity_get_controller('chado_data_type')->create($values);
+function tripal_data_type_create($values = array()) {
+  return entity_get_controller('tripal_data_type')->create($values);
 }
 
 /**
- * Saves a chado_data to the database.
+ * Saves a tripal_data to the database.
  *
- * @param $chado_data
- *   The chado_data object.
+ * @param $tripal_data
+ *   The tripal_data object.
  */
-function chado_data_save(ChadoData $chado_data) {
-  return $chado_data->save();
+function tripal_data_save(TripalData $tripal_data) {
+  return $tripal_data->save();
 }
 
 
 /**
- * Saves a chado_data type to the db.
+ * Saves a tripal_data type to the db.
  */
-function chado_data_type_save(ChadoDataType $type) {
+function tripal_data_type_save(TripalDataType $type) {
   $type->save();
 }
 
 
 /**
- * Deletes a chado_data type from the db.
+ * Deletes a tripal_data type from the db.
  */
-function chado_data_type_delete(ChadoDataType $type) {
+function tripal_data_type_delete(TripalDataType $type) {
   $type->delete();
 }
 
 
 /**
- * URI callback for chado_datas
+ * URI callback for tripal_datas
  */
-function chado_data_uri(ChadoData $entity){
+function tripal_data_uri(TripalData $entity){
   return array(
     'path' => 'data/' . $entity->entity_id,
   );

+ 0 - 18
tripal_entities/includes/ChadoData.inc

@@ -1,18 +0,0 @@
-<?php
-/**
- * A class the controller will use for instantiating the ChadoData entity.
- */
-class ChadoData extends Entity {
-  public function __construct($values = array()) {
-    parent::__construct($values, 'chado_data');
-  }
-
-  protected function defaultLabel() {
-    return $this->title;
-  }
-
-  protected function defaultUri() {
-    return array('path' => 'data/' . $this->entity_id);
-  }
-
-}

+ 0 - 13
tripal_entities/includes/ChadoDataType.inc

@@ -1,13 +0,0 @@
-<?php
-/**
- * The class used for Chado data type entities
- */
-class ChadoDataType extends Entity {
-
-  public $type;
-  public $label;
-
-  public function __construct($values = array()) {
-    parent::__construct($values, 'chado_data_type');
-  }
-}

+ 0 - 72
tripal_entities/includes/ChadoDataTypeUIController.inc

@@ -1,72 +0,0 @@
-<?php
-
-/**
- * @file
- */
-
-/**
- * UI controller.
- */
-class ChadoDataTypeUIController extends EntityDefaultUIController {
-
-  /**
-   * Overrides hook_menu() defaults.
-   */
-  public function hook_menu() {
-    $items = parent::hook_menu();
-    $items[$this->path]['description'] = 'Manage Chado data types, including adding
-      and removing fields and the display of fields.';
-
-    // We don't want to let the user add new Chado data types. They
-    // are added automatically.
-     unset($items[$this->path . '/add']);
-     unset($items[$this->path . '/import']);
-
-    return $items;
-  }
-}
-/**
- * Access callback for the entity API.
- */
-function chado_data_type_access($op, $type = NULL, $account = NULL) {
-  return user_access('administer chado data types', $account);
-}
-
-/**
- * Generates the chado data type editing form.
- */
-function chado_data_type_form($form, &$form_state, $chado_data_type, $op = 'edit') {
-
-  if ($op == 'clone') {
-    $chado_data_type->label .= ' (cloned)';
-    $chado_data_type->type = '';
-  }
-
-  $form['label'] = array(
-    '#title' => t('Label'),
-    '#type' => 'textfield',
-    '#default_value' => $chado_data_type->label,
-    '#description' => t('The human-readable name of this chado data type.'),
-    '#required' => TRUE,
-    '#size' => 30,
-  );
-
-  return $form;
-}
-
-/**
- * Form API submit callback for the type form.
- */
-function chado_data_type_form_submit(&$form, &$form_state) {
-  $chado_data_type = entity_ui_form_submit_build_entity($form, $form_state);
-  $chado_data_type->save();
-  $form_state['redirect'] = 'admin/structure/chado_data_types';
-}
-
-/**
- * Form API submit callback for the delete button.
- */
-function chado_data_type_form_submit_delete(&$form, &$form_state) {
-  $form_state['redirect'] = 'admin/structure/chado_data_types/manage/' . $form_state['chado_data_type']->type . '/delete';
-}
-

+ 18 - 0
tripal_entities/includes/TripalData.inc

@@ -0,0 +1,18 @@
+<?php
+/**
+ * A class the controller will use for instantiating the TripalData entity.
+ */
+class TripalData extends Entity {
+  public function __construct($values = array(), $entity_type) {
+    parent::__construct($values, $entity_type);
+  }
+
+  protected function defaultLabel() {
+    return $this->title;
+  }
+
+  protected function defaultUri() {
+    return array('path' => 'data/' . $this->id);
+  }
+
+}

+ 11 - 11
tripal_entities/includes/ChadoDataController.inc → tripal_entities/includes/TripalDataController.inc

@@ -1,18 +1,18 @@
 <?php
 /**
- * ChadoDataController extends DrupalDefaultEntityController.
+ * TripalDataController extends DrupalDefaultEntityController.
  *
  * Our subclass of DrupalDefaultEntityController lets us add a few
  * important create, update, and delete methods.
  */
-class ChadoDataController extends EntityAPIController {
+class TripalDataController extends EntityAPIController {
 
   public function __construct($entityType) {
     parent::__construct($entityType);
   }
 
   /**
-   * Create a Chado data entity - we first set up the values that are specific
+   * Create a Tripal data entity - we first set up the values that are specific
    * to our data schema but then also go through the EntityAPIController
    * function.
    *
@@ -59,11 +59,11 @@ class ChadoDataController extends EntityAPIController {
       try {
         foreach ($entities as $entity) {
           // Invoke hook_entity_delete().
-          module_invoke_all('entity_delete', $entity, 'chado_data');
-          field_attach_delete('chado_data', $entity);
+          module_invoke_all('entity_delete', $entity, 'tripal_data');
+          field_attach_delete('tripal_data', $entity);
           $entity_ids[] = $entity->entity_id;
         }
-        db_delete('chado_data')
+        db_delete('tripal_data')
         ->condition('entity_id', $entity_ids, 'IN')
         ->execute();
       }
@@ -95,14 +95,14 @@ class ChadoDataController extends EntityAPIController {
     // to determine whether to update or insert, and which hook we
     // need to invoke.
     if ($invocation == 'entity_insert') {
-      field_attach_insert('chado_data', $entity);
+      field_attach_insert('tripal_data', $entity);
     }
     else {
-      field_attach_update('chado_data', $entity);
+      field_attach_update('tripal_data', $entity);
     }
 
     // Invoke hook_entity_presave().
-    module_invoke_all('entity_presave', $entity, 'chado_data');
+    module_invoke_all('entity_presave', $entity, 'tripal_data');
 
     // Write out the entity record.
     $tablename = 'feature';
@@ -119,13 +119,13 @@ class ChadoDataController extends EntityAPIController {
       'created'   => $entity->created,
       'changed'   => time(),
     );
-    $success = drupal_write_record('chado_data', $record);
+    $success = drupal_write_record('tripal_data', $record);
     if ($success == SAVED_NEW) {
       $entity->entity_id = $record['entity_id'];
     }
 
     // Invoke either hook_entity_update() or hook_entity_insert().
-    module_invoke_all($invocation, $entity, 'chado_data');
+    module_invoke_all($invocation, $entity, 'tripal_data');
 
     return $entity;
   }

+ 13 - 0
tripal_entities/includes/TripalDataType.inc

@@ -0,0 +1,13 @@
+<?php
+/**
+ * The class used for Tripal data type entities
+ */
+class TripalDataType extends Entity {
+
+  public $type;
+  public $label;
+
+  public function __construct($values = array()) {
+    parent::__construct($values, 'tripal_data_type');
+  }
+}

+ 3 - 3
tripal_entities/includes/ChadoDataTypeController.inc → tripal_entities/includes/TripalDataTypeController.inc

@@ -1,8 +1,8 @@
 <?php
 /**
- * The Controller for Chado data type entities
+ * The Controller for Tripal data type entities
  */
-class ChadoDataTypeController extends EntityAPIControllerExportable {
+class TripalDataTypeController extends EntityAPIControllerExportable {
   public function __construct($entityType) {
     parent::__construct($entityType);
   }
@@ -13,7 +13,7 @@ class ChadoDataTypeController extends EntityAPIControllerExportable {
    * function.
    *
    * @param $type
-   *   The machine-readable type of the chado data entity.
+   *   The machine-readable type of the tripal data entity.
    *
    * @return
    *   A type object with all default fields initialized.

+ 72 - 0
tripal_entities/includes/TripalDataTypeUIController.inc

@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * @file
+ */
+
+/**
+ * UI controller.
+ */
+class TripalDataTypeUIController extends EntityDefaultUIController {
+
+  /**
+   * Overrides hook_menu() defaults.
+   */
+  public function hook_menu() {
+    $items = parent::hook_menu();
+    $items[$this->path]['description'] = 'Manage Tripal data types, including adding
+      and removing fields and the display of fields.';
+
+    // We don't want to let the user add new Tripal data types. They
+    // are added automatically.
+     unset($items[$this->path . '/add']);
+     unset($items[$this->path . '/import']);
+
+    return $items;
+  }
+}
+/**
+ * Access callback for the entity API.
+ */
+function tripal_data_type_access($op, $type = NULL, $account = NULL) {
+  return user_access('administer tripal data types', $account);
+}
+
+/**
+ * Generates the tripal data type editing form.
+ */
+function tripal_data_type_form($form, &$form_state, $tripal_data_type, $op = 'edit') {
+
+  if ($op == 'clone') {
+    $tripal_data_type->label .= ' (cloned)';
+    $tripal_data_type->type = '';
+  }
+
+  $form['label'] = array(
+    '#title' => t('Label'),
+    '#type' => 'textfield',
+    '#default_value' => $tripal_data_type->label,
+    '#description' => t('The human-readable name of this tripal data type.'),
+    '#required' => TRUE,
+    '#size' => 30,
+  );
+
+  return $form;
+}
+
+/**
+ * Form API submit callback for the type form.
+ */
+function tripal_data_type_form_submit(&$form, &$form_state) {
+  $tripal_data_type = entity_ui_form_submit_build_entity($form, $form_state);
+  $tripal_data_type->save();
+  $form_state['redirect'] = 'admin/structure/tripal_data_types';
+}
+
+/**
+ * Form API submit callback for the delete button.
+ */
+function tripal_data_type_form_submit_delete(&$form, &$form_state) {
+  $form_state['redirect'] = 'admin/structure/tripal_data_types/manage/' . $form_state['tripal_data_type']->type . '/delete';
+}
+

+ 73 - 73
tripal_entities/includes/ChadoDataUIController.inc → tripal_entities/includes/TripalDataUIController.inc

@@ -2,7 +2,7 @@
 /**
  * UI controller.
  */
-class ChadoDataUIController extends EntityDefaultUIController {
+class TripalDataUIController extends EntityDefaultUIController {
 
   /**
    * Overrides hook_menu() defaults. Main reason for doing this is that
@@ -37,35 +37,35 @@ class ChadoDataUIController extends EntityDefaultUIController {
 
     // Add an action link to the admin page for adding new data.
     $items[$this->path . '/add'] = array(
-      'title' => 'Add Chado Data',
-      'description' => 'Add a new chado data record',
+      'title' => 'Add Tripal Data',
+      'description' => 'Add a new tripal data record',
       'page callback'  => 'drupal_get_form',
-      'page arguments' => array('chado_data_form'),
-      'access callback'  => 'chado_data_access',
+      'page arguments' => array('tripal_data_form'),
+      'access callback'  => 'tripal_data_access',
       'access arguments' => array('edit'),
       'type' => MENU_LOCAL_ACTION,
       'weight' => 20,
     );
 
-    // Set a custom page for adding new chado data entities.
+    // Set a custom page for adding new tripal data entities.
     $items['data/add'] = array(
-      'title' => 'Add Chado data',
-      'description' => 'Add a new chado data record',
+      'title' => 'Add Tripal data',
+      'description' => 'Add a new tripal data record',
       'page callback'  => 'drupal_get_form',
-      'page arguments' => array('chado_data_form'),
-      'access callback'  => 'chado_data_access',
+      'page arguments' => array('tripal_data_form'),
+      'access callback'  => 'tripal_data_access',
       'access arguments' => array('edit'),
       'type' => MENU_NORMAL_ITEM,
       'weight' => 20,
     );
 
-    // Link for viewing a chado data type.
+    // Link for viewing a tripal data type.
     $items['data/' . $wildcard] = array(
-      'title callback' => 'chado_data_title',
+      'title callback' => 'tripal_data_title',
       'title arguments' => array(1),
-      'page callback' => 'chado_data_view',
+      'page callback' => 'tripal_data_view',
       'page arguments' => array(1),
-      'access callback' => 'chado_data_access',
+      'access callback' => 'tripal_data_access',
       'access arguments' => array('view', 1),
       'type' => MENU_CALLBACK,
     );
@@ -73,9 +73,9 @@ class ChadoDataUIController extends EntityDefaultUIController {
     // 'View' tab for an individual entity page.
     $items['data/' . $wildcard . '/view'] = array(
       'title' => 'View',
-      'page callback' => 'chado_data_view',
+      'page callback' => 'tripal_data_view',
       'page arguments' => array(1),
-      'access callback' => 'chado_data_access',
+      'access callback' => 'tripal_data_access',
       'access arguments' => array('view', 1),
       'type' => MENU_DEFAULT_LOCAL_TASK,
       'weight' => -10,
@@ -86,19 +86,19 @@ class ChadoDataUIController extends EntityDefaultUIController {
     $items['data/' . $wildcard . '/edit'] = array(
       'title' => 'Edit',
       'page callback' => 'drupal_get_form',
-      'page arguments' => array('chado_data_form', 1),
-      'access callback' => 'chado_data_access',
+      'page arguments' => array('tripal_data_form', 1),
+      'access callback' => 'tripal_data_access',
       'access arguments' => array('edit', 1),
       'type' => MENU_LOCAL_TASK,
 
     );
 
-    // Menu item for deleting chado data entities.
+    // Menu item for deleting tripal data entities.
     $items['data/' . $wildcard . '/delete'] = array(
       'title'  => 'Delete',
       'page callback' => 'drupal_get_form',
-      'page arguments' => array('chado_data_delete_form', 1),
-      'access callback' => 'chado_data_access',
+      'page arguments' => array('tripal_data_delete_form', 1),
+      'access callback' => 'tripal_data_access',
       'access arguments' => array('edit', 1),
       'type' => MENU_CALLBACK,
 
@@ -109,21 +109,21 @@ class ChadoDataUIController extends EntityDefaultUIController {
 
 }
 /**
- * Determines whether the given user has access to a chado data entity.
+ * Determines whether the given user has access to a tripal data entity.
  *
  * @param $op
  *   The operation being performed. One of 'view', 'update', 'create', 'delete'
  *   or just 'edit' (being the same as 'create' or 'update').
  * @param $entity
- *   Optionally a chado data entity or a chado data type to check access for.
+ *   Optionally a tripal data entity or a tripal data type to check access for.
  *   If nothing is given, access for all types is determined.
  * @param $account
  *   The user to check for. Leave it to NULL to check for the global user.
  * @return boolean
  *   Whether access is allowed or not.
  */
-function chado_data_access($op, $entity = NULL, $account = NULL) {
-  if (user_access('administer chado data', $account)) {
+function tripal_data_access($op, $entity = NULL, $account = NULL) {
+  if (user_access('administer tripal data', $account)) {
     return TRUE;
   }
   if (isset($entity) && $type_name = $entity->type) {
@@ -137,7 +137,7 @@ function chado_data_access($op, $entity = NULL, $account = NULL) {
 /**
  *
  */
-function chado_data_form($form, &$form_state, $entity = NULL) {
+function tripal_data_form($form, &$form_state, $entity = NULL) {
 
   // Set the defaults.
   $cv_id = NULL;
@@ -166,8 +166,8 @@ function chado_data_form($form, &$form_state, $entity = NULL) {
     $cvterm = chado_generate_var('cvterm', $values);
   }
 
-  // Let the user select the vocabulary and chado_data but only if they haven't
-  // already selected a chado_data.
+  // Let the user select the vocabulary and tripal_data but only if they haven't
+  // already selected a tripal_data.
   $cvs = tripal_get_cv_select_options();
   if (!$term_name) {
     $form['cv_id'] = array(
@@ -178,8 +178,8 @@ function chado_data_form($form, &$form_state, $entity = NULL) {
       '#description' => t('Select a vocabulary that contains the term for the type of data you want to add.'),
       '#default_value' => $cv_id,
       '#ajax' => array(
-        'callback' => "chado_data_form_ajax_callback",
-        'wrapper' => 'chado_data_form',
+        'callback' => "tripal_data_form_ajax_callback",
+        'wrapper' => 'tripal_data_form',
         'effect' => 'fade',
         'method' => 'replace'
       )
@@ -243,8 +243,8 @@ function chado_data_form($form, &$form_state, $entity = NULL) {
 
 /*
 
-    // Create the Chado data type entity.
-    $data_type_entity = chado_data_type_create(array(
+    // Create the Tripal data type entity.
+    $data_type_entity = tripal_data_type_create(array(
       'type' => $bundle_id,
       'label' => $cvterm->name,
       'module' => 'tripal_entities'
@@ -271,7 +271,7 @@ function chado_data_form($form, &$form_state, $entity = NULL) {
       'widget' => array(
         'type' => 'text_textfield'
       ),
-      'entity_type' => 'chado_data',
+      'entity_type' => 'tripal_data',
       'required' => 'true',
       'settings' => array(
         'max_length' => 255
@@ -295,7 +295,7 @@ function chado_data_form($form, &$form_state, $entity = NULL) {
       'widget' => array(
        'type' => 'text_textfield'
       ),
-      'entity_type' => 'chado_data',
+      'entity_type' => 'tripal_data',
       'required' => 'true',
       'settings' => array(
        'max_length' => 255
@@ -316,7 +316,7 @@ function chado_data_form($form, &$form_state, $entity = NULL) {
     $field_instance = array(
       'field_name' => 'feature__organism_id',
       'label' => 'Organism',
-      'entity_type' => 'chado_data',
+      'entity_type' => 'tripal_data',
       'required' => 'true',
       'settings' => array(),
       'bundle' => $bundle_id,
@@ -325,8 +325,8 @@ function chado_data_form($form, &$form_state, $entity = NULL) {
 */
     // If the entity doesn't exist then create one.
     if (!$entity) {
-      $entity = entity_get_controller('chado_data')->create(array('type' => $bundle_id));
-      field_attach_form('chado_data', $entity, $form, $form_state);
+      $entity = entity_get_controller('tripal_data')->create(array('type' => $bundle_id));
+      field_attach_form('tripal_data', $entity, $form, $form_state);
 
       $form['submit'] = array(
         '#type' => 'submit',
@@ -336,7 +336,7 @@ function chado_data_form($form, &$form_state, $entity = NULL) {
       );
     }
     else {
-      field_attach_form('chado_data', $entity, $form, $form_state);
+      field_attach_form('tripal_data', $entity, $form, $form_state);
 
       $form['submit'] = array(
         '#type' => 'submit',
@@ -347,44 +347,44 @@ function chado_data_form($form, &$form_state, $entity = NULL) {
     }
     // The entity object must be added to the $form_state in order for
     // the Entity API to work.  It must have a key of the entity name.
-    $form_state['chado_data'] = $entity;
+    $form_state['tripal_data'] = $entity;
   }
-  $form['#prefix'] = '<div id="chado_data_form">';
+  $form['#prefix'] = '<div id="tripal_data_form">';
   $form['#suffix'] = '</div>';
   return $form;
 }
 
 /**
- * An Ajax callback for the chado_data_form.
+ * An Ajax callback for the tripal_data_form.
  */
-function chado_data_form_ajax_callback($form, $form_state) {
+function tripal_data_form_ajax_callback($form, $form_state) {
   // return the form so Drupal can update the content on the page
   return $form;
 
 }
 /**
- * Implements hook_validate() for the chado_data_form.
+ * Implements hook_validate() for the tripal_data_form.
  */
-function chado_data_form_validate($form, &$form_state) {
+function tripal_data_form_validate($form, &$form_state) {
 
   if ($form_state['clicked_button']['#name'] == 'add_data') {
-    $chado_data = (object) $form_state['values'];
-    field_attach_form_validate('chado_data', $chado_data, $form, $form_state);
+    $tripal_data = (object) $form_state['values'];
+    field_attach_form_validate('tripal_data', $tripal_data, $form, $form_state);
   }
 }
 
 /**
- * Implements hook_submit() for the chado_data_form.
+ * Implements hook_submit() for the tripal_data_form.
  *
  */
-function chado_data_form_submit($form, &$form_state) {
+function tripal_data_form_submit($form, &$form_state) {
   if ($form_state['clicked_button']['#name'] == 'cancel') {
     if (array_key_exists('entity_id', $form_state['values'])){
       $entity = $form_state['values']['entity'];
       $form_state['redirect'] = "data/$entity->entity_id";
     }
     else {
-      $form_state['redirect'] = "admin/structure/chado_data";
+      $form_state['redirect'] = "admin/structure/tripal_data";
     }
     return;
   }
@@ -396,7 +396,7 @@ function chado_data_form_submit($form, &$form_state) {
       $form_state['clicked_button']['#name'] == 'add_data') {
     // Use the Entity API to get the entity from the form state, then
     // attach the fields and save.
-    $entity = entity_ui_controller('chado_data')->entityFormSubmitBuildEntity($form, $form_state);
+    $entity = entity_ui_controller('tripal_data')->entityFormSubmitBuildEntity($form, $form_state);
     $entity->save();
     $form_state['redirect'] = "data/$entity->entity_id";
   }
@@ -406,27 +406,27 @@ function chado_data_form_submit($form, &$form_state) {
  *
  * @todo Remove hard-coded path
  */
-function chado_data_form_submit_delete(&$form, &$form_state) {
-  $form_state['redirect'] = 'admin/content/chado_datas/chado_data/' . $form_state['chado_data']->chado_data_id . '/delete';
+function tripal_data_form_submit_delete(&$form, &$form_state) {
+  $form_state['redirect'] = 'admin/content/tripal_datas/tripal_data/' . $form_state['tripal_data']->tripal_data_id . '/delete';
 }
 
 
 /**
- * Form callback: confirmation form for deleting a chado_data.
+ * Form callback: confirmation form for deleting a tripal_data.
  *
- * @param $chado_data
- *   The chado_data to delete
+ * @param $tripal_data
+ *   The tripal_data to delete
  *
  * @see confirm_form()
  */
-function chado_data_delete_form($form, &$form_state, $chado_data) {
-  $form_state['chado_data'] = $chado_data;
+function tripal_data_delete_form($form, &$form_state, $tripal_data) {
+  $form_state['tripal_data'] = $tripal_data;
 
-  $form['#submit'][] = 'chado_data_delete_form_submit';
+  $form['#submit'][] = 'tripal_data_delete_form_submit';
 
   $form = confirm_form($form,
-    t('Are you sure you want to delete chado_data %name?', array('%name' => $chado_data->name)),
-    'admin/content/chado_datas/chado_data',
+    t('Are you sure you want to delete tripal_data %name?', array('%name' => $tripal_data->name)),
+    'admin/content/tripal_datas/tripal_data',
     '<p>' . t('This action cannot be undone.') . '</p>',
     t('Delete'),
     t('Cancel'),
@@ -437,28 +437,28 @@ function chado_data_delete_form($form, &$form_state, $chado_data) {
 }
 
 /**
- * Submit callback for chado_data_delete_form
+ * Submit callback for tripal_data_delete_form
  */
-function chado_data_delete_form_submit($form, &$form_state) {
-  $chado_data = $form_state['chado_data'];
+function tripal_data_delete_form_submit($form, &$form_state) {
+  $tripal_data = $form_state['tripal_data'];
 
-  chado_data_delete($chado_data);
+  tripal_data_delete($tripal_data);
 
-  drupal_set_message(t('The chado_data %name has been deleted.', array('%name' => $chado_data->name)));
-  watchdog('chado_data', 'Deleted chado_data %name.', array('%name' => $chado_data->name));
+  drupal_set_message(t('The tripal_data %name has been deleted.', array('%name' => $tripal_data->name)));
+  watchdog('tripal_data', 'Deleted tripal_data %name.', array('%name' => $tripal_data->name));
 
-  $form_state['redirect'] = 'admin/content/chado_datas';
+  $form_state['redirect'] = 'admin/content/tripal_datas';
 }
 
 /**
- * Sets the breadcrumb for administrative chado_data pages.
+ * Sets the breadcrumb for administrative tripal_data pages.
  */
-function chado_data_set_breadcrumb() {
+function tripal_data_set_breadcrumb() {
   $breadcrumb = array(
     l(t('Home'), '<front>'),
     l(t('Administration'), 'admin'),
     l(t('Content'), 'admin/content'),
-    l(t('Chado Data'), 'admin/content/chado_data'),
+    l(t('Tripal Data'), 'admin/content/tripal_data'),
   );
 
   drupal_set_breadcrumb($breadcrumb);
@@ -474,8 +474,8 @@ function chado_data_set_breadcrumb() {
  * @see hook_entity_view()
  * @see hook_entity_view_alter()
  */
-function chado_data_view($entity, $view_mode = 'full') {
-  $controller = entity_get_controller('chado_data');
+function tripal_data_view($entity, $view_mode = 'full') {
+  $controller = entity_get_controller('tripal_data');
   $content = $controller->view(array($entity->entity_id => $entity));
   drupal_set_title($entity->title);
   return $content;
@@ -484,6 +484,6 @@ function chado_data_view($entity, $view_mode = 'full') {
 /**
  * Menu title callback for showing individual entities
  */
-function chado_data_title(ChadoData $entity){
+function tripal_data_title(TripalData $entity){
   return $entity->title;
 }

+ 0 - 0
tripal_entities/theme/templates/chado_data.tpl.php → tripal_entities/theme/templates/tripal_data.tpl.php


+ 1 - 1
tripal_entities/tripal_entities.info

@@ -1,5 +1,5 @@
 name = Tripal Entities
-description = Exposes data in Chado as Drupal Entities.
+description = Creates Drupal entities using Controlled Vocabulary terms and integrtates those with Chado.
 core = 7.x
 project = tripal
 package = Tripal

+ 10 - 10
tripal_entities/tripal_entities.install

@@ -1,7 +1,7 @@
 <?php
 /**
  * @file
- * Install for a chado data entity - creates the base table for our entity.
+ * Install for a tripal data entity - creates the base table for our entity.
  */
 
 /**
@@ -11,7 +11,7 @@
  */
 function tripal_entities_schema() {
 
-  $schema['chado_data'] = array(
+  $schema['tripal_data'] = array(
     'description' => 'The base table for Tripal Vocabulary-based entities.',
     'fields' => array(
       'entity_id' => array(
@@ -82,7 +82,7 @@ function tripal_entities_schema() {
       'entity_created' => array('created'),
       'tablename' => array('tablename'),
       'record_id' => array('record_id'),
-      'chado_record' => array('tablename', 'record_id'),
+      'tripal_record' => array('tablename', 'record_id'),
       'type' => array('type'),
       'cvterm_id' => array('cvterm_id'),
       'uid' => array('uid'),
@@ -93,8 +93,8 @@ function tripal_entities_schema() {
     'primary key' => array('entity_id'),
   );
 
-  $schema['chado_data_type'] = array(
-    'description' => 'Stores information about defined chado data types.',
+  $schema['tripal_data_type'] = array(
+    'description' => 'Stores information about defined tripal data types.',
     'fields' => array(
       'id' => array(
         'type' => 'serial',
@@ -102,13 +102,13 @@ function tripal_entities_schema() {
         'description' => 'Primary Key: Unique Chado data type identifier.',
       ),
       'type' => array(
-        'description' => 'The machine-readable name of this chado data type.',
+        'description' => 'The machine-readable name of this tripal data type.',
         'type' => 'varchar',
         'length' => 255,
         'not null' => TRUE,
       ),
       'label' => array(
-        'description' => 'The human-readable name of this chado data type.',
+        'description' => 'The human-readable name of this tripal data type.',
         'type' => 'varchar',
         'length' => 255,
         'not null' => TRUE,
@@ -119,14 +119,14 @@ function tripal_entities_schema() {
         'not null' => TRUE,
         'default' => 0,
         'size' => 'tiny',
-        'description' => 'The weight of this chado data type in relation to others.',
+        'description' => 'The weight of this tripal data type in relation to others.',
       ),
       'data' => array(
         'type' => 'text',
         'not null' => FALSE,
         'size' => 'big',
         'serialize' => TRUE,
-        'description' => 'A serialized array of additional data related to this chado data type.',
+        'description' => 'A serialized array of additional data related to this tripal data type.',
       ),
     ) + entity_exportable_schema_fields(),
     'primary key' => array('id'),
@@ -147,5 +147,5 @@ function tripal_entities_schema() {
  */
 function tripal_entities_uninstall() {
   // TODO: make this dynamic (not hardcoded bundle).
-  field_attach_delete_bundle('chado_data', 'gene');
+  field_attach_delete_bundle('tripal_data', 'gene');
 }

+ 41 - 41
tripal_entities/tripal_entities.module

@@ -3,12 +3,12 @@
 require_once "api/tripal_entities.api.inc";
 require_once "includes/tripal_entities.field_storage.inc";
 require_once "includes/tripal_entities.fields.inc";
-require_once "includes/ChadoData.inc";
-require_once "includes/ChadoDataController.inc";
-require_once "includes/ChadoDataUIController.inc";
-require_once "includes/ChadoDataType.inc";
-require_once "includes/ChadoDataTypeController.inc";
-require_once "includes/ChadoDataTypeUIController.inc";
+require_once "includes/TripalData.inc";
+require_once "includes/TripalDataController.inc";
+require_once "includes/TripalDataUIController.inc";
+require_once "includes/TripalDataType.inc";
+require_once "includes/TripalDataTypeController.inc";
+require_once "includes/TripalDataTypeUIController.inc";
 
 /**
  * Implements hook_views_api().
@@ -26,18 +26,18 @@ function tripal_entities_permission() {
   // We set up permisssions to manage entity types, manage all entities and the
   // permissions for each individual entity
   $permissions = array(
-    'administer chado data types' => array(
-      'title' => t('Administer Chado data types'),
-      'description' => t('Create and delete fields for Chado data types, and set their permissions.'),
+    'administer tripal data types' => array(
+      'title' => t('Administer Tripal data types'),
+      'description' => t('Create and delete fields for Tripal data types, and set their permissions.'),
     ),
-    'administer chado data' => array(
-      'title' => t('Administer Chado data'),
-      'description' => t('Edit and delete all chado data'),
+    'administer tripal data' => array(
+      'title' => t('Administer Tripal data'),
+      'description' => t('Edit and delete all tripal data'),
     ),
   );
 
   // Generate permissions per each data type.
-  foreach (chado_data_get_types() as $type) {
+  foreach (tripal_data_get_types() as $type) {
     $type_name = check_plain($type->type);
     $permissions += array(
       "edit any $type_name data" => array(
@@ -56,9 +56,9 @@ function tripal_entities_permission() {
  */
 function tripal_entities_theme($existing, $type, $theme, $path) {
   return array(
-    'chado_data' => array(
+    'tripal_data' => array(
       'render element' => 'elements',
-      'template' => 'chado_data',
+      'template' => 'tripal_data',
       'path' => "$path/theme/templates"
     ),
   );
@@ -70,7 +70,7 @@ function tripal_entities_theme($existing, $type, $theme, $path) {
 function tripal_entities_rdf_mapping() {
   return array();
 /*   return array(
-    'type' => 'chado_data',
+    'type' => 'tripal_data',
     'bundle' => 'gene',
     'mapping' => array(
       'rdftype' => array('sioc:Item', 'foaf:Document'),
@@ -103,18 +103,18 @@ function tripal_entities_rdf_mapping() {
 function tripal_entities_entity_info() {
   $entities = array();
 
-  $entities['chado_data'] = array(
+  $entities['tripal_data'] = array(
     // A human readable label to identify our entity.
-    'label' => t('Chado Data'),
-    'plural label' => t('Chado Data'),
+    'label' => t('Tripal Data'),
+    'plural label' => t('Tripal Data'),
 
     // The entity class and controller class extend the classes provided by the
     // Entity API.
-    'entity class' => 'ChadoData',
-    'controller class' => 'ChadoDataController',
+    'entity class' => 'TripalData',
+    'controller class' => 'TripalDataController',
 
     // The table for this entity defined in hook_schema()
-    'base table' => 'chado_data',
+    'base table' => 'tripal_data',
 
     // Returns the uri elements of an entity.
     'uri callback' => 'tripal_entities_vocbulary_term_uri',
@@ -134,7 +134,7 @@ function tripal_entities_entity_info() {
     ),
 
     // Callback function for access to this entity.
-    'access callback' => 'chado_data_access',
+    'access callback' => 'tripal_data_access',
 
     // FALSE disables caching. Caching functionality is handled by Drupal core.
     'static cache' => FALSE,
@@ -143,17 +143,17 @@ function tripal_entities_entity_info() {
     'bundles' => array(),
 
     'label callback' => 'entity_class_label',
-    'creation callback' => 'chado_data_create',
+    'creation callback' => 'tripal_data_create',
 
-    // The information below is used by the ChadoDataUIController
+    // The information below is used by the TripalDataUIController
     // (which extends the EntityDefaultUIController).  The admin_ui
     // key here is mean to appear on the 'Find Content' page of the
     // administrative menu.
     'admin ui' => array(
       'path' => 'admin/content/data',
-      'controller class' => 'ChadoDataUIController',
-      'menu wildcard' => '%chado_data',
-      'file' => 'includes/ChadoDataUIController.inc',
+      'controller class' => 'TripalDataUIController',
+      'menu wildcard' => '%tripal_data',
+      'file' => 'includes/TripalDataUIController.inc',
     ),
     'view modes' => array(
       'full' => array(
@@ -168,28 +168,28 @@ function tripal_entities_entity_info() {
   );
 
   // The entity that holds information about the entity types
-  $entities['chado_data_type'] = array(
-    'label' => t('Chado Data Type'),
-    'entity class' => 'ChadoDataType',
-    'controller class' => 'ChadoDataTypeController',
-    'base table' => 'chado_data_type',
+  $entities['tripal_data_type'] = array(
+    'label' => t('Tripal Data Type'),
+    'entity class' => 'TripalDataType',
+    'controller class' => 'TripalDataTypeController',
+    'base table' => 'tripal_data_type',
     'fieldable' => FALSE,
     // If this entity can be used as a bundle of another entity then
     // that can be specified via the 'bundle of' key.
-    'bundle of' => 'chado_data',
+    'bundle of' => 'tripal_data',
     'exportable' => TRUE,
     'entity keys' => array(
       'id' => 'id',
       'name' => 'type',
       'label' => 'label',
     ),
-    'access callback' => 'chado_data_type_access',
+    'access callback' => 'tripal_data_type_access',
     'module' => 'tripal_entities',
     // Enable the entity API's admin UI.
     'admin ui' => array(
       'path' => 'admin/structure/data_types',
-      'controller class' => 'ChadoDataTypeUIController',
-      'file' => 'includes/ChadoDataTypeUIController.inc',
+      'controller class' => 'TripalDataTypeUIController',
+      'file' => 'includes/TripalDataTypeUIController.inc',
     ),
   );
   return $entities;
@@ -197,7 +197,7 @@ function tripal_entities_entity_info() {
 /**
  * Implements hook_entity_info_alter().
  *
- * We are adding the info about the chado data types via a hook to avoid a
+ * We are adding the info about the tripal data types via a hook to avoid a
  * recursion issue as loading the model types requires the entity info as well.
  *
  */
@@ -215,13 +215,13 @@ function tripal_entities_entity_info_alter(&$entity_info) {
   $cvterm = chado_generate_var('cvterm', $values);
   $label = preg_replace('/_/', ' ', ucwords($cvterm->name));
   $type = $cvterm->dbxref_id->db_id->name . '_' . $cvterm->dbxref_id->accession;
-  $entity_info['chado_data']['bundles'][$type] = array(
+  $entity_info['tripal_data']['bundles'][$type] = array(
     'label' => $label,
     'admin' => array(
-      'path' => 'admin/structure/data_types/manage/%chado_data_type',
+      'path' => 'admin/structure/data_types/manage/%tripal_data_type',
       'real path' => 'admin/structure/data_types/manage/' . $type,
       'bundle argument' => 4,
-      'access arguments' => array('administer chado data types'),
+      'access arguments' => array('administer tripal data types'),
     ),
   );
 }

+ 14 - 14
tripal_entities/tripal_entities.views_default.inc

@@ -4,18 +4,18 @@ function tripal_entities_views_default_views() {
   $views = array();
 
 $view = new view();
-$view->name = 'chado_data';
+$view->name = 'tripal_data';
 $view->description = '';
 $view->tag = 'default';
-$view->base_table = 'chado_data_type';
-$view->human_name = 'Chado Data';
+$view->base_table = 'tripal_data_type';
+$view->human_name = 'Tripal Data';
 $view->core = 7;
 $view->api_version = '3.0';
 $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
 
 /* Display: Master */
 $handler = $view->new_display('default', 'Master', 'default');
-$handler->display->display_options['title'] = 'Chado Data';
+$handler->display->display_options['title'] = 'Biological Data';
 $handler->display->display_options['use_more_always'] = FALSE;
 $handler->display->display_options['access']['type'] = 'perm';
 $handler->display->display_options['access']['perm'] = 'administer blocks';
@@ -45,28 +45,28 @@ $handler->display->display_options['empty']['area']['label'] = 'No Data';
 $handler->display->display_options['empty']['area']['empty'] = TRUE;
 $handler->display->display_options['empty']['area']['content'] = 'There is currently no data available.';
 $handler->display->display_options['empty']['area']['format'] = 'filtered_html';
-/* Field: Chado Data Type: Internal, numeric chado data type ID */
+/* Field: Tripal Data Type: Internal, numeric tripal data type ID */
 $handler->display->display_options['fields']['id']['id'] = 'id';
-$handler->display->display_options['fields']['id']['table'] = 'chado_data_type';
+$handler->display->display_options['fields']['id']['table'] = 'tripal_data_type';
 $handler->display->display_options['fields']['id']['field'] = 'id';
 $handler->display->display_options['fields']['id']['label'] = 'Data ID';
-/* Field: Chado Data Type: Label */
+/* Field: Tripal Data Type: Label */
 $handler->display->display_options['fields']['label']['id'] = 'label';
-$handler->display->display_options['fields']['label']['table'] = 'chado_data_type';
+$handler->display->display_options['fields']['label']['table'] = 'tripal_data_type';
 $handler->display->display_options['fields']['label']['field'] = 'label';
 $handler->display->display_options['fields']['label']['label'] = 'Type ID';
-/* Field: Chado Data Type: Machine-readable name */
+/* Field: Tripal Data Type: Machine-readable name */
 $handler->display->display_options['fields']['type']['id'] = 'type';
-$handler->display->display_options['fields']['type']['table'] = 'chado_data_type';
+$handler->display->display_options['fields']['type']['table'] = 'tripal_data_type';
 $handler->display->display_options['fields']['type']['field'] = 'type';
 $handler->display->display_options['fields']['type']['label'] = 'Type Name';
-/* Field: Chado Data Type: Status */
+/* Field: Tripal Data Type: Status */
 $handler->display->display_options['fields']['status']['id'] = 'status';
-$handler->display->display_options['fields']['status']['table'] = 'chado_data_type';
+$handler->display->display_options['fields']['status']['table'] = 'tripal_data_type';
 $handler->display->display_options['fields']['status']['field'] = 'status';
-/* Filter criterion: Chado Data Type: Machine-readable name */
+/* Filter criterion: Tripal Data Type: Machine-readable name */
 $handler->display->display_options['filters']['type']['id'] = 'type';
-$handler->display->display_options['filters']['type']['table'] = 'chado_data_type';
+$handler->display->display_options['filters']['type']['table'] = 'tripal_data_type';
 $handler->display->display_options['filters']['type']['field'] = 'type';
 $handler->display->display_options['filters']['type']['exposed'] = TRUE;
 $handler->display->display_options['filters']['type']['expose']['operator_id'] = 'type_op';