Browse Source

Separated entity hooksf or tripal and tripal_chado modules into separate include files

Stephen Ficklin 8 years ago
parent
commit
4383801029

+ 254 - 0
tripal/includes/tripal.entity.inc

@@ -0,0 +1,254 @@
+<?php
+
+
+/**
+ * Implement hook_entity_info().
+ *
+ * See the following for documentaiton of this type setup for Entities:
+ *
+ * http://www.bluespark.com/blog/drupal-entities-part-3-programming-hello-drupal-entity
+ * http://dikini.net/31.08.2010/entities_bundles_fields_and_field_instances
+ */
+function tripal_entity_info() {
+  $entities = array();
+
+  // The TripalVocab entity is meant to house vocabularies.  It is these
+  // vocabs that are used by the TripalTerm entities.  The storage backend
+  // is responsible for setting the values of this entity.
+  //
+  $entities['TripalVocab'] = array(
+    // A human readable label to identify our entity.
+    'label' => 'Controlled Vocabulary',
+    'plural label' => 'Controlled Vocabularies',
+
+    // The entity class and controller class extend the classes provided by the
+    // Entity API.
+    'entity class' => 'TripalVocab',
+    'controller class' => 'TripalVocabController',
+
+    // Adds Views integration for this entity.
+    'views controller class' => 'TripalVocabViewsController',
+
+    // The table for this entity defined in hook_schema()
+    'base table' => 'tripal_vocab',
+
+    // 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',
+    ),
+
+    // Callback function for access to this entity.
+    'access callback' => 'tripal_entity_access',
+
+    // FALSE disables caching. Caching functionality is handled by Drupal core.
+    'static cache' => FALSE,
+
+    // This entity doesn't support bundles.
+    'bundles' => array (),
+
+    'view modes' => array (
+      'full' => array (
+        'label' => t ('Full content'),
+        'custom settings' => FALSE
+      ),
+      'teaser' => array (
+        'label' => t ('Teaser'),
+        'custom settings' => TRUE
+      ),
+    ),
+  );
+
+  //
+  // The TripalTerm entity is meant to house vocabulary terms.  It is these
+  // terms that are used by the TripalEntity entities.  The storage backend
+  // is responsible for setting the values of this entity.
+  //
+  $entities['TripalTerm'] = array(
+    // A human readable label to identify our entity.
+    'label' => 'Controlled Vocabulary Term',
+    'plural label' => 'Controlled Vocabulary Terms',
+
+    // The entity class and controller class extend the classes provided by the
+    // Entity API.
+    'entity class' => 'TripalTerm',
+    'controller class' => 'TripalTermController',
+
+    // Adds Views integration for this entity.
+    'views controller class' => 'TripalTermViewsController',
+
+    // The table for this entity defined in hook_schema()
+    'base table' => 'tripal_term',
+
+    // 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',
+    ),
+
+    // Callback function for access to this entity.
+    'access callback' => 'tripal_entity_access',
+
+    // FALSE disables caching. Caching functionality is handled by Drupal core.
+    'static cache' => FALSE,
+
+    // This entity doesn't support bundles.
+    'bundles' => array (),
+
+    'view modes' => array (
+      'full' => array (
+        'label' => t ('Full content'),
+        'custom settings' => FALSE
+      ),
+      'teaser' => array (
+        'label' => t ('Teaser'),
+        'custom settings' => TRUE
+      ),
+    ),
+  );
+
+  //
+  // The TripalEntity is used for all data. It links data from a storage
+  // back-end to a TripalTerm entity.
+  //
+  $entities['TripalEntity'] = array (
+    // A human readable label to identify our entity.
+    'label' => 'Tripal Content',
+    'plural label' => 'Tripal Content',
+
+    // The entity class and controller class extend the classes provided by the
+    // Entity API.
+    'entity class' => 'TripalEntity',
+    'controller class' => 'TripalEntityController',
+
+    // Adds Views integration for this entity.
+    'views controller class' => 'TripalEntityViewsController',
+
+    // The table for this entity defined in hook_schema()
+    'base table' => 'tripal_entity',
+
+    // Returns the uri elements of an entity.
+    'uri callback' => 'tripal_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' => 'bundle'
+    ),
+    'bundle keys' => array (
+      'bundle' => 'name'
+    ),
+
+    // Callback function for access to this entity.
+    'access callback' => 'tripal_entity_access',
+
+    // FALSE disables caching. Caching functionality is handled by Drupal core.
+    'static cache' => FALSE,
+
+    // Bundles are added dynamically below.
+    'bundles' => array (),
+
+    'label callback' => 'tripal_entity_label',
+
+    // The information below is used by the TripalEntityUIController
+    // (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/bio_data',
+      'controller class' => 'TripalEntityUIController',
+      'menu wildcard' => '%TripalEntity',
+      'file' => 'includes/TripalEntityUIController.inc'
+    ),
+    'view modes' => array (
+      'full' => array (
+        'label' => t ('Full content'),
+        'custom settings' => FALSE
+      ),
+      'teaser' => array (
+        'label' => t ('Teaser'),
+        'custom settings' => TRUE
+      )
+    )
+  );
+
+  //
+  // The TripalBundle entity is used manage the bundle types.  The 'bundle of'
+  // attribute links this to the TripalEntity and allows the UI provided
+  // by the entity module to work for each TripalEntity bundle.
+  //
+  $entities['TripalBundle'] = array (
+    'label' => 'Tripal Content Type',
+    'entity class' => 'TripalBundle',
+    'controller class' => 'TripalBundleController',
+    'base table' => 'tripal_bundle',
+    'fieldable' => FALSE,
+    'bundle of' => 'TripalEntity',
+    'exportable' => FALSE,
+    'entity keys' => array (
+      'id' => 'id',
+      'name' => 'name',
+      'label' => 'label'
+    ),
+    'access callback' => 'tripal_bundle_access',
+    'module' => 'tripal',
+    // Enable the entity API's admin UI.
+    'admin ui' => array (
+      'path' => 'admin/structure/bio_data',
+      'controller class' => 'TripalBundleUIController',
+      'file' => 'includes/TripalBundleUIController.inc',
+      'menu wildcard' => '%TripalBundle',
+    )
+  );
+
+  return $entities;
+}
+
+/**
+ * Implements hook_entities_info_alter().
+ *
+ * Add in the bundles (entity types) to the TripalEntity entity.
+ */
+function tripal_entity_info_alter(&$entity_info){
+
+  if (array_key_exists('TripalEntity', $entity_info)) {
+    // Dynamically add in the bundles. Bundles are alternative groups of fields
+    // or configuration associated with an entity type .We want to dynamically
+    // add the bundles to the entity.
+    $bundles = db_select('tripal_bundle', 'tb')
+    ->fields('tb')
+    ->execute();
+    while ($bundle = $bundles->fetchObject()) {
+      $bundle_name = $bundle->name;
+      $term_id = $bundle->term_id;
+      $term = entity_load('TripalTerm', array('id' => $term_id));
+      $term = reset($term);
+      $label = preg_replace('/_/', ' ', ucwords($term->name));
+
+      $entity_info['TripalEntity']['bundles'][$bundle_name] = array (
+        'label' => $label,
+        'admin' => array (
+          'path' => 'admin/structure/bio_data/manage/%TripalBundle',
+          'real path' => 'admin/structure/bio_data/manage/' . $bundle_name,
+          'bundle argument' => 4,
+          'access arguments' => array (
+            'administer tripal data types'
+          )
+        )
+      );
+    }
+  }
+}

+ 1 - 248
tripal/tripal.module

@@ -9,6 +9,7 @@ tripal_import_api();
 
 require_once "includes/tripal.field_storage.inc";
 require_once "includes/tripal.fields.inc";
+require_once "includes/tripal.entity.inc";
 
 require_once "includes/TripalVocab.inc";
 require_once "includes/TripalVocabController.inc";
@@ -437,255 +438,7 @@ function tripal_shortcut_default_set($account) {
     }
   }
 }
-// http://www.bluespark.com/blog/drupal-entities-part-3-programming-hello-drupal-entity
-// http://dikini.net/31.08.2010/entities_bundles_fields_and_field_instances
-/**
- * Implement hook_entity_info().
- */
-function tripal_entity_info() {
-  $entities = array();
-  //return $entities;
-  //
-  // The TripalVocab entity is meant to house vocabularies.  It is these
-  // vocabs that are used by the TripalTerm entities.  The storage backend
-  // is responsible for setting the values of this entity.
-  //
-  $entities['TripalVocab'] = array(
-    // A human readable label to identify our entity.
-    'label' => 'Controlled Vocabulary',
-    'plural label' => 'Controlled Vocabularies',
-
-    // The entity class and controller class extend the classes provided by the
-    // Entity API.
-    'entity class' => 'TripalVocab',
-    'controller class' => 'TripalVocabController',
-
-    // Adds Views integration for this entity.
-    'views controller class' => 'TripalVocabViewsController',
-
-    // The table for this entity defined in hook_schema()
-    'base table' => 'tripal_vocab',
-
-    // 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',
-    ),
-
-    // Callback function for access to this entity.
-    'access callback' => 'tripal_entity_access',
-
-    // FALSE disables caching. Caching functionality is handled by Drupal core.
-    'static cache' => FALSE,
-
-    // This entity doesn't support bundles.
-    'bundles' => array (),
-
-    'view modes' => array (
-      'full' => array (
-        'label' => t ('Full content'),
-        'custom settings' => FALSE
-      ),
-      'teaser' => array (
-        'label' => t ('Teaser'),
-        'custom settings' => TRUE
-      ),
-    ),
-  );
-
-  //
-  // The TripalTerm entity is meant to house vocabulary terms.  It is these
-  // terms that are used by the TripalEntity entities.  The storage backend
-  // is responsible for setting the values of this entity.
-  //
-  $entities['TripalTerm'] = array(
-    // A human readable label to identify our entity.
-    'label' => 'Controlled Vocabulary Term',
-    'plural label' => 'Controlled Vocabulary Terms',
-
-    // The entity class and controller class extend the classes provided by the
-    // Entity API.
-    'entity class' => 'TripalTerm',
-    'controller class' => 'TripalTermController',
-
-    // Adds Views integration for this entity.
-    'views controller class' => 'TripalTermViewsController',
-
-    // The table for this entity defined in hook_schema()
-    'base table' => 'tripal_term',
-
-    // 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',
-    ),
-
-    // Callback function for access to this entity.
-    'access callback' => 'tripal_entity_access',
-
-    // FALSE disables caching. Caching functionality is handled by Drupal core.
-    'static cache' => FALSE,
-
-    // This entity doesn't support bundles.
-    'bundles' => array (),
-
-    'view modes' => array (
-      'full' => array (
-        'label' => t ('Full content'),
-        'custom settings' => FALSE
-      ),
-      'teaser' => array (
-        'label' => t ('Teaser'),
-        'custom settings' => TRUE
-      ),
-    ),
-  );
-
-  //
-  // The TripalEntity is used for all data. It links data from a storage
-  // back-end to a TripalTerm entity.
-  //
-  $entities['TripalEntity'] = array (
-    // A human readable label to identify our entity.
-    'label' => 'Tripal Content',
-    'plural label' => 'Tripal Content',
-
-    // The entity class and controller class extend the classes provided by the
-    // Entity API.
-    'entity class' => 'TripalEntity',
-    'controller class' => 'TripalEntityController',
-
-    // Adds Views integration for this entity.
-    'views controller class' => 'TripalEntityViewsController',
-
-    // The table for this entity defined in hook_schema()
-    'base table' => 'tripal_entity',
-
-    // Returns the uri elements of an entity.
-    'uri callback' => 'tripal_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' => 'bundle'
-    ),
-    'bundle keys' => array (
-      'bundle' => 'name'
-    ),
-
-    // Callback function for access to this entity.
-    'access callback' => 'tripal_entity_access',
-
-    // FALSE disables caching. Caching functionality is handled by Drupal core.
-    'static cache' => FALSE,
-
-    // Bundles are added dynamically below.
-    'bundles' => array (),
-
-    'label callback' => 'tripal_entity_label',
-
-    // The information below is used by the TripalEntityUIController
-    // (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/bio_data',
-      'controller class' => 'TripalEntityUIController',
-      'menu wildcard' => '%TripalEntity',
-      'file' => 'includes/TripalEntityUIController.inc'
-    ),
-    'view modes' => array (
-      'full' => array (
-        'label' => t ('Full content'),
-        'custom settings' => FALSE
-      ),
-      'teaser' => array (
-        'label' => t ('Teaser'),
-        'custom settings' => TRUE
-      )
-    )
-  );
-
-  //
-  // The TripalBundle entity is used manage the bundle types.  The 'bundle of'
-  // attribute links this to the TripalEntity and allows the UI provided
-  // by the entity module to work for each TripalEntity bundle.
-  //
-  $entities['TripalBundle'] = array (
-    'label' => 'Tripal Content Type',
-    'entity class' => 'TripalBundle',
-    'controller class' => 'TripalBundleController',
-    'base table' => 'tripal_bundle',
-    'fieldable' => FALSE,
-    'bundle of' => 'TripalEntity',
-    'exportable' => FALSE,
-    'entity keys' => array (
-      'id' => 'id',
-      'name' => 'name',
-      'label' => 'label'
-    ),
-    'access callback' => 'tripal_bundle_access',
-    'module' => 'tripal',
-    // Enable the entity API's admin UI.
-    'admin ui' => array (
-      'path' => 'admin/structure/bio_data',
-      'controller class' => 'TripalBundleUIController',
-      'file' => 'includes/TripalBundleUIController.inc',
-      'menu wildcard' => '%TripalBundle',
-    )
-  );
-
-  return $entities;
-}
 
-/**
- * Implements hook_entities_info_alter().
- *
- * Add in the bundles (entity types) to the TripalEntity entity.
- */
-function tripal_entity_info_alter(&$entity_info){
-
-  if (array_key_exists('TripalEntity', $entity_info)) {
-    // Dynamically add in the bundles. Bundles are alternative groups of fields
-    // or configuration associated with an entity type .We want to dynamically
-    // add the bundles to the entity.
-    $bundles = db_select('tripal_bundle', 'tb')
-      ->fields('tb')
-      ->execute();
-    while ($bundle = $bundles->fetchObject()) {
-      $bundle_name = $bundle->name;
-      $term_id = $bundle->term_id;
-      $term = entity_load('TripalTerm', array('id' => $term_id));
-      $term = reset($term);
-      $label = preg_replace('/_/', ' ', ucwords($term->name));
-
-      $entity_info['TripalEntity']['bundles'][$bundle_name] = array (
-        'label' => $label,
-        'admin' => array (
-          'path' => 'admin/structure/bio_data/manage/%TripalBundle',
-          'real path' => 'admin/structure/bio_data/manage/' . $bundle_name,
-          'bundle argument' => 4,
-          'access arguments' => array (
-            'administer tripal data types'
-          )
-        )
-      );
-    }
-  }
-}
 
 /**
  * Menu argument loader; Load a tripal data type by string.

+ 168 - 8
tripal_chado/includes/tripal_chado.entity.inc

@@ -79,22 +79,21 @@ function tripal_chado_entity_load($entities, $type) {
   }
 }
 
-/**
- * Implements hook_field_attach_form().
- */
-function tripal_chado_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) { }
-
 /**
  *
  * Implements hook_entity_insert().
  */
-function tripal_chado_entity_insert($entity, $type) { }
+function tripal_chado_entity_insert($entity, $type) {
+
+}
 
 /**
  *
  * Implements hook_entity_update().
  */
-function tripal_chado_entity_update($entity, $type) { }
+function tripal_chado_entity_update($entity, $type) {
+
+}
 
 /**
  *
@@ -170,7 +169,7 @@ function tripal_chado_tripal_default_title_format($entity, $available_tokens) {
   // For organism titles  we want the genus and species with no comma separation.
   if ($table == 'organism') {
     $format[] = array(
-      'format' => '[organism__genus] [organism__species]',
+      'format' => '[organism.genus] [organism.species]',
       'weight' => -5
     );
   }
@@ -193,4 +192,165 @@ function tripal_chado_tripal_default_title_format($entity, $available_tokens) {
     );
   }
   return $format;
+}
+
+/**
+ * Implements hook_entity_property_info_alter().
+ *
+ * This is being implemented to ensure chado fields are exposed for search api
+ * indexing. All fields are available for index by default but the getter
+ * function set by default is not actually capable of getting the value from
+ * chado. Thus we change the getter function to one that can :-).
+ */
+function tripal_chado_entity_property_info_alter(&$info) {
+
+  // Get a list of fields with the chado storage backend.
+
+  // Loop through all of the bundles.
+  if (isset($info['TripalEntity']['bundles'])) {
+    foreach ($info['TripalEntity']['bundles'] as $bundle_id => $bundle) {
+      // Loop through each of the fields for a given bundle.
+      foreach ($bundle['properties'] as $field_name => $field_info) {
+        // If the field is a chado field, then change the callback.
+        // @todo check this properly.
+        if (preg_match('/(\w+)__(\w+)/', $field_name, $matches)) {
+          $info['TripalEntity']['bundles'][$bundle_id]['properties'][$field_name]['getter callback'] =
+          'tripal_chado_entity_property_get_value';
+        }
+      }
+    }
+  }
+
+}
+
+/**
+ * Provides a way for the search api to grab the value of a chado field.
+ *
+ * @param $entity
+ *   The fully-loaded entity object to be indexed.
+ * @param $options
+ *   Options that can be ued when retrieving the value.
+ * @param $field_name
+ *   The machine name of the field we want to retrieve.
+ * @param $entity_type
+ *   The type of entity (ie: TripalEntity).
+ *
+ * @return
+ *   The rendered value of the field specified by $field_name.
+ */
+function tripal_chado_entity_property_get_value($entity, $options, $field_name, $entity_type) {
+
+  $display = array(
+    'type' => '',
+    'label' => 'hidden',
+  );
+
+  $langcode = LANGUAGE_NONE;
+  $items = field_get_items($entity_type, $entity, $field_name);
+  if (count($items) == 1) {
+    $render_array = field_view_value($entity_type, $entity, $field_name, $items[0], $display, $langcode);
+  }
+  // @todo: handle fields with multiple values.
+  else {
+    $render_array = field_view_value($entity_type, $entity, $field_name, $items[0], $display, $langcode);
+    drupal_set_message('Tripal Chado currently only supports views integration for single value fields. The first value has been shown.', 'warning');
+  }
+
+  return drupal_render($render_array);
+}
+
+/**
+ * Implements hook_entity_view().
+ */
+function tripal_chado_entity_view($entity, $type, $view_mode, $langcode) {
+
+  // If this entity is a TripalEntity and is a full view, then
+  // we want to support the legacy view, but only if the legacy
+  // module is enabled (the functions exist).
+  if ($type =='TripalEntity') {
+    // Use the generic template to render the fields
+    if ($view_mode == 'full') {
+
+      // Get the Chado table for this data type.
+      $bundle = tripal_load_bundle_entity(array('name' => $entity->bundle));
+      $chado_table = tripal_get_bundle_variable('chado_table', $bundle->id);
+      $chado_field = tripal_get_bundle_variable('chado_column', $bundle->id);
+
+      // Get the list of templates that should be used for entities and generatte
+      // the key in the array for this entity type (using the chado table the
+      // entity maps to).
+      $enabled_templates = variable_get('tripal_chado_enabled_legacy_templates', array());
+      $legacy_template = 'legacy_template--chado_' . $chado_table;
+
+      // If the site admin has indicated that thhis entity type should use
+      // a legacy tmplate then prepare the entity and content to fake a
+      // node.
+      if (key_exists($legacy_template, $enabled_templates) && $enabled_templates[$legacy_template]) {
+        // Remove the fields added by the chado_field_storage.
+        $fields = field_info_fields();
+        foreach($fields as $field) {
+          if ($field['storage']['type'] == 'field_chado_storage' or
+              $field['storage']['type'] == 'tripal_no_storage') {
+                $field_name = $field['field_name'];
+                if (property_exists($entity, $field_name)) {
+                  $entity->$field_name = NULL;
+                  unset($entity->content[$field_name]);
+                }
+              }
+        }
+
+        // Make the entity look like a node.
+        $entity->type = 'chado_' . $chado_table;
+        $entity->$chado_table = $entity->chado_record;
+
+        // Add any node specific fields to the entity to fake the node.
+        $node_schema = drupal_get_schema('node');
+        foreach ($node_schema['fields'] as $field_name => $details) {
+          if (!property_exists($entity, $field_name)) {
+            $entity->$field_name = '';
+            if (array_key_exists('default', $details)) {
+              $entity->$field_name = $details['default'];
+            }
+          }
+        }
+
+        // Now call the module's node_view hook to add additional
+        // content to our 'fake' entity node.
+        $modules = module_list();
+        foreach ($modules as $mname => $details) {
+          $function_name = $mname . '_node_view';
+          if (function_exists($function_name)) {
+            $function_name($entity, $view_mode, $langcode);
+          }
+        }
+      }
+    }
+  }
+}
+
+/**
+ * Implements hook_entity_view_alter().
+ *
+ * This function is used to support legacy Tripal v2 templates
+ * for use with Tripal v3 entities.
+ */
+function tripal_chado_entity_view_alter(&$build) {
+  // For the legacy support, we need to make sure the TOC
+  // is built.
+  if ($build['#entity_type'] == 'TripalEntity') {
+    $enabled_templates = variable_get('tripal_chado_enabled_legacy_templates', array());
+    $entity = $build['#entity'];
+    $legacy_template = 'legacy_template--' . $entity->type;
+    if (key_exists($legacy_template, $enabled_templates) && $enabled_templates[$legacy_template]) {
+      $build['#entity']->nid = NULL;
+      $build['#node'] = $build['#entity'];
+      $modules = module_list();
+      foreach ($modules as $mname => $details) {
+        $function_name = $mname . '_node_view_alter';
+        if (function_exists($function_name)) {
+          $function_name($build);
+        }
+      }
+    }
+  }
 }

+ 0 - 159
tripal_chado/tripal_chado.module

@@ -601,102 +601,6 @@ function tripal_chado_theme($existing, $type, $theme, $path) {
   return $themes;
 }
 
-/**
- * Implements hook_entity_view().
- */
-function tripal_chado_entity_view($entity, $type, $view_mode, $langcode) {
-
-  // If this entity is a TripalEntity and is a full view, then
-  // we want to support the legacy view, but only if the legacy
-  // module is enabled (the functions exist).
-  if ($type =='TripalEntity') {
-    // Use the generic template to render the fields
-    if ($view_mode == 'full') {
-
-      // Get the Chado table for this data type.
-      $bundle = tripal_load_bundle_entity(array('name' => $entity->bundle));
-      $chado_table = tripal_get_bundle_variable('chado_table', $bundle->id);
-      $chado_field = tripal_get_bundle_variable('chado_column', $bundle->id);
-
-      // Get the list of templates that should be used for entities and generatte
-      // the key in the array for this entity type (using the chado table the
-      // entity maps to).
-      $enabled_templates = variable_get('tripal_chado_enabled_legacy_templates', array());
-      $legacy_template = 'legacy_template--chado_' . $chado_table;
-
-      // If the site admin has indicated that thhis entity type should use
-      // a legacy tmplate then prepare the entity and content to fake a
-      // node.
-      if (key_exists($legacy_template, $enabled_templates) && $enabled_templates[$legacy_template]) {
-        // Remove the fields added by the chado_field_storage.
-        $fields = field_info_fields();
-        foreach($fields as $field) {
-          if ($field['storage']['type'] == 'field_chado_storage' or
-              $field['storage']['type'] == 'tripal_no_storage') {
-            $field_name = $field['field_name'];
-            if (property_exists($entity, $field_name)) {
-              $entity->$field_name = NULL;
-              unset($entity->content[$field_name]);
-            }
-          }
-        }
-
-        // Make the entity look like a node.
-        $entity->type = 'chado_' . $chado_table;
-        $entity->$chado_table = $entity->chado_record;
-
-        // Add any node specific fields to the entity to fake the node.
-        $node_schema = drupal_get_schema('node');
-        foreach ($node_schema['fields'] as $field_name => $details) {
-          if (!property_exists($entity, $field_name)) {
-            $entity->$field_name = '';
-            if (array_key_exists('default', $details)) {
-              $entity->$field_name = $details['default'];
-            }
-          }
-        }
-
-        // Now call the module's node_view hook to add additional
-        // content to our 'fake' entity node.
-        $modules = module_list();
-        foreach ($modules as $mname => $details) {
-          $function_name = $mname . '_node_view';
-          if (function_exists($function_name)) {
-            $function_name($entity, $view_mode, $langcode);
-          }
-        }
-      }
-    }
-  }
-}
-
-/**
- * Implements hook_entity_view_alter().
- *
- * This function is used to support legacy Tripal v2 templates
- * for use with Tripal v3 entities.
- */
-function tripal_chado_entity_view_alter(&$build) {
-  // For the legacy support, we need to make sure the TOC
-  // is built.
-  if ($build['#entity_type'] == 'TripalEntity') {
-    $enabled_templates = variable_get('tripal_chado_enabled_legacy_templates', array());
-    $entity = $build['#entity'];
-    $legacy_template = 'legacy_template--' . $entity->type;
-    if (key_exists($legacy_template, $enabled_templates) && $enabled_templates[$legacy_template]) {
-      $build['#entity']->nid = NULL;
-      $build['#node'] = $build['#entity'];
-      $modules = module_list();
-      foreach ($modules as $mname => $details) {
-        $function_name = $mname . '_node_view_alter';
-        if (function_exists($function_name)) {
-          $function_name($build);
-        }
-      }
-    }
-  }
-}
-
 /**
  * Implements hook_preprocess().
  *
@@ -777,70 +681,7 @@ function tripal_chado_job_describe_args($callback, $args) {
   return $new_args;
 }
 
-/**
- * Implements hook_entity_property_info_alter().
- *
- * This is being implemented to ensure chado fields are exposed for search api indexing.
- * All fields are available for index by default but the getter function set by default
- * is not actually capable of getting the value from chado. Thus we change the getter
- * function to one that can :-).
- */
-function tripal_chado_entity_property_info_alter(&$info) {
-
-  // Get a list of fields with the chado storage backend.
-
-  // Loop through all of the bundles.
-  if (isset($info['TripalEntity']['bundles'])) {
-    foreach ($info['TripalEntity']['bundles'] as $bundle_id => $bundle) {
-      // Loop through each of the fields for a given bundle.
-      foreach ($bundle['properties'] as $field_name => $field_info) {
-        // If the field is a chado field, then change the callback.
-        // @todo check this properly.
-        if (preg_match('/(\w+)__(\w+)/', $field_name, $matches)) {
-          $info['TripalEntity']['bundles'][$bundle_id]['properties'][$field_name]['getter callback'] =
-            'tripal_chado_entity_property_get_value';
-        }
-      }
-    }
-  }
-
-}
-
-/**
- * Provides a way for the search api to grab the value of a chado field.
- *
- * @param $entity
- *   The fully-loaded entity object to be indexed.
- * @param $options
- *   Options that can be ued when retrieving the value.
- * @param $field_name
- *   The machine name of the field we want to retrieve.
- * @param $entity_type
- *   The type of entity (ie: TripalEntity).
- *
- * @return
- *   The rendered value of the field specified by $field_name.
- */
-function tripal_chado_entity_property_get_value($entity, $options, $field_name, $entity_type) {
 
-  $display = array(
-    'type' => '',
-    'label' => 'hidden',
-  );
-
-  $langcode = LANGUAGE_NONE;
-  $items = field_get_items($entity_type, $entity, $field_name);
-  if (count($items) == 1) {
-    $render_array = field_view_value($entity_type, $entity, $field_name, $items[0], $display, $langcode);
-  }
-  // @todo: handle fields with multiple values.
-  else {
-    $render_array = field_view_value($entity_type, $entity, $field_name, $items[0], $display, $langcode);
-    drupal_set_message('Tripal Chado currently only supports views integration for single value fields. The first value has been shown.', 'warning');
-  }
-
-  return drupal_render($render_array);
-}
 
 /**
  * Remove the nid from chado_entity if it exists when the node is deleted