Prechádzať zdrojové kódy

Updated Doxygen comments

spficklin 12 rokov pred
rodič
commit
c423725e2a
39 zmenil súbory, kde vykonal 214 pridanie a 1086 odobranie
  1. 0 1
      tripal_analysis/api/tripal_analysis.api.inc
  2. 4 1
      tripal_analysis/tripal_analysis.module
  3. 0 1
      tripal_analysis/tripal_analysis.views.inc
  4. 7 1
      tripal_bulk_loader/tripal_bulk_loader.module
  5. 1 1
      tripal_contact/tripal_contact.module
  6. 2 2
      tripal_core/api/tripal_core.schema_v1.11.api.inc
  7. 2 2
      tripal_core/api/tripal_core.schema_v1.2.api.inc
  8. 58 10
      tripal_core/api/tripal_core_ahah.api.inc
  9. 27 68
      tripal_core/api/tripal_core_chado.api.inc
  10. 5 207
      tripal_core/includes/custom_tables.php
  11. 1 353
      tripal_core/includes/jobs.php
  12. 4 380
      tripal_core/includes/mviews.php
  13. 42 10
      tripal_core/tripal_core.module
  14. 0 1
      tripal_cv/api/tripal_cv.api.inc
  15. 8 7
      tripal_cv/includes/obo_loader.inc
  16. 0 1
      tripal_cv/tripal_cv.views.inc
  17. 0 1
      tripal_db/api/tripal_db.api.inc
  18. 0 1
      tripal_db/tripal_db.views.inc
  19. 4 2
      tripal_feature/api/tripal_feature.api.inc
  20. 2 1
      tripal_feature/includes/fasta_loader.inc
  21. 1 1
      tripal_feature/includes/gff_loader.inc
  22. 1 1
      tripal_feature/tripal_feature.module
  23. 0 1
      tripal_feature/tripal_feature.views.inc
  24. 1 1
      tripal_featuremap/tripal_featuremap.module
  25. 0 1
      tripal_featuremap/tripal_featuremap.views.inc
  26. 5 0
      tripal_genetic/tripal_genetic.views.inc
  27. 2 5
      tripal_library/api/tripal_library.api.inc
  28. 1 1
      tripal_library/tripal_library.module
  29. 0 1
      tripal_library/tripal_library.views.inc
  30. 6 0
      tripal_natural_diversity/tripal_natural_diversity.views.inc
  31. 4 10
      tripal_organism/api/tripal_organism.api.inc
  32. 0 1
      tripal_organism/tripal_organism.views.inc
  33. 5 0
      tripal_phenotype/tripal_phenotype.views.inc
  34. 2 3
      tripal_project/api/tripal_project.api.inc
  35. 5 0
      tripal_project/tripal_project.views.inc
  36. 1 2
      tripal_stock/api/tripal_stock.api.inc
  37. 1 1
      tripal_stock/tripal_stock.module
  38. 0 1
      tripal_stock/tripal_stock.views.inc
  39. 12 5
      tripal_views/tripal_views.views.inc

+ 0 - 1
tripal_analysis/api/tripal_analysis.api.inc

@@ -5,7 +5,6 @@
  * API functions relating to Analysis'
  *
  * @defgroup tripal_analysis_api Analysis Module API
- * @ingroup tripal_analysis
  * @ingroup tripal_api
  */
 /**

+ 4 - 1
tripal_analysis/tripal_analysis.module

@@ -5,10 +5,13 @@
  * Contains all the main hook implementations for the tripal_analysis module
  *
  * @defgroup tripal_analysis Analysis Module
+ * @ingroup tripal_modules
  * @{
  * Provides functions for managing chado analysis' including creating details pages for each one
+ * 
  * @}
- * @ingroup tripal_modules
+ * 
+ * 
  */
 
 require('api/tripal_analysis.api.inc');

+ 0 - 1
tripal_analysis/tripal_analysis.views.inc

@@ -13,7 +13,6 @@
 /**
  * @defgroup tripal_analysis_views Analysis Views Integration
  * @ingroup views
- * @ingroup tripal_analysis
  */
 
 /**

+ 7 - 1
tripal_bulk_loader/tripal_bulk_loader.module

@@ -1,5 +1,11 @@
 <?php
-
+/**
+ * @file
+ * The functions for the Tripal bulk loader.
+ *
+ * 
+ * 
+ */
 include('tripal_bulk_loader.loader.inc');
 include('tripal_bulk_loader.constants.inc');
 include('tripal_bulk_loader.admin.inc');

+ 1 - 1
tripal_contact/tripal_contact.module

@@ -11,6 +11,7 @@
 
 /**
  * @defgroup tripal_contact Contact Module
+ * @ingroup tripal_modules
  * @{
  * Currently this module only provides support for integration with Drupal
  * views and some support for querying using the Tripal Core API.
@@ -19,7 +20,6 @@
  * contact information within Chado, and full definitions for foreign
  * key relationships in Chado.
  * @}
- * @ingroup tripal_modules
  */
 
 require('api/tripal_contact.api.inc');

+ 2 - 2
tripal_core/api/tripal_core.schema_v1.11.api.inc

@@ -8,7 +8,8 @@
  *        (specifically to add missing definitions) by implementing
  *        hook_chado_schema_v1_11_<table name>().
  *
- * @defgroup tripal_schema_api Core Module Schema API
+ * @defgroup tripal_schema_v1_11_api Chado v1.11 Schema API
+ * @ingroup tripal_core_api
  * @{
  * Provides an application programming interface (API) for describing Chado tables.
  * This API consists of a set of functions, one for each table in Chado.  Each
@@ -30,7 +31,6 @@
  * hook function to retrieve the table schema.
  *
  * @}
- * @ingroup tripal_api
  */
 
 /**

+ 2 - 2
tripal_core/api/tripal_core.schema_v1.2.api.inc

@@ -8,7 +8,8 @@
  *        (specifically to add missing definitions) by implementing
  *        hook_chado_schema_v1_2_<table name>().
  *
- * @defgroup tripal_schema_api Core Module Schema API
+ * @defgroup tripal_schema_v1_2_api Chado v1.2 Schema API
+ * @ingroup tripal_core_api
  * @{
  * Provides an application programming interface (API) for describing Chado tables.
  * This API consists of a set of functions, one for each table in Chado.  Each
@@ -30,7 +31,6 @@
  * hook function to retrieve the table schema.
  *
  * @}
- * @ingroup tripal_api
  */
 
 /**

+ 58 - 10
tripal_core/api/tripal_core.ahah.inc → tripal_core/api/tripal_core_ahah.api.inc

@@ -1,12 +1,33 @@
 <?php
-
-/*
+/**
  * @file
- * Part of the Tripal Core API.
+ * The Tripal AJAX/AHAH API
  *
- * Provides support for dynamic forms through AHAH
+ * This file provides the API to help Tripal modules more easily use 
+ * Drupal's AHAH functionality with forms.
  */
 
+/**
+ * @defgroup tripal_ahah_api AHAH API
+ * @ingroup tripal_core_api
+ * @{
+ * Provides an application programming interface (API) for improved 
+ * support of Drupal's AHAH functionality.
+ *
+ * @} 
+ */
+
+/**
+ * This function should be called to initialize the page
+ * for use of AHAH elements in a form.
+ * 
+ * See http://tripal.info/documentation/ahah_api for example usage
+ *
+ * @returns
+ *   nothing
+ *
+ * @ingroup tripal_ahah_api
+ */
 function tripal_core_ahah_init_form() {
   // If form elements have autocomplete elements returned in
   // an ahah call they won't work because the following JS file
@@ -15,9 +36,17 @@ function tripal_core_ahah_init_form() {
   drupal_add_js('misc/autocomplete.js');
 }
 
-/*
+/**
  * This function simply gets the posted form ID, builds the form
- * and retrieves the specified element
+ * and retrieves the specified element.  This function should be
+ * called in an AHAH callback function to retrieve the form
+ *
+ * See http://tripal.info/documentation/ahah_api for example usage
+ *
+ * @returns
+ *   A Drupal form array 
+ *
+ * @ingroup tripal_ahah_api
  */
 function tripal_core_ahah_prepare_form() {
   
@@ -60,8 +89,17 @@ function tripal_core_ahah_prepare_form() {
   return $form;
 }
 
-/*
- * 
+/**
+ * This function rebuilds the $settings array needed by the 
+ * javascript that handles AHAH data returns.  This function should be
+ * called in an AHAH callback function prior to returning.
+ *
+ * See http://tripal.info/documentation/ahah_api for example usage
+ *
+ * @returns
+ *   an associative array with an 'ahah' key.
+ *
+ * @ingroup tripal_ahah_api
  */
 function tripal_core_ahah_bind_events() {
   
@@ -72,8 +110,18 @@ function tripal_core_ahah_bind_events() {
   return array('ahah' => $settings['ahah']);
 }
 
-/*
- * 
+/**
+ * This function is a helperfunction of the 
+ * tripal_core_ahah_prepare_form() function.  It simply
+ * disables field validations for all fields (recursively) so that
+ * when the form is rebuilt it doesn't try to validate and submit the form.
+ *
+ * See http://tripal.info/documentation/ahah_api for example usage
+ *
+ * @returns
+ *   nothing 
+ *
+ * @ingroup tripal_ahah_api
  */
 function tripal_core_ahah_form_element_disable_validation(&$form) {
   // --START code borrowed from ahah_helper module

+ 27 - 68
tripal_core/api/tripal_core.api.inc → tripal_core/api/tripal_core_chado.api.inc

@@ -10,20 +10,9 @@ require_once "tripal_core.schema_v1.11.api.inc";
  * This file provides the API needed for all other Tripal and Tripal dependent
  * modules.
  *
- * @defgroup tripal_api Tripal API
- * @{
- * Provides an application programming interface (API) for Tripal
- *
- * The Tripal API currently provides generic insert/update/select functions for all chado content as
- * well as some module specific functions that insert/update/delete/select specific chado content.
- *
- * This API is currently in its infancy and some necessary functions might be missing. If you find
- * a missing function that you think should be included go to the sourceforge feature request
- * page and request it's inclusion in the API. Such feature requests with a working function
- * definition will be given priority.
- * @}
  *
- * @defgroup tripal_chado_api Core Module Chado API
+ * @defgroup tripal_chado_api Chado API
+ * @ingroup tripal_core_api
  * @{
  * Provides an application programming interface (API) to manage data withing the Chado database.
  * This includes functions for selecting, inserting, updating and deleting records
@@ -48,17 +37,10 @@ require_once "tripal_core.schema_v1.11.api.inc";
  * there is a set of functions for inserting, updating and deleting properties for
  * any table.  This provides quick lookup of properties (provided the CV term is
  * known).
- *
+ * 
  * @}
- * @ingroup tripal_api
- *
- * @defgroup tripal_files_api Core Module Files API
- * @{
- * Provides an application programming interface (API) for managing files within
- * the Tripal data directory structure.
  *
- * @}
- * @ingroup tripal_api
+ */
 
  /**
  * Provides a generic routine for inserting into any Chado table
@@ -2372,6 +2354,8 @@ function tripal_core_exclude_field_from_feature_by_default() {
  * @returns
  *   A database query result resource or FALSE if the query was not
  *   executed correctly
+ *   
+ * @ingroup tripal_chado_api
  */
 function chado_pager_query($query, $limit, $element, $count) {
   
@@ -2420,6 +2404,8 @@ function chado_pager_query($query, $limit, $element, $count) {
  * @returns
  *   A database query result resource or FALSE if the query was not
  *   executed correctly
+ *   
+ * @ingroup tripal_chado_api
  */
 function chado_query_range($query) {
   $args = func_get_args();
@@ -2448,6 +2434,8 @@ function chado_query_range($query) {
  * @returns
  *   A database query result resource or FALSE if the query was not
  *   executed correctly
+ *   
+ * @ingroup tripal_chado_api  
  */
 function chado_query($sql) {
   global $persistent_chado;
@@ -2565,6 +2553,8 @@ function chado_query($sql) {
  * Likewise,
  * $organism_id = chado_get_id_for_node ('organism', $node)
  * $feature_id = chado_get_id_for_node ('feature', $node)
+ * 
+ * @ingroup tripal_chado_api
  */
 function chado_get_id_for_node($table, $node) {
   return db_result(db_query("SELECT %s_id FROM {chado_%s} WHERE nid = %d", $table, $table, $node->nid));
@@ -2577,6 +2567,8 @@ function chado_get_id_for_node($table, $node) {
  *  Likewise,
  *  $nid = chado_get_node_id ('organism', $organism_id)
  *  $nid = chado_get_node_id ('feature', $feature_id)
+ *  
+ *  @ingroup tripal_chado_api
  */
 function chado_get_node_id($table, $id) {
   return db_result(db_query("SELECT nid FROM {chado_%s} WHERE %s_id = %d", $table, $table, $id));
@@ -2895,50 +2887,9 @@ function tripal_core_delete_property_by_id($basetable, $record_id) {
   return tripal_core_chado_delete($basetable . 'prop', $match);
 }
 
-/**
- * This function is typically used in the '.install' file for a Tripal module
- * Each module should call this function during installation to create
- * the module data directory which is sites/default/files/tripal/[module_name]
- * for default Drupal settings.  This directory can then be used by the module
- * for storing files.
- *
- * @param $module_name
- *   the name of the module being installed.
- *
- * @returns
- *   nothing
- *
- * @ingroup tripal_files_api
- */
-function tripal_create_moddir($module_name) {
 
-  // make the data directory for this module
-  $data_dir = file_directory_path() . "/tripal/$module_name";
-  if (!file_check_directory($data_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
-    $message = "Cannot create directory $data_dir. This module may not ".
-               "behave correctly without this directory.  Please  create ".
-               "the directory manually or fix the problem and reinstall.";
-    drupal_set_message(check_plain(t($message)), 'error');
-    watchdog('tripal_core', $message, array(), WATCHDOG_ERROR);
-  }
-}
 
-/**
- * Each Tripal module has a unique data directory which was creatd using the
- * tripal_create_moddir function during installation.  This function
- * retrieves the directory path.
- *
- * @param $module_name
- *   The name of the module
- *
- * @returns
- *   The path within the Drupal installation where the data directory resides
- * @ingroup tripal_files_api
- */
-function tripal_get_moddir($module_name) {
-  $data_dir = file_directory_path() . "/tripal/$module_name";
-  return $data_dir;
-}
+
 
 /**
  * Set the Tripal Database
@@ -3090,10 +3041,10 @@ function tripal_core_is_sql_prepared($statement_name) {
  *   The name of the prepared statement
  * @param $psql
  *   The SQL statement to be executed via chado_query.
- *   Should be of the form PREPARE <statement name> AS <SQL Statement to be prepared>
+ *   Should be of the form PREPARE [statement name] AS [SQL Statement to be prepared]
  * @param $args
  *   An array of arguements required to execute the prepared statement. The keys of
- *   the array should correspond to the $\d in the prepare statement and the value should
+ *   the array should correspond to the variables in the prepared statement and the value should
  *   be the type of value needed (ie: text, int, etc.)
  */
 function tripal_core_chado_prepare($statement_name, $psql, $args) {
@@ -3144,7 +3095,7 @@ function tripal_core_chado_prepare($statement_name, $psql, $args) {
  *   The name of the prepared statement
  * @param $sql
  *   The SQL to execute using chado query.
- *   Should be of the form EXECUTE <statement_name> (<arg1>,<arg2>...<argn>)
+ *   Should be of the form EXECUTE [statement_name] ([arg1],[arg2]...[argn])
  * @param $values
  *   An array of values in the execute sql statement
  */
@@ -3327,7 +3278,9 @@ function tripal_db_set_savepoint_transaction($savepoint, $release = FALSE) {
 }
 
 /**
- * Commit changes made during the current transaction
+ * A simple function to commit a database transaction
+ *   
+ * @return nothing
  */
 function tripal_db_commit_transaction() {
   chado_query("COMMIT");
@@ -3341,6 +3294,12 @@ function tripal_db_commit_transaction() {
  *
  * @param $savepoint
  *   The name of the saved point in the transaction to rollback to
+ *   
+ * @param $commit
+ *   The transcation will only be committed if this value is TRUE. The
+ *   default is TRUE.
+ *   
+ * @return nothing
  */
 function tripal_db_rollback_transaction($savepoint = NULL, $commit = TRUE) {
 

+ 5 - 207
tripal_core/includes/custom_tables.php

@@ -2,213 +2,11 @@
 
 /**
  * @file
- * Contains functions for the Custom Tables API
-
- * @defgroup tripal_custom_tables_api Core Module Custom Tables API
- * @{
- * Provides an application programming interface (API) to manage custom tables in Chado.
- * @}
- * @ingroup tripal_api
- */
-
-
-/**
- * Edits a custom table in the chado database. It supports 
- * using the Drupal Schema API array.
- *
- * @param $table_id
- *   The table_id of the table to edit
- * @param $table_name
- *   The name of the custom table
- * @param $schema
- *   Use the Schema API array to define the custom table.
- * @param $skip_creation
- *   Set as TRUE to skip dropping and re-creation of the table.  This is
- *   useful if the table was already created through another means and you
- *   simply want to make Tripal aware of the table schema.
- *
- * @ingroup tripal_custom_tables_api
- */
-function tripal_core_edit_custom_table($table_id, $table_name, $schema, $skip_creation = 1) {
-
-  // Create a new record
-  $record = new stdClass();
-  $record->table_id = $table_id;
-  $record->table_name = $table_name;
-  $record->schema = serialize($schema);
-
-  // get the current custom table record
-  $sql = "SELECT * FROM {tripal_custom_tables} WHERE table_id = %d";
-  $custom_table = db_fetch_object(db_query($sql, $table_id));
-  
-  // if the user changed the table name, we want to drop the old one and force
-  // creation of the new one.
-  if ($custom_table->table_name != $table_name) {
-    chado_query("DROP TABLE %s", $custom_table->table_name);  
-    $skip_creation = 0; // we want to create the table
-  }
-
-  // if skip creation is not set, then drop the table from chado if it exists
-  if(!$skip_creation){
-    if (db_table_exists($custom_table->table_name)) {
-      chado_query("DROP TABLE %s", $custom_table->table_name);
-      drupal_set_message(t("Custom Table '%name' dropped", array('%name' => $custom_table->table_name)));
-    }
-  }
-
-  // update the custom table record and re-create the table in Chado
-  if (drupal_write_record('tripal_custom_tables', $record, 'table_id')) {
-
-    // drop the table from chado if it exists
-    if(!$skip_creation){
-      if (db_table_exists($custom_table->table_name)) {
-        chado_query("DROP TABLE %s", $custom_table->table_name);
-        drupal_set_message(t("Custom Table '%name' dropped", array('%name' => $custom_table->table_name)));
-      }
-
-      // re-create the table
-      if (!tripal_core_create_custom_table ($ret, $table_name, $schema)) {
-        drupal_set_message(t("Could not create the custom table. Check Drupal error report logs."));
-      }
-      else {
-        drupal_set_message(t("Custom table '%name' created", array('%name' => $table_name)));
-      }
-    }
-    // TODO: add FK constraints
-  }
-}
-
-/**
- * Add a new table to the Chado schema. This function is simply a wrapper for
- * the db_create_table() function of Drupal, but ensures the table is created
- * inside the Chado schema rather than the Drupal schema.  If the table already
- * exists then it will be dropped and recreated using the schema provided.
- * However, it will only drop a table if it exsits in the tripal_custom_tables
- * table. This way the function cannot be used to accidentally alter existing
- * non custom tables.  If $skip_creation is set then the table is simply
- * added to the tripal_custom_tables and no table is created in Chado.
+ * Contains functions for creating, editing and deleting custom tables
+ * on the Tripal website.
  *
- * @param $ret
- *   Array to which query results will be added.
- * @param $table
- *   The name of the table to create.
- * @param $schema
- *   A Drupal-style Schema API definition of the table
- * @param $skip_creation
- *   Set as TRUE to skip dropping and re-creation of the table if it already
- *   exists.  This is useful if the table was already created through another 
- *   means and you simply want to make Tripal aware of the table schema.  If the
- *   table does not exist it will be created.
- *
- * @return
- *   A database query result resource for the new table, or FALSE if table was not constructed.
- *
- * @ingroup tripal_custom_tables_api
- */
-function tripal_core_create_custom_table(&$ret, $table, $schema, $skip_creation = 1) {
-  $ret = array();
-      
-  // see if the table entry already exists in the tripal_custom_tables table.
-  $sql = "SELECT * FROM {tripal_custom_tables} WHERE table_name = '%s'";
-  $centry = db_fetch_object(db_query($sql, $table));
-  
-  // check to see if the table already exists in the chado schema  
-  $previous_db = tripal_db_set_active('chado');  // use chado database
-  $exists = db_table_exists($table);
-  tripal_db_set_active($previous_db);  // now use drupal database
-
-  
-  // if the table does not exist then create it
-  if (!$exists) {
-    $previous_db = tripal_db_set_active('chado');  // use chado database
-    db_create_table($ret, $table, $schema);
-    tripal_db_set_active($previous_db);  // now use drupal database
-    if (count($ret)==0) {
-      watchdog('tripal_core', "Error adding custom table '!table_name'.",
-        array('!table_name' => $table), WATCHDOG_ERROR);
-      return FALSE;
-    }
-  }  
-
-  // if the table exists in Chado and in our custom table and
-  // skip creation is turned off then drop and re-create the table 
-  if ($exists and is_object($centry) and !$skip_creation) {    
-    
-    // drop the table we'll recreate it with the new schema
-    $previous_db = tripal_db_set_active('chado');  // use chado database
-    db_drop_table($ret, $table);
-    db_create_table($ret, $table, $schema);
-    tripal_db_set_active($previous_db);  // now use drupal database
-  }
-
-  // add an entry in the tripal_custom_table
-  $record = new stdClass();
-  $record->table_name = $table;
-  $record->schema = serialize($schema);
-
-  // if an entry already exists then remove it
-  if ($centry) {
-    $sql = "DELETE FROM {tripal_custom_tables} WHERE table_name = '%s'";
-    db_query($sql, $table);
-  }
-  $success = drupal_write_record('tripal_custom_tables', $record);
-  if (!$success) {
-    watchdog('tripal_core', "Error adding custom table %table_name.",
-      array('%table_name' => $table), WATCHDOG_ERROR);
-    drupal_set_message(t("Could not add custom table %table_name. 
-      Please check the schema array.", array('%table_name' => $table)), 'error');      
-    return FALSE;
-  }
-  
-  // now add any foreign key constraints
-  if(!$skip_creation and array_key_exists('foreign keys', $schema)){
-  	$fkeys = $schema['foreign keys'];
-  	foreach ($fkeys as $fktable => $fkdetails) {
-  		$relations = $fkdetails['columns'];
-  		foreach ($relations as $left => $right) {
-  			$sql = "ALTER TABLE $table ADD CONSTRAINT " . 
-  			  $table . "_" . $left . "_fkey FOREIGN KEY ($left) REFERENCES  $fktable ($right) " .
-  			  "ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED";
-  			if(!chado_query($sql)){
-  			  watchdog('tripal_core', "Error, could not add foreign key contraint to custom table.",
-            array('!table_name' => $table), WATCHDOG_ERROR);
-			    drupal_set_message(t("Could not add foreign key contraint to table %table_name. 
-			      Please check the schema array and the report log for errors.", 
-			      array('%table_name' => $table)), 'error');      
-          return FALSE;
-  			}
-  		}
-  	}
-  }
-
-  return TRUE;
-}
-
-/**
- * Retrieve the custom table id given the name
- *
- * @param $table_name
- *   The name of the custom table
- *
- * @return
- *   The unique identifier for the given table
- *
- * @ingroup tripal_custom_tables_api
+ * @ingroup tripal_core
  */
-function tripal_custom_tables_get_table_id($table_name) {
-  $sql = "SELECT * FROM {tripal_custom_tables} ".
-         "WHERE table_name = '%s'";
-  if (db_table_exists('tripal_custom_tables')) {
-    $custom_table = db_fetch_object(db_query($sql, $table_name));
-    if ($custom_table) {
-      return $custom_table->table_id;
-    }
-  }
-
-  return FALSE;
-}
-
-
 
 /**
  * A template function which returns markup to display details for the custom table
@@ -216,7 +14,7 @@ function tripal_custom_tables_get_table_id($table_name) {
  * @param $table_id
  *  The unique ID of the custom table
  *
- * @ingroup tripal_custom_tables_api
+ * @ingroup tripal_core
  */
 function tripal_custom_table_view($table_id) {
 
@@ -261,7 +59,7 @@ function tripal_custom_table_view($table_id) {
 /**
  * A template function to render a listing of all Custom tables
  *
- * @ingroup tripal_custom_tables_api
+ * @ingroup tripal_core
  */
 function tripal_custom_tables_list() {
   $header = array('', 'Table Name', 'Description');

+ 1 - 353
tripal_core/includes/jobs.php

@@ -2,135 +2,10 @@
 
 /**
  * @file
- * Contains functions related to the Tripal Jobs API
+ * Contains functions related to the display of Tripal jobs in a Tripal website.
  *
- * @defgroup tripal_jobs_api Core Module Jobs API
- * @{
- * Tripal offers a job management subsystem for managing tasks that may require an extended period of time for
- * completion.  Drupal uses a UNIX-based cron job to handle tasks such as  checking  the  availability of updates,
- * indexing new nodes for searching, etc.   Drupal's cron uses the web interface for launching these tasks, however,
- * Tripal provides several administrative tasks that may time out and not complete due to limitations of the web
- * server.  Examples including syncing of a large number of features between chado and Drupal.  To circumvent this,
- * as well as provide more fine-grained control and monitoring, Tripal uses a jobs management sub-system built into
- * the Tripal Core module.   It is anticipated that this functionality will be used for managing analysis jobs provided by
- * future tools, with eventual support for distributed computing.
- *
- * The  Tripal jobs management system allows administrators to submit tasks to be performed which can then  be
- * launched through a UNIX command-line PHP script or cron job.  This command-line script can be added to a cron
- * entry along-side the Drupal cron entry for automatic, regular launching of Tripal jobs.  The order of execution of
- * waiting jobs is determined first by priority and second by the order the jobs were entered.
- *
- * The API functions described below provide a programmatic interface for adding, checking and viewing jobs.
- * @}
- * @ingroup tripal_api
  */
 
-/**
- * Adds a job to the Tripal Jbo queue
- *
- * @param $job_name
- *    The human readable name for the job
- * @param $modulename
- *    The name of the module adding the job
- * @param $callback
- *    The name of a function to be called when the job is executed
- * @param $arguments
- *    An array of arguements to be passed on to the callback
- * @param $uid
- *    The uid of the user adding the job
- * @param $priority
- *    The priority at which to run the job where the highest priority is 10 and the lowest priority
- *    is 1. The default priority is 10.
- *
- * @return
- *    The job_id of the registered job
- *
- * Example usage:
- * @code
- *  $args = array($dfile, $organism_id, $type, $library_id, $re_name, $re_uname,
- *        $re_accession, $db_id, $rel_type, $re_subject, $parent_type, $method,
- *         $user->uid, $analysis_id, $match_type);
- *
- * tripal_add_job("Import FASTA file: $dfile", 'tripal_feature',
- *   'tripal_feature_load_fasta', $args, $user->uid);
- * @endcode
- * The code above is copied from the tripal_feature/fasta_loader.php file. The
- * snipped first builds an array of arguments that will then be passed to the
- * tripal_add_job function.  The number of arguments provided in the $arguments
- * variable should match the argument set for the callback function provided
- * as the third argument.
- *
- * @ingroup tripal_jobs_api
- */
-function tripal_add_job($job_name, $modulename, $callback, $arguments, $uid, $priority = 10) {
-
-  // convert the arguments into a string for storage in the database
-  $args = implode("::", $arguments);
-  $record = new stdClass();
-  $record->job_name = $job_name;
-  $record->modulename = $modulename;
-  $record->callback = $callback;
-  $record->status = 'Waiting';
-  $record->submit_date = time();
-  $record->uid = $uid;
-  $record->priority = $priority;  # the lower the number the higher the priority
-  if ($args) {
-    $record->arguments = $args;
-  }
-  if (drupal_write_record('tripal_jobs', $record)) {
-    $jobs_url = url("admin/tripal/tripal_jobs");
-    drupal_set_message(t("Job '%job_name' submitted.  Check the <a href='!jobs_url'>jobs page</a> for status", array('%job_name' => $job_name, '!jobs_url' => $jobs_url)));
-  }
-  else {
-    drupal_set_message(t("Failed to add job %job_name.", array('%job_name' => $job_name)), 'error');
-  }
-
-  return $record->job_id;
-}
-
-/**
- * An internal function for setting the progress for a current job
- *
- * @param $job_id
- *   The job_id to set the progress for
- * @param $percentage
- *   The progress to set the job to
- *
- * @return
- *   True on success and False otherwise
- *
- * @ingroup tripal_core
- */
-function tripal_job_set_progress($job_id, $percentage) {
-
-  if (preg_match("/^(\d+|100)$/", $percentage)) {
-    $record = new stdClass();
-    $record->job_id = $job_id;
-    $record->progress = $percentage;
-    if (drupal_write_record('tripal_jobs', $record, 'job_id')) {
-      return TRUE;
-    }
-  }
-
-  return FALSE;
-}
-
-/**
- * Returns a list of jobs associated with the given module
- *
- * @param $modulename
- *    The module to return a list of jobs for
- *
- * @return
- *    An array of objects where each object describes a tripal job
- *
- * @ingroup tripal_jobs_api
- */
-function tripal_get_module_active_jobs($modulename) {
-  $sql =  "SELECT * FROM {tripal_jobs} TJ ".
-           "WHERE TJ.end_time IS NULL and TJ.modulename = '%s' ";
-  return db_fetch_object(db_query($sql, $modulename));
-}
 /**
  *
  * @ingroup tripal_core
@@ -245,177 +120,6 @@ function tripal_jobs_report() {
   $output .= theme_pager();
   return $output;
 }
-
-/**
- * Returns the start time for a given job
- *
- * @param $job
- *   An object describing the job
- *
- * @return
- *   The start time of the job if it was already run and either "Cancelled" or "Not Yet Started" otherwise
- *
- * @ingroup tripal_jobs_api
- */
-function tripal_jobs_get_start_time($job) {
-
-  if ($job->start_time > 0) {
-    $start = format_date($job->start_time);
-  }
-  else {
-    if (strcmp($job->job_status, 'Cancelled')==0) {
-      $start = 'Cancelled';
-    }
-    else {
-      $start = 'Not Yet Started';
-    }
-  }
-  return $start;
-}
-
-/**
- * Returns the end time for a given job
- *
- * @param $job
- *   An object describing the job
- *
- * @return
- *   The end time of the job if it was already run and empty otherwise
- *
- * @ingroup tripal_jobs_api
- */
-function tripal_jobs_get_end_time($job) {
-
-  if ($job->end_time > 0) {
-    $end = format_date($job->end_time);
-  }
-  else {
-    $end = '';
-  }
-
-  return $end;
-}
-
-/**
- * Returns the date the job was added to the queue
- *
- * @param $job
- *   An object describing the job
- *
- * @return
- *   The date teh job was submitted
- *
- * @ingroup tripal_jobs_api
- */
-function tripal_jobs_get_submit_date($job) {
-  return format_date($job->submit_date);
-}
-
-/**
- * A function used to manually launch all queued tripal jobs
- *
- * @param $do_parallel
- *   A boolean indicating whether jobs should be attempted to run in parallel
- *
- * @param $job_id
- *   To launch a specific job provide the job id.  This option should be
- *   used sparingly as the jobs queue managment system should launch jobs
- *   based on order and priority.  However there are times when a specific
- *   job needs to be launched and this argument will allow it.  Only jobs
- *   which have not been run previously will run.
- *
- * @ingroup tripal_jobs_api
- */
-function tripal_jobs_launch($do_parallel = 0, $job_id = NULL) {
-
-  // first check if any jobs are currently running
-  // if they are, don't continue, we don't want to have
-  // more than one job script running at a time
-  if (!$do_parallel and tripal_jobs_check_running()) {
-    print "Jobs are still running. Use the --parallel=1 option with the Drush command to run jobs in parallel.";
-    return;
-  }
-
-  // get all jobs that have not started and order them such that
-  // they are processed in a FIFO manner.
-  if ($job_id) {
-    $sql =  "SELECT * FROM {tripal_jobs} TJ ".
-            "WHERE TJ.start_time IS NULL and TJ.end_time IS NULL and TJ.job_id = %d ".
-            "ORDER BY priority ASC,job_id ASC";
-    $job_res = db_query($sql,$job_id);
-  }
-  else {
-    $sql =  "SELECT * FROM {tripal_jobs} TJ ".
-            "WHERE TJ.start_time IS NULL and TJ.end_time IS NULL ".
-            "ORDER BY priority ASC,job_id ASC";
-    $job_res = db_query($sql);
-  }
-  while ($job = db_fetch_object($job_res)) {
-    // set the start time for this job
-    $record = new stdClass();
-    $record->job_id = $job->job_id;
-    $record->start_time = time();
-    $record->status = 'Running';
-    $record->pid = getmypid();
-    drupal_write_record('tripal_jobs', $record, 'job_id');
-
-    // call the function provided in the callback column.
-    // Add the job_id as the last item in the list of arguments. All
-    // callback functions should support this argument.
-    $callback = $job->callback;
-    $args = split("::", $job->arguments);
-    $args[] = $job->job_id;
-    print "Calling: $callback(" . implode(", ", $args) . ")\n";
-    call_user_func_array($callback, $args);
-    // set the end time for this job
-    $record->end_time = time();
-    $record->status = 'Completed';
-    $record->progress = '100';
-    drupal_write_record('tripal_jobs', $record, 'job_id');
-
-    // send an email to the user advising that the job has finished
-  }
-}
-
-/**
- * Returns a list of running tripal jobs
- *
- * @return
- *    and array of objects where each object describes a running job or FALSE if no jobs are running
- *
- * @ingroup tripal_jobs_api
- */
-function tripal_jobs_check_running() {
-
-  // iterate through each job that has not ended
-  // and see if it is still running. If it is not
-  // running but does not have an end_time then
-  // set the end time and set the status to 'Error'
-  $sql =  "SELECT * FROM {tripal_jobs} TJ ".
-         "WHERE TJ.end_time IS NULL and NOT TJ.start_time IS NULL ";
-  $jobs = db_query($sql);
-  while ($job = db_fetch_object($jobs)) {
-    $status = `ps --pid=$job->pid --no-header`;
-    if ($job->pid && $status) {
-      // the job is still running so let it go
-      // we return 1 to indicate that a job is running
-      return TRUE;
-    }
-    else {
-      // the job is not running so terminate it
-      $record = new stdClass();
-      $record->job_id = $job->job_id;
-      $record->end_time = time();
-      $record->status = 'Error';
-      $record->error_msg = 'Job has terminated unexpectedly.';
-      drupal_write_record('tripal_jobs', $record, 'job_id');
-    }
-  }
-
-  // return 1 to indicate that no jobs are currently running.
-  return FALSE;
-}
-
 /**
  * Returns the HTML code to display a given job
  *
@@ -481,60 +185,4 @@ function tripal_core_preprocess_tripal_core_job_view(&$variables) {
   $variables['job'] = $job;
 }
 
-/**
- * Set a job to be re-ran (ie: add it back into the job queue)
- *
- * @param $job_id
- *   The job_id of the job to be re-ran
- *
- * @ingroup tripal_jobs_api
- */
-function tripal_jobs_rerun($job_id, $goto_jobs_page = TRUE) {
-  global $user;
-
-  $sql = "SELECT * FROM {tripal_jobs} WHERE job_id = %d";
-  $job = db_fetch_object(db_query($sql, $job_id));
-  $args = explode("::", $job->arguments);
-  $job_id = tripal_add_job(
-    $job->job_name,
-    $job->modulename,
-    $job->callback,
-    $args,
-    $user->uid,
-    $job->priority);
-
-  if ($goto_jobs_page) {
-    drupal_goto("admin/tripal/tripal_jobs");
-  }
-  return $job_id;
-}
-
-/**
- * Cancel a Tripal Job currently waiting in the job queue
- *
- * @param $job_id
- *   The job_id of the job to be cancelled
- *
- * @ingroup tripal_jobs_api
- */
-function tripal_jobs_cancel($job_id, $redirect = TRUE) {
-  $sql = "SELECT * FROM {tripal_jobs} WHERE job_id = %d";
-  $job = db_fetch_object(db_query($sql, $job_id));
 
-  // set the end time for this job
-  if ($job->start_time == 0) {
-    $record = new stdClass();
-    $record->job_id = $job->job_id;
-    $record->end_time = time();
-    $record->status = 'Cancelled';
-    $record->progress = '0';
-    drupal_write_record('tripal_jobs', $record, 'job_id');
-    drupal_set_message(t("Job #%job_id cancelled", array('%job_id' => $job_id)));
-  }
-  else {
-    drupal_set_message(t("Job %job_id cannot be cancelled. It is in progress or has finished.", array('%job_id' => $job_id)));
-  }
-  if ($redirect) {
-    drupal_goto("admin/tripal/tripal_jobs");
-  }
-}

+ 4 - 380
tripal_core/includes/mviews.php

@@ -2,393 +2,17 @@
 
 /**
  * @file
- * Contains functions for the Materialized Views API
-
- * @defgroup tripal_mviews_api Core Module Materalized Views API
- * @{
- * Provides an application programming interface (API) to manage materialized views in Chado.
- * The Perl-based chado comes with an interface for managing materialzed views.  This
- * API provides an alternative Drupal-based method.
- * @}
- * @ingroup tripal_api
+ * Contains functions for viewing and editing of Materialized Views 
+ * on a Tripal website.
  */
 
-/**
- * Add a materialized view to the chado database to help speed data access. This
- * function supports the older style where postgres column specifications
- * are provided using the $mv_table, $mv_specs and $indexed variables. It also
- * supports the newer preferred method where the materialized view is described
- * using the Drupal Schema API array.
- *
- * @param $name
- *   The name of the materialized view.
- * @param $modulename
- *   The name of the module submitting the materialized view (e.g. 'tripal_library')
- * @param $mv_table
- *   The name of the table to add to chado. This is the table that can be queried.
- * @param $mv_specs
- *   The table definition
- * @param $indexed
- *   The columns that are to be indexed
- * @param $query
- *   The SQL query that loads the materialized view with data
- * @param $special_index
- *   currently not used
- * @param $comment
- *   A string containing a description of the materialized view
- * @param $mv_schema
- *   If using the newer Schema API array to define the materialized view then
- *   this variable should contain the array or a string representation of the 
- *   array.
- * 
- * @ingroup tripal_mviews_api
- */
-function tripal_add_mview($name, $modulename, $mv_table, $mv_specs, $indexed,
-  $query, $special_index, $comment = NULL, $mv_schema = NULL) {
-
-  // get the table name from the schema array
-  $schema_arr = array();
-  if ($mv_schema) {
-    // if the schema is provided as a string then convert it to an array
-    if (!is_array($mv_schema)) {
-      eval("\$schema_arr = $mv_schema;");
-    }
-    // if the schema is provided as an array then create a string
-    // copy of it for storage in the mview 
-    else {
-      $schema_arr = $mv_schema;
-      $mv_schema = var_export($schema_arr, 1);
-    }
-    $mv_table = $schema_arr['table'];
-  }
-
-  // Create a new record
-  $record = new stdClass();
-  $record->name = $name;
-  $record->modulename = $modulename;
-  $record->mv_table = $mv_table;
-  $record->mv_specs = $mv_specs;
-  $record->indexed = $indexed;
-  $record->query = $query;
-  $record->special_index = $special_index;
-  $record->comment = $comment;
-  $record->mv_schema = $mv_schema;
-
-  // add the record to the tripal_mviews table and if successful
-  // create the new materialized view in the chado schema
-  if (drupal_write_record('tripal_mviews', $record)) {
-
-    // drop the table from chado if it exists
-    $previous_db = tripal_db_set_active('chado');  // use chado database
-    if (db_table_exists($mv_table)) {
-      $sql = "DROP TABLE $mv_table";
-      db_query($sql);
-    }
-    tripal_db_set_active($previous_db);  // now use drupal database
-
-    // now construct the indexes
-    $index = '';
-    if ($indexed) {
-      // add to the array of values
-      $vals = preg_split("/[\n,]+/", $indexed);
-      $index = '';
-      foreach ($vals as $field) {
-        $field = trim($field);
-        $index .= "CREATE INDEX idx_${mv_table}_${field} ON $mv_table ($field);";
-      }
-    }
-
-    // create the table differently depending on if it the traditional method
-    // or the Drupal Schema API method
-    if ($mv_schema) {
-      if (!tripal_core_create_custom_table ($ret, $mv_table, $schema_arr, 0)) {
-        drupal_set_message(t("Could not create the materialized view. Check Drupal error report logs."), 'error');
-      }
-      else {
-        drupal_set_message(t("View '%name' created", array('%name' => $name)));
-      }
-    }
-    else {
-      // add the table to the database
-      $sql = "CREATE TABLE {$mv_table} ($mv_specs); $index";
-      $previous_db = tripal_db_set_active('chado');  // use chado database
-      $results = db_query($sql);
-      tripal_db_set_active($previous_db);  // now use drupal database
-      if ($results) {
-        drupal_set_message(t("View '%name' created", array('%name' => $name)));
-      }
-      else {
-        drupal_set_message(t("Failed to create the materialized view table: '%mv_table'", array('%mv_table' => $mv_table)), 'error');
-      }
-    }
-  }
-}
-
-/**
- * Edits a materialized view to the chado database to help speed data access.This
- * function supports the older style where postgres column specifications
- * are provided using the $mv_table, $mv_specs and $indexed variables. It also
- * supports the newer preferred method where the materialized view is described
- * using the Drupal Schema API array.
- *
- * @param $mview_id
- *   The mview_id of the materialized view to edit
- * @param $name
- *   The name of the materialized view.
- * @param $modulename
- *   The name of the module submitting the materialized view (e.g. 'tripal_library')
- * @param $mv_table
- *   The name of the table to add to chado. This is the table that can be queried.
- * @param $mv_specs
- *   The table definition
- * @param $indexed
- *   The columns that are to be indexed
- * @param $query
- *   The SQL query that loads the materialized view with data
- * @param $special_index
- *   currently not used
- * @param $comment
- *   A string containing a description of the materialized view
- * @param $mv_schema
- *   If using the newer Schema API array to define the materialized view then
- *   this variable should contain the array.
- *
- * @ingroup tripal_mviews_api
- */
-function tripal_edit_mview($mview_id, $name, $modulename, $mv_table, $mv_specs,
-  $indexed, $query, $special_index, $comment = NULL, $mv_schema = NULL) {
-
-  // get the table name from the schema array
-  $schema_arr = array();
-  if ($mv_schema) {
-    // get the schema from the mv_specs and use it to add the custom table
-    eval("\$schema_arr = $mv_schema;");
-    $mv_table = $schema_arr['table'];
-  }
-
-  $record = new stdClass();
-  $record->mview_id = $mview_id;
-  $record->name = $name;
-  $record->modulename = $modulename;
-  $record->query = $query;
-  $record->last_update = 0;
-  $record->status = '';
-  $record->comment = $comment;
-
-  // get the view before we update and check to see if the table structure has
-  // changed. IF so, then we want to drop and recreate the table. If not, then
-  // just save the updated SQL.
-  $create_table = 1;  
-  $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = %d";
-  $mview = db_fetch_object(db_query($sql, $mview_id));  
-  if($mview->mv_schema == $mv_schema and $mview->mv_table == $mv_table and 
-     $mview->mv_specs == $mv_specs and $mview->indexed == $indexed and 
-     $mview->special_index == $special_index) {
-    // nothing has changed so simpy update the SQL and other fields 
-    $create_table = 0;
-  }
-  else {
-    // add in the table structure fields
-    $record->mv_schema = $mv_schema;
-    $record->mv_table = $mv_table;
-    $record->mv_specs = $mv_specs;
-    $record->indexed = $indexed;
-    $record->query = $query;
-    $record->special_index = $special_index;
-  }
-  
-  // if we are going to create the table then we must first drop it if it exists
-  if ($create_table) {
-    $previous_db = tripal_db_set_active('chado');  // use chado database
-    if (db_table_exists($mview->mv_table)) {
-      $sql = "DROP TABLE %s";
-      db_query($sql, $mview->mv_table);
-      drupal_set_message(t("View '%name' dropped", array('%name' => $name)));
-    }
-    tripal_db_set_active($previous_db);  // now use drupal database
-  }
-
-  // update the record to the tripal_mviews table and if successful
-  // create the new materialized view in the chado schema
-  if (drupal_write_record('tripal_mviews', $record, 'mview_id')) {
-    // construct the indexes SQL if needed
-    $index = '';
-    if ($indexed) {
-      // add to the array of values
-      $vals = preg_split("/[\n,]+/", $indexed);
-      $index = '';
-      foreach ($vals as $field) {
-        $field = trim($field);
-        $index .= "CREATE INDEX idx_${mv_table}_${field} ON $mv_table ($field);";
-      }
-    }
-
-    // re-create the table differently depending on if it the traditional method
-    // or the Drupal Schema API method
-    if ($create_table and $mv_schema) {    	
-      if (!tripal_core_create_custom_table($ret, $mv_table, $schema_arr, 0)) {
-        drupal_set_message(t("Could not create the materialized view. Check Drupal error report logs."));
-      }
-      else {
-        drupal_set_message(t("View '%name' created", array('%name' => $name)));
-      }
-    }
-    if ($create_table and !$mv_schema) {
-      $sql = "CREATE TABLE {$mv_table} ($mv_specs); $index";
-      $results = chado_query($sql);
-      if ($results) {
-        drupal_set_message(t("View '%name' created.  All records cleared. Please re-populate the view.", 
-          array('%name' => $name)));
-      }
-      else {
-        drupal_set_message(t("Failed to create the materialized view table: '%mv_table'", 
-          array('%mv_table' => $mv_table)), 'error');
-      }
-    }
-    if (!$create_table) {
-      $message = "View '%name' updated.  All records remain. ";
-      if ($query != $mview->query) {
-        $message .= "Please repopulate the view to use updated query.";
-      }
-      drupal_set_message(t($message, array('%name' => $name)));  
-    }
-  }
-  else {
-    drupal_set_message(t("Failed to update the materialized view: '%mv_table'", 
-      array('%mv_table' => $mv_table)), 'error');  
-  }
-}
-
-/**
- * Retrieve the materialized view_id given the name
- *
- * @param $view_name
- *   The name of the materialized view
- *
- * @return
- *   The unique identifier for the given view
- *
- * @ingroup tripal_mviews_api
- */
-function tripal_mviews_get_mview_id($view_name) {
-  $sql = "SELECT * FROM {tripal_mviews} ".
-        "WHERE name = '%s'";
-  if (db_table_exists('tripal_mviews')) {
-    $mview = db_fetch_object(db_query($sql, $view_name));
-    if ($mview) {
-      return $mview->mview_id;
-    }
-  }
-
-  return FALSE;
-}
-
-/**
- * Does the specified action for the specified Materialized View
- *
- * @param $op
- *   The action to be taken. One of update or delete
- * @param $mview_id
- *   The unique ID of the materialized view for the action to be performed on
- * @param $redirect
- *   TRUE/FALSE depending on whether you want to redirect the user to admin/tripal/mviews
- *
- * @ingroup tripal_core
- */
-function tripal_mviews_action($op, $mview_id, $redirect = FALSE) {
-  global $user;
-
-  $args = array("$mview_id");
-  if (!$mview_id) {
-    return '';
-  }
-
-  // get this mview details
-  $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = %d";
-  $mview = db_fetch_object(db_query($sql, $mview_id));
-
-  // add a job or perform the action based on the given operation
-  if ($op == 'update') {
-    tripal_add_job("Populate materialized view '$mview->name'", 'tripal_core',
-       'tripal_update_mview', $args, $user->uid);
-  }
-  if ($op == 'delete') {
-    // remove the mview from the tripal_mviews table
-    $sql = "DELETE FROM {tripal_mviews} ".
-           "WHERE mview_id = $mview_id";
-    db_query($sql);
-    // drop the table from chado if it exists
-    $previous_db = tripal_db_set_active('chado');  // use chado database
-    if (db_table_exists($mview->mv_table)) {
-      $sql = "DROP TABLE $mview->mv_table";
-      db_query($sql);
-    }
-    tripal_db_set_active($previous_db);  // now use drupal database
-  }
-
-  // Redirect the user
-  if ($redirect) {
-    drupal_goto("admin/tripal/mviews");
-  }
-}
-
-/**
- * Update a Materialized View
- *
- * @param $mview_id
- *   The unique identifier for the materialized view to be updated
- *
- * @return
- *   True if successful, FALSE otherwise
- *
- * @ingroup tripal_mviews_api
- */
-function tripal_update_mview($mview_id) {
-  $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = %d ";
-  $mview = db_fetch_object(db_query($sql, $mview_id));
-  if ($mview) {    
-    // execute the query inside a transaction so that it doesn't destroy existing data
-    // that may leave parts of the site unfunctional
-    tripal_db_start_transaction();
-    $previous_db = tripal_db_set_active('chado');  // use chado database
-    $results = db_query("DELETE FROM {%s}", $mview->mv_table);
-    $results = db_query("INSERT INTO {%s} ($mview->query)", $mview->mv_table);    
-    tripal_db_set_active($previous_db);  // now use drupal database
-    if ($results) {
-      // commit the transaction
-      tripal_db_commit_transaction();
-      $sql = "SELECT count(*) as cnt FROM {%s}";
-      $previous_db = tripal_db_set_active('chado');  // use chado database
-      $count = db_fetch_object(db_query($sql, $mview->mv_table));
-      tripal_db_set_active($previous_db);  // now use drupal database
-      $record = new stdClass();
-      $record->mview_id = $mview_id;
-      $record->last_update = time();
-      $record->status = "Populated with " . number_format($count->cnt) . " rows";
-      drupal_write_record('tripal_mviews', $record, 'mview_id');
-      return TRUE;
-    }
-    else {
-      // rollback the transaction
-      tripal_db_rollback_transaction();
-      // print and save the error message
-      $record = new stdClass();
-      $record->mview_id = $mview_id;
-      $record->status = "ERROR populating. See Drupal's recent log entries for details.";
-      print $record->status . "\n";
-      drupal_write_record('tripal_mviews', $record, 'mview_id');
-      return FALSE;
-    }
-  }
-}
-
 /**
  * A template function which returns markup to display details for the current materialized view
  *
  * @param $mview_id
  *  The unique ID of the materialized view to render
  *
- * @ingroup tripal_mviews_api
+ * @ingroup tripal_core
  */
 function tripal_mview_report($mview_id) {
 
@@ -452,7 +76,7 @@ function tripal_mview_report($mview_id) {
 /**
  * A template function to render a listing of all Materialized Views
  *
- * @ingroup tripal_mviews_api
+ * @ingroup tripal_core
  */
 function tripal_mviews_report() {
   $header = array('', 'MView Name', 'Last Update', 'Status', 'Description', '');

+ 42 - 10
tripal_core/tripal_core.module

@@ -1,22 +1,54 @@
 <?php
-
-require_once "includes/jobs.php";
-require_once "includes/mviews.php";
-require_once "includes/custom_tables.php";
-require_once "includes/chado_install.php";
-require_once "api/tripal_core.api.inc";
-require_once "api/tripal_core.ahah.inc";
-
 /**
+ * @file
+ * The Tripal Core module
+ */
+
+ /**
  * @defgroup tripal_modules Tripal Modules
  * @{
- * All documented functions for the various Tripal Modules
+ * All documented functions for the various Tripal Modules excluding API functions and Views Integration functions. 
  * @}
+ */
+
+/**
+ * @defgroup tripal_api Tripal API
+ * @{
+ * Provides an application programming interface (API) for Tripal
+ *
+ * The Tripal API currently provides generic insert/update/select functions for all chado content as 
+ * well as some module specific functions that insert/update/delete/select specific chado content. 
  *
- * @defgroup tripal_core Core Tripal Module
+ * This API is currently in its infancy and some necessary functions might be missing. If you find
+ * a missing function that you think should be included go to the sourceforge feature request 
+ * page and request it's inclusion in the API. Such feature requests with a working function 
+ * definition will be given priority.
+ * @}
+ */
+
+ /**
+ * @defgroup tripal_core_api Core Module API
+ * @ingroup tripal_api
+ */
+
+/**
+ * @defgroup tripal_core Tripal Core Module
  * @ingroup tripal_modules
  */
 
+
+
+require_once "api/tripal_core_chado.api.inc";
+require_once "api/tripal_core_files.api.inc";
+require_once "api/tripal_core_ahah.api.inc";
+require_once "api/tripal_core_custom_tables.api.inc";
+require_once "api/tripal_core_jobs.api.inc";
+require_once "api/tripal_core_mviews.api.inc";
+require_once "includes/jobs.php";
+require_once "includes/mviews.php";
+require_once "includes/custom_tables.php";
+require_once "includes/chado_install.php";
+
 /**
  * Implements hook_init().
  * Used to set the search_path, create default content and set default variables.

+ 0 - 1
tripal_cv/api/tripal_cv.api.inc

@@ -6,7 +6,6 @@
  *
  * @defgroup tripal_cv_api CV Module API
  * @ingroup tripal_api
- * @ingroup tripal_cv
  * This module provides a set of functions to simplify working with
  * controlled vocabularies.  Most of the API functions deal with retrieving
  * terms or their parent vocabularies.

+ 8 - 7
tripal_cv/includes/obo_loader.inc

@@ -1,4 +1,11 @@
 <?php
+/**
+ * @file
+ * Tripal Ontology Loader
+ *
+ * @defgroup tripal_obo_loader Ontology Loader
+ * @ingroup tripal_cv
+ */
 
 /**
  * Purpose: Provides the form to load an already existing controlled
@@ -166,13 +173,7 @@ function tripal_cv_cvtermpath_form() {
 
   return $form;
 }
-/**
- * @file
- * Tripal Ontology Loader
- *
- * @defgroup tripal_obo_loader Tripal Ontology Loader
- * @ingroup tripal_cv
- */
+
 
 /**
  *

+ 0 - 1
tripal_cv/tripal_cv.views.inc

@@ -13,7 +13,6 @@
 /**
  * @defgroup tripal_cv_views Controlled Vocabulary Views Integration
  * @ingroup views
- * @ingroup tripal_cv
  */
 
 /**

+ 0 - 1
tripal_db/api/tripal_db.api.inc

@@ -6,7 +6,6 @@
  *
  * @defgroup tripal_db_api DB Module API
  * @ingroup tripal_api
- * @ingroup tripal_db
  */
 
 /**

+ 0 - 1
tripal_db/tripal_db.views.inc

@@ -13,7 +13,6 @@
 /**
  * @defgroup tripal_db_views External Database Views Integration
  * @ingroup views
- * @ingroup tripal_db
  */
 
 /**

+ 4 - 2
tripal_feature/api/tripal_feature.api.inc

@@ -1,10 +1,12 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Provides an application programming interface (API) for working with features
+ *
+ * @defgroup tripal_feature_api Feature Module API
+ * @ingroup tripal_api
  */
 
-
 /**
  * Retrieve properties from the analysisfeatureprop table for a feature.
  *

+ 2 - 1
tripal_feature/includes/fasta_loader.inc

@@ -8,10 +8,11 @@
 
 /**
  * @defgroup fasta_loader FASTA Feature Loader
+ * @ingroup tripal_feature
  * @{
  * Provides fasta loading functionality. Creates features based on their specification in a fasta file.
  * @}
- * @ingroup tripal_feature
+ * 
  */
 
 /**

+ 1 - 1
tripal_feature/includes/gff_loader.inc

@@ -7,10 +7,10 @@
 
 /**
  * @defgroup gff3_loader GFF3 Feature Loader
+ * @ingroup tripal_feature
  * @{
  * Provides gff3 loading functionality. Creates features based on their specification in a GFF3 file.
  * @}
- * @ingroup tripal_feature
  */
 
 /**

+ 1 - 1
tripal_feature/tripal_feature.module

@@ -7,10 +7,10 @@
 
 /**
  * @defgroup tripal_feature Feature
+ * @ingroup tripal_modules
  * @{
  * Provides functions for managing chado features including creating details pages for each feature
  * @}
- * @ingroup tripal_modules
  */
 
 require_once "includes/tripal_feature.admin.inc";

+ 0 - 1
tripal_feature/tripal_feature.views.inc

@@ -13,7 +13,6 @@
 /**
  * @defgroup tripal_feature_views Feature Views Integration
  * @ingroup views
- * @ingroup tripal_feature
  */
 
 /**

+ 1 - 1
tripal_featuremap/tripal_featuremap.module

@@ -2,10 +2,10 @@
 
 /**
  * @defgroup tripal_featuremap Map
+ * @ingroup tripal_modules
  * @{
  * Provides functions for managing chado maps including creating details pages for each map
  * @}
- * @ingroup tripal_modules
  */
 
 require('api/tripal_featuremap.api.inc');

+ 0 - 1
tripal_featuremap/tripal_featuremap.views.inc

@@ -13,7 +13,6 @@
 /**
  * @defgroup tripal_featuremap_views Map Views Integration
  * @ingroup views
- * @ingroup tripal_featuremap
  */
 
 /*************************************************************************

+ 5 - 0
tripal_genetic/tripal_genetic.views.inc

@@ -10,6 +10,11 @@
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
+/**
+ * @defgroup tripal_genetic_views Genetic Views Integration
+ * @ingroup views
+ */
+
 /*************************************************************************
  * Implements hook_views_data()
  * Purpose: Describe chado/tripal tables & fields to views

+ 2 - 5
tripal_library/api/tripal_library.api.inc

@@ -1,13 +1,10 @@
 <?php
 /**
  * @file
- * @todo Add file header description
- */
-
-/**
+ * Provides an application programming interface (API) to manage libraries
+ *
  * @defgroup tripal_library_api Library Module API
  * @ingroup tripal_api
- * @ingroup tripal_library
  */
 
 /**

+ 1 - 1
tripal_library/tripal_library.module

@@ -2,10 +2,10 @@
 
 /**
  * @defgroup tripal_library Library
+ * @ingroup tripal_modules
  * @{
  * Provides functions for managing chado libraries including creating details pages for each library
  * @}
- * @ingroup tripal_modules
  */
 
 require('api/tripal_library.api.inc');

+ 0 - 1
tripal_library/tripal_library.views.inc

@@ -13,7 +13,6 @@
 /**
  * @defgroup tripal_library_views Library Views Integration
  * @ingroup views
- * @ingroup tripal_library
  */
 
 /*************************************************************************

+ 6 - 0
tripal_natural_diversity/tripal_natural_diversity.views.inc

@@ -9,6 +9,12 @@
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
+/**
+ * @defgroup tripal_natural_diversity_views Natural Diversity Views Integration
+ * @ingroup views
+ */
+
+
 /**
  * Implements hook_views_data()
  * Purpose: Describe chado/tripal tables & fields to views

+ 4 - 10
tripal_organism/api/tripal_organism.api.inc

@@ -2,7 +2,10 @@
 
 /**
  * @file
- * Provides an API to tripal organisms
+ * Provides an application programming interface (API) to manage organisms
+ *
+ * @defgroup tripal_library_api Organism Module API
+ * @ingroup tripal_api
  */
 
 /**
@@ -40,15 +43,6 @@ function tripal_organism_get_organism_by_organism_id($organism_id) {
 
 }
 
-/**
- * @section Chado Table Descriptions
- * There should be a default table description for all chado tables included
- * in core.
- */
-
-
-
-
 /**
  *  Returns a list of organisms that are currently synced with Drupal
  * @ingroup tripal_organism_api

+ 0 - 1
tripal_organism/tripal_organism.views.inc

@@ -13,7 +13,6 @@
 /**
  * @defgroup tripal_organism_views Organism Views Integration
  * @ingroup views
- * @ingroup tripal_organism
  */
 
 /**

+ 5 - 0
tripal_phenotype/tripal_phenotype.views.inc

@@ -10,6 +10,11 @@
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
+/**
+ * @defgroup tripal_phenotype_views Phenotype Views Integration
+ * @ingroup views
+ */
+
 /*************************************************************************
  * Implements hook_views_data()
  * Purpose: Describe chado/tripal tables & fields to views

+ 2 - 3
tripal_project/api/tripal_project.api.inc

@@ -1,13 +1,12 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Provides an application programming interface (API) to manage projects
  */
 
 /**
- * @defgroup tripal_project_api Library Module API
+ * @defgroup tripal_project_api Project Module API
  * @ingroup tripal_api
- * @ingroup tripal_project
  */
 
 /**

+ 5 - 0
tripal_project/tripal_project.views.inc

@@ -10,6 +10,11 @@
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
+/**
+ * @defgroup tripal_project_views Project Views Integration
+ * @ingroup views
+ */
+
 /*************************************************************************
  * Implements hook_views_data()
  * Purpose: Describe chado/tripal tables & fields to views

+ 1 - 2
tripal_stock/api/tripal_stock.api.inc

@@ -1,13 +1,12 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Provides an application programming interface (API) to manage stocks
  */
 
 /**
  * @defgroup tripal_stock_api Stock Module API
  * @ingroup tripal_api
- * @ingroup tripal_stock
  */
 
 /**

+ 1 - 1
tripal_stock/tripal_stock.module

@@ -7,6 +7,7 @@
 
 /**
  * @defgroup tripal_stock Stock Module
+ * @ingroup tripal_modules
  * @{
  * Provides functions for managing chado stocks including creating details pages for each stock
  *
@@ -19,7 +20,6 @@
  * transgene), and could be described by some ontology term. For more information about the chado
  * Stock Module see the GMOD Wiki Page (http://gmod.org/wiki/Chado_Stock_Module)
  * @}
- * @ingroup tripal_modules
  */
 require_once("includes/tripal_stock-administration.inc");
 require_once("includes/other_module_api_functions.inc");

+ 0 - 1
tripal_stock/tripal_stock.views.inc

@@ -13,7 +13,6 @@
 /**
  * @defgroup tripal_stock_views Stock Views Integration
  * @ingroup views
- * @ingroup tripal_stock
  */
 
 /**

+ 12 - 5
tripal_views/tripal_views.views.inc

@@ -16,30 +16,37 @@ include('views/chado_linking.TMP.inc');
  * @{
  * Provide rules for formatting and composition of fields
  * @}
+ * 
+ * @defgroup views_handlers Views Integration Handlers
+ * @ingroup views
+ * @{
+ * Provide rules for formatting and composition of fields
+ * @}
  *
  * @defgroup views_field_handlers Views Field Handlers
+ * @ingroup views_handlers
  * @{
  * Provide rules for formatting and composition of fields
  * @}
- * @ingroup views
+ * 
  *
  * @defgroup views_filter_handlers Views Filter Handlers
+ * @ingroup views_handlers
  * @{
  * Provide the ability to filter based on specified data
- * @}
- * @ingroup views
+ * @} 
  *
  * @defgroup views_sort_handlers Views Sort Handlers
+ * @ingroup views_handlers
  * @{
  * Provide methods describing how specific data should be sorted
  * @}
- * @ingroup views
  *
  * @defgroup views_argument_handlers Views Arguement Handlers
+ * @ingroup views_handlers
  * @{
  * Provide the ability to filter pased on arguments in the path of the view
  * @}
- * @ingroup views
  */
 
 /**