Browse Source

incremental checkin

Stephen Ficklin 9 years ago
parent
commit
833434d7fa
32 changed files with 1045 additions and 981 deletions
  1. 0 0
      tripal/api/tripal.entities.api.inc
  2. 0 0
      tripal/includes/TripalBundle.inc
  3. 0 0
      tripal/includes/TripalBundleController.inc
  4. 14 14
      tripal/includes/TripalBundleUIController.inc
  5. 0 0
      tripal/includes/TripalEntity.inc
  6. 1 1
      tripal/includes/TripalEntityController.inc
  7. 32 32
      tripal/includes/TripalEntityUIController.inc
  8. 0 0
      tripal/includes/TripalTerm.inc
  9. 1 1
      tripal/includes/TripalTermController.inc
  10. 0 0
      tripal/includes/TripalVocab.inc
  11. 1 1
      tripal/includes/TripalVocabController.inc
  12. 0 0
      tripal/includes/tripal.admin.inc
  13. 0 0
      tripal/theme/templates/tripal_data.tpl.php
  14. 1 0
      tripal/tripal.info
  15. 387 5
      tripal/tripal.install
  16. 438 14
      tripal/tripal.module
  17. 8 0
      tripal_chado/api/tripal_chado.schema_v1.11.api.inc
  18. 0 0
      tripal_chado/files/cv_property.obo
  19. 0 0
      tripal_chado/includes/tripal_chado.chado_install.inc
  20. 0 0
      tripal_chado/includes/tripal_chado.custom_tables.inc
  21. 0 0
      tripal_chado/includes/tripal_chado.mviews.inc
  22. 0 27
      tripal_chado/includes/tripal_chado.schema.inc
  23. 1 1
      tripal_chado/tripal_chado.info
  24. 157 2
      tripal_chado/tripal_chado.install
  25. 1 1
      tripal_chado/tripal_chado.module
  26. 0 10
      tripal_entities/tripal_entities.info
  27. 0 397
      tripal_entities/tripal_entities.install
  28. 0 470
      tripal_entities/tripal_entities.module
  29. 0 2
      tripal_entities/tripal_entities.views_default.inc
  30. 1 1
      tripal_fields_layout/tripal_fields_layout.info
  31. 1 1
      tripal_fields_layout/tripal_fields_layout.install
  32. 1 1
      tripal_ws/tripal_ws.info

+ 0 - 0
tripal_entities/api/tripal_entities.api.inc → tripal/api/tripal.entities.api.inc


+ 0 - 0
tripal_entities/includes/TripalBundle.inc → tripal/includes/TripalBundle.inc


+ 0 - 0
tripal_entities/includes/TripalBundleController.inc → tripal/includes/TripalBundleController.inc


+ 14 - 14
tripal_entities/includes/TripalBundleUIController.inc → tripal/includes/TripalBundleUIController.inc

@@ -31,10 +31,10 @@ class TripalBundleUIController extends EntityDefaultUIController {
       'title' => 'Add Tripal Content Type',
       'description' => 'Add new biological content',
       'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_entities_admin_add_type_form'),
+      'page arguments' => array('tripal_admin_add_type_form'),
       'access arguments' => array('administer tripal data types'),
-      'file' =>  'includes/tripal_entities.admin.inc',
-      'file path' => drupal_get_path('module', 'tripal_entities'),
+      'file' =>  'includes/tripal.admin.inc',
+      'file path' => drupal_get_path('module', 'tripal'),
       'type' => MENU_LOCAL_ACTION,
       'weight' => 2
     );
@@ -52,7 +52,7 @@ class TripalBundleUIController extends EntityDefaultUIController {
     // named after the entity type but we can't dynamically create these
     // functions. We'll use a single form for all entity types.
     $forms[$this->entityType . '_form'] = array(
-      'callback' => 'tripal_entities_tripal_bundle_form',
+      'callback' => 'tripal_tripal_bundle_form',
       'callback arguments' => array($this->entityType)
     );
 
@@ -71,7 +71,7 @@ class TripalBundleUIController extends EntityDefaultUIController {
  * @param $entityDataType
  *    A string indicating the entity type. This will always be TripalBundle.
  */
-function tripal_entities_tripal_bundle_form($form, &$form_state, $entityDataType) {
+function tripal_tripal_bundle_form($form, &$form_state, $entityDataType) {
 
   $entity_type = $form_state['build_info']['args'][0];
   $term = NULL;
@@ -84,8 +84,8 @@ function tripal_entities_tripal_bundle_form($form, &$form_state, $entityDataType
   }
 
   // Add a validate and submit handler to save the data in this form.
-  $form['#validate'] = array('tripal_entities_tripal_bundle_form_validate');
-  $form['#submit'] = array('tripal_entities_tripal_bundle_form_submit');
+  $form['#validate'] = array('tripal_tripal_bundle_form_validate');
+  $form['#submit'] = array('tripal_tripal_bundle_form_submit');
 
   // @TODO: Move this into a css file.
   $form['#attached']['css'] = array(
@@ -268,7 +268,7 @@ function tripal_entities_tripal_bundle_form($form, &$form_state, $entityDataType
 /**
  * Validate: Tripal content type edit form.
  */
-function tripal_entities_tripal_bundle_form_validate($form, $form_state) {
+function tripal_tripal_bundle_form_validate($form, $form_state) {
 
   // VALIDATE: The only tokens used should be those we mentioned under "Available Tokens".
   // PART 1: Set Titles.
@@ -321,7 +321,7 @@ function tripal_entities_tripal_bundle_form_validate($form, $form_state) {
 /**
  * Submit: Tripal content type edit form.
  */
-function tripal_entities_tripal_bundle_form_submit($form, &$form_state) {
+function tripal_tripal_bundle_form_submit($form, &$form_state) {
 
   $bundle_entity = $form_state['build_info']['args'][0];
 
@@ -372,7 +372,7 @@ function tripal_bundle_access($op, $type = NULL, $account = NULL) {
  * implements the hook_vocab_storage_info() hook.
  *
  */
-function tripal_entities_admin_add_type_form($form, &$form_state) {
+function tripal_admin_add_type_form($form, &$form_state) {
 
   // TODO: we need some sort of administrative interface that lets the user
   // switch to the desired vocabulary type. For now, we'll just use the
@@ -395,10 +395,10 @@ function tripal_entities_admin_add_type_form($form, &$form_state) {
   return $form;
 }
 /**
- * Implements hook_validate() for the tripal_entities_admin_add_type_form.
+ * Implements hook_validate() for the tripal_admin_add_type_form.
  *
  */
-function tripal_entities_admin_add_type_form_validate($form, &$form_state) {
+function tripal_admin_add_type_form_validate($form, &$form_state) {
   // TODO: we need some sort of administrative interface that lets the user
   // switch to the desired vocabulary type. For now, we'll just use the
   // first one in the list.
@@ -413,12 +413,12 @@ function tripal_entities_admin_add_type_form_validate($form, &$form_state) {
   }
 }
 /**
- * Implements hook_submit() for the tripal_entities_admin_add_type_form.
+ * Implements hook_submit() for the tripal_admin_add_type_form.
  *
  * The storage backend must set the
  *
  */
-function tripal_entities_admin_add_type_form_submit($form, &$form_state) {
+function tripal_admin_add_type_form_submit($form, &$form_state) {
   $namespace = '';
   $accession = '';
   if (array_key_exists('storage', $form_state)) {

+ 0 - 0
tripal_entities/includes/TripalEntity.inc → tripal/includes/TripalEntity.inc


+ 1 - 1
tripal_entities/includes/TripalEntityController.inc → tripal/includes/TripalEntityController.inc

@@ -86,7 +86,7 @@ class TripalEntityController extends EntityAPIController {
     }
     catch (Exception $e) {
       $transaction->rollback();
-      watchdog_exception('tripal_entities', $e);
+      watchdog_exception('tripal', $e);
       throw $e;
       return FALSE;
     }

+ 32 - 32
tripal_entities/includes/TripalEntityUIController.inc → tripal/includes/TripalEntityUIController.inc

@@ -19,9 +19,9 @@ class TripalEntityUIController extends EntityDefaultUIController {
     // The content menu.
     $items[$this->path] = array(
       'title' => 'Tripal Content',
-      'page callback' => 'tripal_entities_content_view',
-      'file' =>  'includes/tripal_entities.admin.inc',
-      'file path' => drupal_get_path('module', 'tripal_entities'),
+      'page callback' => 'tripal_content_view',
+      'file' =>  'includes/tripal.admin.inc',
+      'file path' => drupal_get_path('module', 'tripal'),
       'access arguments' => array('administer tripal data'),
       'type' => MENU_LOCAL_TASK,
       'weight' => -9
@@ -29,7 +29,7 @@ class TripalEntityUIController extends EntityDefaultUIController {
 
     $items['bio-data/add'] = array(
       'title' => 'Add Tripal Content',
-      'page callback' => 'tripal_entities_add_page',
+      'page callback' => 'tripal_add_page',
       'access arguments' => array('administer tripal data'),
     );
 
@@ -47,8 +47,8 @@ class TripalEntityUIController extends EntityDefaultUIController {
           'title' => ucfirst($bundle->label),
           'description' => tripal_get_bundle_variable('description', $bundle->id, $term->definition),
           'page callback'  => 'drupal_get_form',
-          'page arguments' => array('tripal_entities_entity_form', 2),
-          'access callback'  => 'tripal_entities_entity_access',
+          'page arguments' => array('tripal_entity_form', 2),
+          'access callback'  => 'tripal_entity_access',
           'access arguments' => array('edit'),
         );
       }
@@ -56,11 +56,11 @@ class TripalEntityUIController extends EntityDefaultUIController {
 
     // Link for viewing a tripal data type.
     $items['bio-data/' . $wildcard] = array(
-      'title callback' => 'tripal_entities_entity_title',
+      'title callback' => 'tripal_entity_title',
       'title arguments' => array(1),
-      'page callback' => 'tripal_entities_view_entity',
+      'page callback' => 'tripal_view_entity',
       'page arguments' => array(1),
-      'access callback' => 'tripal_entities_entity_access',
+      'access callback' => 'tripal_entity_access',
       'access arguments' => array('view', 1),
       'type' => MENU_CALLBACK,
     );
@@ -68,9 +68,9 @@ class TripalEntityUIController extends EntityDefaultUIController {
     // 'View' tab for an individual entity page.
     $items['bio-data/' . $wildcard . '/view'] = array(
       'title' => 'View',
-      'page callback' => 'tripal_entities_view_entity',
+      'page callback' => 'tripal_view_entity',
       'page arguments' => array(1),
-      'access callback' => 'tripal_entities_entity_access',
+      'access callback' => 'tripal_entity_access',
       'access arguments' => array('view', 1),
       'type' => MENU_DEFAULT_LOCAL_TASK,
       'weight' => -10,
@@ -80,8 +80,8 @@ class TripalEntityUIController extends EntityDefaultUIController {
     $items['bio-data/' . $wildcard . '/edit'] = array(
       'title' => 'Edit',
       'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_entities_entity_form', NULL, 1),
-      'access callback' => 'tripal_entities_entity_access',
+      'page arguments' => array('tripal_entity_form', NULL, 1),
+      'access callback' => 'tripal_entity_access',
       'access arguments' => array('edit', 1),
       'type' => MENU_LOCAL_TASK,
       'weight' => -8,
@@ -91,8 +91,8 @@ class TripalEntityUIController extends EntityDefaultUIController {
     $items['bio-data/' . $wildcard . '/delete'] = array(
       'title'  => 'Delete',
       'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_entities_entity_delete_form', 1),
-      'access callback' => 'tripal_entities_entity_access',
+      'page arguments' => array('tripal_entity_delete_form', 1),
+      'access callback' => 'tripal_entity_access',
       'access arguments' => array('edit', 1),
       'type' => MENU_CALLBACK,
       'weight' => 10,
@@ -120,7 +120,7 @@ function tripal_entity_manage_fields($entity) {
  * @see hook_entity_view()
  * @see hook_entity_view_alter()
  */
-function tripal_entities_view_entity($entity, $view_mode = 'full') {
+function tripal_view_entity($entity, $view_mode = 'full') {
    $content = '';
    $controller = entity_get_controller($entity->type);
    $content = $controller->view(array($entity->id => $entity));
@@ -134,10 +134,10 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
   * This function is a callback in a menu item which is set in the
   * TripalEntityUIController class.
   */
- function tripal_entities_content_view() {
+ function tripal_content_view() {
 
    // Retrieve our data listing form and render it.
-   $form = drupal_get_form('tripal_entities_content_overview_form');
+   $form = drupal_get_form('tripal_content_overview_form');
    $output = drupal_render($form);
 
    // Set the breadcrumb.
@@ -160,7 +160,7 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
   * @return
   *   A form array describing this listing to the Form API.
   */
- function tripal_entities_content_overview_form($form, &$form_state) {
+ function tripal_content_overview_form($form, &$form_state) {
 
    // Set the title to be informative (defaults to content for some reason).
    drupal_set_title('Tripal Content');
@@ -233,7 +233,7 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
  /**
   *
   */
- function tripal_entities_entity_form($form, &$form_state, $term_id = '', $entity = NULL) {
+ function tripal_entity_form($form, &$form_state, $term_id = '', $entity = NULL) {
 
    $bundle_name = 'bio-data_' . $term_id;
 
@@ -281,17 +281,17 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
 
  }
  /**
-  * An Ajax callback for the tripal_entities_entity_form.
+  * An Ajax callback for the tripal_entity_form.
   */
- function tripal_entities_entity_form_ajax_callback($form, $form_state) {
+ function tripal_entity_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 tripal_entities_entity_form.
+  * Implements hook_validate() for the tripal_entity_form.
   */
- function tripal_entities_entity_form_validate($form, &$form_state) {
+ function tripal_entity_form_validate($form, &$form_state) {
 
    if (array_key_exists('clicked_button', $form_state) and
        $form_state['clicked_button']['#name'] =='add_data') {
@@ -302,9 +302,9 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
 
 
  /**
-  * Implements hook_submit() for the tripal_entities_entity_form.
+  * Implements hook_submit() for the tripal_entity_form.
   */
- function tripal_entities_entity_form_submit($form, &$form_state) {
+ function tripal_entity_form_submit($form, &$form_state) {
    $entity = $form_state['TripalEntity'];
 
    if ($form_state['clicked_button']['#name'] =='cancel') {
@@ -334,7 +334,7 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
   * This function is a callback in a menu item which is set in the
   * TripalEntityUIController class.
   */
- function tripal_entities_add_page() {
+ function tripal_add_page() {
    $item = menu_get_item();
 
    $content = system_admin_menu_block($item);
@@ -344,7 +344,7 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
      $item = array_shift($content);
      drupal_goto($item['href']);
    }
-   return theme('tripal_entities_add_list', array('content' => $content));
+   return theme('tripal_add_list', array('content' => $content));
 
  }
 
@@ -357,7 +357,7 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
   *
   * @ingroup themeable
   */
- function theme_tripal_entities_add_list($variables) {
+ function theme_tripal_add_list($variables) {
    $content = $variables['content'];
    $output = '';
 
@@ -391,9 +391,9 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
   *
   * @see confirm_form()
   */
- function tripal_entities_entity_delete_form($form, &$form_state, $entity) {
+ function tripal_entity_delete_form($form, &$form_state, $entity) {
    $form_state['entity'] = $entity;
-   $form['#submit'][] = 'tripal_entities_entity_delete_form_submit';
+   $form['#submit'][] = 'tripal_entity_delete_form_submit';
 
    $form = confirm_form($form,
        t('Click the delete button below to confirm deletion of the record titled: %title',
@@ -406,7 +406,7 @@ function tripal_entities_view_entity($entity, $view_mode = 'full') {
  /**
   * Submit callback for tripal_entity_delete_form
   */
- function tripal_entities_entity_delete_form_submit($form, &$form_state) {
+ function tripal_entity_delete_form_submit($form, &$form_state) {
    $entity = $form_state['entity'];
 
    $entity_controller = new TripalEntityController($entity->type);

+ 0 - 0
tripal_entities/includes/TripalTerm.inc → tripal/includes/TripalTerm.inc


+ 1 - 1
tripal_entities/includes/TripalTermController.inc → tripal/includes/TripalTermController.inc

@@ -31,7 +31,7 @@ class TripalTermController extends EntityAPIController {
     }
     catch (Exception $e) {
       $transaction->rollback();
-      watchdog_exception('tripal_entities', $e);
+      watchdog_exception('tripal', $e);
       throw $e;
       return FALSE;
     }

+ 0 - 0
tripal_entities/includes/TripalVocab.inc → tripal/includes/TripalVocab.inc


+ 1 - 1
tripal_entities/includes/TripalVocabController.inc → tripal/includes/TripalVocabController.inc

@@ -34,7 +34,7 @@ class TripalVocabController extends EntityAPIController {
     }
     catch (Exception $e) {
       $transaction->rollback();
-      watchdog_exception('tripal_entities', $e);
+      watchdog_exception('tripal', $e);
       throw $e;
       return FALSE;
     }

+ 0 - 0
tripal_entities/includes/tripal_entities.admin.inc → tripal/includes/tripal.admin.inc


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


+ 1 - 0
tripal/tripal.info

@@ -13,3 +13,4 @@ dependencies[] = views
 dependencies[] = path
 dependencies[] = search
 dependencies[] = php
+dependencies[] = entity

+ 387 - 5
tripal/tripal.install

@@ -11,6 +11,44 @@
  */
 function tripal_install() {
 
+  // Add tripal bundle variables needed for storing additional settings for Tripal Bundles.
+  tripal_insert_variable('title_format', 'A pattern including tokens that can be used to generate tripal entity titles.');
+  tripal_insert_variable('url_format', 'A pattern including tokens that can be used to generate tripal entity url aliases.');
+  tripal_insert_variable('description', 'The description of a Tripal Entity type/bundle.');
+
+}
+
+function tripal_uninstall() {
+  /*
+   // So somehow I was able to uninstall this module without deleting the bundles. This
+   // caused aweful errors because fields weren't deleted so when I re-installed, the code
+   // tried to create fields that were inactive (despite checking if the field exists
+   // before creating). The following code was meant to ensure that all content was deleted
+   // before uninstall so these errors would not occur. Unfortunatly I am now unable to
+   // test this because the Field API module is disabling uninstall of Tripal Chado until
+   // all the content is deleted. Thus ensuring the errors described above don't occur.
+   // But I'm Sure I was able to uninstall with content before...
+   // **I am slowly going crazy; Crazy going slowly am I**
+   // Anyway, I'll leaving the solution code here in case I am able to repeat it in
+   // the future.
+   // @see https://www.drupal.org/node/1262092
+   // @see https://www.drupal.org/node/1861710
+
+   // First delete all TripalEntities.
+   $entity_ids = (new EntityFieldQuery)->entityCondition("entity_type", "TripalEntity")->execute();
+   $entity_ids = reset($entity_ids);
+   entity_delete_multiple("TripalEntity", array_keys($entity_ids));
+
+   // Then delete all TripalBundles.
+   $bundle_ids = (new EntityFieldQuery)->entityCondition("entity_type", "TripalBundle")->execute();
+   $bundle_ids = reset($bundle_ids);
+   entity_delete_multiple("TripalBundle", array_keys($bundle_ids));
+
+   // @TODO: Should we delete all TripalVocabularies and TripalTerms?
+
+   // Finally purge all fields that are no longer used.
+   field_purge_batch(100);
+   */
 }
 /**
  * Implementation of hook_schema().
@@ -19,7 +57,25 @@ function tripal_install() {
  */
 function tripal_schema() {
   $schema = array();
-  $schema['tripal_jobs'] = array(
+
+  $schema['tripal_jobs'] = tripal_tripal_jobs_schema();
+  $schema['tripal_token_formats'] = tripal_tripal_token_formats_schema();
+  $schema['tripal_variables'] = tripal_tripal_variables_schema();
+
+
+  // Adds a table for managing TripalEntity entities.
+  $schema['tripal_vocab'] = tripal_tripal_vocab_schema();
+  $schema['tripal_term'] = tripal_tripal_term_schema();
+  $schema['tripal_entity'] = tripal_tripal_entity_schema();
+  $schema['tripal_bundle'] = tripal_tripal_bundle_schema();
+
+  // Adds a table for additional information related to bundles.
+  $schema['tripal_bundle_variables'] = tripal_tripal_bundle_variables_schema();
+
+  return $schema;
+}
+function tripal_tripal_jobs_schema() {
+  return array(
     'fields' => array(
       'job_id' => array(
         'type' => 'serial',
@@ -117,8 +173,9 @@ function tripal_schema() {
     ),
     'primary key' => array('job_id'),
   );
-
-  $schema['tripal_token_formats'] = array(
+}
+function tripal_tripal_token_formats_schema() {
+  return array(
     'fields' => array(
       'tripal_format_id' => array(
         'type' => 'serial',
@@ -149,9 +206,10 @@ function tripal_schema() {
     ),
     'primary key' => array('tripal_format_id'),
   );
+}
+function tripal_tripal_variables_schema() {
 
-
-  $schema['tripal_variables'] = array(
+   return array(
     'description' => 'This table houses a list of unique variable names that ' .
       'can be used in the tripal_node_variables table.',
     'fields' => array(
@@ -186,3 +244,327 @@ function tripal_schema() {
 
   return $schema;
 }
+/**
+ * @section
+ * Schema Definitions.
+ */
+
+/**
+ * The base table for Biological Data Entities.
+ *
+ * This contains the actual data. For example, if you have a 5 genes and 10 mRNA then
+ * this table will have 15 records and include both genes and mRNA's.
+ */
+function tripal_tripal_entity_schema() {
+
+  $schema = array(
+    'description' => 'The base table for Tripal Vocabulary-based entities.',
+    'fields' => array(
+      'id' => array(
+        'description' => 'The primary identifier for a vocabulary entity.',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'type' => array(
+        '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' => '',
+      ),
+      'term_id' => array(
+        'description' => 'The term_id for the type of entity. This term_id corresponds to a TripalTerm record.',
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'title' => array(
+        'description' => 'The title of this node, always treated as non-markup plain text.',
+        'type' => 'text',
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'uid' => array(
+        'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'status' => array(
+        'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 1,
+      ),
+      'created' => array(
+        'description' => 'The Unix timestamp when the node was created.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'changed' => array(
+        'description' => 'The Unix timestamp when the node was most recently saved.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'indexes' => array(
+      'term_id' => array('term_id'),
+      'entity_changed' => array('changed'),
+      'entity_created' => array('created'),
+      'type' => array('type'),
+      'uid' => array('uid'),
+    ),
+    'unique keys' => array(),
+    'primary key' => array('id'),
+  );
+  return $schema;
+}
+
+/**
+ * The base table for TripalVocab schema.
+ *
+ * This contains the actual data. For example, if you have a 5 genes and 10 mRNA then
+ * this table will have 15 records and include both genes and mRNA's.
+ */
+function tripal_tripal_vocab_schema() {
+
+  // This schema only provides enough information to assign a unique ID
+  // to the vocabulary. Any additonal information is added to the Entity object
+  // by the selected database back-end.
+  $schema = array(
+    'description' => 'The base table for TripalVocab entities.',
+    'fields' => array(
+      'id' => array(
+        'description' => 'The primary identifier for a vocab entity.',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'namespace' => array(
+        'description' => 'The namespace for the vocabulary (e.g. SO, PATO, etc.).',
+        'type' => 'varchar',
+        'length' => 10,
+        'not null' => TRUE,
+      ),
+      'created' => array(
+        'description' => 'The Unix timestamp when the entity was created.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'changed' => array(
+        'description' => 'The Unix timestamp when the entity was most recently saved.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'indexes' => array(
+      'namespace' => array('namespace'),
+      'entity_changed' => array('changed'),
+      'entity_created' => array('created'),
+    ),
+    'unique keys' => array('namespace' => array('namespace')),
+    'primary key' => array('id'),
+  );
+  return $schema;
+}
+
+/**
+ * The base table for TripalTerm entities.
+ *
+ * This contains the actual data. For example, if you have a 5 genes and 10 mRNA then
+ * this table will have 15 records and include both genes and mRNA's.
+ */
+function tripal_tripal_term_schema() {
+
+  // This schema only provides enough information to assign a unique ID
+  // to the term and associate it to it's vocabulary. Any additonal information
+  // is added to the Entity object by the selected database back-end.
+  $schema = array(
+    'description' => 'The base table for TripalTerm entities.',
+    'fields' => array(
+      'id' => array(
+        'description' => 'The primary identifier for a term entity.',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'vocab_id' => array(
+        'description' => 'The vocabulary_id of the TripalVocab entity to which this term belongs.',
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'accession' => array(
+        'description' => 'The id (or accession) of this term in the vocabulary.',
+        'type' => 'varchar',
+        'length' => 1024,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'name' => array(
+        'description' => 'The human readable name for this term.',
+        'type' => 'varchar',
+        'length' => 1024,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'created' => array(
+        'description' => 'The Unix timestamp when the entity was created.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'changed' => array(
+        'description' => 'The Unix timestamp when the entity was most recently saved.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'indexes' => array(
+      'vocab_id' => array('vocab_id'),
+      'accession' => array('accession'),
+      'entity_changed' => array('changed'),
+      'entity_created' => array('created'),
+    ),
+    'foreign keys' => array(
+      'tripal_vocab' => array(
+        'table' => 'tripal_vocab',
+        'columns' => array(
+          'vocab_id' => 'vocab_id',
+        ),
+      ),
+    ),
+    'unique keys' => array('vocab_term' => array('vocab_id', 'accession')),
+    'primary key' => array('id'),
+  );
+  return $schema;
+}
+
+/**
+ * The base table for TripalEntity entities.
+ *
+ * This table contains a list of Biological Data Types.
+ * For the example above (5 genes and 10 mRNAs), there would only be two records in
+ * this table one for "gene" and another for "mRNA".
+ */
+function tripal_tripal_bundle_schema() {
+
+  $schema = array(
+    'description' => 'Stores information about defined tripal data types.',
+    'fields' => array(
+      'id' => array(
+        'type' => 'serial',
+        'not null' => TRUE,
+        'description' => 'Primary Key: Unique numeric ID.',
+      ),
+      'type' => array(
+        'description' => 'The type of entity (e.g. TripalEntity).',
+        'type' => 'varchar',
+        'length' => 64,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'term_id' => array(
+        'description' => 'The term_id for the type of entity. This term_id corresponds to a TripalTerm record.',
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'name' => array(
+        'description' => 'The name of the 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' => '',
+      ),
+      'label' => array(
+        'description' => 'The human-readable name of this bundle.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+    ),
+    'indexes' => array(
+      'name' => array('name'),
+      'term_id' => array('term_id'),
+    ),
+    'primary key' => array('id'),
+    'unique keys' => array(
+      'name' => array('name'),
+    ),
+  );
+  return $schema;
+}
+
+/**
+ * Additional Tripal Bundle Information.
+ *
+ * This table is used for storing any additonal information describing
+ * a tripal bundle. For example, this is a good place to store title/url formats.
+ */
+function tripal_tripal_bundle_variables_schema() {
+
+  $schema = array(
+    'description' => 'This table is used for storing any additonal information describing
+      a tripal bundle. For example, this is a good place to store title/url formats.',
+    'fields' => array (
+      'bundle_variable_id' => array (
+        'type' => 'serial',
+        'not null' => TRUE,
+      ),
+      'bundle_id' => array (
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'variable_id' => array (
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'value' => array (
+        'type' => 'text',
+        'not null' => FALSE,
+      ),
+      'rank' => array (
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'primary key' => array (
+      0 => 'bundle_variable_id',
+    ),
+    'unique keys' => array (
+      'tripal_bundle_variables_c1' => array (
+        0 => 'bundle_id',
+        1 => 'variable_id',
+        2 => 'rank',
+      ),
+    ),
+    'indexes' => array (
+      'tripal_bundle_variables_idx1' => array (
+        0 => 'variable_id',
+      ),
+    ),
+    'foreign keys' => array (
+      'tripal_variables' => array (
+        'table' => 'tripal_variables',
+        'columns' => array (
+          'variable_id' => 'variable_id',
+        ),
+      ),
+    ),
+  );
+
+  return $schema;
+}

+ 438 - 14
tripal/tripal.module

@@ -5,6 +5,23 @@
  */
 
 require_once "api/tripal.notice.api.inc";
+require_once "api/tripal.entities.api.inc";
+require_once "api/tripal.files.api.inc";
+require_once "api/tripal.jobs.api.inc";
+require_once "api/tripal.notice.api.inc";
+require_once "api/tripal.variables.api.inc";
+
+require_once "includes/TripalVocab.inc";
+require_once "includes/TripalVocabController.inc";
+require_once "includes/TripalTerm.inc";
+require_once "includes/TripalTermController.inc";
+require_once "includes/TripalEntity.inc";
+require_once "includes/TripalEntityController.inc";
+require_once "includes/TripalEntityUIController.inc";
+require_once "includes/TripalBundle.inc";
+require_once "includes/TripalBundleController.inc";
+require_once "includes/TripalBundleUIController.inc";
+
 
 /**
  * @defgroup tripal Tripal Core Module
@@ -15,6 +32,14 @@ require_once "api/tripal.notice.api.inc";
  * @}
  */
 
+/**
+ * Implements hook_views_api().
+ */
+function tripal_views_api() {
+  return array(
+    'api' => 3,
+  );
+}
 
 /**
  * Implements hook_init().
@@ -154,6 +179,13 @@ function tripal_menu() {
     'type' => MENU_CALLBACK,
   );
 
+  $items['admin/structure/bio-data/term/%'] = array(
+    'page callback' => 'tripal_autocomplete_term',
+    'page arguments' => array(6, 7),
+    'access arguments' => array('administer content'),
+    'type' => MENU_CALLBACK,
+  );
+
   return $items;
 }
 
@@ -174,9 +206,25 @@ function tripal_permission() {
           be disabled once developers are accustomed to these hints.'),
       'restrict access' => TRUE,
     ),
+    '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 tripal data' => array(
+      'title' => t('Administer Tripal data'),
+      'description' => t('Edit and delete all tripal data'),
+    ),
   );
 }
 
+/**
+ * Checks access permissions for a given entity.
+ */
+function tripal_entity_access($entity) {
+  // TODO: need to implement this function.
+  return TRUE;
+}
+
 /**
  * Implements hook_theme().
  * Registers template files/functions used by this module.
@@ -214,7 +262,15 @@ function tripal_theme($existing, $type, $theme, $path) {
     // Theme function for the extension admin page.
     'tripal_extensions_form_tables' => array(
       'render element' => 'element',
-    )
+    ),
+    'tripal_entity' => array(
+      'render element' => 'elements',
+      'template' => 'tripal_entity',
+      'path' => "$path/theme/templates"
+    ),
+    'tripal_add_list' => array(
+      'variables' => array('content' => NULL),
+    ),
   );
 }
 
@@ -230,19 +286,6 @@ function tripal_coder_ignore() {
   );
 }
 
-/**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
- *  for this module which then includes tripal_db.views.inc where all the
- *  views integration code is
- *
- * @ingroup tripal_organism
- */
-function tripal_views_api() {
-  return array(
-    'api' => 3.0,
-  );
-}
 
 /**
  * Implements hook_libraries_info().
@@ -265,4 +308,385 @@ function tripal_libraries_info() {
   );
 
   return $libraries;
+}
+
+/**
+ * Implements hook_admin_paths().
+ * Define administrative paths.
+ */
+function tripal_admin_paths() {
+  if (variable_get('node_admin_theme')) {
+    $paths = array(
+      'bio-data/*/edit' => TRUE,
+      'bio-data/*/delete' => TRUE,
+      'bio-data/add' => TRUE,
+      'bio-data/add/*' => TRUE,
+    );
+    return $paths;
+  }
+}
+
+/**
+ * Implements hook_menu_local_tasks_alter().
+ *
+ * Used to add action links to pages.
+ */
+function tripal_menu_local_tasks_alter(&$data, $router_item, $root_path) {
+
+  // Add an "Add Tripal Content" action link to the Admin >> Content >>
+  // Biological Content page.
+  if ($root_path == 'admin/content/bio-data') {
+    $item = menu_get_item('bio-data/add');
+    if ($item['access']) {
+      $data['actions']['output'][] = array(
+        '#theme' => 'menu_local_action',
+        '#link' => $item,
+      );
+    }
+  }
+}
+/**
+ * Implements hook_shortcut_default_set().
+ * Modify the shortcut menu to include Biological content links.
+ *
+ * @param object $account
+ *   The user account whose default shortcut set will be returned. If not provided, the
+ *   function will return the currently logged-in user's default shortcut set.
+ *
+ * @return
+ *   An object representing the default shortcut set.
+ */
+function tripal_shortcut_default_set($account) {
+  $sets = shortcut_sets();
+  $found = FALSE;
+  foreach ($sets as $set) {
+    if ($set->title == 'TripalDefault') {
+      $found = TRUE;
+    }
+  }
+  if (!$found) {
+    $t = get_t();
+    // Create an initial default shortcut set.
+    $shortcut_set = new stdClass();
+    $shortcut_set->title = $t('TripalDefault');
+    $shortcut_set->links = array(
+      array(
+        'link_path' => 'node/add',
+        'link_title' => $t('Add content'),
+        'weight' => -35,
+      ),
+      array(
+        'link_path' => 'bio-data/add',
+        'link_title' => 'Add Tripal Content',
+        'weight' => -30,
+      ),
+      array(
+        'link_path' => 'admin/content',
+        'link_title' => $t('Find content'),
+        'weight' => -25,
+      ),
+      array(
+        'link_path' => 'admin/content/bio-data',
+        'link_title' => 'Find Tripal Content',
+        'weight' => -20,
+      ),
+    );
+    shortcut_set_save($shortcut_set);
+  }
+
+  $sets = shortcut_sets();
+  foreach ($sets as $set) {
+    if ($set->title == 'TripalDefault') {
+      return $set->set_name;
+    }
+  }
+}
+// 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',
+
+    // 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',
+
+    // 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',
+
+    // 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.
+ *
+ * This function is not meant to be used as an API function. It is only meant
+ * for use in the menu to resolve the %tripal_bundle wildcard.
+ *
+ * @param $type
+ *   The machine-readable name of a tripal data type to load.
+ * @return
+ *   A tripal data type array or FALSE if $type does not exist.
+ */
+
+function TripalBundleload($bundle_type, $reset = FALSE) {
+  // Get the type of entity by the ID.
+  $bundle = db_select('tripal_bundle', 'tdt')
+  ->fields('tdt')
+  ->condition('name', $bundle_type)
+  ->execute()
+  ->fetchObject();
+  if ($bundle) {
+    $entity = entity_load('TripalBundle', array($bundle->id), array(), $reset);
+    return reset($entity);
+  }
+  return FALSE;
+}
+
+/**
+ * Allows the menu system to use a wildcard to fetch the entity.
+ *
+ * Make sure that the wildcard you choose in the tripal_entity entity
+ * definition fits the function name here.
+ *
+ * This function is not meant to be used as an API function. It is only mean
+ * for use in the menu to resolve the %tripal_entity wildcard.
+ *
+ * @param $id
+ *   Integer specifying the tripal_entity id.
+ * @param $reset
+ *   A boolean indicating that the internal cache should be reset.
+ * @return
+ *   A fully-loaded $tripal_entity object or FALSE if it cannot be loaded.
+ *
+ * @see tripal_entity_load_multiple()
+ */
+function TripalEntity_load($id, $reset = FALSE) {
+  $entity = entity_load('TripalEntity', array($id), array(), $reset);
+  return reset($entity);
 }

+ 8 - 0
tripal_chado/api/tripal_chado.schema_v1.11.api.inc

@@ -6037,6 +6037,14 @@ function tripal_chado_chado_schema_v1_11_genotype() {
     ),
     'foreign keys' => array(
     ),
+    'referring_tables' => array(
+      'analysisfeature',
+      'feature_genotype',
+      'phendesc',
+      'phenotype_comparison',
+      'phenstatement',
+      'stock_genotype',
+    )
   );
   return $description;
 }

+ 0 - 0
legacy/tripal_cv/files/cv_property.obo → tripal_chado/files/cv_property.obo


+ 0 - 0
tripal_chado/includes/tripal_core.chado_install.inc → tripal_chado/includes/tripal_chado.chado_install.inc


+ 0 - 0
tripal_chado/includes/tripal_core.custom_tables.inc → tripal_chado/includes/tripal_chado.custom_tables.inc


+ 0 - 0
tripal_chado/includes/tripal_core.mviews.inc → tripal_chado/includes/tripal_chado.mviews.inc


+ 0 - 27
tripal_chado/includes/tripal_chado.schema.inc

@@ -1246,30 +1246,3 @@ function tripal_chado_chado_schema_v1_11_nd_reagentprop() {
 
   return $description;
 }
-
-/**
- * Implements hook_chado_schema_v1_11_table()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the genotype table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_chado_chado_schema_v1_11_genotype() {
-  $description = array();
-
-  $referring_tables = array(
-    'analysisfeature',
-    'feature_genotype',
-    'phendesc',
-    'phenotype_comparison',
-    'phenstatement',
-    'stock_genotype',
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-
-}

+ 1 - 1
tripal_chado/tripal_chado.info

@@ -8,5 +8,5 @@ version = 7.x-2.0
 stylesheets[all][] = theme/css/tripal_chado.css
 
 dependencies[] = tripal
-dependencies[] = tripal_entities
+dependencies[] = tripal
 dependencies[] = date

+ 157 - 2
tripal_chado/tripal_chado.install

@@ -10,6 +10,21 @@ function tripal_chado_install() {
       ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
   ');
 
+  // Add the cv_root_mview.
+  tripal_cv_add_cv_root_mview();
+
+  // Add defaults to the tables that correlate OBO files/references with
+  // a chado CV.
+  tripal_cv_add_obo_defaults();
+
+  // Add the Chado ontology CV.
+  $obo_path = '{tripal_chado}/files/cv_property.obo';
+  $obo_id = tripal_insert_obo('Chado CV Properties', $obo_path);
+  tripal_submit_obo_job(array('obo_id' => $obo_id));
+
+  // Create the temp table we will use for loading OBO files.
+  tripal_cv_create_tripal_obo_temp();
+
   // Unfortunately, some Chado base tables do not have a type_id, so we must
   // take special action for those tables.  These include: organism and
   // analysis. Until we can find an appropriate controlled vocabulary
@@ -59,8 +74,8 @@ function tripal_chado_install() {
   // We want to provide a set of commonly used entity types by default. This
   // way when a user first installs Tripal there are some commonly used
   // formats.
-  module_load_include('inc', 'tripal_entities', 'api/tripal_entities.api');
-  module_load_include('inc', 'tripal_entities', 'includes/tripal_entities.admin');
+  module_load_include('inc', 'tripal', 'api/tripal.api');
+  module_load_include('inc', 'tripal', 'includes/tripal.admin');
 
   // Create the 'Organism' entity type. This uses the local:organism term.
   $error = '';
@@ -102,6 +117,143 @@ function tripal_chado_uninstall() {
   ');
 }
 
+/**
+ * Table definition for the tripal_cv_obo table
+ * @param $schema
+ */
+function tripal_chado_tripal_cv_obo_schema(&$schema) {
+  return array(
+    'fields' => array(
+      'obo_id' => array(
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE
+      ),
+      'name' => array(
+        'type' => 'varchar',
+        'length' => 255
+      ),
+      'path'  => array(
+        'type' => 'varchar',
+        'length' => 1024
+      ),
+    ),
+    'indexes' => array(
+      'tripal_cv_obo_idx1' => array('obo_id'),
+    ),
+    'primary key' => array('obo_id'),
+  );
+}
+
+/**
+ * * Table definition for the tripal_cv_defaults table
+ * @param unknown $schema
+ */
+function tripal_chado_tripal_cv_defaults_schema(&$schema) {
+  return array(
+    'fields' => array(
+      'cv_default_id' => array(
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE
+      ),
+      'table_name' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+      ),
+      'field_name' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+      ),
+      'cv_id' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+      )
+    ),
+    'indexes' => array(
+      'tripal_cv_defaults_idx1' => array('table_name', 'field_name'),
+    ),
+    'unique keys' => array(
+      'tripal_cv_defaults_unq1' => array('table_name', 'field_name', 'cv_id'),
+    ),
+    'primary key' => array('cv_default_id')
+  );
+}
+
+/**
+ * Add a materialized view of root terms for all chado cvs. This is needed for viewing cv trees
+ *
+ * @ingroup tripal_cv
+ */
+function tripal_cv_add_cv_root_mview() {
+  $mv_name = 'cv_root_mview';
+  $comment = 'A list of the root terms for all controlled vocabularies. This is needed for viewing CV trees';
+  $schema = array(
+    'table' => $mv_name,
+    'description' => $comment,
+    'fields' => array(
+      'name' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+      ),
+      'cvterm_id' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'cv_id' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'cv_name' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+      ),
+    ),
+    'indexes' => array(
+      'cv_root_mview_indx1' => array('cvterm_id'),
+      'cv_root_mview_indx2' => array('cv_id'),
+    ),
+  );
+
+  $sql = "
+    SELECT DISTINCT CVT.name,CVT.cvterm_id, CV.cv_id, CV.name
+    FROM cvterm_relationship CVTR
+      INNER JOIN cvterm CVT on CVTR.object_id = CVT.cvterm_id
+      INNER JOIN cv CV on CV.cv_id = CVT.cv_id
+    WHERE CVTR.object_id not in
+      (SELECT subject_id FROM cvterm_relationship)
+  ";
+
+  // Create the MView
+  tripal_add_mview($mv_name, 'tripal_cv', $schema, $sql, $comment);
+}
+
+/**
+ * Add's defaults to the tripal_cv_obo table
+ *
+ * @ingroup tripal_cv
+ */
+function tripal_cv_add_obo_defaults() {
+
+  // Insert commonly used ontologies into the tables.
+  $ontologies = array(
+    array('Relationship Ontology', 'http://purl.obolibrary.org/obo/ro.obo'),
+    //    array('Relationship Ontology (older deprecated version)', 'http://www.obofoundry.org/ro/ro.obo'),
+    array('Sequence Ontology', 'https://github.com/The-Sequence-Ontology/SO-Ontologies/blob/master/so-xp-simple.obo'),
+    array('Gene Ontology', 'http://www.geneontology.org/ontology/gene_ontology.obo'),
+    //    array('Cell Ontology', 'https://raw.githubusercontent.com/obophenotype/cell-ontology/master/cl.obo'),
+  //    array('Plant Structure Ontology', 'http://palea.cgrb.oregonstate.edu/viewsvn/Poc/trunk/ontology/OBO_format/po_anatomy.obo?view=co'),
+  //    array('Plant Growth and Development Stages Ontology', 'http://palea.cgrb.oregonstate.edu/viewsvn/Poc/trunk/ontology/OBO_format/po_temporal.obo?view=co')
+  );
+  foreach ($ontologies as $o) {
+    db_query("INSERT INTO {tripal_cv_obo} (name,path) VALUES (:name, :path)", array(':name' => $o[0], ':path' => $o[1]));
+  }
+}
+
 /**
  * Implements hook_schema().
  */
@@ -112,6 +264,9 @@ function tripal_chado_schema() {
   $schema['tripal_mviews'] = tripal_chado_tripal_mviews_schema();
   $schema['tripal_custom_tables'] = tripal_chado_tripal_custom_tables_schema();
 
+  $schema['tripal_cv_obo'] = tripal_chado_tripal_cv_obo_schema($schema);
+  $schema['tripal_cv_defaults'] = tripal_chado_tripal_cv_defaults_schema($schema);
+
   // if this module is already installed and enabled, then we want to provide
   // the schemas for all of the custom tables.  This will allow Views to
   // see the schemas.  We check if the module is installed because during

+ 1 - 1
tripal_chado/tripal_chado.module

@@ -3,7 +3,7 @@
 // APPLICATION PROGRAMMER INTERFACE -------------
 // Chado API
 require_once "api/tripal_chado.api.inc";
-require_once 'api/tripal_chado.general.api.inc';
+require_once 'api/tripal_chado.property.api.inc';
 require_once 'api/tripal_chado.query.api.inc';
 require_once 'api/tripal_chado.variables.api.inc';
 require_once 'api/tripal_chado.schema.api.inc';

+ 0 - 10
tripal_entities/tripal_entities.info

@@ -1,10 +0,0 @@
-name = Tripal Entities
-description = Provides a framework for Entities based on controlled vocabularies.
-core = 7.x
-project = tripal
-package = Tripal
-version = 7.x-2.0
-
-dependencies[] = date
-dependencies[] = entity
-dependencies[] = tripal

+ 0 - 397
tripal_entities/tripal_entities.install

@@ -1,397 +0,0 @@
-<?php
-/**
- * @file
- * Install for a tripal data entity - creates the base table for our entity.
- */
-
-/**
- * Implements hook_install().
- */
-function tripal_entities_install() {
-
-  // Add tripal bundle variables needed for storing additional settings for Tripal Bundles.
-  tripal_insert_variable('title_format', 'A pattern including tokens that can be used to generate tripal entity titles.');
-  tripal_insert_variable('url_format', 'A pattern including tokens that can be used to generate tripal entity url aliases.');
-  tripal_insert_variable('description', 'The description of a Tripal Entity type/bundle.');
-
-}
-
-/**
- * Implements hook_uninstall().
- */
-function tripal_entities_uninstall() {
-
-/*
-  // So somehow I was able to uninstall this module without deleting the bundles. This
-  // caused aweful errors because fields weren't deleted so when I re-installed, the code
-  // tried to create fields that were inactive (despite checking if the field exists 
-  // before creating). The following code was meant to ensure that all content was deleted
-  // before uninstall so these errors would not occur. Unfortunatly I am now unable to 
-  // test this because the Field API module is disabling uninstall of Tripal Chado until 
-  // all the content is deleted. Thus ensuring the errors described above don't occur.
-  // But I'm Sure I was able to uninstall with content before... 
-  // **I am slowly going crazy; Crazy going slowly am I**
-  // Anyway, I'll leaving the solution code here in case I am able to repeat it in
-  // the future.
-  // @see https://www.drupal.org/node/1262092
-  // @see https://www.drupal.org/node/1861710
-  
-  // First delete all TripalEntities.
-  $entity_ids = (new EntityFieldQuery)->entityCondition("entity_type", "TripalEntity")->execute(); 
-  $entity_ids = reset($entity_ids);
-  entity_delete_multiple("TripalEntity", array_keys($entity_ids));
-
-  // Then delete all TripalBundles.
-  $bundle_ids = (new EntityFieldQuery)->entityCondition("entity_type", "TripalBundle")->execute(); 
-  $bundle_ids = reset($bundle_ids);
-  entity_delete_multiple("TripalBundle", array_keys($bundle_ids));
-  
-  // @TODO: Should we delete all TripalVocabularies and TripalTerms?
-  
-  // Finally purge all fields that are no longer used.
-  field_purge_batch(100);
-  */
-}
-
-/**
- * Implements hook_schema().
- */
-function tripal_entities_schema() {
-
-  // Adds a table for managing TripalEntity entities.
-  $schema['tripal_vocab'] = tripal_entities_tripal_vocab_schema();
-  $schema['tripal_term'] = tripal_entities_tripal_term_schema();
-  $schema['tripal_entity'] = tripal_entities_tripal_entity_schema();
-  $schema['tripal_bundle'] = tripal_entities_tripal_bundle_schema();
-
-  // Adds a table for additional information related to bundles.
-  $schema['tripal_bundle_variables'] = tripal_entities_tripal_bundle_variables_schema();
-
-  return $schema;
-}
-
-/**
- * @section
- * Schema Definitions.
- */
-
-/**
- * The base table for Biological Data Entities.
- *
- * This contains the actual data. For example, if you have a 5 genes and 10 mRNA then
- * this table will have 15 records and include both genes and mRNA's.
- */
-function tripal_entities_tripal_entity_schema() {
-
-  $schema = array(
-    'description' => 'The base table for Tripal Vocabulary-based entities.',
-    'fields' => array(
-      'id' => array(
-        'description' => 'The primary identifier for a vocabulary entity.',
-        'type' => 'serial',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-      ),
-      'type' => array(
-        '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' => '',
-      ),
-      'term_id' => array(
-        'description' => 'The term_id for the type of entity. This term_id corresponds to a TripalTerm record.',
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'title' => array(
-        'description' => 'The title of this node, always treated as non-markup plain text.',
-        'type' => 'text',
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'uid' => array(
-        'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'status' => array(
-        'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 1,
-      ),
-      'created' => array(
-        'description' => 'The Unix timestamp when the node was created.',
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'changed' => array(
-        'description' => 'The Unix timestamp when the node was most recently saved.',
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-    ),
-    'indexes' => array(
-      'term_id' => array('term_id'),
-      'entity_changed' => array('changed'),
-      'entity_created' => array('created'),
-      'type' => array('type'),
-      'uid' => array('uid'),
-    ),
-    'unique keys' => array(),
-    'primary key' => array('id'),
-  );
-  return $schema;
-}
-
-/**
- * The base table for TripalVocab schema.
- *
- * This contains the actual data. For example, if you have a 5 genes and 10 mRNA then
- * this table will have 15 records and include both genes and mRNA's.
- */
-function tripal_entities_tripal_vocab_schema() {
-
-  // This schema only provides enough information to assign a unique ID
-  // to the vocabulary. Any additonal information is added to the Entity object
-  // by the selected database back-end.
-  $schema = array(
-    'description' => 'The base table for TripalVocab entities.',
-    'fields' => array(
-      'id' => array(
-        'description' => 'The primary identifier for a vocab entity.',
-        'type' => 'serial',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-      ),
-      'namespace' => array(
-        'description' => 'The namespace for the vocabulary (e.g. SO, PATO, etc.).',
-        'type' => 'varchar',
-        'length' => 10,
-        'not null' => TRUE,
-      ),
-      'created' => array(
-        'description' => 'The Unix timestamp when the entity was created.',
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'changed' => array(
-        'description' => 'The Unix timestamp when the entity was most recently saved.',
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-    ),
-    'indexes' => array(
-      'namespace' => array('namespace'),
-      'entity_changed' => array('changed'),
-      'entity_created' => array('created'),
-    ),
-    'unique keys' => array('namespace' => array('namespace')),
-    'primary key' => array('id'),
-  );
-  return $schema;
-}
-
-/**
- * The base table for TripalTerm entities.
- *
- * This contains the actual data. For example, if you have a 5 genes and 10 mRNA then
- * this table will have 15 records and include both genes and mRNA's.
- */
-function tripal_entities_tripal_term_schema() {
-
-  // This schema only provides enough information to assign a unique ID
-  // to the term and associate it to it's vocabulary. Any additonal information
-  // is added to the Entity object by the selected database back-end.
-  $schema = array(
-    'description' => 'The base table for TripalTerm entities.',
-    'fields' => array(
-      'id' => array(
-        'description' => 'The primary identifier for a term entity.',
-        'type' => 'serial',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-      ),
-      'vocab_id' => array(
-        'description' => 'The vocabulary_id of the TripalVocab entity to which this term belongs.',
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'accession' => array(
-        'description' => 'The id (or accession) of this term in the vocabulary.',
-        'type' => 'varchar',
-        'length' => 1024,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'name' => array(
-        'description' => 'The human readable name for this term.',
-        'type' => 'varchar',
-        'length' => 1024,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'created' => array(
-        'description' => 'The Unix timestamp when the entity was created.',
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'changed' => array(
-        'description' => 'The Unix timestamp when the entity was most recently saved.',
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-    ),
-    'indexes' => array(
-      'vocab_id' => array('vocab_id'),
-      'accession' => array('accession'),
-      'entity_changed' => array('changed'),
-      'entity_created' => array('created'),
-    ),
-    'foreign keys' => array(
-      'tripal_vocab' => array(
-        'table' => 'tripal_vocab',
-        'columns' => array(
-          'vocab_id' => 'vocab_id',
-        ),
-      ),
-    ),
-    'unique keys' => array('vocab_term' => array('vocab_id', 'accession')),
-    'primary key' => array('id'),
-  );
-  return $schema;
-}
-
-/**
- * The base table for TripalEntity entities.
- *
- * This table contains a list of Biological Data Types.
- * For the example above (5 genes and 10 mRNAs), there would only be two records in
- * this table one for "gene" and another for "mRNA".
- */
-function tripal_entities_tripal_bundle_schema() {
-
-  $schema = array(
-    'description' => 'Stores information about defined tripal data types.',
-    'fields' => array(
-      'id' => array(
-        'type' => 'serial',
-        'not null' => TRUE,
-        'description' => 'Primary Key: Unique numeric ID.',
-      ),
-      'type' => array(
-        'description' => 'The type of entity (e.g. TripalEntity).',
-        'type' => 'varchar',
-        'length' => 64,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'term_id' => array(
-        'description' => 'The term_id for the type of entity. This term_id corresponds to a TripalTerm record.',
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'name' => array(
-        'description' => 'The name of the 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' => '',
-      ),
-      'label' => array(
-        'description' => 'The human-readable name of this bundle.',
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-    ),
-    'indexes' => array(
-      'name' => array('name'),
-      'term_id' => array('term_id'),
-    ),
-    'primary key' => array('id'),
-    'unique keys' => array(
-      'name' => array('name'),
-    ),
-  );
-  return $schema;
-}
-
-/**
- * Additional Tripal Bundle Information.
- *
- * This table is used for storing any additonal information describing
- * a tripal bundle. For example, this is a good place to store title/url formats.
- */
-function tripal_entities_tripal_bundle_variables_schema() {
-
-  $schema = array(
-    'description' => 'This table is used for storing any additonal information describing
-      a tripal bundle. For example, this is a good place to store title/url formats.',
-    'fields' => array (
-      'bundle_variable_id' => array (
-        'type' => 'serial',
-        'not null' => TRUE,
-      ),
-      'bundle_id' => array (
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'variable_id' => array (
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'value' => array (
-        'type' => 'text',
-        'not null' => FALSE,
-      ),
-      'rank' => array (
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-    ),
-    'primary key' => array (
-      0 => 'bundle_variable_id',
-    ),
-    'unique keys' => array (
-      'tripal_bundle_variables_c1' => array (
-        0 => 'bundle_id',
-        1 => 'variable_id',
-        2 => 'rank',
-      ),
-    ),
-    'indexes' => array (
-      'tripal_bundle_variables_idx1' => array (
-        0 => 'variable_id',
-      ),
-    ),
-    'foreign keys' => array (
-      'tripal_variables' => array (
-        'table' => 'tripal_variables',
-        'columns' => array (
-          'variable_id' => 'variable_id',
-        ),
-      ),
-    ),
-  );
-
-  return $schema;
-}
-

+ 0 - 470
tripal_entities/tripal_entities.module

@@ -1,470 +0,0 @@
-<?php
-
-require_once "api/tripal_entities.api.inc";
-require_once "includes/TripalVocab.inc";
-require_once "includes/TripalVocabController.inc";
-require_once "includes/TripalTerm.inc";
-require_once "includes/TripalTermController.inc";
-require_once "includes/TripalEntity.inc";
-require_once "includes/TripalEntityController.inc";
-require_once "includes/TripalEntityUIController.inc";
-require_once "includes/TripalBundle.inc";
-require_once "includes/TripalBundleController.inc";
-require_once "includes/TripalBundleUIController.inc";
-
-/**
- * Implements hook_views_api().
- */
-function tripal_entities_views_api() {
-  return array(
-    'api' => 3,
-  );
-}
-
-/**
- * Implements hook_menu().
- */
-function tripal_entities_menu() {
-
-  // Note:  menu items for the entities can be found in the
-  // Entity's UI Controller class.
-
-  $items = array();
-
-  $items['admin/structure/bio-data/term/%'] = array(
-    'page callback' => 'tripal_autocomplete_term',
-    'page arguments' => array(6, 7),
-    'access arguments' => array('administer content'),
-    'type' => MENU_CALLBACK,
-  );
-
-  return $items;
-}
-
-
-/**
- * Implements hook_admin_paths().
- * Define administrative paths.
- */
-function tripal_entities_admin_paths() {
-  if (variable_get('node_admin_theme')) {
-    $paths = array(
-      'bio-data/*/edit' => TRUE,
-      'bio-data/*/delete' => TRUE,
-      'bio-data/add' => TRUE,
-      'bio-data/add/*' => TRUE,
-    );
-    return $paths;
-  }
-}
-
-/**
- * Implements hook_menu_local_tasks_alter().
- *
- * Used to add action links to pages.
- */
-function tripal_entities_menu_local_tasks_alter(&$data, $router_item, $root_path) {
-
-  // Add an "Add Tripal Content" action link to the Admin >> Content >>
-  // Biological Content page.
-  if ($root_path == 'admin/content/bio-data') {
-    $item = menu_get_item('bio-data/add');
-    if ($item['access']) {
-      $data['actions']['output'][] = array(
-        '#theme' => 'menu_local_action',
-        '#link' => $item,
-      );
-    }
-  }
-}
-
-/**
- * Implements hook_shortcut_default_set().
- * Modify the shortcut menu to include Biological content links.
- *
- * @param object $account
- *   The user account whose default shortcut set will be returned. If not provided, the
- *   function will return the currently logged-in user's default shortcut set.
- *
- * @return
- *   An object representing the default shortcut set.
- */
-function tripal_entities_shortcut_default_set($account) {
-  $sets = shortcut_sets();
-  $found = FALSE;
-  foreach ($sets as $set) {
-    if ($set->title == 'TripalDefault') {
-      $found = TRUE;
-    }
-  }
-  if (!$found) {
-    $t = get_t();
-    // Create an initial default shortcut set.
-    $shortcut_set = new stdClass();
-    $shortcut_set->title = $t('TripalDefault');
-    $shortcut_set->links = array(
-      array(
-        'link_path' => 'node/add',
-        'link_title' => $t('Add content'),
-        'weight' => -35,
-      ),
-      array(
-        'link_path' => 'bio-data/add',
-        'link_title' => 'Add Tripal Content',
-        'weight' => -30,
-      ),
-      array(
-        'link_path' => 'admin/content',
-        'link_title' => $t('Find content'),
-        'weight' => -25,
-      ),
-      array(
-        'link_path' => 'admin/content/bio-data',
-        'link_title' => 'Find Tripal Content',
-        'weight' => -20,
-      ),
-    );
-    shortcut_set_save($shortcut_set);
-  }
-
-  $sets = shortcut_sets();
-  foreach ($sets as $set) {
-   if ($set->title == 'TripalDefault') {
-     return $set->set_name;
-   }
-  }
-}
-
-/**
- * Implements hook_permission().
- */
-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 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 tripal data' => array(
-      'title' => t('Administer Tripal data'),
-      'description' => t('Edit and delete all tripal data'),
-    ),
-  );
-
-  return $permissions;
-}
-/**
- * Checks access permissions for a given entity.
- */
-function tripal_entities_entity_access($entity) {
-  // TODO: need to implement this function.
-  return TRUE;
-}
-/**
- * Implements hook_theme().
- */
-function tripal_entities_theme($existing, $type, $theme, $path) {
-  return array(
-    'tripal_entity' => array(
-      'render element' => 'elements',
-      'template' => 'tripal_entity',
-      'path' => "$path/theme/templates"
-    ),
-    'tripal_entities_add_list' => array(
-      'variables' => array('content' => NULL),
-    ),
-
-  );
-}
-// 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_entities_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',
-
-    // 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',
-
-    // 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',
-
-    // The table for this entity defined in hook_schema()
-    'base table' => 'tripal_entity',
-
-    // 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' => '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' => '%tripal_entity',
-      '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_entities',
-    // Enable the entity API's admin UI.
-    'admin ui' => array (
-      'path' => 'admin/structure/bio-data',
-      'controller class' => 'TripalBundleUIController',
-      'file' => 'includes/TripalBundleUIController.inc',
-      'menu wildcard' => '%tripal_bundle',
-    )
-  );
-
-  return $entities;
-}
-
-/**
- * Implements hook_entities_info_alter().
- *
- * Add in the bundles (entity types) to the TripalEntity entity.
- */
-function tripal_entities_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/%tripal_bundle',
-          '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.
- *
- * This function is not meant to be used as an API function. It is only meant
- * for use in the menu to resolve the %tripal_bundle wildcard.
- *
- * @param $type
- *   The machine-readable name of a tripal data type to load.
- * @return
- *   A tripal data type array or FALSE if $type does not exist.
- */
-
-function tripal_bundle_load($bundle_type, $reset = FALSE) {
-  // Get the type of entity by the ID.
-  $bundle = db_select('tripal_bundle', 'tdt')
-    ->fields('tdt')
-    ->condition('name', $bundle_type)
-    ->execute()
-    ->fetchObject();
-  if ($bundle) {
-    $entity = entity_load('TripalBundle', array($bundle->id), array(), $reset);
-    return reset($entity);
-  }
-  return FALSE;
-}
-
-/**
- * Allows the menu system to use a wildcard to fetch the entity.
- *
- * Make sure that the wildcard you choose in the tripal_entity entity
- * definition fits the function name here.
- *
- * This function is not meant to be used as an API function. It is only mean
- * for use in the menu to resolve the %tripal_entity wildcard.
- *
- * @param $id
- *   Integer specifying the tripal_entity id.
- * @param $reset
- *   A boolean indicating that the internal cache should be reset.
- * @return
- *   A fully-loaded $tripal_entity object or FALSE if it cannot be loaded.
- *
- * @see tripal_entity_load_multiple()
- */
-function tripal_entity_load($id, $reset = FALSE) {
-  $entity = entity_load('TripalEntity', array($id), array(), $reset);
-  return reset($entity);
-}
-

+ 0 - 2
tripal_entities/tripal_entities.views_default.inc

@@ -1,2 +0,0 @@
-<?php
-

+ 1 - 1
tripal_fields_layout/tripal_fields_layout.info

@@ -6,4 +6,4 @@ package = Tripal
 version = 7.x-2.0
 
 dependencies[] = tripal
-dependencies[] = tripal_entities
+dependencies[] = tripal

+ 1 - 1
tripal_fields_layout/tripal_fields_layout.install

@@ -111,7 +111,7 @@ function tripal_fields_layout_schema() {
 /**
  *
  */
-function tripal_entities_add_tripal_bundle_panes_table(){
+function tripal_add_tripal_bundle_panes_table(){
   $schema = array (
     'table' => 'tripal_bundle_panes',
     'fields' => array (

+ 1 - 1
tripal_ws/tripal_ws.info

@@ -7,4 +7,4 @@ version = 7.x-3.0
 configure = admin/tripal/chado/tripal_ws
 
 dependencies[] = tripal
-dependencies[] = tripal_entities
+dependencies[] = tripal