Browse Source

Renamed the tripal api functions for improved readability and consistency. Created deprecated file to ensure backwards compatibility.

Lacey Sanderson 11 years ago
parent
commit
d32cab3f4d

+ 838 - 0
tripal_core/api/tripal_core.DEPRECATED.inc

@@ -0,0 +1,838 @@
+<?php
+/**
+ * @file
+ * Contains all the deprecated functions to keep the tripal api backwards compatible.
+ */
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_get_id_from_nid().
+ */
+function chado_get_id_for_node($table, $nid) {
+  //New API Function
+  return chado_get_id_from_nid($table, $nid);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_get_nid_from_id().
+ */
+function chado_get_node_id($table, $id) {
+  //New API Function
+  return chado_get_nid_from_id($table, $id);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_cleanup_orphaned_nodes().
+ */
+function tripal_core_chado_node_cleanup_orphaned($table, $job_id = NULL) {
+  //New API Function
+  return chado_cleanup_orphaned_nodes($table, $job_id);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_dbxrefs().
+ */
+function chado_node_additional_dbxrefs_form(&$form, &$form_state, $details) {
+  //New API Function
+  return chado_add_node_form_dbxrefs($form, $form_state, $details);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_dbxrefs().
+ */
+function chado_node_additional_dbxrefs_form_add_button_validate($form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_dbxrefs_add_button_validate($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_dbxrefs().
+ */
+function chado_node_additional_dbxrefs_form_add_button_submit(&$form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_dbxrefs_add_button_submit($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_dbxrefs().
+ */
+function chado_node_additional_dbxrefs_form_remove_button_validate($form, $form_state) {
+  //New API Function
+  return chado_add_node_form_dbxrefs_remove_button_validate($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_dbxrefs().
+ */
+function chado_node_additional_dbxrefs_form_remove_button_submit(&$form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_dbxrefs_remove_button_submit($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_dbxrefs().
+ */
+function chado_node_additional_dbxrefs_form_ajax_update($form, $form_state) {
+  //New API Function
+  return chado_add_node_form_dbxrefs_ajax_update($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_dbxrefs().
+ */
+function chado_node_additional_dbxrefs_form_create_dbxref_formstate_array($form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_dbxrefs_create_dbxref_formstate_array($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_dbxrefs().
+ */
+function theme_chado_node_additional_dbxrefs_form_table($variables) {
+  //New API Function
+  return theme_chado_add_node_form_dbxrefs_table($variables);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_retrieve_node_form_dbxrefs().
+ */
+function chado_node_additional_dbxrefs_form_retreive($node) {
+  //New API Function
+  return chado_retrieve_node_form_dbxrefs($node);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_update_node_form_dbxrefs().
+ */
+function chado_node_additional_dbxrefs_form_update_dbxrefs($node, $details, $retrieved_dbxrefs = FALSE) {
+  //New API Function
+  return chado_update_node_form_dbxrefs($node, $details, $retrieved_dbxrefs);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_properties().
+ */
+function chado_node_properties_form($form, $form_state, $details) {
+  //New API Function
+  return chado_add_node_form_properties($form, $form_state, $details);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_properties().
+ */
+function chado_node_properties_form_add_button_validate($form, &$form_state) {
+  //New API Function
+  return chado_update_node_form_properties_add_button_validate($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_properties().
+ */
+function chado_node_properties_form_add_button_submit(&$form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_properties_add_button_submit($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_properties().
+ */
+function chado_node_properties_form_remove_button_validate($form, $form_state) {
+  //New API Function
+  return chado_add_node_form_properties_remove_button_validate($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_properties().
+ */
+function chado_node_properties_form_remove_button_submit(&$form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_properties_remove_button_submit($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_properties().
+ */
+function chado_node_properties_form_ajax_update($form, $form_state) {
+  //New API Function
+  return chado_add_node_form_properties_ajax_update($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_properties().
+ */
+function chado_node_properties_form_create_property_formstate_array($form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_properties_create_property_formstate_array($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_properties().
+ */
+function theme_chado_node_properties_form_table($variables) {
+  //New API Function
+  return theme_chado_add_node_form_properties($variables);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_retrieve_node_form_properties().
+ */
+function chado_node_properties_form_retreive($node) {
+  //New API Function
+  return chado_retrieve_node_form_properties($node);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_update_node_form_properties().
+ */
+function chado_node_properties_form_update_properties($node, $details, $retrieved_properties = FALSE) {
+  //New API Function
+  return chado_update_node_form_properties($node, $details, $retrieved_properties);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_relationships().
+ */
+function chado_node_relationships_form(&$form, &$form_state, $details) {
+  //New API Function
+  return chado_add_node_form_relationships($form, $form_state, $details);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_relationships().
+ */
+function chado_node_relationships_form_add_button_validate($form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_relationships_add_button_validate($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_relationships().
+ */
+function chado_node_relationships_form_add_button_submit(&$form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_relationships_add_button_submit($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_relationships().
+ */
+function chado_node_relationships_form_remove_button_validate($form, $form_state) {
+  //New API Function
+  return chado_add_node_form_relationships_form_remove_button_validate($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_relationships().
+ */
+function chado_node_relationships_form_remove_button_submit(&$form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_relationships_remove_button_submit($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_relationships().
+ */
+function chado_node_relationships_form_ajax_update($form, $form_state) {
+  //New API Function
+  return chado_add_node_form_relationships_ajax_update($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_relationships().
+ */
+function chado_node_relationships_form_create_relationship_formstate_array($form, &$form_state) {
+  //New API Function
+  return chado_add_node_form_relationships_create_relationship_formstate_array($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_relationships().
+ */
+function theme_chado_node_relationships_form_table($variables) {
+  //New API Function
+  return theme_chado_add_node_form_relationships_table($variables);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_add_node_form_relationships().
+ */
+function chado_node_relationships_name_to_id_callback($base_table, $name_field, $string) {
+  //New API Function
+  return chado_add_node_form_relationships_name_to_id_callback($base_table, $name_field, $string);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_retrieve_node_form_relationships().
+ */
+function chado_node_relationships_form_retreive($node) {
+  //New API Function
+  return chado_retrieve_node_form_relationships($node);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_update_node_form_relationships().
+ */
+function chado_node_relationships_form_update_relationships($node, $details, $retrieved_relationships = FALSE) {
+  //New API Function
+  return chado_update_node_form_relationships($node, $details, $retrieved_relationships);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_node_sync_form().
+ */
+function tripal_core_chado_node_sync_form($form, &$form_state) {
+  //New API Function
+  return chado_node_sync_form($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_node_sync_form_submit().
+ */
+function tripal_core_chado_node_sync_form_submit($form, $form_state) {
+  //New API Function
+  return chado_node_sync_form_submit($form, $form_state);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_node_sync_records().
+ */
+function tripal_core_chado_node_sync_records($base_table, $max_sync = FALSE, $organism_id = FALSE,
+    $types = array(), $ids = array(), $job_id = NULL) {
+  //New API Function
+  return chado_node_sync_records($base_table, $max_sync, $organism_id, $types, $ids, $job_id);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * There is no new functionality as this function was deamed unnecessary.
+ */
+function tripal_core_is_tripal_node_type() {
+
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_schema_get_foreign_key().
+ */
+function tripal_core_chado_get_foreign_key($table_desc, $field, $values, $options = NULL) {
+  //New API Function
+  return chado_schema_get_foreign_key($table_desc, $field, $values, $options);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_delete_record().
+ */
+function tripal_core_chado_delete($table, $match, $options = NULL) {
+  //New API Function
+  return chado_delete_record();
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_expand_var().
+ */
+function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_options = array()) {
+  //New API Function
+  return chado_expand_var($object, $type, $to_expand, $table_options);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_generate_var().
+ */
+function tripal_core_generate_chado_var($table, $values, $base_options = array()) {
+  //New API Function
+  return chado_generate_var($table, $values, $base_options);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_insert_record().
+ */
+function tripal_core_chado_insert($table, $values, $options = array()) {
+  //New API Function
+  return chado_insert_record($table, $values, $options);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_select_record();
+ */
+function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
+  //New API Function
+  return chado_select_record($table, $columns, $values, $options);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_update_record();
+ */
+function tripal_core_chado_update($table, $match, $values, $options = NULL) {
+  //New API Function
+  return chado_update_record($table, $match, $values, $options);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_create_files_dir();
+ */
+function tripal_create_moddir($module_name) {
+  //New API Function
+  return tripal_create_files_dir($module_name);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_create_files_dir();
+ */
+function tripal_create_mod_subdir($module_name, $path) {
+  //New API Function
+  return tripal_create_files_dir($module_name, $path);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_create_files_dir().
+ */
+function tripal_file_directory_path() {
+  //New API Function
+  return tripal_get_files_dir();
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_get_files_dir().
+ */
+function tripal_get_moddir($module_name) {
+  //New API Function
+  return tripal_get_files_dir($module_name);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_cancel_job().
+ */
+function tripal_jobs_cancel($job_id, $redirect = TRUE) {
+  //New API Function
+  return tripal_cancel_job($job_id);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_get_active_jobs().
+ */
+function tripal_get_module_active_jobs($modulename) {
+  //New API Function
+  return tripal_get_active_jobs($modulename);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_get_job_end().
+ */
+function tripal_jobs_get_end_time($job) {
+  //New API Function
+  return tripal_get_job_end($job);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_get_job_start().
+ */
+function tripal_jobs_get_start_time($job) {
+  //New API Function
+  return tripal_get_job_start($job);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_get_job_submit_date().
+ */
+function tripal_jobs_get_submit_date($job) {
+  //New API Function
+  return tripal_get_job_submit_date($job);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_is_job_running().
+ */
+function tripal_jobs_check_running() {
+  //New API Function
+  return tripal_is_job_running();
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_launch_job().
+ */
+function tripal_jobs_launch($do_parallel = 0, $job_id = NULL) {
+  //New API Function
+  return tripal_launch_job($do_parallel, $job_id);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_rerun_job().
+ */
+function tripal_jobs_rerun($job_id, $goto_jobs_page = TRUE) {
+  //New API Function
+  return tripal_rerun_job($job_id, $goto_jobs_page);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_set_job_progress().
+ */
+function tripal_job_set_progress($job_id, $percentage) {
+  //New API Function
+  return tripal_set_job_progress($job_id, $percentage);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_update_mview().
+ */
+function tripal_mviews_action($op, $mview_id, $redirect = FALSE) {
+
+  if ($op == 'update') {
+    //New API Function
+    return tripal_add_populate_mview($mview_id, $redirect);
+  }
+  if ($op == 'delete') {
+    //New API Function
+    return tripal_delete_mview($mview_id, $redirect);
+  }
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 1.0 and will is in the process of being removed.
+ */
+function tripal_add_legacy_mview($name, $modulename, $mv_table, $mv_specs, $indexed,
+  $query, $special_index, $comment) {
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_populate_mview();
+ */
+function tripal_update_mview($mview_id) {
+  //New API Function
+  return tripal_populate_mview($mview_id);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_delete_property().
+ */
+function tripal_core_delete_property_by_id($basetable, $record_id) {
+  //New API Function
+  // D7 @todo: change parameters
+  return chado_delete_property($basetable, $record_id);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_delete_property().
+ */
+function tripal_core_delete_property($basetable, $record_id, $property, $cv_name) {
+  //New API Function
+  // D7 @todo: change parameters
+  return chado_delete_property($basetable, $record_id, $property, $cv_name);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_get_property().
+ */
+function tripal_core_get_property($basetable, $record_id, $property, $cv_name) {
+  //New API Function
+  return chado_get_property($basetable, $record_id, $property, $cv_name);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_get_table_max_rank().
+ */
+function tripal_core_get_max_chado_rank($tablename, $where_options) {
+  //New API Function
+  return chado_get_table_max_rank($tablename, $where_options);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_insert_property().
+ */
+function tripal_core_insert_property($basetable, $record_id, $property,
+$cv_name, $value, $update_if_present = 0) {
+  //New API Function
+  return chado_insert_property($basetable, $record_id, $property, $cv_name, $value, $update_if_present);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_update_property().
+ */
+function tripal_core_update_property_by_id($basetable, $record_id, $property,
+$cv_name, $value) {
+  //New API Function
+  // D7 @todo: change parameters
+  return chado_update_property($basetable, $record_id, $property, $cv_name, $value);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_update_property().
+ */
+function tripal_core_update_property($basetable, $record_id, $property,
+$cv_name, $value, $insert_if_missing = 0) {
+  //New API Function
+  // D7 @todo: change parameters
+  return chado_update_property($basetable, $record_id, $property, $cv_name, $value, $insert_if_missing);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_create_custom_table().
+ */
+function tripal_core_create_custom_table($table, $schema, $skip_creation = 1) {
+  //New API Function
+  return chado_create_custom_table($table, $schema, $skip_creation);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_edit_custom_table().
+ */
+function tripal_core_edit_custom_table($table_id, $table_name, $schema, $skip_creation = 1) {
+  //New API Function
+  return chado_edit_custom_table($table_id, $table_name, $schema, $skip_creation);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_get_custom_table_id().
+ */
+function tripal_custom_tables_get_table_id($table_name) {
+  //New API Function
+  return chado_get_custom_table_id($table_name);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_get_custom_table_schema().
+ */
+function tripal_get_chado_custom_schema($table) {
+  //New API Function
+  return chado_get_custom_table_schema($table);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_is_installed().
+ */
+function tripal_core_is_chado_installed() {
+  //New API Function
+  return chado_is_installed();
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_get_schema().
+ */
+function tripal_core_get_chado_table_schema($table) {
+  //New API Function
+  return chado_get_schema($table);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_get_version().
+ */
+function tripal_core_get_chado_version($exact = FALSE, $warn_if_unsupported = FALSE) {
+  //New API Function
+  return chado_get_version($exact, $warn_if_unsupported);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_set_active().
+ */
+function tripal_db_set_active($dbname  = 'default') {
+  //New API Function
+  return chado_set_active($dbname);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_is_local().
+ */
+function tripal_core_is_chado_local() {
+  //New API Function
+  return chado_is_local();
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_get_table_names().
+ */
+function tripal_core_get_chado_tables($include_custom = NULL) {
+  //New API Function
+  return chado_get_table_names($include_custom);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_is_local().
+ */
+function tripal_core_chado_schema_exists() {
+  //New API Function
+  return chado_is_local();
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see chado_dbschema_exists().
+ */
+function tripal_core_schema_exists($schema) {
+  //New API Function
+  return chado_dbschema_exists($schema);
+}
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_set_admin_message().
+ *
+function theme_tripal_admin_message($variables) {
+  //New API Function
+  return tripal_set_admin_message();
+}
+*/
+
+/**
+ * @deprecated Restructured API to make naming more readable and consistent.
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
+ * This function has been replaced by @see tripal_report_error().
+ */
+function tripal_core_report_error($type, $severity, $message, $variables = array(), $options = array()) {
+  //New API Function
+  return tripal_report_error($type, $severity, $message, $variables, $options);
+}

+ 20 - 39
tripal_core/api/tripal_core.chado_general.api.inc

@@ -20,7 +20,7 @@ require_once "tripal_core.schema_v1.11.api.inc";
  * foreign keys also nested.  The only fields that are not included are text
  * fields (which may be very large) or many-to-many foreign key relationships.
  * However, these fields and relationships can be expanded using the
- * tripal_core_expand_chado_vars.
+ * chado_expand_var.
  *
  * When a row from a chado table is selected using these two functions, it provides
  * a way for users who want to cutomize Drupal template files to access all data
@@ -44,25 +44,6 @@ define('TRIPAL_NOTICE',5);
 define('TRIPAL_INFO',6);
 define('TRIPAL_DEBUG',7);
 
-
-/**
- * This function is used to set the global Chado variables
- * @ingroup tripal_chado_api
- */
-function tripal_core_set_globals() {
-  // these global variables are meant to be accessed by all Tripal
-  // modules to find the chado version installed and if Chado is local.
-  // these variables are stored as globals rather than using the drupal_set_variable
-  // functions because the Drupal functions make databaes queries and for long
-  // running loaders we don't want those queries repeatedly.
-  $GLOBALS["chado_is_installed"]  = tripal_core_is_chado_installed();
-  if ($GLOBALS["chado_is_installed"]) {
-    $GLOBALS["chado_is_local"]      = tripal_core_is_chado_local();
-    $GLOBALS["chado_version"]       = tripal_core_get_chado_version();
-    $GLOBALS["exact_chado_version"] = tripal_core_get_chado_version(TRUE);
-  }
-}
-
 /**
  * Provide better error notice for Tripal
  * @param $type
@@ -90,7 +71,7 @@ function tripal_core_set_globals() {
  *
  * @ingroup tripal_chado_api
  */
-function tripal_core_report_error($type, $severity, $message, $variables = array(), $options = array()) {
+function tripal_report_error($type, $severity, $message, $variables = array(), $options = array()) {
 
   // Get human-readable severity string
   $severity_string = '';
@@ -137,16 +118,16 @@ function tripal_core_report_error($type, $severity, $message, $variables = array
  * Get chado id for a node. E.g, if you want to get 'analysis_id' from the
  * 'analysis' table for a synced 'chado_analysis' node, (the same for
  * organisms and features):
- * $analysis_id = chado_get_id_for_node ('analysis', $node->nid)
- * $organism_id = chado_get_id_for_node ('organism', $node->nid)
- * $feature_id  = chado_get_id_for_node ('feature', $node->nid)
+ * $analysis_id = chado_get_id_from_nid ('analysis', $node->nid)
+ * $organism_id = chado_get_id_from_nid ('organism', $node->nid)
+ * $feature_id  = chado_get_id_from_nid ('feature', $node->nid)
  *
  * @param $table
  * @param $nid
  *
  * @ingroup tripal_chado_api
  */
-function chado_get_id_for_node($table, $nid) {
+function chado_get_id_from_nid($table, $nid) {
   $sql = "SELECT " . $table . "_id as id FROM {chado_$table} WHERE nid = :nid";
   return db_query($sql, array(':nid' => $nid))->fetchField();
 }
@@ -154,14 +135,14 @@ function chado_get_id_for_node($table, $nid) {
 /**
  *  Get node id for a chado feature/organism/analysis. E.g, if you want to
  *  get the node id for an analysis, use:
- *  $nid = chado_get_node_id ('analysis', $analysis_id)
+ *  $nid = chado_get_nid_from_id ('analysis', $analysis_id)
  *  Likewise,
- *  $nid = chado_get_node_id ('organism', $organism_id)
- *  $nid = chado_get_node_id ('feature', $feature_id)
+ *  $nid = chado_get_nid_from_id ('organism', $organism_id)
+ *  $nid = chado_get_nid_from_id ('feature', $feature_id)
  *
  *  @ingroup tripal_chado_api
  */
-function chado_get_node_id($table, $id) {
+function chado_get_nid_from_id($table, $id) {
   $sql = "SELECT nid FROM {chado_$table} WHERE " . $table . "_id = :" . $table . "_id";
   return db_query($sql, array(":" . $table . "_id" => $id))->fetchField();
 }
@@ -169,7 +150,7 @@ function chado_get_node_id($table, $id) {
 /**
  * Set the Tripal Database
  *
- * The tripal_db_set_active function is used to prevent namespace collisions
+ * The chado_set_active function is used to prevent namespace collisions
  * when chado and drupal are installed in the same database but in different
  * schemas.  It is also used for backwards compatibility with older versions
  * of tripal or in cases where chado is located outside of the Drupal database.
@@ -177,7 +158,7 @@ function chado_get_node_id($table, $id) {
  *
  * @ingroup tripal_chado_api
  */
-function tripal_db_set_active($dbname  = 'default') {
+function chado_set_active($dbname  = 'default') {
   global $databases, $active_db;
 
   if ($dbname ) {
@@ -218,7 +199,7 @@ function tripal_db_set_active($dbname  = 'default') {
  *
  * @ingroup tripal_chado_api
  */
-function tripal_core_get_max_chado_rank($tablename, $where_options) {
+function chado_get_table_max_rank($tablename, $where_options) {
 
   $where_clauses = array();
   $where_args = array();
@@ -248,24 +229,24 @@ function tripal_core_get_max_chado_rank($tablename, $where_options) {
 }
 
 /**
- * Use this function to encapsulate text intended to be 
+ * Use this function to encapsulate text intended to be
  * visible only by the site administrator. A small tripal logo
  * appears alongside the text.  Do not call this function directly, but
  * rather, use the theme() function:
- * 
+ *
  *   theme('tripal_admin_message', array('message' => $my_message));
- * 
+ *
  * @param $message
  *   The message to be displayed to the site administrator
- * 
+ *
  * @ingroup tripal_chado_api
  */
 function theme_tripal_admin_message($variables) {
-  
+
   $message = $variables['message'];
-  
+
   if (!user_access('access administration pages')) {
-    return ''; 
+    return '';
   }
   return "
     <div class=\"tripal-site-admin-only\">

+ 17 - 16
tripal_core/api/tripal_core.chado_nodes.api.inc

@@ -11,7 +11,7 @@
  * it easier for new Tripal modules to implement drupal node types and to centralize the
  * maintenance effort as much as possible.
  *
- * A generic sync form has been created. See tripal_core_chado_node_sync_form() for
+ * A generic sync form has been created. See chado_node_sync_form() for
  * instructions on how to implement this form in your module.
  *
  * Many of the base chado tables also have associated prop, _dbxref and _relationship
@@ -19,7 +19,7 @@
  * implement this functionality you call the mini-form from your module node form and
  * then call the associated update functions from both your hook_insert and hook_update.
  * The functions of interest are as follows:
- *   - chado_node_properties_form() and chado_node_properties_form_update_properties()
+ *   - chado_add_node_form_properties() and chado_update_node_form_properties()
  *     to provide an interface for adding/removing properties
  *   - tripal_core_additional_dbxrefs_form() and tripal_core_additional_dbxrefs_form_update_dbxrefs()
  *     to provide an interface for adding/removing additional database references
@@ -38,7 +38,7 @@
  *   TRUE if it is linked to a node and FALSE otherwise
  *
  * @ingroup tripal_chado_node_api
- */
+ *
 function tripal_core_is_tripal_node_type($chado_table) {
   $linking_table = 'chado_' . $chado_table;
   if (db_table_exists($linking_table)) {
@@ -48,6 +48,7 @@ function tripal_core_is_tripal_node_type($chado_table) {
     return FALSE;
   }
 }
+*/
 
 /**
  * Sync'ing chado records with Drupal by creating nodes
@@ -65,7 +66,7 @@ function tripal_core_is_tripal_node_type($chado_table) {
       'title' => ' Sync',
       'description' => 'Sync examples from Chado with Drupal',
       'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_core_chado_node_sync_form', $module_name, $linking_table),
+      'page arguments' => array('chado_node_sync_form', $module_name, $linking_table),
       'access arguments' => array('administer tripal examples'),
       'type' => MENU_LOCAL_TASK,
       'weight' => 0
@@ -146,7 +147,7 @@ function tripal_core_is_tripal_node_type($chado_table) {
     tripal_add_job(
       $title,                                   // the title of the job -be descriptive
       $module,                                  // the name of your module
-      'tripal_core_chado_node_sync_records',    // the chado node api sync function
+      'chado_node_sync_records',    // the chado node api sync function
       $job_args,                                // an array with the arguments to pass to the above function
       $user->uid                                // the user who submitted the job
     );
@@ -183,7 +184,7 @@ function tripal_core_is_tripal_node_type($chado_table) {
  *
  * @ingroup tripal_chado_node_api
  */
-function tripal_core_chado_node_sync_form($form, &$form_state) {
+function chado_node_sync_form($form, &$form_state) {
   $form = array();
 
   if (isset($form_state['build_info']['args'][0])) {
@@ -260,7 +261,7 @@ function tripal_core_chado_node_sync_form($form, &$form_state) {
   if (array_key_exists('checkboxes', $args['sync_filters'])) {
     // get the base schema
     $base_table = $args['base_table'];
-    $table_info = tripal_core_get_chado_table_schema($base_table);
+    $table_info = chado_get_schema($base_table);
 
     // if the base table does not have a primary key or has more than one then
     // we can't proceed, otherwise, generate the checkboxes
@@ -353,7 +354,7 @@ function tripal_core_chado_node_sync_form($form, &$form_state) {
  *
  * @ingroup tripal_chado_node_api
  */
-function tripal_core_chado_node_sync_form_submit($form, $form_state) {
+function chado_node_sync_form_submit($form, $form_state) {
 
   global $user;
 
@@ -411,13 +412,13 @@ function tripal_core_chado_node_sync_form_submit($form, $form_state) {
     );
 
     $title = "Sync " . $args['record_type_title']['plural'];
-    tripal_add_job($title, $module, 'tripal_core_chado_node_sync_records', $job_args, $user->uid);
+    tripal_add_job($title, $module, 'chado_node_sync_records', $job_args, $user->uid);
   }
   if (preg_match('/^Clean up orphaned/', $form_state['values']['op'])) {
     $module = $form_state['chado_node_api']['hook_prefix'];
     $base_table = $form_state['chado_node_api']['base_table'];
     $job_args = array($base_table);
-    tripal_add_job($form_state['values']['op'], $module, 'tripal_core_chado_node_cleanup_orphaned', $job_args, $user->uid);
+    tripal_add_job($form_state['values']['op'], $module, 'chado_cleanup_orphaned_nodes', $job_args, $user->uid);
   }
 }
 
@@ -426,7 +427,7 @@ function tripal_core_chado_node_sync_form_submit($form, $form_state) {
  *
  * @ingroup tripal_chado_node_api
  */
-function tripal_core_chado_node_sync_records($base_table, $max_sync = FALSE, $organism_id = FALSE,
+function chado_node_sync_records($base_table, $max_sync = FALSE, $organism_id = FALSE,
     $types = array(), $ids = array(), $job_id = NULL) {
 
   global $user;
@@ -464,7 +465,7 @@ function tripal_core_chado_node_sync_records($base_table, $max_sync = FALSE, $or
 
   // If Organism is supplied
   if ($organism_id) {
-    $organism = tripal_core_chado_select('organism', array('*'), array('organism_id' => $organism_id));
+    $organism = chado_select_record('organism', array('*'), array('organism_id' => $organism_id));
     $restrictions .= "  Organism: " . $organism[0]->genus . " " . $organism[0]->species . "\n";
 
     $select[] = 'organism.*';
@@ -545,7 +546,7 @@ function tripal_core_chado_node_sync_records($base_table, $max_sync = FALSE, $or
       if ($job_id and $i % $interval == 0) {
         $percent = sprintf("%.2f", ($i / $count) * 100);
         print "Parsing Line $line_num (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes.\n";
-        tripal_job_set_progress($job_id, intval(($i/$count)*100));
+        tripal_set_job_progress($job_id, intval(($i/$count)*100));
       }
 
       // Check if it is in the chado linking table (ie: check to see if it is already linked to a node)
@@ -614,7 +615,7 @@ function tripal_core_chado_node_sync_records($base_table, $max_sync = FALSE, $or
  *
  * @ingroup tripal_chado_node_api
  */
-function tripal_core_chado_node_cleanup_orphaned($table, $job_id = NULL) {
+function chado_cleanup_orphaned_nodes($table, $job_id = NULL) {
   $count = 0;
 
   // build the SQL statments needed to check if nodes point to valid analyses
@@ -654,7 +655,7 @@ function tripal_core_chado_node_cleanup_orphaned($table, $job_id = NULL) {
 
     // update the job status every 1% analyses
     if ($job_id and $i % $interval == 0) {
-      tripal_job_set_progress($job_id, intval(($i / $count) * 100));
+      tripal_set_job_progress($job_id, intval(($i / $count) * 100));
     }
 
     // see if the node exits, if not remove the entry from the chado_$table table
@@ -689,7 +690,7 @@ function tripal_core_chado_node_cleanup_orphaned($table, $job_id = NULL) {
 
     // update the job status every 1% libraries
     if ($job_id and $i % $interval == 0) {
-      tripal_job_set_progress($job_id, intval(($i / $count) * 100));
+      tripal_set_job_progress($job_id, intval(($i / $count) * 100));
     }
 
     // check to see if the node has a corresponding entry

+ 30 - 30
tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc

@@ -39,7 +39,7 @@
     );
 
     // Finally, and add the additional form elements to the form
-    chado_node_additional_dbxrefs_form($form, $form_state, $details);
+    chado_add_node_form_dbxrefs($form, $form_state, $details);
 
     return $form;
   }
@@ -58,7 +58,7 @@
       // Add all additional database references
       // This function will create new database references as needed and select existing ones.
       // Existing _dbxref links will be cleared and then re-added
-      chado_node_additional_dbxrefs_form_update_dbxrefs(
+      chado_update_node_form_dbxrefs(
         $node,              // the node object passed in via hook_insert()
         'example_dbxref',   // the name of the _dbxref linking table
         'example_id',       // key to link to the chado content created by this node
@@ -80,7 +80,7 @@
       // Update all additional database references
       // This function will create new database references as needed and select existing ones.
       // Existing _dbxref links will be cleared and then re-added
-      chado_node_additional_dbxrefs_form_update_dbxrefs(
+      chado_update_node_form_dbxrefs(
         $node,              // the node object passed in via hook_insert()
         'example_dbxref',   // the name of the _dbxref linking table
         'example_id',       // key to link to the chado content created by this node
@@ -122,7 +122,7 @@
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_additional_dbxrefs_form(&$form, &$form_state, $details) {
+function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
 
   // Set Defaults for optional fields
   $details['fieldset_title'] = 'Additional Database References';
@@ -134,7 +134,7 @@ function chado_node_additional_dbxrefs_form(&$form, &$form_state, $details) {
   }
   else {
     $db_options = array(0 => 'Select a Database');
-    $select = tripal_core_chado_select('db', array('db_id','name'), array(), array('order_by' => array('name' => 'ASC')));
+    $select = chado_select_record('db', array('db_id','name'), array(), array('order_by' => array('name' => 'ASC')));
     foreach($select as $db) {
       $db_options[$db->db_id] = $db->name;
     }
@@ -274,7 +274,7 @@ function chado_node_additional_dbxrefs_form(&$form, &$form_state, $details) {
         '#value' => t('Remove'),
         '#name' => "dbxref_remove-".$dbxref->db_id.'-'.$version,
         '#ajax' => array(
-          'callback' => "chado_node_additional_dbxrefs_form_ajax_update",
+          'callback' => "chado_add_node_form_dbxrefs_ajax_update",
           'wrapper' => 'tripal-generic-edit-addtl_dbxrefs-table',
           'effect'   => 'fade',
           'method'   => 'replace',
@@ -287,8 +287,8 @@ function chado_node_additional_dbxrefs_form(&$form, &$form_state, $details) {
         // from the chado_additional_dbxrefs array. In order to keep validate errors
         // from the node form validate and Drupal required errors for non-dbxref fields
         // preventing the user from removing dbxrefs we set the #limit_validation_errors below
-        '#validate' => array('chado_node_additional_dbxrefs_form_remove_button_validate'),
-        '#submit' => array('chado_node_additional_dbxrefs_form_remove_button_submit'),
+        '#validate' => array('chado_add_node_form_dbxrefs_remove_button_validate'),
+        '#submit' => array('chado_add_node_form_dbxrefs_remove_button_submit'),
         // Limit the validation of the form upon clicking this button to the dbxref_table tree
         // No other fields will be validated (ie: no fields from the main form or any other api
         // added form).
@@ -327,7 +327,7 @@ function chado_node_additional_dbxrefs_form(&$form, &$form_state, $details) {
     '#value' => t('Add'),
     '#name' => "dbxref-add",
     '#ajax' => array(
-      'callback' => "chado_node_additional_dbxrefs_form_ajax_update",
+      'callback' => "chado_add_node_form_dbxrefs_ajax_update",
       'wrapper' => 'tripal-generic-edit-addtl_dbxrefs-table',
       'effect'   => 'fade',
       'method'   => 'replace',
@@ -340,8 +340,8 @@ function chado_node_additional_dbxrefs_form(&$form, &$form_state, $details) {
     // array. In order to keep validate errors from the node form validate and Drupal
     // required errors for non-dbxref fields preventing the user from adding dbxrefs we
     // set the #limit_validation_errors below
-    '#validate' => array('chado_node_additional_dbxrefs_form_add_button_validate'),
-    '#submit' => array('chado_node_additional_dbxrefs_form_add_button_submit'),
+    '#validate' => array('chado_add_node_form_dbxrefs_add_button_validate'),
+    '#submit' => array('chado_add_node_form_dbxrefs_add_button_submit'),
     // Limit the validation of the form upon clicking this button to the dbxref_table tree
     // No other fields will be validated (ie: no fields from the main form or any other api
     // added form).
@@ -354,14 +354,14 @@ function chado_node_additional_dbxrefs_form(&$form, &$form_state, $details) {
 
 /**
  * Validate the user input for creating a new dbxref
- * Called by the add button in chado_node_additional_dbxrefs_form
+ * Called by the add button in chado_add_node_form_dbxrefs
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_additional_dbxrefs_form_add_button_validate($form, &$form_state) {
+function chado_add_node_form_dbxrefs_add_button_validate($form, &$form_state) {
 
   // Ensure the db_id is supplied & Valid
-  $db = tripal_core_chado_select(
+  $db = chado_select_record(
     'db',
     array('db_id', 'name'),
     array('db_id' => $form_state['values']['dbxref_table']['new']['db'])
@@ -380,19 +380,19 @@ function chado_node_additional_dbxrefs_form_add_button_validate($form, &$form_st
 }
 
 /**
- * Called by the add button in chado_node_additional_dbxrefs_form
+ * Called by the add button in chado_add_node_form_dbxrefs
  *
  * Create an array of additional dbxrefs in the form state. This array will then be
  * used to rebuild the form in subsequent builds
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_additional_dbxrefs_form_add_button_submit(&$form, &$form_state) {
+function chado_add_node_form_dbxrefs_add_button_submit(&$form, &$form_state) {
 
   // if the chado_additional_dbxrefs array is not set then this is the first time modifying the
   // dbxref table. this means we need to include all the dbxrefs from the db
   if (!isset($form_state['chado_additional_dbxrefs'])) {
-    chado_node_additional_dbxrefs_form_create_dbxref_formstate_array($form, $form_state);
+    chado_add_node_form_dbxrefs_create_dbxref_formstate_array($form, $form_state);
   }
 
   // get details for the new dbxref
@@ -414,26 +414,26 @@ function chado_node_additional_dbxrefs_form_add_button_submit(&$form, &$form_sta
  * There is no user input for the remove buttons so there is no need to validate
  * However, both a submit & validate need to be specified so this is just a placeholder
  *
- * Called by the many remove buttons in chado_node_additional_dbxrefs_form
+ * Called by the many remove buttons in chado_add_node_form_dbxrefs
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_additional_dbxrefs_form_remove_button_validate($form, $form_state) {
+function chado_add_node_form_dbxrefs_remove_button_validate($form, $form_state) {
   // No Validation needed for remove
 }
 
 /**
  * Remove the correct dbxref from the form
- * Called by the many remove buttons in chado_node_additional_dbxrefs_form
+ * Called by the many remove buttons in chado_add_node_form_dbxrefs
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_additional_dbxrefs_form_remove_button_submit(&$form, &$form_state) {
+function chado_add_node_form_dbxrefs_remove_button_submit(&$form, &$form_state) {
 
   // if the chado_additional_dbxrefs array is not set then this is the first time modifying the
   // dbxref table. this means we need to include all the dbxrefs from the db
   if (!isset($form_state['chado_additional_dbxrefs'])) {
-    chado_node_additional_dbxrefs_form_create_dbxref_formstate_array($form, $form_state);
+    chado_add_node_form_dbxrefs_create_dbxref_formstate_array($form, $form_state);
   }
 
   // remove the specified dbxref from the form dbxref table
@@ -452,7 +452,7 @@ function chado_node_additional_dbxrefs_form_remove_button_submit(&$form, &$form_
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_additional_dbxrefs_form_ajax_update($form, $form_state) {
+function chado_add_node_form_dbxrefs_ajax_update($form, $form_state) {
   return $form['addtl_dbxrefs']['dbxref_table'];
 }
 
@@ -474,7 +474,7 @@ function chado_node_additional_dbxrefs_form_ajax_update($form, $form_state) {
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_additional_dbxrefs_form_create_dbxref_formstate_array($form, &$form_state) {
+function chado_add_node_form_dbxrefs_create_dbxref_formstate_array($form, &$form_state) {
 
   $form_state['chado_additional_dbxrefs'] = array();
 
@@ -502,7 +502,7 @@ function chado_node_additional_dbxrefs_form_create_dbxref_formstate_array($form,
  *
  * @ingroup tripal_chado_node_api
  */
-function theme_chado_node_additional_dbxrefs_form_table($variables) {
+function theme_chado_add_node_form_dbxrefs_table($variables) {
   $element = $variables['element'];
 
   $header = array(
@@ -559,7 +559,7 @@ function theme_chado_node_additional_dbxrefs_form_table($variables) {
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_additional_dbxrefs_form_retreive($node) {
+function chado_retrieve_node_form_dbxrefs($node) {
   $dbxrefs = array();
 
   if (isset($node->dbxref_table)) {
@@ -587,12 +587,12 @@ function chado_node_additional_dbxrefs_form_retreive($node) {
  *   - foreignkey_name: the name of the foreign key used to link to the node content (ie: feature_id)
  *   - foreignkey_value: the value of the foreign key (ie: 445, if there exists a feature where feature_id=445)
  * @param $retrieved_dbxrefs
- *   An array of databa references from chado_node_additional_dbxrefs_form_retreive($node).
+ *   An array of databa references from chado_retrieve_node_form_dbxrefs($node).
  *   This can be used if you need special handling for some of the database references
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_additional_dbxrefs_form_update_dbxrefs($node, $details, $retrieved_dbxrefs = FALSE) {
+function chado_update_node_form_dbxrefs($node, $details, $retrieved_dbxrefs = FALSE) {
 
   $linking_table = $details['linking_table'];
   $foreignkey_name = $details['foreignkey_name'];
@@ -600,14 +600,14 @@ function chado_node_additional_dbxrefs_form_update_dbxrefs($node, $details, $ret
 
   if (isset($node->dbxref_table) AND ($foreignkey_value > 0)) {
     // First remove existing dbxref links
-    tripal_core_chado_delete($linking_table, array($foreignkey_name => $foreignkey_value));
+    chado_delete_record($linking_table, array($foreignkey_name => $foreignkey_value));
 
     // Add back in dbxref links and insert dbxrefs as needed
     if ($retrieved_dbxrefs) {
       $dbxrefs = $retrieved_dbxrefs;
     }
     else {
-      $dbxrefs = chado_node_additional_dbxrefs_form_retreive($node);
+      $dbxrefs = chado_retrieve_node_form_dbxrefs($node);
     }
     foreach ($dbxrefs as $db_id => $versions) {
       foreach ($versions as $version => $elements) {

+ 57 - 57
tripal_core/api/tripal_core.chado_nodes.properties.api.inc

@@ -40,7 +40,7 @@
     );
 
     // Finally, and add the additional form elements to the form
-    chado_node_properties_form($form, $form_state, $details);
+    chado_add_node_form_properties($form, $form_state, $details);
 
     return $form;
   }
@@ -112,15 +112,15 @@
  *
  * @return
  *   An array in the same format as that generated by the function
- *   tripal_core_generate_chado_var().  If only one record is returned it
+ *   chado_generate_var().  If only one record is returned it
  *   is a single object.  If more than one record is returned then it is an array
  *   of objects
  *
  * @ingroup tripal_chado_node_api
  */
-function tripal_core_get_property($basetable, $record_id, $property, $cv_name) {
+function chado_get_property($basetable, $record_id, $property, $cv_name) {
   // get the foreign key for this property table
-  $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
+  $table_desc = chado_get_schema($basetable . 'prop');
   $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
 
   // construct the array of values to be selected
@@ -134,9 +134,9 @@ function tripal_core_get_property($basetable, $record_id, $property, $cv_name) {
       'is_obsolete' => 0
     ),
   );
-  $results = tripal_core_generate_chado_var($basetable . 'prop', $values);
+  $results = chado_generate_var($basetable . 'prop', $values);
   if ($results) {
-    $results = tripal_core_expand_chado_vars($results, 'field', $basetable . 'prop.value');
+    $results = chado_expand_var($results, 'field', $basetable . 'prop.value');
   }
 
   return $results;
@@ -169,13 +169,13 @@ function tripal_core_get_property($basetable, $record_id, $property, $cv_name) {
  *
  * @ingroup tripal_chado_node_api
  */
-function tripal_core_insert_property($basetable, $record_id, $property,
+function chado_insert_property($basetable, $record_id, $property,
 $cv_name, $value, $update_if_present = 0) {
 
   // first see if the property already exists, if the user want's to update
   // then we can do that, but otherwise we want to increment the rank and
   // insert
-  $props = tripal_core_get_property($basetable, $record_id, $property, $cv_name);
+  $props = chado_get_property($basetable, $record_id, $property, $cv_name);
   if (!is_array($props) and $props) {
     $props = array($props);
   }
@@ -183,7 +183,7 @@ $cv_name, $value, $update_if_present = 0) {
   $rank = 0;
   if (count($props) > 0) {
     if ($update_if_present) {
-      return tripal_core_update_property($basetable, $record_id, $property, $cv_name, $value);
+      return chado_update_property($basetable, $record_id, $property, $cv_name, $value);
     }
     else {
       // iterate through the properties returned and check to see if the
@@ -212,15 +212,15 @@ $cv_name, $value, $update_if_present = 0) {
   );
 
   $options = array();
-  $term = tripal_core_chado_select('cvterm', array('cvterm_id'), $values, $options);
+  $term = chado_select_record('cvterm', array('cvterm_id'), $values, $options);
   if (!$term or count($term) == 0) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, "Cannot find property '%prop_name' in vocabulary '%cvname'.",
+    tripal_report_error('tripal_core', TRIPAL_ERROR, "Cannot find property '%prop_name' in vocabulary '%cvname'.",
     array('%prop_name' => $property, '%cvname' => $cv_name));
     return FALSE;
   }
 
   // get the foreign key for this property table
-  $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
+  $table_desc = chado_get_schema($basetable . 'prop');
   $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
 
   // construct the array of values to be inserted
@@ -237,7 +237,7 @@ $cv_name, $value, $update_if_present = 0) {
   );
 
   $options = array();
-  $result = tripal_core_chado_insert($basetable . 'prop', $values, $options);
+  $result = chado_insert_record($basetable . 'prop', $values, $options);
   return $result;
 }
 
@@ -245,7 +245,7 @@ $cv_name, $value, $update_if_present = 0) {
  * Update a property for a given base table record and property name.  This
  * function should be used only if one record of the property will be present.
  * If the property name can have multiple entries (with increasing rank) then
- * use the function named tripal_core_update_property_by_id
+ * use the function named chado_update_propertyID
  *
  * @param $basetable
  *   The base table for which the property should be updated. The property table
@@ -271,14 +271,14 @@ $cv_name, $value, $update_if_present = 0) {
  *
  * @ingroup tripal_chado_node_api
  */
-function tripal_core_update_property($basetable, $record_id, $property,
+function chado_update_property($basetable, $record_id, $property,
 $cv_name, $value, $insert_if_missing = 0) {
 
   // first see if the property is missing (we can't update a missing property
-  $prop = tripal_core_get_property($basetable, $record_id, $property, $cv_name);
+  $prop = chado_get_property($basetable, $record_id, $property, $cv_name);
   if (count($prop)==0) {
     if ($insert_if_missing) {
-      return tripal_core_insert_property($basetable, $record_id, $property, $cv_name, $value);
+      return chado_insert_property($basetable, $record_id, $property, $cv_name, $value);
     }
     else {
       return FALSE;
@@ -286,7 +286,7 @@ $cv_name, $value, $insert_if_missing = 0) {
   }
 
   // get the foreign key for this property table
-  $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
+  $table_desc = chado_get_schema($basetable . 'prop');
   $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
 
   // construct the array that will match the exact record to update
@@ -305,7 +305,7 @@ $cv_name, $value, $insert_if_missing = 0) {
     'value' => $value,
   );
 
-  return tripal_core_chado_update($basetable . 'prop', $match, $values);
+  return chado_update_record($basetable . 'prop', $match, $values);
 }
 
 /**
@@ -332,11 +332,11 @@ $cv_name, $value, $insert_if_missing = 0) {
  *
  * @ingroup tripal_chado_node_api
  */
-function tripal_core_update_property_by_id($basetable, $record_id, $property,
+function chado_update_propertyID($basetable, $record_id, $property,
 $cv_name, $value) {
 
   // get the primary key for this property table
-  $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
+  $table_desc = chado_get_schema($basetable . 'prop');
   $pkcol = $table_desc['primary key'][0];
 
   // construct the array that will match the exact record to update
@@ -355,7 +355,7 @@ $cv_name, $value) {
     'value' => $value,
   );
 
-  return tripal_core_chado_update($basetable . 'prop', $match, $values);
+  return chado_update_record($basetable . 'prop', $match, $values);
 }
 
 /**
@@ -378,10 +378,10 @@ $cv_name, $value) {
  *
  * @ingroup tripal_chado_node_api
  */
-function tripal_core_delete_property($basetable, $record_id, $property, $cv_name) {
+function chado_delete_property($basetable, $record_id, $property, $cv_name) {
 
   // get the foreign key for this property table
-  $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
+  $table_desc = chado_get_schema($basetable . 'prop');
   $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
 
   // construct the array that will match the exact record to update
@@ -395,7 +395,7 @@ function tripal_core_delete_property($basetable, $record_id, $property, $cv_name
     ),
   );
 
-  return tripal_core_chado_delete($basetable . 'prop', $match);
+  return chado_delete_record($basetable . 'prop', $match);
 }
 
 /**
@@ -412,10 +412,10 @@ function tripal_core_delete_property($basetable, $record_id, $property, $cv_name
  *
  * @ingroup tripal_chado_node_api
  */
-function tripal_core_delete_property_by_id($basetable, $record_id) {
+function chado_delete_propertyID($basetable, $record_id) {
 
   // get the foreign key for this property table
-  $table_desc = tripal_core_get_chado_table_schema($basetable . 'prop');
+  $table_desc = chado_get_schema($basetable . 'prop');
   $pkcol = $table_desc['primary key'][0];
 
   // construct the array that will match the exact record to update
@@ -423,7 +423,7 @@ function tripal_core_delete_property_by_id($basetable, $record_id) {
     $pkcol => $record_id,
   );
 
-  return tripal_core_chado_delete($basetable . 'prop', $match);
+  return chado_delete_record($basetable . 'prop', $match);
 }
 
 /**
@@ -455,7 +455,7 @@ function tripal_core_delete_property_by_id($basetable, $record_id) {
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_properties_form(&$form, &$form_state, $details) {
+function chado_add_node_form_properties(&$form, &$form_state, $details) {
 
   // Set Defaults for optional fields
   $details['fieldset_title'] = 'Properties';
@@ -646,7 +646,7 @@ function chado_node_properties_form(&$form, &$form_state, $details) {
         '#value' => t('Remove'),
         '#name' => "property_remove-".$property->type_id.'-'.$property->rank,
         '#ajax' => array(
-          'callback' => "chado_node_properties_form_ajax_update",
+          'callback' => "chado_add_node_form_properties_ajax_update",
           'wrapper' => 'tripal-generic-edit-properties-table',
           'effect'   => 'fade',
           'method'   => 'replace',
@@ -659,8 +659,8 @@ function chado_node_properties_form(&$form, &$form_state, $details) {
         // from the chado_properties array. In order to keep validate errors
         // from the node form validate and Drupal required errors for non-property fields
         // preventing the user from removing properties we set the #limit_validation_errors below
-        '#validate' => array('chado_node_properties_form_remove_button_validate'),
-        '#submit' => array('chado_node_properties_form_remove_button_submit'),
+        '#validate' => array('chado_add_node_form_properties_remove_button_validate'),
+        '#submit' => array('chado_add_node_form_properties_remove_button_submit'),
         // Limit the validation of the form upon clicking this button to the property_table tree
         // No other fields will be validated (ie: no fields from the main form or any other api
         // added form).
@@ -695,7 +695,7 @@ function chado_node_properties_form(&$form, &$form_state, $details) {
     '#value' => t('Add'),
     '#name' => "property-add",
     '#ajax' => array(
-      'callback' => "chado_node_properties_form_ajax_update",
+      'callback' => "chado_add_node_form_properties_ajax_update",
       'wrapper' => 'tripal-generic-edit-properties-table',
       'effect'   => 'fade',
       'method'   => 'replace',
@@ -708,8 +708,8 @@ function chado_node_properties_form(&$form, &$form_state, $details) {
     // array. In order to keep validate errors from the node form validate and Drupal
     // required errors for non-property fields preventing the user from adding properties we
     // set the #limit_validation_errors below
-    '#validate' => array('chado_node_properties_form_add_button_validate'),
-    '#submit' => array('chado_node_properties_form_add_button_submit'),
+    '#validate' => array('chado_update_node_form_properties_add_button_validate'),
+    '#submit' => array('chado_add_node_form_properties_add_button_submit'),
     // Limit the validation of the form upon clicking this button to the property_table tree
     // No other fields will be validated (ie: no fields from the main form or any other api
     // added form).
@@ -721,14 +721,14 @@ function chado_node_properties_form(&$form, &$form_state, $details) {
 
 /**
  * Validate the user input for creating a new property
- * Called by the add button in chado_node_properties_form
+ * Called by the add button in chado_add_node_form_properties
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_properties_form_add_button_validate($form, &$form_state) {
+function chado_update_node_form_properties_add_button_validate($form, &$form_state) {
 
   // Ensure the type_id is supplied & Valid
-  $cvterm = tripal_core_chado_select(
+  $cvterm = chado_select_record(
     'cvterm',
     array('cvterm_id', 'name'),
     array('cvterm_id' => $form_state['values']['property_table']['new']['type'])
@@ -747,21 +747,21 @@ function chado_node_properties_form_add_button_validate($form, &$form_state) {
 }
 
 /**
- * Called by the add button in chado_node_properties_form
+ * Called by the add button in chado_add_node_form_properties
  *
  * Create an array of properties in the form state. This array will then be
  * used to rebuild the form in subsequent builds
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_properties_form_add_button_submit(&$form, &$form_state) {
+function chado_add_node_form_properties_add_button_submit(&$form, &$form_state) {
 
   $details = unserialize($form_state['values']['property_table']['details']);
 
   // if the chado_additional_properties array is not set then this is the first time modifying the
   // property table. this means we need to include all the properties from the db
   if (!isset($form_state['chado_properties'])) {
-    chado_node_properties_form_create_property_formstate_array($form, $form_state);
+    chado_add_node_form_properties_create_property_formstate_array($form, $form_state);
   }
 
   // get details for the new property
@@ -774,7 +774,7 @@ function chado_node_properties_form_add_button_submit(&$form, &$form_state) {
   );
 
   // get max rank
-  $rank = tripal_core_get_max_chado_rank(
+  $rank = chado_get_table_max_rank(
     $details['property_table'],
     array(
       $details['base_foreign_key'] => $details['base_key_value'],
@@ -793,26 +793,26 @@ function chado_node_properties_form_add_button_submit(&$form, &$form_state) {
  * There is no user input for the remove buttons so there is no need to validate
  * However, both a submit & validate need to be specified so this is just a placeholder
  *
- * Called by the many remove buttons in chado_node_properties_form
+ * Called by the many remove buttons in chado_add_node_form_properties
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_properties_form_remove_button_validate($form, $form_state) {
+function chado_add_node_form_properties_remove_button_validate($form, $form_state) {
   // No Validation needed for remove
 }
 
 /**
  * Remove the correct property from the form
- * Called by the many remove buttons in chado_node_properties_form
+ * Called by the many remove buttons in chado_add_node_form_properties
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_properties_form_remove_button_submit(&$form, &$form_state) {
+function chado_add_node_form_properties_remove_button_submit(&$form, &$form_state) {
 
   // if the chado_properties array is not set then this is the first time modifying the
   // property table. this means we need to include all the properties from the db
   if (!isset($form_state['chado_properties'])) {
-    chado_node_properties_form_create_property_formstate_array($form, $form_state);
+    chado_add_node_form_properties_create_property_formstate_array($form, $form_state);
   }
 
   // remove the specified property from the form property table
@@ -829,7 +829,7 @@ function chado_node_properties_form_remove_button_submit(&$form, &$form_state) {
 /**
  * Ajax function which returns the section of the form to be re-rendered
  */
-function chado_node_properties_form_ajax_update($form, $form_state) {
+function chado_add_node_form_properties_ajax_update($form, $form_state) {
   return $form['properties']['property_table'];
 }
 
@@ -851,7 +851,7 @@ function chado_node_properties_form_ajax_update($form, $form_state) {
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_properties_form_create_property_formstate_array($form, &$form_state) {
+function chado_add_node_form_properties_create_property_formstate_array($form, &$form_state) {
 
   $form_state['chado_properties'] = array();
 
@@ -878,7 +878,7 @@ function chado_node_properties_form_create_property_formstate_array($form, &$for
  *
  * @ingroup tripal_chado_node_api
  */
-function theme_chado_node_properties_form_table($variables) {
+function theme_chado_add_node_form_properties($variables) {
   $element = $variables['element'];
 
   $header = array(
@@ -933,7 +933,7 @@ function theme_chado_node_properties_form_table($variables) {
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_properties_form_retreive($node) {
+function chado_retrieve_node_form_properties($node) {
   $properties = array();
 
   if (isset($node->property_table)) {
@@ -961,30 +961,30 @@ function chado_node_properties_form_retreive($node) {
  *   - foreignkey_name: the name of the foreign key used to link to the node content (ie: feature_id)
  *   - foreignkey_value: the value of the foreign key (ie: 445, if there exists a feature where feature_id=445)
  * @param $retrieved_properties
- *   An array of properties from chado_node_properties_form_retreive($node). This can be used if you need
+ *   An array of properties from chado_retrieve_node_form_properties($node). This can be used if you need
  *   special handling for some of the properties (See FeatureMap chado_featuremap_insert for an example)
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_properties_form_update_properties($node, $details, $retrieved_properties = FALSE) {
+function chado_update_node_form_properties($node, $details, $retrieved_properties = FALSE) {
 
   $details['foreignkey_value'] = (isset($details['foreignkey_value'])) ? $details['foreignkey_value'] : 0;
 
   if (isset($node->property_table) AND ($details['foreignkey_value'] > 0)) {
     // First remove existing property links
-    tripal_core_chado_delete($details['property_table'], array($details['foreignkey_name'] => $details['foreignkey_value']));
+    chado_delete_record($details['property_table'], array($details['foreignkey_name'] => $details['foreignkey_value']));
 
     // Add back in property links and insert properties as needed
     if ($retrieved_properties) {
       $properties = $retrieved_properties;
     }
     else {
-      $properties = chado_node_properties_form_retreive($node);
+      $properties = chado_retrieve_node_form_properties($node);
     }
     foreach ($properties as $type_id => $ranks) {
       foreach ($ranks as $rank => $value) {
 
-        $success = tripal_core_chado_insert(
+        $success = chado_insert_record(
           $details['property_table'],
           array(
             $details['foreignkey_name'] => $details['foreignkey_value'],
@@ -995,7 +995,7 @@ function chado_node_properties_form_update_properties($node, $details, $retrieve
         );
 
         if (!$success) {
-          tripal_core_report_error('tripal_' . $details['base_table'], TRIPAL_ERROR,
+          tripal_report_error('tripal_' . $details['base_table'], TRIPAL_ERROR,
             $details['base_table'] . ' Insert: Unable to insert property type_id %cvterm with value %value.',
             array('%cvterm' => $type_id, '%value' => $value));
         }

+ 36 - 36
tripal_core/api/tripal_core.chado_nodes.relationships.api.inc

@@ -40,7 +40,7 @@
     );
 
     // Finally, and add the additional form elements to the form
-    chado_node_relationships_form($form, $form_state, $details);
+    chado_add_node_form_relationships($form, $form_state, $details);
 
     return $form;
   }
@@ -59,7 +59,7 @@
       // Add all relationships
       // Existing _relationship links with the current example as either the subject_id
       // or object_id will be cleared and then re-added
-      chado_node_relationships_form_update_relationships(
+      chado_update_node_form_relationships(
         $node,
         'example_relationship',
         $node->example_id
@@ -80,7 +80,7 @@
       // Update all additional database references
       // Existing _relationship links with the current example as either the subject_id
       // or object_id will be cleared and then re-added
-      chado_node_relationships_form_update_relationships(
+      chado_update_node_form_relationships(
         $node,
         'example_relationship',
         $node->example_id
@@ -124,7 +124,7 @@
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_relationships_form(&$form, &$form_state, $details) {
+function chado_add_node_form_relationships(&$form, &$form_state, $details) {
 
   $form_state['rebuild'] = TRUE;
 
@@ -138,7 +138,7 @@ function chado_node_relationships_form(&$form, &$form_state, $details) {
 
   // Some relationship tables don't have a rank
   // thus we need to first check this table has a rank before trying to set it
-  $table_schema = tripal_core_get_chado_table_schema($details['relationship_table']);
+  $table_schema = chado_get_schema($details['relationship_table']);
   $details['table_has_rank'] = (isset($table_schema['fields']['rank'])) ? TRUE : FALSE;
 
   // Get Property Types for the Select List
@@ -330,7 +330,7 @@ function chado_node_relationships_form(&$form, &$form_state, $details) {
         '#value' => t('Remove'),
         '#name' => "rel_remove-".$relationship->type_id.'-'.$rank,
         '#ajax' => array(
-          'callback' => 'chado_node_relationships_form_ajax_update',
+          'callback' => 'chado_add_node_form_relationships_ajax_update',
           'wrapper' => 'tripal-generic-edit-relationships-table',
           'effect'   => 'fade',
           'method'   => 'replace',
@@ -343,8 +343,8 @@ function chado_node_relationships_form(&$form, &$form_state, $details) {
         // from the chado_relationships array. In order to keep validate errors
         // from the node form validate and Drupal required errors for non-relationship fields
         // preventing the user from removing relationships we set the #limit_validation_errors below
-        '#validate' => array('chado_node_relationships_form_remove_button_validate'),
-        '#submit' => array('chado_node_relationships_form_remove_button_submit'),
+        '#validate' => array('chado_add_node_form_relationships_form_remove_button_validate'),
+        '#submit' => array('chado_add_node_form_relationships_remove_button_submit'),
         // Limit the validation of the form upon clicking this button to the relationship_table tree
         // No other fields will be validated (ie: no fields from the main form or any other api
         // added form).
@@ -390,7 +390,7 @@ function chado_node_relationships_form(&$form, &$form_state, $details) {
     '#value' => t('Add'),
     '#name' => 'rel_add',
     '#ajax' => array(
-      'callback' => 'chado_node_relationships_form_ajax_update',
+      'callback' => 'chado_add_node_form_relationships_ajax_update',
       'wrapper' => 'tripal-generic-edit-relationships-table',
       'effect'   => 'fade',
       'method'   => 'replace',
@@ -403,8 +403,8 @@ function chado_node_relationships_form(&$form, &$form_state, $details) {
     // array. In order to keep validate errors from the node form validate and Drupal
     // required errors for non-relationship fields preventing the user from adding relationships we
     // set the #limit_validation_errors below
-    '#validate' => array('chado_node_relationships_form_add_button_validate'),
-    '#submit' => array('chado_node_relationships_form_add_button_submit'),
+    '#validate' => array('chado_add_node_form_relationships_add_button_validate'),
+    '#submit' => array('chado_add_node_form_relationships_add_button_submit'),
     // Limit the validation of the form upon clicking this button to the relationship_table tree
     // No other fields will be validated (ie: no fields from the main form or any other api
     // added form).
@@ -417,11 +417,11 @@ function chado_node_relationships_form(&$form, &$form_state, $details) {
 
 /**
  * Validate the user input for creating a new relationship
- * Called by the add button in chado_node_relationships_form
+ * Called by the add button in chado_add_node_form_relationships
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_relationships_form_add_button_validate($form, &$form_state) {
+function chado_add_node_form_relationships_add_button_validate($form, &$form_state) {
 
   $details = unserialize($form_state['values']['relationship_table']['details']);
 
@@ -468,7 +468,7 @@ function chado_node_relationships_form_add_button_validate($form, &$form_state)
 
   // The non-current uniquename must be exist in the base table (subject)
   if (!($form_state['values']['relationship_table']['new']['subject_is_current'])) {
-    $result = tripal_core_chado_select(
+    $result = chado_select_record(
       $details['base_table'],
       array($details['base_name_field']),
       array($details['base_foreign_key'] => $form_state['values']['relationship_table']['new']['subject_id'])
@@ -484,7 +484,7 @@ function chado_node_relationships_form_add_button_validate($form, &$form_state)
 
   // The non-current uniquename must exist in the base table (object)
   if (!($form_state['values']['relationship_table']['new']['object_is_current'])) {
-    $result = tripal_core_chado_select(
+    $result = chado_select_record(
       $details['base_table'],
       array($details['base_name_field']),
       array($details['base_foreign_key'] => $form_state['values']['relationship_table']['new']['object_id'])
@@ -501,7 +501,7 @@ function chado_node_relationships_form_add_button_validate($form, &$form_state)
   // The type must be a valid cvterm
   if ($form_state['values']['relationship_table']['new']['type_name']) {
     $form_state['values']['relationship_table']['new']['type_id'] = $form_state['values']['relationship_table']['new']['type_name'];
-    $result = tripal_core_chado_select(
+    $result = chado_select_record(
       'cvterm',
       array('name'),
       array('cvterm_id' => $form_state['values']['relationship_table']['new']['type_id'])
@@ -519,21 +519,21 @@ function chado_node_relationships_form_add_button_validate($form, &$form_state)
 }
 
 /**
- * Called by the add button in chado_node_relationships_form
+ * Called by the add button in chado_add_node_form_relationships
  *
  * Create an array of additional relationships in the form state. This array will then be
  * used to rebuild the form in subsequent builds
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_relationships_form_add_button_submit(&$form, &$form_state) {
+function chado_add_node_form_relationships_add_button_submit(&$form, &$form_state) {
 
   $details = unserialize($form_state['values']['relationship_table']['details']);
 
   // if the chado_relationships array is not set then this is the first time modifying the
   // relationship table. this means we need to include all the relationships from the db
   if (!isset($form_state['chado_relationships'])) {
-    chado_node_relationships_form_create_relationship_formstate_array($form, $form_state);
+    chado_add_node_form_relationships_create_relationship_formstate_array($form, $form_state);
   }
 
   $name = (isset($form_state['node']->{$details['base_table']}->uniquename)) ? $form_state['node']->{$details['base_table']}->uniquename : 'CURRENT';
@@ -573,26 +573,26 @@ function chado_node_relationships_form_add_button_submit(&$form, &$form_state) {
  * There is no user input for the remove buttons so there is no need to validate
  * However, both a submit & validate need to be specified so this is just a placeholder
  *
- * Called by the many remove buttons in chado_node_relationships_form
+ * Called by the many remove buttons in chado_add_node_form_relationships
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_relationships_form_remove_button_validate($form, $form_state) {
+function chado_add_node_form_relationships_form_remove_button_validate($form, $form_state) {
   // No Validation needed for remove
 }
 
 /**
  * Remove the correct relationship from the form
- * Called by the many remove buttons in chado_node_relationships_form
+ * Called by the many remove buttons in chado_add_node_form_relationships
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_relationships_form_remove_button_submit(&$form, &$form_state) {
+function chado_add_node_form_relationships_remove_button_submit(&$form, &$form_state) {
 
   // if the chado_relationships array is not set then this is the first time modifying the
   // relationship table. this means we need to include all the relationships from the db
   if (!isset($form_state['chado_relationships'])) {
-    chado_node_relationships_form_create_relationship_formstate_array($form, $form_state);
+    chado_add_node_form_relationships_create_relationship_formstate_array($form, $form_state);
   }
 
   // remove the specified relationship from the form relationship table
@@ -611,7 +611,7 @@ function chado_node_relationships_form_remove_button_submit(&$form, &$form_state
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_relationships_form_ajax_update($form, $form_state) {
+function chado_add_node_form_relationships_ajax_update($form, $form_state) {
   return $form['relationships']['relationship_table'];
 }
 
@@ -633,7 +633,7 @@ function chado_node_relationships_form_ajax_update($form, $form_state) {
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_relationships_form_create_relationship_formstate_array($form, &$form_state) {
+function chado_add_node_form_relationships_create_relationship_formstate_array($form, &$form_state) {
 
   $form_state['chado_relationships'] = array();
 
@@ -662,7 +662,7 @@ function chado_node_relationships_form_create_relationship_formstate_array($form
  *
  * @ingroup tripal_chado_node_api
  */
-function theme_chado_node_relationships_form_table($variables) {
+function theme_chado_add_node_form_relationships_table($variables) {
   $element = $variables['element'];
 
   $details = unserialize($element['details']['#value']);
@@ -731,7 +731,7 @@ function theme_chado_node_relationships_form_table($variables) {
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_relationships_form_retreive($node) {
+function chado_retrieve_node_form_relationships($node) {
   $rels = array();
 
   if (isset($node->relationship_table)) {
@@ -758,12 +758,12 @@ function chado_node_relationships_form_retreive($node) {
  *  - relationship_table: the name of the _relationship linking table (ie: feature_relationship)
  *  - foreignkey_value: the value of the foreign key (ie: 445, if there exists a feature where feature_id=445)
  * @param $retrieved_relationships
- *   An array of relationships from chado_node_relationships_form_retreive($node). This
+ *   An array of relationships from chado_retrieve_node_form_relationships($node). This
  *   can be used if you need special handling for some of the relationships.
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_node_relationships_form_update_relationships($node, $details, $retrieved_relationships = FALSE) {
+function chado_update_node_form_relationships($node, $details, $retrieved_relationships = FALSE) {
 
   $relationship_table = $details['relationship_table'];
   $current_id = $details['foreignkey_value'];
@@ -775,11 +775,11 @@ function chado_node_relationships_form_update_relationships($node, $details, $re
     $has_rank = $form_details['table_has_rank'];
 
     // First remove existing relationships links
-    tripal_core_chado_delete(
+    chado_delete_record(
       $relationship_table,
       array($form_details['subject_field_name'] => $current_id)
     );
-    tripal_core_chado_delete(
+    chado_delete_record(
       $relationship_table,
       array($form_details['object_field_name'] => $current_id)
     );
@@ -789,7 +789,7 @@ function chado_node_relationships_form_update_relationships($node, $details, $re
       $relationships = $retrieved_relationships;
     }
     else {
-      $relationships = chado_node_relationships_form_retreive($node);
+      $relationships = chado_retrieve_node_form_relationships($node);
     }
     foreach ($relationships as $type_id => $ranks) {
       foreach ($ranks as $rank => $element) {
@@ -811,7 +811,7 @@ function chado_node_relationships_form_update_relationships($node, $details, $re
 
         if ($has_rank) {
           // Ensure that the rank is Set & Current
-          $rank_select = tripal_core_get_max_chado_rank(
+          $rank_select = chado_get_table_max_rank(
             $relationship_table,
             array(
               $form_details['subject_field_name'] => $values['subject_id'],
@@ -823,7 +823,7 @@ function chado_node_relationships_form_update_relationships($node, $details, $re
         }
 
         // add relationship
-        $success_link = tripal_core_chado_insert(
+        $success_link = chado_insert_record(
           $relationship_table,
           $values
         );
@@ -839,7 +839,7 @@ function chado_node_relationships_form_update_relationships($node, $details, $re
  * @param $string
  *    The part of the string already typed in the textfield
  */
-function chado_node_relationships_name_to_id_callback($base_table, $name_field, $string) {
+function chado_add_node_form_relationships_name_to_id_callback($base_table, $name_field, $string) {
   $matches = array();
 
   $base_key = $base_table.'_id';

+ 97 - 97
tripal_core/api/tripal_core.chado_query.api.inc

@@ -13,7 +13,7 @@
  *
  * Generic Queries to a specifc chado table:
  *
- * tripal_core_chado_select( [table name], [columns to select], [specify record to select], [options*] )
+ * chado_select_record( [table name], [columns to select], [specify record to select], [options*] )
  * This function allows you to select various columns from the specified chado table. Although
  * you can only select from a single table, you can specify the record to select using values
  * from related tables through use of a nested array. For example, the following code shows
@@ -33,14 +33,14 @@
  *         'is_obsolete' => 0
  *      ),
  *   );
- *   $result = tripal_core_chado_select(
+ *   $result = chado_select_record(
  *      'feature',                      // table to select from
  *      array('name', 'uniquename'),    // columns to select
  *      $values                         // record to select (see variable defn. above)
  *   );
  * @endcode
  *
- * tripal_core_chado_insert( [table name], [values to insert], [options*] )
+ * chado_insert_record( [table name], [values to insert], [options*] )
  * This function allows you to insert a single record into a specific table. The values to
  * insert are specified using an associative array where the keys are the column names to
  * insert into and they point to the value to be inserted into that column. If the column
@@ -65,13 +65,13 @@
  *         'is_obsolete' => 0
  *      ),
  *   );
- *   $result = tripal_core_chado_insert(
+ *   $result = chado_insert_record(
  *     'feature',             // table to insert into
  *     $values                // values to insert
  *   );
  * @endcode
  *
- * tripal_core_chado_update( [table name], [specify record to update], [values to change], [options*] )
+ * chado_update_record( [table name], [specify record to update], [values to change], [options*] )
  * This function allows you to update records in a specific chado table. The record(s)
  * you wish to update are specified the same as in the select function above and
  * the values to be update are specified the same as the values to be inserted were. For
@@ -103,10 +103,10 @@
  *     'is_obsolete' => 0
  *   ),
  * );
- *   $result = tripal_core_chado_update('feature',$umatch,$uvalues);
+ *   $result = chado_update_record('feature',$umatch,$uvalues);
  * @endcode
  *
- * tripal_core_chado_delete( [table name], [specify records to delete], [options*] )
+ * chado_delete_record( [table name], [specify records to delete], [options*] )
  * This function allows you to delete records from a specific chado table. The record(s)
  * to delete are specified the same as the record to select/update was above. For example,
  * the following code will delete all genes from the organism Citrus sinensis.
@@ -124,7 +124,7 @@
  *         'is_obsolete' => 0
  *      ),
  *   );
- *   $result = tripal_core_chado_select(
+ *   $result = chado_select_record(
  *      'feature',                      // table to select from
  *      $values                         // records to delete (see variable defn. above)
  *   );
@@ -153,7 +153,7 @@
  * @endcode
  *
  * If you are going to need more then a couple fields, you might want to use the
- * Chado Variables API (specifically tripal_core_generate_chado_var()) to select all
+ * Chado Variables API (specifically chado_generate_var()) to select all
  * of the common fields needed including following foreign keys.
  */
 
@@ -199,7 +199,7 @@
  *         'is_obsolete' => 0
  *      ),
  *   );
- *   $result = tripal_core_chado_insert('feature',$values);
+ *   $result = chado_insert_record('feature',$values);
  * @endcode
  * The above code inserts a record into the feature table.  The $values array is
  * nested such that the organism is selected by way of the organism_id foreign
@@ -209,19 +209,19 @@
  *
  * @ingroup tripal_chado_query_api
  */
-function tripal_core_chado_insert($table, $values, $options = array()) {
+function chado_insert_record($table, $values, $options = array()) {
 
   $print_errors = (isset($options['print_errors'])) ? $options['print_errors'] : FALSE;
 
   if (!is_array($values)) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       'Cannot pass non array as values for inserting.', array(),
       array('print' => $print_errors)
     );
     return FALSE;
   }
   if (count($values)==0) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       'Cannot pass an empty array as values for inserting.',
       array(),array('print' => $print_errors)
     );
@@ -251,10 +251,10 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
   }
 
   // get the table description
-  $table_desc = tripal_core_get_chado_table_schema($table);
+  $table_desc = chado_get_schema($table);
   if (empty($table_desc)) {
-    tripal_core_report_error('tripal_core', TRIPAL_WARNING,
-      'tripal_core_chado_insert; There is no table description for !table_name',
+    tripal_report_error('tripal_core', TRIPAL_WARNING,
+      'chado_insert_record; There is no table description for !table_name',
       array('!table_name' => $table), array('print' => $print_errors)
     );
   }
@@ -266,8 +266,8 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
     // make sure the field is in the table description. If not then return an error
     // message
     if (!array_key_exists($field, $table_desc['fields'])) {
-      tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-        "tripal_core_chado_insert; The field '%field' does not exist " .
+      tripal_report_error('tripal_core', TRIPAL_ERROR,
+        "chado_insert_record; The field '%field' does not exist " .
           "for the table '%table'.  Cannot perform insert. Values: %array",
         array('%field' => $field, '%table' => $table, '%array' => print_r($values, 1)),
         array('print' => $print_errors)
@@ -277,18 +277,18 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
 
     if (is_array($value)) {
       // select the value from the foreign key relationship for this value
-      $results = tripal_core_chado_get_foreign_key($table_desc, $field, $value);
+      $results = chado_schema_get_foreign_key($table_desc, $field, $value);
 
       if (sizeof($results) > 1) {
-        tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-          'tripal_core_chado_insert: Too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
+        tripal_report_error('tripal_core', TRIPAL_ERROR,
+          'chado_insert_record: Too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
         );
       }
       elseif (sizeof($results) < 1) {
-        tripal_core_report_error('tripal_core', TRIPAL_DEBUG,
-          'tripal_core_chado_insert: no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
+        tripal_report_error('tripal_core', TRIPAL_DEBUG,
+          'chado_insert_record: no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
         );
@@ -326,9 +326,9 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
           }
         }
         // now check the constraint
-        if (tripal_core_chado_select($table, $ukselect_cols, $ukselect_vals)) {
-          tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-            "tripal_core_chado_insert; Cannot insert duplicate record into $table table: !values",
+        if (chado_select_record($table, $ukselect_cols, $ukselect_vals)) {
+          tripal_report_error('tripal_core', TRIPAL_ERROR,
+            "chado_insert_record; Cannot insert duplicate record into $table table: !values",
             array('!values' => print_r($values, TRUE)), array('print' => $print_errors)
           );
           return FALSE;
@@ -341,9 +341,9 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
       $pkey = $table_desc['primary key'][0];
       if (array_key_exists($pkey, $insert_values)) {
         $coptions = array();
-        if (tripal_core_chado_select($table, array($pkey), array($pkey => $insert_values[$pkey]), $coptions)) {
-          tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-            'tripal_core_chado_insert; Cannot insert duplicate primary key into !table table: !values',
+        if (chado_select_record($table, array($pkey), array($pkey => $insert_values[$pkey]), $coptions)) {
+          tripal_report_error('tripal_core', TRIPAL_ERROR,
+            'chado_insert_record; Cannot insert duplicate primary key into !table table: !values',
             array('!table' => $table, '!values' => print_r($values, TRUE)),
             array('print' => $print_errors)
           );
@@ -355,8 +355,8 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
     // make sure required fields have a value
     if (!is_array($table_desc['fields'])) {
       $table_desc['fields'] = array();
-      tripal_core_report_error('tripal_core', TRIPAL_WARNING,
-        "tripal_core_chado_insert; %table missing fields: \n %schema",
+      tripal_report_error('tripal_core', TRIPAL_WARNING,
+        "chado_insert_record; %table missing fields: \n %schema",
         array('%table' => $table, '%schema' => print_r($table_desc, 1)),
         array('print' => $print_errors)
       );
@@ -368,8 +368,8 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
           !array_key_exists($field, $insert_values) and
           !array_key_exists('default', $def) and
           strcmp($def['type'], serial) != 0) {
-        tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-          "tripal_core_chado_insert; Field %table.%field cannot be NULL: %values",
+        tripal_report_error('tripal_core', TRIPAL_ERROR,
+          "chado_insert_record; Field %table.%field cannot be NULL: %values",
           array('%table' => $table, '%field' => $field, '%values' => print_r($values, 1)),
           array('print' => $print_errors)
         );
@@ -407,8 +407,8 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
         $results = chado_query($sql);
         $value = $results->fetchField();
         if (!$value) {
-          tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-            "tripal_core_chado_insert; not able to retrieve primary key after insert: %sql",
+          tripal_report_error('tripal_core', TRIPAL_ERROR,
+            "chado_insert_record; not able to retrieve primary key after insert: %sql",
             array('%sql' => $sql),
             array('print' => $print_errors)
           );
@@ -423,8 +423,8 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
     return TRUE;
   }
   else {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-      'tripal_core_chado_insert; Cannot insert record into "%table": %values',
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
+      'chado_insert_record; Cannot insert record into "%table": %values',
       array('%table' => $table, '%values' => print_r($values, 1)),
       array('print' => $print_errors)
     );
@@ -485,7 +485,7 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
      'is_obsolete' => 0
    ),
  );
- *   $result = tripal_core_chado_update('feature',$umatch,$uvalues);
+ *   $result = chado_update_record('feature',$umatch,$uvalues);
  * @endcode
  * The above code species that a feature with a given uniquename, organism_id,
  * and type_id (the unique constraint for the feature table) will be updated.
@@ -497,19 +497,19 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
  *
  * @ingroup tripal_chado_query_api
  */
-function tripal_core_chado_update($table, $match, $values, $options = NULL) {
+function chado_update_record($table, $match, $values, $options = NULL) {
 
   $print_errors = (isset($options['print_errors'])) ? $options['print_errors'] : FALSE;
 
   if (!is_array($values)) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       'Cannot pass non array as values for updating.',
       array(), array('print' => $print_errors)
     );
     return FALSE;
   }
   if (count($values)==0) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       'Cannot pass an empty array as values for updating.',
       array(), array('print' => $print_errors)
     );
@@ -517,14 +517,14 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
   }
 
   if (!is_array($match)) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       'Cannot pass non array as values for matching.',
       array(), array('print' => $print_errors)
     );
     return FALSE;
   }
   if (count($match)==0) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       'Cannot pass an empty array as values for matching.',
       array(), array('print' => $print_errors)
     );
@@ -546,7 +546,7 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
 
 
   // get the table description
-  $table_desc = tripal_core_get_chado_table_schema($table);
+  $table_desc = chado_get_schema($table);
 
   // if the user wants us to return the record then we need to get the
   // unique primary key if one exists.  That way we can add it to the
@@ -561,7 +561,7 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
         $stmt_suffix .= substr($field, 0, 2);
       }
       $options2 = array();
-      $results = tripal_core_chado_select($table, $columns, $match, $options2);
+      $results = chado_select_record($table, $columns, $match, $options2);
       if (count($results) > 0) {
         foreach ($results as $index => $pkey) {
           $pkeys[] = $pkey;
@@ -573,17 +573,17 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
   // get the values needed for matching in the SQL statement
   foreach ($match as $field => $value) {
     if (is_array($value)) {
-      $results = tripal_core_chado_get_foreign_key($table_desc, $field, $value);
+      $results = chado_schema_get_foreign_key($table_desc, $field, $value);
       if (sizeof($results) > 1) {
-        tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-          'tripal_core_chado_update: When trying to find record to update, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
+        tripal_report_error('tripal_core', TRIPAL_ERROR,
+          'chado_update_record: When trying to find record to update, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
         );
       }
       elseif (sizeof($results) < 1) {
-        tripal_core_report_error('tripal_core', TRIPAL_DEBUG,
-          'tripal_core_chado_update: When trying to find record to update, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
+        tripal_report_error('tripal_core', TRIPAL_DEBUG,
+          'chado_update_record: When trying to find record to update, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
         );
@@ -602,17 +602,17 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
     if (is_array($value)) {
       $foreign_options = array();
       // select the value from the foreign key relationship for this value
-      $results = tripal_core_chado_get_foreign_key($table_desc, $field, $value, $foreign_options);
+      $results = chado_schema_get_foreign_key($table_desc, $field, $value, $foreign_options);
       if (sizeof($results) > 1) {
-        tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-          'tripal_core_chado_update: When trying to find update values, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
+        tripal_report_error('tripal_core', TRIPAL_ERROR,
+          'chado_update_record: When trying to find update values, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
         );
       }
       elseif (sizeof($results) < 1) {
-        tripal_core_report_error('tripal_core', TRIPAL_DEBUG,
-          'tripal_core_chado_update: When trying to find update values, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
+        tripal_report_error('tripal_core', TRIPAL_DEBUG,
+          'chado_update_record: When trying to find update values, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value,TRUE)),
           array('print' => $print_errors)
         );
@@ -672,8 +672,8 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
     return TRUE;
   }
   else {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-      "tripal_core_chado_update: Cannot update record in %table table.  \nMatch: %match \nValues: %values",
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
+      "chado_update_record: Cannot update record in %table table.  \nMatch: %match \nValues: %values",
       array('%table' => table, '%match' => print_r($match,TRUE), '%values' => print_r($values, 1)),
       array('print' => $print_errors)
     );
@@ -726,7 +726,7 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
      'is_obsolete' => 0
    ),
  );
- *   $result = tripal_core_chado_update('feature', $umatch, $uvalues);
+ *   $result = chado_update_record('feature', $umatch, $uvalues);
  * @endcode
  * The above code species that a feature with a given uniquename, organism_id,
  * and type_id (the unique constraint for the feature table) will be deleted.
@@ -738,15 +738,15 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
  *
  * @ingroup tripal_chado_query_api
  */
-function tripal_core_chado_delete($table, $match, $options = NULL) {
+function chado_delete_record($table, $match, $options = NULL) {
 
   if (!is_array($match)) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       'Cannot pass non array as values for matching.', array());
     return FALSE;
   }
   if (count($match)==0) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       'Cannot pass an empty array as values for matching.', array());
     return FALSE;
   }
@@ -760,7 +760,7 @@ function tripal_core_chado_delete($table, $match, $options = NULL) {
   $delete_matches = array();  // contains the values for the where clause
 
   // get the table description
-  $table_desc = tripal_core_get_chado_table_schema($table);
+  $table_desc = chado_get_schema($table);
   $fields = $table_desc['fields'];
 
   // get the values needed for matching in the SQL statement
@@ -772,14 +772,14 @@ function tripal_core_chado_delete($table, $match, $options = NULL) {
         $delete_matches[$field] = $value;
       }
       else {
-        $results = tripal_core_chado_get_foreign_key($table_desc, $field, $value);
+        $results = chado_schema_get_foreign_key($table_desc, $field, $value);
         if (sizeof($results) > 1) {
-          tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
-            'tripal_core_chado_delete: When trying to find record to delete, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)', 
+          tripal_report_error('tripal_core', TRIPAL_ERROR,
+            'chado_delete_record: When trying to find record to delete, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
             array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)));
         }
         elseif (sizeof($results) < 1) {
-          //tripal_core_report_error('tripal_core', TRIPAL_ERROR, 'tripal_core_chado_delete: When trying to find record to delete, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)', array('!foreign_key' => $field, '!criteria' => print_r($value,TRUE)));
+          //tripal_report_error('tripal_core', TRIPAL_ERROR, 'chado_delete_record: When trying to find record to delete, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)', array('!foreign_key' => $field, '!criteria' => print_r($value,TRUE)));
         }
         else {
           $delete_matches[$field] = $results[0];
@@ -827,7 +827,7 @@ function tripal_core_chado_delete($table, $match, $options = NULL) {
     return TRUE;
   }
   else {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       "Cannot delete record in $table table.  Match:" . print_r($match, 1) . ". Values: " . print_r($values, 1), array());
     return FALSE;
   }
@@ -910,7 +910,7 @@ function tripal_core_chado_delete($table, $match, $options = NULL) {
  *        'name' => 'ASC'
  *     ),
  *   );
- *   $result = tripal_core_chado_select('feature',$columns,$values,$options);
+ *   $result = chado_select_record('feature',$columns,$values,$options);
  * @endcode
  * The above code selects a record from the feature table using the three fields
  * that uniquely identify a feature.  The $columns array simply lists the columns
@@ -922,24 +922,24 @@ function tripal_core_chado_delete($table, $match, $options = NULL) {
  *
  * @ingroup tripal_chado_query_api
  */
-function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
+function chado_select_record($table, $columns, $values, $options = NULL) {
 
   $print_errors = (isset($options['print_errors'])) ? $options['print_errors'] : FALSE;
 
   if (!is_array($values)) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, 'Cannot pass non array as values for selecting.',
+    tripal_report_error('tripal_core', TRIPAL_ERROR, 'Cannot pass non array as values for selecting.',
       array(), array('print' => $print_errors)
     );
     return FALSE;
   }
   if (!is_array($columns)) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, 'Cannot pass non array as columns for selecting.',
+    tripal_report_error('tripal_core', TRIPAL_ERROR, 'Cannot pass non array as columns for selecting.',
       array(), array('print' => $print_errors)
     );
     return FALSE;
   }
   if (count($columns)==0) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, 'Cannot pass an empty array as columns for selecting.',
+    tripal_report_error('tripal_core', TRIPAL_ERROR, 'Cannot pass an empty array as columns for selecting.',
       array(), array('print' => $print_errors)
     );
     return FALSE;
@@ -975,16 +975,16 @@ function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
 
   // check that our columns and values arguments are proper arrays
   if (!is_array($columns)) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-      'tripal_core_chado_select; the $columns argument must be an array. Columns:%columns',
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
+      'chado_select_record; the $columns argument must be an array. Columns:%columns',
       array('%columns' => print_r($columns, TRUE)),
       array('print' => $print_errors)
     );
     return FALSE;
   }
   if (!is_array($values)) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-      'tripal_core_chado_select; the $values argument must be an array. Values:%values',
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
+      'chado_select_record; the $values argument must be an array. Values:%values',
       array('%values' => print_r($values, TRUE)),
       array('print' => $print_errors)
     );
@@ -992,7 +992,7 @@ function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
   }
 
   // get the table description
-  $table_desc = tripal_core_get_chado_table_schema($table);
+  $table_desc = chado_get_schema($table);
   $select = '';
   $from = '';
   $where = array();
@@ -1058,14 +1058,14 @@ function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
         // and there is no default value then we cannot check if the record
         // is a duplicate so return FALSE
         else {
-          tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-            'tripal_core_chado_select: There is no value for %field thus we cannot check if this record is unique',
+          tripal_report_error('tripal_core', TRIPAL_ERROR,
+            'chado_select_record: There is no value for %field thus we cannot check if this record is unique',
             array('%field' => $field), array('print' => $print_errors));
           return FALSE;
         }
       }
 
-      $results = tripal_core_chado_select($table, $new_columns, $new_values, $new_options);
+      $results = chado_select_record($table, $new_columns, $new_values, $new_options);
       // if we have a duplicate record then return the results
       if (count($results) > 0) {
         $has_results = 1;
@@ -1086,8 +1086,8 @@ function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
     // make sure the field is in the table description. If not then return an error
     // message
     if (!array_key_exists($field, $table_desc['fields'])) {
-      tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-        'tripal_core_chado_select: The field "%field" does not exist for the table "%table".  Cannot perform query. Values: %array',
+      tripal_report_error('tripal_core', TRIPAL_ERROR,
+        'chado_select_record: The field "%field" does not exist for the table "%table".  Cannot perform query. Values: %array',
         array('%field' => $field, '%table' => $table, '%array' => print_r($values, 1)),
         array('print' => $print_errors)
       );
@@ -1108,7 +1108,7 @@ function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
           'regex_columns' => $options['regex_columns'],
         );
 
-        $results = tripal_core_chado_get_foreign_key($table_desc, $field, $value, $foreign_options);
+        $results = chado_schema_get_foreign_key($table_desc, $field, $value, $foreign_options);
         if (!$results or count($results)==0) {
           return array();
         }
@@ -1258,7 +1258,7 @@ function chado_query($sql, $args = array()) {
 
   // Args should be an array
   if (!is_array($args)) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       'chado_query; Need to pass an array to chado_query, "%value" passed instead. Query: %query',
       array('%value' => $args, '%query' => $sql)
     );
@@ -1276,9 +1276,9 @@ function chado_query($sql, $args = array()) {
     // and those calls do not reference a schema, therefore, any tables with featureloc
     // must automaticaly have the chado schema set as active to find
     if(preg_match('/chado.featureloc/i', $sql)) {
-      $previous_db = tripal_db_set_active('chado') ;
+      $previous_db = chado_set_active('chado') ;
       $results = db_query($sql, $args);
-      tripal_db_set_active($previous_db);
+      chado_set_active($previous_db);
     }
     // for all other tables we should have everything in scope so just run the query
     else {
@@ -1288,9 +1288,9 @@ function chado_query($sql, $args = array()) {
   // if Chado is not local to the Drupal database then we have to
   // switch to another database
   else {
-    $previous_db = tripal_db_set_active('chado') ;
+    $previous_db = chado_set_active('chado') ;
     $results = db_query($sql, $args);
-    tripal_db_set_active($previous_db);
+    chado_set_active($previous_db);
   }
 
   return $results;
@@ -1333,7 +1333,7 @@ function chado_pager_query($query, $args, $limit, $element, $count_query = '') {
   // We calculate the total of pages as ceil(items / limit).
   $results = chado_query($count_query, $args);
   if (!$results) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       "chado_pager_query(): Query failed: %cq", array('%cq' => $count_query));
     return;
   }
@@ -1352,8 +1352,8 @@ function chado_pager_query($query, $args, $limit, $element, $count_query = '') {
 /**
  * Gets the value of a foreign key relationship
  *
- * This function is used by tripal_core_chado_select, tripal_core_chado_insert,
- * and tripal_core_chado_update to iterate through the associate array of
+ * This function is used by chado_select_record, chado_insert_record,
+ * and chado_update_record to iterate through the associate array of
  * values that gets passed to each of those routines.  The values array
  * is nested where foreign key contraints are used to specify a value that.  See
  * documentation for any of those functions for further information.
@@ -1367,7 +1367,7 @@ function chado_pager_query($query, $args, $limit, $element, $count_query = '') {
  *  An associative array containing the values
  * @param $options
  *  An associative array of additional options where the key is the option
- *  and the value is the value of that option. These options are passed on to tripal_core_chado_select.
+ *  and the value is the value of that option. These options are passed on to chado_select_record.
  *
  * Additional Options Include:
  *  - case_insensitive_columns
@@ -1385,7 +1385,7 @@ function chado_pager_query($query, $args, $limit, $element, $count_query = '') {
  *     'genus' => 'Citrus',
  *     'species' => 'sinensis',
  *   );
- *   $value = tripal_core_chado_get_foreign_key('feature', 'organism_id',$values);
+ *   $value = chado_schema_get_foreign_key('feature', 'organism_id',$values);
  *
  * @endcode
  * The above code selects a record from the feature table using the three fields
@@ -1397,7 +1397,7 @@ function chado_pager_query($query, $args, $limit, $element, $count_query = '') {
  *
  * @ingroup tripal_chado_query_api
  */
-function tripal_core_chado_get_foreign_key($table_desc, $field, $values, $options = NULL) {
+function chado_schema_get_foreign_key($table_desc, $field, $values, $options = NULL) {
 
   // set defaults for options. If we don't set defaults then
   // we get memory leaks when we try to access the elements
@@ -1426,7 +1426,7 @@ function tripal_core_chado_get_foreign_key($table_desc, $field, $values, $option
           . "implemented and defined this foreign key when it wasn't supposed to. Modules "
           . "this hook was implemented in: " . implode(', ',
         module_implements("chado_" . $table_desc['table'] . "_schema")) . ".";
-        tripal_core_report_error('tripal_core', $message);
+        tripal_report_error('tripal_core', $message);
         drupal_set_message(check_plain($message), 'error');
         continue;
       }
@@ -1440,7 +1440,7 @@ function tripal_core_chado_get_foreign_key($table_desc, $field, $values, $option
           // the column name of the foreign key matches the field we want
           // so this is the right relationship.  Now we want to select
           $select_cols = array($right);
-          $result = tripal_core_chado_select($table, $select_cols, $values, $options);
+          $result = chado_select_record($table, $select_cols, $values, $options);
           $fields = array();
           if ($result and count($result) > 0) {
             foreach ($result as $obj) {
@@ -1462,7 +1462,7 @@ function tripal_core_chado_get_foreign_key($table_desc, $field, $values, $option
        key referrs to (<foreign table>) and then implement
        hook_chado_chado_schema_v<version>_<foreign table>(). See
        tripal_feature_chado_v1_2_schema_feature for an example. Chado version: $version");
-    tripal_core_report_error('tripal_core', $message);
+    tripal_report_error('tripal_core', $message);
     drupal_set_message(check_plain($message), 'error');
   }
 

+ 16 - 37
tripal_core/api/tripal_core.chado_schema.api.inc

@@ -16,10 +16,10 @@
  * the Drupal-style array definition for any table, use the following function
  * call:
  *
- *   $table_desc = tripal_core_get_chado_table_schema($table)
+ *   $table_desc = chado_get_schema($table)
  *
  * where the variable $table contains the name of the table you want to
- * retireve.  The tripal_core_get_chado_table_schema function determines the appropriate version of
+ * retireve.  The chado_get_schema function determines the appropriate version of
  * Chado and uses the Drupal hook infrastructure to call the appropriate
  * hook function to retrieve the table schema.
  * @}
@@ -67,7 +67,7 @@ function chado_table_exists($table) {
  *
  * @ingroup tripal_chado_schema_api
  */
-function tripal_core_schema_exists($schema) {
+function chado_dbschema_exists($schema) {
 
   // check that the chado schema now exists
   $sql = "
@@ -94,7 +94,7 @@ function tripal_core_schema_exists($schema) {
  *
  * @ingroup tripal_chado_schema_api
  */
-function tripal_core_chado_schema_exists() {
+function chado_is_local() {
 
   // This is postgresql-specific code to check the existence of the chado schema
   // @coder-ignore: acting on pg_catalog schema rather then drupal schema therefore, table prefixing does not apply
@@ -125,7 +125,7 @@ function tripal_core_chado_schema_exists() {
  *
  * @ingroup tripal_chado_schema_api
  */
-function tripal_core_is_chado_installed() {
+function chado_is_installed() {
   global $databases;
 
   // first check if chado is in the $databases variable of the settings.php file
@@ -134,28 +134,7 @@ function tripal_core_is_chado_installed() {
   }
 
   // check to make sure the chado schema exists
-  return tripal_core_chado_schema_exists();
-}
-
-/**
- * Check whether chado is installed local to the Drupal database
- * in its own Chado schema.
- *
- * @return
- *   TRUE/FALSE depending upon whether chado is local.
- *
- * @ingroup tripal_chado_schema_api
- */
-function tripal_core_is_chado_local() {
-  global $databases, $db_type;
-
-  // first check if chado is in the $databases variable of the settings.php file
-  if (array_key_exists('chado', $databases)) {
-    return FALSE;
-  }
-
-  // check to make sure the chado schema exists
-  return tripal_core_chado_schema_exists();
+  return chado_is_local();
 }
 
 /**
@@ -181,14 +160,14 @@ function tripal_core_is_chado_local() {
  *
  * @ingroup tripal_chado_schema_api
  */
-function tripal_core_get_chado_version($exact = FALSE, $warn_if_unsupported = FALSE) {
+function chado_get_version($exact = FALSE, $warn_if_unsupported = FALSE) {
 
   global $databases;
   $version = '';
   $is_local = 0;
 
   // check that Chado is installed if not return 'uninstalled as the version'
-  $chado_exists = tripal_core_chado_schema_exists();
+  $chado_exists = chado_is_local();
   if (!$chado_exists) {
     // if it's not in the drupal database check to see if it's specified in the $db_url
     // in the settings.php
@@ -198,9 +177,9 @@ function tripal_core_get_chado_version($exact = FALSE, $warn_if_unsupported = FA
       return 'not installed';
     }
     $is_local = 0;
-    $previous_db = tripal_db_set_active('chado');
+    $previous_db = chado_set_active('chado');
     $prop_exists = db_table_exists('chadoprop');
-    tripal_db_set_active($previous_db);
+    chado_set_active($previous_db);
   }
   else {
     $is_local = 1;
@@ -221,9 +200,9 @@ function tripal_core_get_chado_version($exact = FALSE, $warn_if_unsupported = FA
       WHERE CV.name = 'chado_properties' and CVT.name = 'version'
     ";
     if (!$is_local) {
-      $previous_db = tripal_db_set_active('chado');
+      $previous_db = chado_set_active('chado');
       $results = db_query($sql);
-      tripal_db_set_active($previous_db);
+      chado_set_active($previous_db);
     }
     else {
       $results = chado_query($sql);
@@ -285,7 +264,7 @@ function tripal_core_get_chado_version($exact = FALSE, $warn_if_unsupported = FA
  *
  * @ingroup tripal_chado_schema_api
  */
-function tripal_core_get_chado_tables($include_custom = NULL) {
+function chado_get_table_names($include_custom = NULL) {
 
   // first get the chado version that is installed
   $v = $GLOBALS["chado_version"];
@@ -330,7 +309,7 @@ function tripal_core_get_chado_tables($include_custom = NULL) {
  *
  * @ingroup tripal_chado_schema_api
  */
-function tripal_core_get_chado_table_schema($table) {
+function chado_get_schema($table) {
 
   // first get the chado version that is installed
   $v = $GLOBALS["chado_version"];
@@ -341,7 +320,7 @@ function tripal_core_get_chado_table_schema($table) {
 
   // if the table_arr is empty then maybe this is a custom table
   if (!is_array($table_arr) or count($table_arr) == 0) {
-    $table_arr = tripal_get_chado_custom_schema($table);
+    $table_arr = chado_get_custom_table_schema($table);
   }
 
   return $table_arr;
@@ -359,7 +338,7 @@ function tripal_core_get_chado_table_schema($table) {
  *
  * @ingroup tripal_chado_schema_api
  */
-function tripal_get_chado_custom_schema($table) {
+function chado_get_custom_table_schema($table) {
 
   $sql = "SELECT schema FROM {tripal_custom_tables} WHERE table_name = :table_name";
   $results = db_query($sql, array(':table_name' => $table));

+ 53 - 53
tripal_core/api/tripal_core.chado_variables.api.inc

@@ -7,39 +7,39 @@
  * This API generates objects containing the full details of a record(s) in chado.
  * These should be used in all theme templates.
  *
- * This differs from the objects returned by tripal_core_chado_select in so far as all foreign key
+ * This differs from the objects returned by chado_select_record in so far as all foreign key
  * relationships have been followed meaning you have more complete details. Thus this function
- * should be used whenever you need a full variable and tripal_core_chado_select should be used if
+ * should be used whenever you need a full variable and chado_select_record should be used if
  * you only case about a few columns.
  *
  * The initial variable is generated by the
- * tripal_core_generate_chado_var([table], [filter criteria], [optional options])
+ * chado_generate_var([table], [filter criteria], [optional options])
  * function. An example of how to use this function is:
  * @code
    $values = array(
      'name' => 'Medtr4g030710'
    );
-   $features = tripal_core_generate_chado_var('feature', $values);
+   $features = chado_generate_var('feature', $values);
  * @endcode
  * This will return an object if there is only one feature with the name Medtr4g030710 or it will
  * return an array of feature objects if more than one feature has that name.
  *
  * Some tables and fields are excluded by default. To have those tables & fields added to
  * your variable you can use the
- * tripal_core_expand_chado_vars([chado variable], [type], [what to expand], [optional options])
+ * chado_expand_var([chado variable], [type], [what to expand], [optional options])
  * function. An example of how to use this function is:
  * @code
    // Get a chado object to be expanded
    $values = array(
      'name' => 'Medtr4g030710'
    );
-   $features = tripal_core_generate_chado_var('feature', $values);
+   $features = chado_generate_var('feature', $values);
    // Expand the organism node
-   $feature = tripal_core_expand_chado_vars($feature, 'node', 'organism');
+   $feature = chado_expand_var($feature, 'node', 'organism');
    // Expand the feature.residues field
-   $feature = tripal_core_expand_chado_vars($feature, 'field', 'feature.residues');
+   $feature = chado_expand_var($feature, 'field', 'feature.residues');
    // Expand the feature properties (featureprop table)
-   $feature = tripal_core_expand_chado_vars($feature, 'table', 'featureprop');
+   $feature = chado_expand_var($feature, 'table', 'featureprop');
  * @endcode
  */
 
@@ -47,9 +47,9 @@
  * Implements hook_exclude_type_by_default()
  *
  * This hooks allows fields of a specified type that match a specified criteria to be excluded by
- * default from any table when tripal_core_generate_chado_var() is called. Keep in mind that if
+ * default from any table when chado_generate_var() is called. Keep in mind that if
  * fields are excluded by default they can always be expanded at a later date using
- * tripal_core_expand_chado_vars().
+ * chado_expand_var().
  *
  * Criteria are php strings that evaluate to either TRUE or FALSE. These strings are evaluated using
  * drupal_eval() which suppresses syntax errors and throws watchdog entries of type php. There are
@@ -76,9 +76,9 @@ function tripal_core_exclude_type_by_default() {
  * Implements hook_exclude_field_from_<tablename>_by_default()
  *
  * This hooks allows fields from a specified table that match a specified criteria to be excluded by
- * default from any table when tripal_core_generate_chado_var() is called. Keep in mind that if
+ * default from any table when chado_generate_var() is called. Keep in mind that if
  * fields are excluded by default they can always be expanded at a later date using
- * tripal_core_expand_chado_vars().
+ * chado_expand_var().
  *
  * Criteria are php strings that evaluate to either TRUE or FALSE. These strings are evaluated using
  * drupal_eval() which suppresses syntax errors and throws watchdog entries of type php. There are
@@ -104,21 +104,21 @@ function tripal_core_exclude_field_from_feature_by_default() {
 /**
  * Generates an object containing the full details of a record(s) in chado.
  *
- * This differs from the objects returned by tripal_core_chado_select in so far as all foreign key
+ * This differs from the objects returned by chado_select_record in so far as all foreign key
  * relationships have been followed meaning you have more complete details. Thus this function
- * should be used whenever you need a full variable and tripal_core_chado_select should be used if
+ * should be used whenever you need a full variable and chado_select_record should be used if
  * you only case about a few columns.
  *
  * @param $table
  *   The name of the base table to generate a variable for
  * @param $values
  *   A select values array that selects the records you want from the base table
- *   (this has the same form as tripal_core_chado_select)
+ *   (this has the same form as chado_select_record)
  * @param $base_options
  *   An array containing options for the base table.  For example, an
  *   option of 'order_by' may be used to sort results in the base table
  *   if more than one are returned.  The options must be compatible with
- *   the options accepted by the tripal_core_chado_select() function.
+ *   the options accepted by the chado_select_record() function.
  *   Additionally,  These options are available for this function:
  *   -return_array:
  *     can be provided to force the function to always return an array. Default
@@ -126,7 +126,7 @@ function tripal_core_exclude_field_from_feature_by_default() {
  *     an array if multiple records exist.
  *  - include_fk:
  *     an array of FK relationships to follow. By default, the
- *     tripal_core_chado_select function will follow all FK relationships but this
+ *     chado_select_record function will follow all FK relationships but this
  *     may generate more queries then is desired slowing down this function call when
  *     there are lots of FK relationships to follow.  Provide an array specifying the
  *     fields to include.  For example, if expanding a property table (e.g. featureprop)
@@ -162,7 +162,7 @@ function tripal_core_exclude_field_from_feature_by_default() {
    $values = array(
      'name' => 'Medtr4g030710'
    );
-   $features = tripal_core_generate_chado_var('feature', $values);
+   $features = chado_generate_var('feature', $values);
  * @endcode
  * This will return an object if there is only one feature with the name Medtr4g030710 or it will
  * return an array of feature objects if more than one feature has that name.
@@ -192,7 +192,7 @@ function tripal_core_exclude_field_from_feature_by_default() {
  *
  * @ingroup tripal_chado_variables_api
  */
-function tripal_core_generate_chado_var($table, $values, $base_options = array()) {
+function chado_generate_var($table, $values, $base_options = array()) {
   $all = new stdClass();
 
   $return_array = 0;
@@ -208,10 +208,10 @@ function tripal_core_generate_chado_var($table, $values, $base_options = array()
     $pager = $base_options['pager'];
   }
   // get description for the current table----------------------------------------------------------
-  $table_desc = tripal_core_get_chado_table_schema($table);
+  $table_desc = chado_get_schema($table);
   if (!$table_desc or count($table_desc) == 0) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
-      "tripal_core_generate_chado_var: The table '%table' has not been defined. " .
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
+      "chado_generate_var: The table '%table' has not been defined. " .
       "and cannot be expanded. If this is a custom table, please add it using the Tripal " .
       "custom table interface.", array('%table' => $table));
     if ($return_array) {
@@ -286,7 +286,7 @@ function tripal_core_generate_chado_var($table, $values, $base_options = array()
   } //end of foreach type to be removed
 */
   // get the values for the record in the current table---------------------------------------------
-  $results = tripal_core_chado_select($table, $table_columns, $values, $base_options);
+  $results = chado_select_record($table, $table_columns, $values, $base_options);
 
   if ($results) {
     foreach ($results as $key => $object) {
@@ -357,7 +357,7 @@ function tripal_core_generate_chado_var($table, $values, $base_options = array()
               $options['include_fk'] = $include_fk[$foreign_key];
             }
 
-            $foreign_object = tripal_core_generate_chado_var($foreign_table, $foreign_values, $options);
+            $foreign_object = chado_generate_var($foreign_table, $foreign_values, $options);
 
             // add the foreign record to the current object in a nested manner
             $object->{$foreign_key} = $foreign_object;
@@ -426,12 +426,12 @@ function tripal_core_generate_chado_var($table, $values, $base_options = array()
 /**
  * Retrieves fields/tables/nodes that were excluded by default from a variable and adds them
  *
- * This function exists to allow tripal_core_generate_chado_var() to excldue some
+ * This function exists to allow chado_generate_var() to excldue some
  * fields/tables/nodes from the default form of a variable without making it extremely difficult for
  * the tripal admin to get at these variables if he/she wants them.
  *
  * @param $object
- *   This must be an object generated using tripal_core_generate_chado_var()
+ *   This must be an object generated using chado_generate_var()
  * @param $type
  *   Must be one of 'field', 'table', 'node'. Indicates what is being expanded.
  * @param $to_expand
@@ -441,7 +441,7 @@ function tripal_core_generate_chado_var($table, $values, $base_options = array()
  *     An array containing options for the base table.  For example, an
  *     option of 'order_by' may be used to sort results in the base table
  *     if more than one are returned.  The options must be compatible with
- *     the options accepted by the tripal_core_chado_select() function.
+ *     the options accepted by the chado_select_record() function.
  *   - return_array:
  *     Additionally,  The option 'return_array' can be provided to force
  *     the function to expand tables as an array. Default behavior is to expand
@@ -449,7 +449,7 @@ function tripal_core_generate_chado_var($table, $values, $base_options = array()
  *     multiple records exist.
  *   - include_fk:
  *     an array of FK relationships to follow. By default, the
- *     tripal_core_expand_chado_vars function will follow all FK relationships but this
+ *     chado_expand_var function will follow all FK relationships but this
  *     may generate more queries then is desired slowing down this function call when
  *     there are lots of FK relationships to follow.  Provide an array specifying the
  *     fields to include.  For example, if expanding a property table (e.g. featureprop)
@@ -485,30 +485,30 @@ function tripal_core_generate_chado_var($table, $values, $base_options = array()
    $values = array(
      'name' => 'Medtr4g030710'
    );
-   $features = tripal_core_generate_chado_var('feature', $values);
+   $features = chado_generate_var('feature', $values);
    // Expand the organism node
-   $feature = tripal_core_expand_chado_vars($feature, 'node', 'organism');
+   $feature = chado_expand_var($feature, 'node', 'organism');
    // Expand the feature.residues field
-   $feature = tripal_core_expand_chado_vars($feature, 'field', 'feature.residues');
+   $feature = chado_expand_var($feature, 'field', 'feature.residues');
    // Expand the feature properties (featureprop table)
-   $feature = tripal_core_expand_chado_vars($feature, 'table', 'featureprop');
+   $feature = chado_expand_var($feature, 'table', 'featureprop');
  * @endcode
  *
  * @ingroup tripal_chado_variables_api
  */
-function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_options = array()) {
+function chado_expand_var($object, $type, $to_expand, $table_options = array()) {
 
   // make sure we have a value
   if (!$object) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
-      'Cannot pass non array as argument, $object, to tripal_core_expand_chado_vars function.', array());
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
+      'Cannot pass non array as argument, $object, to chado_expand_var function.', array());
     return $object;
   }
 
   // check to see if we are expanding an array of objects
   if (is_array($object)) {
     foreach ($object as $index => $o) {
-      $object[$index] = tripal_core_expand_chado_vars($o, $type, $to_expand);
+      $object[$index] = chado_expand_var($o, $type, $to_expand);
     }
     return $object;
   }
@@ -521,7 +521,7 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
       if (preg_match('/(\w+)\.(\w+)/', $to_expand, $matches)) {
         $tablename = $matches[1];
         $fieldname = $matches[2];
-        $table_desc = tripal_core_get_chado_table_schema($tablename);
+        $table_desc = chado_get_schema($tablename);
         $values = array();
         foreach ($table_desc['primary key'] as $key) {
           if(property_exists($object, $key)) {
@@ -530,7 +530,7 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
         }
         if ($base_table == $tablename) {
           //get the field
-          $results = tripal_core_chado_select($tablename, array($fieldname), $values);
+          $results = chado_select_record($tablename, array($fieldname), $values);
           $object->{$fieldname} = $results[0]->{$fieldname};
           $object->expanded = $to_expand;
         }
@@ -538,7 +538,7 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
           //We need to recurse -the field is in a nested object
           foreach ((array) $object as $field_name => $field_value) {
             if (is_object($field_value)) {
-              $object->{$field_name} = tripal_core_expand_chado_vars(
+              $object->{$field_name} = chado_expand_var(
               $field_value,
                 'field',
               $to_expand
@@ -548,8 +548,8 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
         }
       }
       else {
-        tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
-          'tripal_core_expand_chado_vars: Field (%field) not in the right format. " .
+        tripal_report_error('tripal_core', TRIPAL_ERROR,
+          'chado_expand_var: Field (%field) not in the right format. " .
           "It should be <tablename>.<fieldname>');
       }
       break;
@@ -560,7 +560,7 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
       if (array_key_exists($foreign_table, $object)) {
         return $object;
       }
-      $foreign_table_desc = tripal_core_get_chado_table_schema($foreign_table);
+      $foreign_table_desc = chado_get_schema($foreign_table);
 
       // If it's connected to the base table via a FK constraint
       if (array_key_exists($base_table, $foreign_table_desc['foreign keys'])) {
@@ -572,7 +572,7 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
 
           // generate a new object for this table using the FK values in the base table.
           $new_options = $table_options;
-          $foreign_object = tripal_core_generate_chado_var($foreign_table, array($left => $object->{$right}), $new_options);
+          $foreign_object = chado_generate_var($foreign_table, array($left => $object->{$right}), $new_options);
 
           // if the generation of the object was successful, update the base object to include it.
           if ($foreign_object) {
@@ -619,17 +619,17 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
         foreach ((array) $object as $field_name => $field_value) {
           // if we have a nested object ->expand the table in it
           // check to see if the $field_name is a valid chado table, we don't need
-          // to call tripal_core_expand_chado_vars on fields that aren't tables
-          $check = tripal_core_get_chado_table_schema($field_name);
+          // to call chado_expand_var on fields that aren't tables
+          $check = chado_get_schema($field_name);
           if ($check) {
             $did_expansion = 1;
-            $object->{$field_name} = tripal_core_expand_chado_vars($field_value, 'table', $foreign_table);
+            $object->{$field_name} = chado_expand_var($field_value, 'table', $foreign_table);
           }
         }
         // if we did not expand this table we should return a message that the foreign table
         // could not be expanded
         if (!$did_expansion) {
-          tripal_core_report_error('tripal_core', TRIPAL_ERROR, 'tripal_core_expand_chado_vars: Could not expand table, %table. It is ' .
+          tripal_report_error('tripal_core', TRIPAL_ERROR, 'chado_expand_var: Could not expand table, %table. It is ' .
             'not in a foreign key relationship with the base object nor with any other expanded table. ' .
             'Check the table definition to ensure that a proper foreign key relationship is present.',
             array('%table' => $foreign_table));
@@ -652,7 +652,7 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
           $object = $node;
         }
         else {
-          tripal_core_report_error('tripal_core', TRIPAL_ERROR, 'tripal_core_expand_chado_vars: No node matches the nid (%nid) supplied.',
+          tripal_report_error('tripal_core', TRIPAL_ERROR, 'chado_expand_var: No node matches the nid (%nid) supplied.',
             array('%nid' => $object->nid));
         } //end of if node
       }
@@ -660,7 +660,7 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
         //We need to recurse -the node to expand is one of the nested objects
         foreach ((array) $object as $field_name => $field_value) {
           if (is_object($field_value)) {
-            $object->{$field_name} = tripal_core_expand_chado_vars(
+            $object->{$field_name} = chado_expand_var(
             $field_value,
               'node',
             $to_expand
@@ -670,7 +670,7 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
       }
       break;
     default:
-      tripal_core_report_error('tripal_core', TRIPAL_ERROR, 'tripal_core_expand_chado_vars: Unrecognized type (%type). Should be one of "field", "table", "node".',
+      tripal_report_error('tripal_core', TRIPAL_ERROR, 'chado_expand_var: Unrecognized type (%type). Should be one of "field", "table", "node".',
         array('%type' => $type));
       return FALSE;
   }
@@ -698,8 +698,8 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
     else {
       // if there is an expandable array then we've reached the base object
       // if we get here and don't have anything expanded then something went wrong
-      //      tripal_core_report_error('tripal_core', TRIPAL_ERROR,
-      //        'tripal_core_expand_chado_vars: Unable to expand the %type %to_expand',
+      //      tripal_report_error('tripal_core', TRIPAL_ERROR,
+      //        'chado_expand_var: Unable to expand the %type %to_expand',
       //        array('%type'=>$type, '%to_expand'=>$to_expand),
       //      );
     } //end of it we've reached the base object

+ 8 - 8
tripal_core/api/tripal_core.custom_tables.api.inc

@@ -24,7 +24,7 @@
  *
  * @ingroup tripal_custom_tables_api
  */
-function tripal_core_edit_custom_table($table_id, $table_name, $schema, $skip_creation = 1) {
+function chado_edit_custom_table($table_id, $table_name, $schema, $skip_creation = 1) {
 
   // Create a new record
   $record = new stdClass();
@@ -63,7 +63,7 @@ function tripal_core_edit_custom_table($table_id, $table_name, $schema, $skip_cr
       }
 
       // re-create the table
-      if (!tripal_core_create_custom_table ($table_name, $schema)) {
+      if (!chado_create_custom_table ($table_name, $schema)) {
         drupal_set_message(t("Could not create the custom table. Check Drupal error report logs."));
       }
       else {
@@ -99,7 +99,7 @@ function tripal_core_edit_custom_table($table_id, $table_name, $schema, $skip_cr
  *
  * @ingroup tripal_custom_tables_api
  */
-function tripal_core_create_custom_table($table, $schema, $skip_creation = 1) {
+function chado_create_custom_table($table, $schema, $skip_creation = 1) {
   global $databases;
   $created = 0;
   $recreated = 0;
@@ -120,7 +120,7 @@ function tripal_core_create_custom_table($table, $schema, $skip_creation = 1) {
     }
     catch (Exception $e) {
       $error = $e->getMessage();
-      tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
+      tripal_report_error('tripal_core', TRIPAL_ERROR,
         "Error adding custom table: @message", array('@message' => $error));
       drupal_set_message("Could not add custom table. $error.", "error");
       return FALSE;
@@ -139,7 +139,7 @@ function tripal_core_create_custom_table($table, $schema, $skip_creation = 1) {
     }
     catch (Exception $e) {
       $error = $e->getMessage();
-      tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
+      tripal_report_error('tripal_core', TRIPAL_ERROR,
         "Error adding custom table: @message",
         array('@message' => $error));
       drupal_set_message("Could not add custom table. $error.", "error");
@@ -159,7 +159,7 @@ function tripal_core_create_custom_table($table, $schema, $skip_creation = 1) {
   }
   $success = drupal_write_record('tripal_custom_tables', $record);
   if (!$success) {
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
+    tripal_report_error('tripal_core', TRIPAL_ERROR,
       "Error adding custom table %table_name.",
       array('%table_name' => $table));
     drupal_set_message(t("Could not add custom table %table_name.
@@ -187,7 +187,7 @@ function tripal_core_create_custom_table($table, $schema, $skip_creation = 1) {
         }
         catch (Exception $e) {
           $error = $e->getMessage();
-          tripal_core_report_error('tripal_core', TRIPAL_ERROR, "Error, could not add foreign key contraint to custom table: %error",
+          tripal_report_error('tripal_core', TRIPAL_ERROR, "Error, could not add foreign key contraint to custom table: %error",
             array('%error' => $error));
           drupal_set_message("Could not add foreign key contraint to table: $error", 'error');
           return FALSE;
@@ -218,7 +218,7 @@ function tripal_core_create_custom_table($table, $schema, $skip_creation = 1) {
  *
  * @ingroup tripal_custom_tables_api
  */
-function tripal_custom_tables_get_table_id($table_name) {
+function chado_get_custom_table_id($table_name) {
   if (db_table_exists('tripal_custom_tables')) {
     $sql = "SELECT * FROM {tripal_custom_tables} WHERE table_name = :table_name";
     $results = db_query($sql, array(':table_name' => $table_name));

+ 29 - 44
tripal_core/api/tripal_core.files.api.inc

@@ -9,18 +9,6 @@
  *
  */
 
-/**
- * This function is a substitute for Drupal 6's file_directory_path()
- * function which no longer exists in Drupal 7.  However, the function
- * call is useful because it's more intitutive. So this wrapper was created
- * to mimic the behavior of the old function.
- *
- * @return
- *   the public directory where tripal files are housed: sites/default/files/tripal
- */
-function tripal_file_directory_path() {
-  return variable_get('file_public_path', conf_path() . '/files/tripal');
-}
 /**
  * This function is typically used in the '.install' file for a Tripal module
  * Each module should call this function during installation to create
@@ -29,61 +17,58 @@ function tripal_file_directory_path() {
  * for storing files.
  *
  * @param $module_name
- *   the name of the module being installed.
- *
- * @returns
- *   nothing
- *
- * @ingroup tripal_files_api
+ *   the name of the module being installed
+ * @param $path
+ *   Optional sub-path to create
  */
-function tripal_create_moddir($module_name) {
+function tripal_create_files_dir($module_name, $path = FALSE) {
 
-  // make the data directory for this module
-  $data_dir = tripal_file_directory_path() . "/$module_name";
-  if (!file_prepare_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');
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, $message, array());
+  // if the path is not supplied then assume they want to create the base files directory
+  // for the specified module
+  if (!$path) {
+    // make the data directory for this module
+    $data_dir = tripal_get_files_dir() . "/$module_name";
+    if (!file_prepare_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');
+      tripal_report_error('tripal_core', TRIPAL_ERROR, $message, array());
+    }
   }
-}
-
-/**
- * This function creates directories inside of the module's
- * Data directory.
- *
- * @param $module_name
- * @param $path
- */
-function tripal_create_mod_subdir($module_name, $path) {
 
   // make sure the module data directory exists
-  tripal_create_moddir($module_name);
+  tripal_create_files_dir($module_name);
 
   // now make sure the sub dir exists
-  $sub_dir = tripal_file_directory_path() . $module_name . $path;
+  $sub_dir = tripal_get_files_dir() . $module_name . $path;
   if (!file_prepare_directory($sub_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
     $message = "Cannot create directory $sub_dir. ";
     drupal_set_message(check_plain(t($message)), 'error');
-    tripal_core_report_error('tripal_core', TRIPAL_ERROR, $message, array());
+    tripal_report_error('tripal_core', TRIPAL_ERROR, $message, array());
   }
 }
 
 /**
  * Each Tripal module has a unique data directory which was creatd using the
- * tripal_create_moddir function during installation.  This function
+ * tripal_create_files_dir function during installation.  This function
  * retrieves the directory path.
  *
  * @param $module_name
- *   The name of the module
+ *   (Optional) 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 = tripal_file_directory_path() . "/$module_name";
+function tripal_get_files_dir($module_name = FALSE) {
+
+  $data_dir = variable_get('file_public_path', conf_path() . '/files/tripal');
+
+  if ($module_name) {
+    $data_dir .= "/$module_name";
+  }
+
   return $data_dir;
 }

+ 10 - 10
tripal_core/api/tripal_core.jobs.api.inc

@@ -95,7 +95,7 @@ function tripal_add_job($job_name, $modulename, $callback, $arguments, $uid, $pr
  *
  * @ingroup tripal_jobs_api
  */
-function tripal_jobs_check_running() {
+function tripal_is_job_running() {
 
   // iterate through each job that has not ended
   // and see if it is still running. If it is not
@@ -137,7 +137,7 @@ function tripal_jobs_check_running() {
  *
  * @ingroup tripal_jobs_api
  */
-function tripal_jobs_get_start_time($job) {
+function tripal_get_job_start($job) {
 
   if ($job->start_time > 0) {
     $start = format_date($job->start_time);
@@ -164,7 +164,7 @@ function tripal_jobs_get_start_time($job) {
  *
  * @ingroup tripal_jobs_api
  */
-function tripal_jobs_get_end_time($job) {
+function tripal_get_job_end($job) {
 
   if ($job->end_time > 0) {
     $end = format_date($job->end_time);
@@ -185,7 +185,7 @@ function tripal_jobs_get_end_time($job) {
  *
  * @ingroup tripal_jobs_api
  */
-function tripal_jobs_rerun($job_id, $goto_jobs_page = TRUE) {
+function tripal_rerun_job($job_id, $goto_jobs_page = TRUE) {
   global $user;
 
   $user_id = $user->uid;
@@ -217,7 +217,7 @@ function tripal_jobs_rerun($job_id, $goto_jobs_page = TRUE) {
  *
  * @ingroup tripal_jobs_api
  */
-function tripal_jobs_cancel($job_id, $redirect = TRUE) {
+function tripal_cancel_job($job_id, $redirect = TRUE) {
   $sql = "SELECT * FROM {tripal_jobs} WHERE job_id = :job_id";
   $results = db_query($sql, array(':job_id' => $job_id));
   $job = $results->fetchObject();
@@ -255,12 +255,12 @@ function tripal_jobs_cancel($job_id, $redirect = TRUE) {
  *
  * @ingroup tripal_jobs_api
  */
-function tripal_jobs_launch($do_parallel = 0, $job_id = NULL) {
+function tripal_launch_job($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()) {
+  if (!$do_parallel and tripal_is_job_running()) {
     print "Jobs are still running. Use the --parallel=1 option with the Drush command to run jobs in parallel.";
     return;
   }
@@ -327,7 +327,7 @@ function tripal_jobs_launch($do_parallel = 0, $job_id = NULL) {
  *
  * @ingroup tripal_core
  */
-function tripal_job_set_progress($job_id, $percentage) {
+function tripal_set_job_progress($job_id, $percentage) {
 
   if (preg_match("/^(\d+|100)$/", $percentage)) {
     $record = new stdClass();
@@ -351,7 +351,7 @@ function tripal_job_set_progress($job_id, $percentage) {
  *
  * @ingroup tripal_jobs_api
  */
-function tripal_get_module_active_jobs($modulename) {
+function tripal_get_active_jobs($modulename) {
   $sql =  "SELECT * FROM {tripal_jobs} TJ " .
            "WHERE TJ.end_time IS NULL and TJ.modulename = :modulename ";
   $results = db_query($sql, array(':modulename' => $modulename));
@@ -369,6 +369,6 @@ function tripal_get_module_active_jobs($modulename) {
  *
  * @ingroup tripal_jobs_api
  */
-function tripal_jobs_get_submit_date($job) {
+function tripal_get_job_submit_date($job) {
   return format_date($job->submit_date);
 }

+ 55 - 30
tripal_core/api/tripal_core.mviews.api.inc

@@ -34,7 +34,7 @@
  *   A string containing a description of the materialized view
  *
  * @ingroup tripal_mviews_api
- */
+ *
 function tripal_add_legacy_mview($name, $modulename, $mv_table, $mv_specs, $indexed,
   $query, $special_index, $comment = NULL) {
 
@@ -74,9 +74,9 @@ function tripal_add_legacy_mview($name, $modulename, $mv_table, $mv_specs, $inde
 
   // add the table to the database
   $sql = "CREATE TABLE {$mv_table} ($mv_specs); $index";
-  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $previous_db = chado_set_active('chado');  // use chado database
   $results = db_query($sql);
-  tripal_db_set_active($previous_db);  // now use drupal database
+  chado_set_active($previous_db);  // now use drupal database
   if ($results) {
     drupal_set_message(t("View '%name' created", array('%name' => $name)));
   }
@@ -84,6 +84,8 @@ function tripal_add_legacy_mview($name, $modulename, $mv_table, $mv_specs, $inde
     drupal_set_message(t("Failed to create the materialized view table: '%mv_table'", array('%mv_table' => $mv_table)), 'error');
   }
 }
+*/
+
 /**
  * Add a materialized view to the chado database to help speed data access. This
  * function supports the older style where postgres column specifications
@@ -111,7 +113,7 @@ function tripal_add_mview($name, $modulename, $schema_arr, $query, $comment = NU
   $mv_table = $schema_arr['table'];
 
   if (!$mv_table) {
-     tripal_core_report_error('tripal_core', TRIPAL_ERROR, 
+     tripal_report_error('tripal_core', TRIPAL_ERROR,
        'Must have a table name when creating an mview.', array());
      return NULL;
   }
@@ -135,7 +137,7 @@ function tripal_add_mview($name, $modulename, $schema_arr, $query, $comment = NU
       chado_query($sql);
     }
     // create the table
-    if (!tripal_core_create_custom_table ($mv_table, $schema_arr, 0)) {
+    if (!chado_create_custom_table ($mv_table, $schema_arr, 0)) {
       drupal_set_message(t("Could not create the materialized view. Check Drupal error report logs."), 'error');
     }
     else {
@@ -220,13 +222,13 @@ function tripal_edit_mview($mview_id, $name, $modulename, $mv_table, $mv_specs,
 
   // 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
+    $previous_db = chado_set_active('chado');  // use chado database
     if (db_table_exists($mview->mv_table)) {
       $sql = "DROP TABLE :table_name";
       db_query($sql, array(':table_name' => $mview->mv_table));
       drupal_set_message(t("View '%name' dropped", array('%name' => $name)));
     }
-    tripal_db_set_active($previous_db);  // now use drupal database
+    chado_set_active($previous_db);  // now use drupal database
   }
 
   // update the record to the tripal_mviews table and if successful
@@ -247,7 +249,7 @@ function tripal_edit_mview($mview_id, $name, $modulename, $mv_table, $mv_specs,
     // 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($mv_table, $schema_arr, 0)) {
+      if (!chado_create_custom_table($mv_table, $schema_arr, 0)) {
         drupal_set_message(t("Could not create the materialized view. Check Drupal error report logs."));
       }
       else {
@@ -307,8 +309,6 @@ function tripal_mviews_get_mview_id($view_name) {
 /**
  * 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
@@ -316,7 +316,7 @@ function tripal_mviews_get_mview_id($view_name) {
  *
  * @ingroup tripal_core
  */
-function tripal_mviews_action($op, $mview_id, $redirect = FALSE) {
+function tripal_add_populate_mview($mview_id, $redirect = FALSE) {
   global $user;
 
   if (!$mview_id) {
@@ -329,27 +329,52 @@ function tripal_mviews_action($op, $mview_id, $redirect = FALSE) {
   $mview = $results->fetchObject();
 
   // add a job or perform the action based on the given operation
-  if ($op == 'update') {
-    $args = array("$mview_id");
-    tripal_add_job("Populate materialized view '$mview->name'", 'tripal_core',
-       'tripal_update_mview', $args, $user->uid);
+  $args = array("$mview_id");
+  tripal_add_job("Populate materialized view '$mview->name'", 'tripal_core',
+     'tripal_populate_mview', $args, $user->uid);
+
+  // Redirect the user
+  if ($redirect) {
+    drupal_goto("admin/tripal/mviews");
   }
+}
 
-  // if op is to delete then do so
-  if ($op == 'delete') {
+/**
+ * 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_delete_mview($mview_id, $redirect = FALSE) {
+  global $user;
+
+  if (!$mview_id) {
+    return '';
+  }
 
-    // remove the mview from the tripal_mviews table
-    $sql = "DELETE FROM {tripal_mviews} WHERE mview_id = $mview_id";
-    db_query($sql);
+  // get this mview details
+  $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id";
+  $results = db_query($sql, array(':mview_id' => $mview_id));
+  $mview = $results->fetchObject();
 
-    // does the table already exist?
-    $mview_exists = db_table_exists('chado.' . $mview->mv_table);
+  // if op is to delete then do so
+  // 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
-    if ($mview_exists) {
-      $sql = "DROP TABLE {" . $mview->mv_table . "}";
-      chado_query($sql);
-    }
+  // does the table already exist?
+  $mview_exists = db_table_exists('chado.' . $mview->mv_table);
+
+  // drop the table from chado if it exists
+  if ($mview_exists) {
+    $sql = "DROP TABLE {" . $mview->mv_table . "}";
+    chado_query($sql);
   }
 
   // Redirect the user
@@ -369,7 +394,7 @@ function tripal_mviews_action($op, $mview_id, $redirect = FALSE) {
  *
  * @ingroup tripal_mviews_api
  */
-function tripal_update_mview($mview_id) {
+function tripal_populate_mview($mview_id) {
   $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id ";
   $results = db_query($sql, array(':mview_id' => $mview_id));
   $mview = $results->fetchObject();
@@ -378,10 +403,10 @@ function tripal_update_mview($mview_id) {
     // that may leave parts of the site unfunctional
     $transaction = db_transaction();
     try {
-      $previous_db = tripal_db_set_active('chado');  // use chado database
+      $previous_db = chado_set_active('chado');  // use chado database
       $success = db_query("DELETE FROM {" . $mview->mv_table . "}");
       $success = db_query("INSERT INTO {" . $mview->mv_table . "} ($mview->query)");
-      tripal_db_set_active($previous_db);  // now use drupal database
+      chado_set_active($previous_db);  // now use drupal database
       // if success get the number of results and update the table record
       if ($success) {
         $sql = "SELECT count(*) as cnt FROM {" . $mview->mv_table . "}";

File diff suppressed because it is too large
+ 230 - 230
tripal_core/api/tripal_core.schema_v1.11.api.inc


File diff suppressed because it is too large
+ 230 - 230
tripal_core/api/tripal_core.schema_v1.2.api.inc


+ 44 - 26
tripal_core/tripal_core.module

@@ -62,6 +62,8 @@ require_once "api/tripal_core.mviews.api.inc";
 require_once "api/tripal_core.files.api.inc";
 require_once "api/tripal_core.jobs.api.inc";
 
+require_once 'api/tripal_core.DEPRECATED.inc';
+
 // INCLUDES -------------------------------------
 require_once "includes/jobs.inc";
 require_once "includes/mviews.inc";
@@ -69,8 +71,24 @@ require_once "includes/custom_tables.inc";
 require_once "includes/chado_install.inc";
 require_once "includes/form_elements.inc";
 
-
 tripal_core_set_globals();
+/**
+ * This function is used to set the global Chado variables
+ * @ingroup tripal_chado_api
+ */
+function tripal_core_set_globals() {
+  // these global variables are meant to be accessed by all Tripal
+  // modules to find the chado version installed and if Chado is local.
+  // these variables are stored as globals rather than using the drupal_set_variable
+  // functions because the Drupal functions make databaes queries and for long
+  // running loaders we don't want those queries repeatedly.
+  $GLOBALS["chado_is_installed"]  = tripal_core_is_chado_installed();
+  if ($GLOBALS["chado_is_installed"]) {
+    $GLOBALS["chado_is_local"]      = tripal_core_is_chado_local();
+    $GLOBALS["chado_version"]       = tripal_core_get_chado_version();
+    $GLOBALS["exact_chado_version"] = tripal_core_get_chado_version(TRUE);
+  }
+}
 
 /**
  * Implements hook_init().
@@ -547,11 +565,11 @@ function tripal_core_views_api() {
  */
 function tripal_core_node_view_alter(&$build) {
   global $theme;
-  
+
   //dpm($build);
-  
+
   // if the $build['tripal_toc'] element is not present, then this is not
-  // a full node view so we do not want to alter 
+  // a full node view so we do not want to alter
   if (!array_key_exists('tripal_toc', $build)) {
     return;
   }
@@ -560,7 +578,7 @@ function tripal_core_node_view_alter(&$build) {
   $node = $build['#node'];
   $toc = array();
   $toc_html = '';
-  
+
   // if we are looking at a Tripal node template then we want to
   // make some changes to each block of content so that we can associate
   // a table of contents and add administrator and curator messages
@@ -571,18 +589,18 @@ function tripal_core_node_view_alter(&$build) {
     $markup = array();
     foreach ($build as $key => $value) {
 
-      // examine elements without a '#' prefix as these should be adding 
+      // examine elements without a '#' prefix as these should be adding
       // contents to the page. Skip the table of contents and links as those
       // will be placed elsewhere
       if (!preg_match('/^#/', $key) and $key != 'tripal_toc' and $key != 'links') {
-        
+
         //-----------------------
         // INITIALIZE THE CONTENT VARIABLES
         //-----------------------
         $toc_item_title = $key;
         $toc_item_id    = $key;
         $toc_item_link  = '';
-        
+
         // get the title for the table of contents.  Tripal templates should
         // have a '#tripal_toc_title' element in the build array
         if (array_key_exists('#tripal_toc_title', $build[$key])) {
@@ -593,21 +611,21 @@ function tripal_core_node_view_alter(&$build) {
           $toc_item_title = $build[$key]['#title'];
         }
         $toc_item_title = ucwords($toc_item_title);
-        
+
         if (array_key_exists('#tripal_toc_id', $build[$key])) {
           $toc_item_id = $build[$key]['#tripal_toc_id'];
         }
         $toc_item_link = "<div class=\"tripal_toc_list_item\"><a id=\"$toc_item_id\" class=\"tripal_toc_list_item_link\" href=\"?block=$toc_item_id\">$toc_item_title</a></div>";
 
-        
+
         //-----------------------
         // GET THE MARKUP FOR EACH ELEMENT
         //-----------------------
         $markup = '';
-        
+
         // find the markup. Some fields will have a '#markup' and others, such
-        // as CCK elements may have a set of '#markup' elements organized by 
-        // numerical keys. 
+        // as CCK elements may have a set of '#markup' elements organized by
+        // numerical keys.
         if (array_key_exists('#markup', $build[$key]) and trim($build[$key]['#markup'])) {
           $markup = $build[$key]['#markup'];
         }
@@ -615,7 +633,7 @@ function tripal_core_node_view_alter(&$build) {
         elseif (array_key_exists('#value', $build[$key]) and trim($build[$key]['#value'])) {
           $markup = $build[$key]['#markup'];
         }
-        
+
         // if we have no '#markup' field then this element has not yet
         // been rendered.  Let's render it and substitute that for markup
         if (!$markup) {
@@ -624,21 +642,21 @@ function tripal_core_node_view_alter(&$build) {
             '#markup' => $markup,
           );
         }
-        
+
         // if we still don't have markup then skip this one
         if (!$markup) {
           continue;
         }
-        
+
         //-----------------------
         // FIND THE TEMPLATE PATH
         //-----------------------
         // get the template path so we can put it in an admin message box
         $path = '';
         if (array_key_exists($key, $cache->data) and array_key_exists('path', $cache->data[$key])) {
-        
+
           $path = $cache->data[$key]['path'] . '/' . $key . '.tpl.php';
-        
+
           $path = theme('tripal_admin_message', array('message' => "Administrators, you can
             customize the way the content above is presented.  Tripal provides a template
             file for each block of content.  To customize, copy the template file to your
@@ -647,7 +665,7 @@ function tripal_core_node_view_alter(&$build) {
             Currently, the content above is provided by this template: <br><br>$path")
           );
         }
-        
+
         //-----------------------
         // SET THE WEIGHTS FOR THE TOC ELEMENTS
         //-----------------------
@@ -658,26 +676,26 @@ function tripal_core_node_view_alter(&$build) {
           $weight = $build[$key]['#weight'];
         }
         $toc[$weight][$toc_item_title] = $toc_item_link;
-    
+
         //-----------------------
         // CREATE THE DATA BLOCK
         //-----------------------
         // add a surrounding <div> box around the content
         $updated_markup = "
           <div id=\"$toc_item_id-tripal-data-block\" class=\"tripal-data-block\">
-            <div class=\"$toc_item_id-tripal-data-block-title tripal-data-block-title\">$toc_item_title</div>  
+            <div class=\"$toc_item_id-tripal-data-block-title tripal-data-block-title\">$toc_item_title</div>
               $markup
-              $path 
+              $path
             </div>
           </div>
         ";
-        
+
         $build[$key]['#markup'] = $updated_markup;
         $build[$key]['#weight'] = $weight;
       }
     }
   }
-  
+
   //-----------------------
   // BUILD THE TABLE OF CONTENTS LINKS
   //-----------------------
@@ -701,10 +719,10 @@ function tripal_core_node_view_alter(&$build) {
  * @ingroup tripal_core
  */
 function tripal_core_node_view($node, $view_mode, $langcode) {
-  
+
   // if this node type is a chado-based node (i.e. Tripal node)
   // the we want to add a table of contents to it's content list
-  // this table of contents will be an empty 
+  // this table of contents will be an empty
   if (preg_match('/^chado_/', $node->type)) {
     // Show feature browser and counts
     if ($view_mode == 'full') {

Some files were not shown because too many files changed in this diff