Browse Source

Fixed several bugs with entities

Stephen Ficklin 9 years ago
parent
commit
be8b0e946c

+ 14 - 46
tripal_entities/api/tripal_entities.api.inc

@@ -10,6 +10,7 @@
  */
 
 function tripal_data_type_load($type) {
+
   $entity = tripal_data_get_types($type);
   return $entity;
 }
@@ -43,28 +44,17 @@ function tripal_data_get_types($type_name = NULL) {
  * @see tripal_data_load_multiple()
  */
 function tripal_data_load($id, $reset = FALSE) {
-  $tripal_datas = tripal_data_load_multiple(array($id), array(), $reset);
-  return reset($tripal_datas);
-}
 
+  // Get the type of entity by the ID.
+  $entity_type = db_select('tripal_data', 'td')
+    ->fields('td', array('type'))
+    ->condition('id', $id)
+    ->execute()
+    ->fetchField();
 
-/**
- * Load multiple tripal_datas based on certain conditions.
- *
- * @param $ids
- *   An array of tripal_data IDs.
- * @param $conditions
- *   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 tripal_data objects, indexed by id.
- *
- * @see entity_load()
- * @see tripal_data_load()
- */
-function tripal_data_load_multiple($ids = array(), $conditions = array(), $reset = FALSE) {
-  return entity_load('tripal_data', $ids, $conditions, $reset);
+  // Load the entity.
+  $entity =  entity_load($entity_type, array($id), array(), $reset);
+  return reset($entity);
 }
 
 
@@ -75,44 +65,22 @@ function tripal_data_delete(TripalData $tripal_data) {
   $tripal_data->delete();
 }
 
-
-/**
- * Delete multiple tripal_datas.
- *
- * @param $ids
- *   An array of tripal_data IDs.
- */
-function tripal_data_delete_multiple(array $ids) {
-  entity_get_controller('tripal_data')->delete($ids);
-}
-
-
-/**
- * Create a tripal_data object.
- */
-function tripal_data_create($values = array()) {
-  return entity_get_controller('tripal_data')->create($values);
-}
-function tripal_data_type_create($values = array()) {
-  return entity_get_controller('tripal_data_type')->create($values);
-}
-
 /**
  * Saves a tripal_data to the database.
  *
  * @param $tripal_data
  *   The tripal_data object.
  */
-function tripal_data_save(TripalData $tripal_data) {
-  return $tripal_data->save();
+function tripal_data_save(TripalData $entity) {
+  return $entity->save();
 }
 
 
 /**
  * Saves a tripal_data type to the db.
  */
-function tripal_data_type_save(TripalDataType $type) {
-  $type->save();
+function tripal_data_type_save(TripalDataType $entity) {
+  $entity->save();
 }
 
 

+ 17 - 11
tripal_entities/includes/TripalDataController.inc

@@ -26,6 +26,7 @@ class TripalDataController extends EntityAPIController {
     // Add values that are specific to our entity
     $values += array(
       'id' => '',
+      'bundle' => '',
       'title' => '',
       'created' => '',
       'changed' => '',
@@ -59,13 +60,13 @@ class TripalDataController extends EntityAPIController {
       try {
         foreach ($entities as $entity) {
           // Invoke hook_entity_delete().
-          module_invoke_all('entity_delete', $entity, 'tripal_data');
-          field_attach_delete('tripal_data', $entity);
+          module_invoke_all('entity_delete', $entity, $entity->type);
+          field_attach_delete($entity->type, $entity);
           $ids[] = $entity->id;
         }
         db_delete('tripal_data')
-        ->condition('id', $ids, 'IN')
-        ->execute();
+          ->condition('id', $ids, 'IN')
+          ->execute();
       }
       catch (Exception $e) {
         $transaction->rollback();
@@ -80,6 +81,7 @@ class TripalDataController extends EntityAPIController {
    */
   public function save($entity) {
     global $user;
+    $pkeys = array();
 
     // If our entity has no id, then we need to give it a
     // time of creation.
@@ -89,29 +91,30 @@ class TripalDataController extends EntityAPIController {
     }
     else {
       $invocation = 'entity_update';
+      $pkeys = array('id');
     }
     // Now we need to either insert or update the fields which are
     // attached to this entity. We use the same primary_keys logic
     // to determine whether to update or insert, and which hook we
     // need to invoke.
     if ($invocation == 'entity_insert') {
-      field_attach_insert('tripal_data', $entity);
+      field_attach_insert($entity->entity_type, $entity);
     }
     else {
-      field_attach_update('tripal_data', $entity);
+      field_attach_update($entity->entity_type, $entity);
     }
 
     // Invoke hook_entity_presave().
-    module_invoke_all('entity_presave', $entity, 'tripal_data');
+    module_invoke_all('entity_presave', $entity, $entity->entity_type);
 
     // Write out the entity record.
     $tablename = 'feature';
-    $type_field = 'type_id';
     $schema = chado_get_schema($tablename);
     $pkey_field = $schema['primary key'][0];
     $record = array(
       'cvterm_id' => $entity->cvterm_id,
-      'type'      => $entity->type,
+      'type'      => $entity->entity_type,
+      'bundle'    => $entity->bundle,
       'tablename' => $tablename,
       'record_id' => $entity->record_id,
       'title'     => 'title',
@@ -119,13 +122,16 @@ class TripalDataController extends EntityAPIController {
       'created'   => $entity->created,
       'changed'   => time(),
     );
-    $success = drupal_write_record('tripal_data', $record);
+    if ($invocation == 'entity_update') {
+      $record['id'] = $entity->id;
+    }
+    $success = drupal_write_record('tripal_data', $record, $pkeys);
     if ($success == SAVED_NEW) {
       $entity->id = $record['id'];
     }
 
     // Invoke either hook_entity_update() or hook_entity_insert().
-    module_invoke_all($invocation, $entity, 'tripal_data');
+    module_invoke_all($invocation, $entity, $entity->entity_type);
 
     return $entity;
   }

+ 6 - 135
tripal_entities/includes/TripalDataUIController.inc

@@ -14,38 +14,6 @@ class TripalDataUIController extends EntityDefaultUIController {
     // Set this on the object so classes that extend hook_menu() can use it.
     $this->id_count = count(explode('/', $this->path));
     $wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%entity_object';
-    $plural_label = isset($this->entityInfo['plural label']) ? $this->entityInfo['plural label'] : $this->entityInfo['label'] . 's';
-
-    $items[$this->path] = array(
-      'title' => 'Biological Data',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array($this->entityType . '_overview_form', $this->entityType),
-      'description' => 'Manage ' . $plural_label . '.',
-      'access callback' => 'entity_access',
-      'access arguments' => array('view', $this->entityType),
-      'file' => 'includes/entity.ui.inc',
-    );
-
-    // Change the overview menu type for the list of models.
-    $items[$this->path]['type'] = MENU_LOCAL_TASK;
-
-    $items[$this->path . '/list'] = array(
-      'title' => 'List',
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -10,
-    );
-
-    // Add an action link to the admin page for adding new data.
-    $items[$this->path . '/add'] = array(
-      'title' => 'Add Tripal Data',
-      'description' => 'Add a new tripal data record',
-      'page callback'  => 'drupal_get_form',
-      '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 tripal data entities.
     $items['data/add'] = array(
@@ -166,7 +134,7 @@ function tripal_data_form($form, &$form_state, $entity = NULL) {
     $cvterm = chado_generate_var('cvterm', $values);
   }
 
-  // Let the user select the vocabulary and tripal_data but only if they haven't
+  // Let the user select the vocabulary          defaut and tripal_data but only if they haven't
   // already selected a tripal_data.
   $cvs = tripal_entities_get_published_vocabularies_as_select_options();
   if (!$term_name) {
@@ -224,7 +192,7 @@ function tripal_data_form($form, &$form_state, $entity = NULL) {
       '#type'  => 'hidden',
       '#value' => $cvterm->cvterm_id,
     );
-    $form['type'] = array(
+    $form['bundle'] = array(
       '#type'  => 'hidden',
       '#value' => $bundle_id,
     );
@@ -245,91 +213,9 @@ function tripal_data_form($form, &$form_state, $entity = NULL) {
       '#markup' => $cvterm->name,
     );
 
-/*
-
-    // Create the Tripal data type entity.
-    $data_type_entity = tripal_data_type_create(array(
-      'type' => $bundle_id,
-      'label' => $cvterm->name,
-      'module' => 'tripal_entities'
-    ));
-
-    $data_type_entity->save();
-*/
-/*
-    // Drupal field types and settings:
-    // https://www.drupal.org/node/1879542
-    $field = array(
-      'field_name' => 'feature__name',
-      'type' => 'text',
-      'cardinality' => 1,
-      'locked' => TRUE,
-      'storage' => array(
-        'type' => 'tripal_entities_storage'
-      ),
-    );
-    field_create_field($field);
-    $field_instance = array(
-      'field_name' => 'feature__name',
-      'label' => 'Name',
-      'widget' => array(
-        'type' => 'text_textfield'
-      ),
-      'entity_type' => 'tripal_data',
-      'required' => 'true',
-      'settings' => array(
-        'max_length' => 255
-      ),
-      'bundle' => $bundle_id,
-    );
-    field_create_instance($field_instance);
-    $field = array(
-      'field_name' => 'feature__uniquename',
-      'type' => 'text',
-      'cardinality' => 1,
-      'locked' => TRUE,
-      'storage' => array(
-        'type' => 'tripal_entities_storage'
-      ),
-    );
-    field_create_field($field);
-    $field_instance = array(
-      'field_name' => 'feature__uniquename',
-      'label' => 'Unique Name',
-      'widget' => array(
-       'type' => 'text_textfield'
-      ),
-      'entity_type' => 'tripal_data',
-      'required' => 'true',
-      'settings' => array(
-       'max_length' => 255
-      ),
-      'bundle' => $bundle_id,
-    );
-    field_create_instance($field_instance);
-    $field = array(
-      'field_name' => 'feature__organism_id',
-      'type' => 'organism_id',
-      'cardinality' => 1,
-      'locked' => TRUE,
-      'storage' => array(
-       'type' => 'tripal_entities_storage'
-      ),
-    );
-    field_create_field($field);
-    $field_instance = array(
-      'field_name' => 'feature__organism_id',
-      'label' => 'Organism',
-      'entity_type' => 'tripal_data',
-      'required' => 'true',
-      'settings' => array(),
-      'bundle' => $bundle_id,
-    );
-    field_create_instance($field_instance);
-*/
     // If the entity doesn't exist then create one.
     if (!$entity) {
-      $entity = entity_get_controller($cvterm->dbxref_id->db_id->name)->create(array('type' => $bundle_id));
+      $entity = entity_get_controller($cvterm->dbxref_id->db_id->name)->create(array('bundle' => $bundle_id));
       field_attach_form($cvterm->dbxref_id->db_id->name, $entity, $form, $form_state);
 
       $form['submit'] = array(
@@ -349,9 +235,10 @@ function tripal_data_form($form, &$form_state, $entity = NULL) {
         '#weight' => 1000
       );
     }
+
     // 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['tripal_data'] = $entity;
+    $form_state[$cvterm->dbxref_id->db_id->name] = $entity;
   }
   $form['#prefix'] = '<div id="tripal_data_form">';
   $form['#suffix'] = '</div>';
@@ -402,9 +289,7 @@ function tripal_data_form_submit($form, &$form_state) {
     // Use the Entity API to get the entity from the form state, then
     // attach the fields and save.
     $entity_type = $form_state['values']['entity_type'];
-    dpm($form_state);
     $entity = entity_ui_controller($entity_type)->entityFormSubmitBuildEntity($form, $form_state);
-dpm($entity);
     $entity->save();
     $form_state['redirect'] = "data/$entity->id";
   }
@@ -458,20 +343,6 @@ function tripal_data_delete_form_submit($form, &$form_state) {
   $form_state['redirect'] = 'admin/content/tripal_datas';
 }
 
-/**
- * Sets the breadcrumb for administrative tripal_data pages.
- */
-function tripal_data_set_breadcrumb() {
-  $breadcrumb = array(
-    l(t('Home'), '<front>'),
-    l(t('Administration'), 'admin'),
-    l(t('Content'), 'admin/content'),
-    l(t('Tripal Data'), 'admin/content/tripal_data'),
-  );
-
-  drupal_set_breadcrumb($breadcrumb);
-}
-
 /**
  * Menu callback to display an entity.
  *
@@ -494,4 +365,4 @@ function tripal_data_view($entity, $view_mode = 'full') {
  */
 function tripal_data_title(TripalData $entity){
   return $entity->title;
-}
+}

+ 76 - 10
tripal_entities/includes/tripal_entities.admin.inc

@@ -6,8 +6,9 @@
  * @ingroup tripal_feature
  */
 function tripal_entities_admin_view() {
-  
-  $output = drupal_render(drupal_get_form('tripal_entities_admin_data_types_form')) . "<br>[ Image Place Holder for Data Type Summary ]<br>";
+
+  $form = drupal_get_form('tripal_entities_admin_data_types_form');
+  $output = drupal_render($form) . "<br>[ Image Place Holder for Data Type Summary ]<br>";
 
   // set the breadcrumb
   $breadcrumb = array();
@@ -45,6 +46,72 @@ function tripal_entities_admin_view() {
   return $output;
 }
 
+/**
+ *
+ */
+function tripal_entities_content_view() {
+  $form = drupal_get_form('tripal_entities_content_overview_form');
+  $output = drupal_render($form);
+
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  drupal_set_breadcrumb($breadcrumb);
+
+  return $output;
+
+}
+
+/**
+ *
+ * @param unknown $form
+ * @param unknown $form_state
+ * @return multitype:
+ */
+function tripal_entities_content_overview_form($form, &$form_state) {
+  $form = array();
+
+  $entities = db_select('tripal_data', 'td')
+    ->fields('td')
+    ->orderBy('created', 'DESC')//ORDER BY created
+    ->range(0,25)
+    ->execute();
+
+  $headers = array('Title', 'Vocabulary', 'Term', 'Author', 'Status', 'Updated', 'Operations');
+  $rows = array();
+  while ($entity = $entities->fetchObject()) {
+    $cvterm = chado_generate_var('cvterm', array('cvterm_id' => $entity->cvterm_id));
+    $author = user_load($entity->uid);
+    $rows[] = array(
+      l($entity->title, 'data/' . $entity->id),
+      $entity->type . ' (' . $cvterm->cv_id->name . ')',
+      $entity->bundle  . ' (' . $cvterm->name . ')',
+      l($author->name, 'user/' . $entity->uid),
+      $entity->status == 1 ? 'published' : 'unpublished',
+      format_date($entity->changed, 'short'),
+      l('edit', 'data/' . $entity->id . '/edit') . '&nbsp;&nbsp;' .
+      l('delete', 'data/' . $entity->id . '/delete')
+    );
+  }
+
+  $table_vars = array(
+    'header'     => $headers,
+    'rows'       => $rows,
+    'attributes' => array(),
+    'sticky'     => TRUE,
+    'caption'    => '',
+    'colgroups'  => array(),
+    'empty'      => '',
+  );
+  $results_table = theme('table', $table_vars);
+
+  $form['results'] = array(
+    '#markup' => $results_table
+  );
+  return $form;
+}
+
 /**
  *
  * @param unknown $form
@@ -68,7 +135,7 @@ function tripal_entities_admin_data_types_form($form, &$form_state) {
   // already selected a tripal_data.
   $sql = "
     SELECT CV.cv_id, CV.name
-    FROM {cv} CV 
+    FROM {cv} CV
     ORDER BY CV.name
   ";
   $vocabs = chado_query($sql);
@@ -96,7 +163,7 @@ function tripal_entities_admin_data_types_form($form, &$form_state) {
     '#value' => t('Refresh Data Types'),
     '#submit' => array('tripal_entity_admin_data_types_form_submit_refresh_data_types'),
   );
-  
+
   $form['publish_new_data'] = array(
     '#type' => 'submit',
     '#value' => t('Publish New Data'),
@@ -109,7 +176,7 @@ function tripal_entities_admin_data_types_form($form, &$form_state) {
 }
 
 /**
- * Submit a job to populate the entity tables 
+ * Submit a job to populate the entity tables
  * This operation makes available data types in the database publishable
  */
 function tripal_entity_admin_data_types_form_submit_refresh_data_types () {
@@ -402,9 +469,9 @@ function tripal_entities_add_bundle_fields($tablename, $entity_type_name, $bundl
     // If this field is a foreign key field then we will have a special custom
     // field provided by Tripal.
     $is_fk = FALSE;
-    if (array_key_exists('foreign keys', $details)) {
-      foreach ($details['foreign keys'] as $remote_table => $fk_details) {
-        if (array_key_exists($field_name, $fk_details['columns'])) {
+    if (array_key_exists('foreign keys', $schema)) {
+      foreach ($schema['foreign keys'] as $remote_table => $fk_details) {
+        if (array_key_exists($column_name, $fk_details['columns'])) {
           $is_fk = TRUE;
         }
       }
@@ -420,11 +487,10 @@ function tripal_entities_add_bundle_fields($tablename, $entity_type_name, $bundl
         case 'organism_id':
           $field_type = 'organism_id';
           $label = 'Organism';
+          $widget_type = 'tripal_entities_organism_select_widget';
           break;
       }
-      continue;
     }
-
     // If the field doesn't exist then create it.
     if (!$field) {
       $field = array(

+ 5 - 3
tripal_entities/includes/tripal_entities.field_storage.inc

@@ -16,8 +16,9 @@ function tripal_entities_field_storage_info() {
  * Implements hook_field_storage_write().
  */
 function tripal_entities_field_storage_write($entity_type, $entity, $op, $fields) {
-
-    // Get the IDs for this entity.
+  dpm($entity_type);
+  drupal_debug($entity_type);
+  // Get the IDs for this entity.
   list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
 
   // Find out which table should receive the insert.
@@ -105,7 +106,8 @@ function tripal_entities_field_storage_load($entity_type, $entities, $age, $fiel
     }
 
     // Get the record
-    $record = chado_select_record($tablename, $columns[$tablename], array($pkey_field => $entity->record_id));
+    $values = array($pkey_field => $entity->record_id);
+    $record = chado_select_record($tablename, $columns[$tablename], $values);
 
     // Now set the field values
     foreach ($fields as $field_id => $ids) {

+ 1 - 4
tripal_entities/includes/tripal_entities.fields.inc

@@ -56,7 +56,6 @@ function tripal_entities_field_formatter_info() {
  */
 function tripal_entities_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
   $element = array();
-
   switch ($display['type']) {
     // This formatter simply outputs the field as text and with a color.
     case 'tripal_entities_organism_formatter':
@@ -71,9 +70,7 @@ function tripal_entities_field_formatter_view($entity_type, $entity, $field, $in
         );
       }
       break;
-
   }
-
   return $element;
 }
 
@@ -94,7 +91,7 @@ function tripal_entities_field_widget_form(&$form, &$form_state, $field,
         '#title' => $element['#title'],
         '#description' => $element['#description'],
         '#options' => $options,
-        '#default_value' => $items[0]['value'],
+        '#default_value' => count($items) > 0 ? $items[0]['value'] : 0,
         '#required' => $element['#required'],
         '#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
         '#delta' => $delta,

+ 16 - 2
tripal_entities/tripal_entities.install

@@ -321,12 +321,19 @@ function tripal_entities_schema() {
         'not null' => TRUE,
       ),
       'type' => array(
-        'description' => 'The type of entity. This should be an official term ID.',
+        'description' => 'The type of entity. This should be an official vocabulary ID (e.g. SO, RO, GO).',
         'type' => 'varchar',
         'length' => 64,
         'not null' => TRUE,
         'default' => '',
       ),
+      'bundle' => array(
+        'description' => 'The type of bundle. This should be an official vocabulary ID (e.g. SO, RO, GO) followed by an underscore and the term accession.',
+        'type' => 'varchar',
+        'length' => 1024,
+        'not null' => TRUE,
+        'default' => '',
+      ),
       'cvterm_id' => array(
         'description' => 'The cvterm_id for the type of entity. This cvterm_id should match a record in the Chado cvterm table.',
         'type' => 'varchar',
@@ -445,5 +452,12 @@ function tripal_entities_schema() {
  */
 function tripal_entities_uninstall() {
   // TODO: make this dynamic (not hardcoded bundle).
-  field_attach_delete_bundle('tripal_data', 'gene');
+  $terms = chado_generate_var('tripal_term', array('publish' => 1), array('return_array' => 1));
+
+  foreach ($terms as $term) {
+    $entity_type = $term->vocab_id->db_id->name;
+    $bundle_id = $term->cvterm_id->dbxref_id->db_id->name . '_' . $term->cvterm_id->dbxref_id->accession;
+    print "$entity_type : $bundle_id\n";
+    field_attach_delete_bundle($entity_type, $bundle_id);
+  }
 }

+ 52 - 34
tripal_entities/tripal_entities.module

@@ -26,7 +26,26 @@ function tripal_entities_views_api() {
 function tripal_entities_menu() {
 
   $items = array();
-  // the administative settings menu
+
+  // The content menu.
+  $items['admin/content/tripal_data'] = array(
+    'title' => 'Biological Data',
+    'page callback' => 'tripal_entities_content_view',
+    'file' =>  'includes/tripal_entities.admin.inc',
+    'access arguments' => array('administer tripal data'),
+    'type' => MENU_LOCAL_TASK,
+  );
+
+  $items['admin/content/tripal_data/add'] = array(
+    'title' => 'Add Biological Data',
+    'page callback'  => 'drupal_get_form',
+    'page arguments' => array('tripal_data_form'),
+    'access arguments' => array('administer tripal data'),
+    'type' => MENU_LOCAL_ACTION,
+  );
+
+
+  // The administative settings menu.
   $items['admin/tripal/data_types'] = array(
     'title' => 'Biological Data',
     'description' => 'Tools for publishing, configurating and managing biological data.',
@@ -35,14 +54,14 @@ function tripal_entities_menu() {
     'file' =>  'includes/tripal_entities.admin.inc',
     'type' => MENU_NORMAL_ITEM,
   );
-  
-  // the default tab
+
+  // The default tab.
   $items['admin/tripal/data_types/default'] = array(
     'title' => 'Biological Data',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' =>  1,
   );
-  
+
   $items['admin/tripal/data_types/publish'] = array(
     'title' => 'Publish',
     'description' => 'Publish Data',
@@ -154,50 +173,49 @@ function tripal_entities_entity_info() {
 
   // Get a list of published vocabularies from 'tripal_vocabulary
   $published_vocs = chado_generate_var('tripal_vocabulary', array('publish' => 1), array('return_array' => 1));
-  
+
   foreach ($published_vocs as $voc) {
     $entities [$voc->db_id->name] = array (
       // A human readable label to identify our entity.
       'label' => $voc->db_id->name . ' (' . $voc->cv_id->name . ')',
       'plural label' => $voc->db_id->name . ' (' . $voc->cv_id->name . ')',
-      
+
       // The entity class and controller class extend the classes provided by the
       // Entity API.
       'entity class' => 'TripalData',
       'controller class' => 'TripalDataController',
-      
+
       // The table for this entity defined in hook_schema()
       'base table' => 'tripal_data',
-      
+
       // Returns the uri elements of an entity.
       'uri callback' => 'tripal_entities_vocbulary_term_uri',
-      
+
       // IF fieldable == FALSE, we can't attach fields.
       'fieldable' => TRUE,
-      
+
       // entity_keys tells the controller what database fields are used for key
       // functions. It is not required if we don't have bundles or revisions.
       // Here we do not support a revision, so that entity key is omitted.
       'entity keys' => array (
         'id' => 'id',
-        'bundle' => 'type' 
+        'bundle' => 'bundle'
       ),
       'bundle keys' => array (
-        'bundle' => 'type' 
+        'bundle' => 'bundle'
       ),
-      
+
       // Callback function for access to this entity.
       'access callback' => 'tripal_data_access',
-      
+
       // FALSE disables caching. Caching functionality is handled by Drupal core.
       'static cache' => FALSE,
-      
+
       // Bundles are added in the hook_entities_info_alter() function.
       'bundles' => array (),
-      
+
       'label callback' => 'tripal_data_label',
-      'creation callback' => 'tripal_data_create',
-      
+
       // 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
@@ -206,20 +224,20 @@ function tripal_entities_entity_info() {
         'path' => 'admin/content/data',
         'controller class' => 'TripalDataUIController',
         'menu wildcard' => '%tripal_data',
-        'file' => 'includes/TripalDataUIController.inc' 
+        'file' => 'includes/TripalDataUIController.inc'
       ),
       'view modes' => array (
         'full' => array (
           'label' => t ( 'Full content' ),
-          'custom settings' => FALSE 
+          'custom settings' => FALSE
         ),
         'teaser' => array (
           'label' => t ( 'Teaser' ),
-          'custom settings' => TRUE 
-        ) 
-      ) 
+          'custom settings' => TRUE
+        )
+      )
     );
-    
+
     // The entity that holds information about the entity types
     $entities [$voc->db_id->name . '_type'] = array (
       'label' => t ($voc->db_id->name . ' (' . $voc->cv_id->name . ')' . ' Type' ),
@@ -234,7 +252,7 @@ function tripal_entities_entity_info() {
       'entity keys' => array (
         'id' => 'id',
         'name' => 'type',
-        'label' => 'label' 
+        'label' => 'label'
       ),
       'access callback' => 'tripal_data_type_access',
       'module' => 'tripal_entities',
@@ -242,8 +260,8 @@ function tripal_entities_entity_info() {
       'admin ui' => array (
         'path' => 'admin/structure/data_types',
         'controller class' => 'TripalDataTypeUIController',
-        'file' => 'includes/TripalDataTypeUIController.inc' 
-      ) 
+        'file' => 'includes/TripalDataTypeUIController.inc'
+      )
     );
   }
   return $entities;
@@ -256,27 +274,27 @@ function tripal_entities_entity_info() {
  *
  */
 function tripal_entities_entity_info_alter(&$entity_info) {
-  
+
   // Get a list of published terms from 'tripal_term
   $published_terms = chado_generate_var('tripal_term', array('publish' => 1), array('return_array' => 1));
   foreach ( $published_terms as $term ) {
-    
+
     // Bundles are alternative groups of fields or configuration
     // associated with a base entity type.
     // We want to dynamically add the bundles (or term types) to the entity.
     $cvterm = $term->cvterm_id;
     $bundle_id = $cvterm->dbxref_id->db_id->name . '_' . $cvterm->dbxref_id->accession;
-    $label = preg_replace ( '/_/', ' ', ucwords ( $cvterm->name ) );
-    $entity_info [$cvterm->dbxref_id->db_id->name] ['bundles'] [$bundle_id] = array (
+    $label = preg_replace('/_/', ' ', ucwords($cvterm->name));
+    $entity_info[$cvterm->dbxref_id->db_id->name]['bundles'][$bundle_id] = array (
       'label' => $label,
       'admin' => array (
         'path' => 'admin/structure/data_types/manage/%tripal_data_type',
         'real path' => 'admin/structure/data_types/manage/' . $bundle_id,
         'bundle argument' => 4,
         'access arguments' => array (
-          'administer tripal data types' 
-        ) 
-      ) 
+          'administer tripal data types'
+        )
+      )
     );
   }
 }