123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817 |
- <?php
- //
- // APPLICATION PROGRAMMER INTERFACE
- //
- // Generic Chado API functions
- require_once "api/tripal_chado.api.inc";
- require_once 'api/tripal_chado.property.api.inc';
- require_once 'api/tripal_chado.query.api.inc';
- require_once 'api/tripal_chado.variables.api.inc';
- require_once 'api/tripal_chado.schema.api.inc';
- require_once 'api/tripal_chado.custom_tables.api.inc';
- require_once 'api/tripal_chado.mviews.api.inc';
- require_once 'api/tripal_chado.schema_v1.3.api.inc';
- require_once 'api/tripal_chado.schema_v1.2.api.inc';
- require_once 'api/tripal_chado.schema_v1.11.api.inc';
- require_once 'api/tripal_chado.semweb.api.inc';
- require_once 'api/tripal_chado.views.api.inc';
- // Chado module specific API functions
- require_once 'api/modules/tripal_chado.analysis.api.inc';
- require_once 'api/modules/tripal_chado.contact.api.inc';
- require_once 'api/modules/tripal_chado.cv.api.inc';
- require_once 'api/modules/tripal_chado.db.api.inc';
- require_once 'api/modules/tripal_chado.feature.api.inc';
- require_once 'api/modules/tripal_chado.organism.api.inc';
- require_once 'api/modules/tripal_chado.pub.api.inc';
- require_once 'api/modules/tripal_chado.stock.api.inc';
- //
- // REQUIRED INCLUDE FILES
- //
- // These require files implement hooks and therefore must
- // ways be included when the module is interpreted.
- require_once "includes/tripal_chado.entity.inc";
- require_once "includes/tripal_chado.schema.inc";
- require_once "includes/tripal_chado.vocab_storage.inc";
- require_once "includes/tripal_chado.field_storage.inc";
- require_once "includes/tripal_chado.bundle.inc";
- require_once "includes/tripal_chado.fields.inc";
- require_once "includes/tripal_chado.mapping.inc";
- require_once "includes/TripalFields/ChadoField.inc";
- require_once "includes/TripalFields/ChadoFieldWidget.inc";
- require_once "includes/TripalFields/ChadoFieldFormatter.inc";
- tripal_chado_set_globals();
- /**
- * This function is used to set the global Chado variables
- *
- * @ingroup tripal_chado
- */
- function tripal_chado_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"] = chado_is_installed();
- if ($GLOBALS["chado_is_installed"]) {
- $GLOBALS["chado_is_local"] = chado_is_local();
- $GLOBALS["chado_version"] = chado_get_version();
- $GLOBALS["exact_chado_version"] = chado_get_version(TRUE);
- }
- }
- /**
- * Implements hook_init().
- * Used to set the search_path, create default content and set default variables.
- *
- * @ingroup tripal_chado
- */
- function tripal_chado_init() {
- if (user_access('administer tripal')) {
- if ($GLOBALS["chado_is_installed"]) {
- // Check to see if the Chado and Drupal have been prepared
- if (!variable_get('tripal_chado_is_prepared', FALSE)) {
- drupal_set_message('Chado is installed but Tripal has not yet prepared Drupal and Chado. Please ' .
- l('prepare both Drupal and Chado', 'admin/tripal/storage/chado/prepare') .
- ' before continuing.', 'warning');
- }
- }
- else {
- drupal_set_message('Tripal cannot find a Chado installation. Please ' .
- l('install Chado', 'admin/tripal/storage/chado/chado_install') .
- ' before continuing.', 'warning');
- }
- }
- }
- /**
- * Implements hook_views_api().
- *
- * Essentially this hook tells drupal that there is views support for
- * for this module which then includes tripal_db.views.inc where all the
- * views integration code is
- *
- * @ingroup tripal_feature
- */
- function tripal_chado_views_api() {
- return array(
- 'api' => 3.0,
- );
- }
- /**
- * Implements hook_menu().
- */
- function tripal_chado_menu() {
- $items = array();
- //////////////////////////////////////////////////////////////////////////////
- // Chado Storage Backend
- //////////////////////////////////////////////////////////////////////////////
- $items['admin/tripal/storage/chado'] = array(
- 'title' => 'Chado',
- 'description' => t("Integrates Chado with Tripal and includes tools to
- load data, and extend the chado schema through custom tables &
- materialized views."),
- 'weight' => -100,
- 'access arguments' => array('administer tripal'),
- );
- $items['admin/tripal/storage/chado/install'] = array(
- 'title' => 'Install Chado',
- 'description' => t('Installs the Chado database tables, views, etc., inside the current Drupal database'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_chado_load_form'),
- 'type' => MENU_NORMAL_ITEM,
- 'access arguments' => array('install chado'),
- 'file' => 'includes/tripal_chado.install.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'weight' => -100
- );
- $items['admin/tripal/storage/chado/prepare'] = array(
- 'title' => 'Prepare Chado',
- 'description' => t('Prepares Drupal to use Chado.'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_chado_prepare_form'),
- 'type' => MENU_NORMAL_ITEM,
- 'access arguments' => array('install chado'),
- 'file' => 'includes/tripal_chado.setup.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'weight' => -99
- );
- $items['admin/tripal/storage/chado/publish'] = array(
- 'title' => 'Publish',
- 'description' => t('Publish data that is present in Chado but which does
- not yet have a page on this site for viewing. In Tripal v2.0 or
- earlier this was refered to as "syncing".'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_chado_publish_form'),
- 'type' => MENU_NORMAL_ITEM,
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.publish.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'weight' => -99
- );
- // Adds a +Publish Chado Content link on the 'Tripal Content Types' page.
- $items['admin/structure/bio_data/publish'] = array(
- 'title' => 'Publish Chado Content',
- 'description' => t('Publish data that is present in Chado but which does
- not yet have a page on this site for viewing. In Tripal v2.0 or
- earlier this was refered to as "syncing".'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_chado_publish_form'),
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.publish.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_LOCAL_ACTION,
- 'weight' => 2
- );
- //////////////////////////////////////////////////////////////////////////////
- // Materialized Views
- //////////////////////////////////////////////////////////////////////////////
- $items['admin/tripal/storage/chado/mviews'] = array(
- 'title' => 'Materialized Views',
- 'description' => t('Materialized views are used to improve speed of large or complex queries.'),
- 'page callback' => 'tripal_mview_admin_view',
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'includes/tripal_chado.mviews.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'weight' => -10
- );
- $items['admin/tripal/storage/chado/mviews/help'] = array(
- 'title' => 'Help',
- 'description' => t('Help for the materialized views management system'),
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_mviews_help'),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'includes/tripal_chado.mviews.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'weight' => 10
- );
- $items['admin/tripal/storage/chado/mviews/report/%'] = array(
- 'title' => 'Materialized View',
- 'description' => t('Materialized views are used to improve speed of large or complex queries. These are database views as compared to Drupal views.'),
- 'page callback' => 'tripal_mview_report',
- 'page arguments' => array(6),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'includes/tripal_chado.mviews.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/mviews/new'] = array(
- 'title' => 'Create Materialized View',
- 'description' => t('Create a new materialized view.'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_mviews_form'),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'includes/tripal_chado.mviews.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/mviews/edit/%'] = array(
- 'title' => 'Edit Materialized View',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_mviews_form', 6),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'includes/tripal_chado.mviews.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/mviews/update/%'] = array(
- 'title' => 'Create Materialized View',
- 'description' => t('Materialized views are used to improve speed of large or complex queries.'),
- 'page callback' => 'tripal_mviews_add_populate_job',
- 'page arguments' => array(6),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'includes/tripal_chado.mviews.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/mviews/delete/%'] = array(
- 'title' => 'Create Materialized View',
- 'description' => t('Materialized views are used to improve speed of large or complex queries.'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_mviews_delete_form', 5),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'includes/tripal_chado.mviews.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- // TODO: complete the code for exporting and importing of MViews.
- // Need to address security issues of sharing SQL.
- $items['admin/tripal/storage/chado/mviews/import'] = array(
- 'title' => 'Import MView',
- 'description' => 'Import a materialized view from another Tripal instance.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_mviews_import_form'),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'includes/tripal_chado.mviews.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/mviews/%tblid/export'] = array(
- 'title' => 'Export MView',
- 'description' => 'Export a materialized view for use by another Tripal instance.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_mviews_export_form', 5),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'includes/tripal_chado.mviews.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- //////////////////////////////////////////////////////////////////////////////
- // Custom Tables
- //////////////////////////////////////////////////////////////////////////////
- $items['admin/tripal/storage/chado/custom_tables'] = array(
- 'title' => 'Custom Tables',
- 'description' => t('Creation of custom tables that are added to Chado database.'),
- 'page callback' => 'tripal_custom_table_admin_view',
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'includes/tripal_chado.custom_tables.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'weight' => -10
- );
- $items['admin/tripal/storage/chado/custom_tables/help'] = array(
- 'title' => 'Help',
- 'description' => t('Help for the tripal job management system'),
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_job_help'),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'includes/tripal_chado.custom_tables.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'weight' => 10
- );
- $items['admin/tripal/storage/chado/custom_tables/view/%'] = array(
- 'title' => 'Custom Tables',
- 'description' => t('Custom tables are added to Chado.'),
- 'page callback' => 'tripal_custom_table_view',
- 'page arguments' => array(6),
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.custom_tables.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/storage/chado/custom_tables/new'] = array(
- 'title' => 'Create Custom Table',
- 'description' => t('An interface for creating your own custom tables.'),
- 'page callback' => 'tripal_custom_table_new_page',
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.custom_tables.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/storage/chado/custom_tables/edit/%'] = array(
- 'title' => 'Edit Custom Table',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_custom_tables_form', 6),
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.custom_tables.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/storage/chado/custom_tables/delete/%'] = array(
- 'title' => 'Create Custom Table',
- 'description' => t('Custom tables are added to Chado.'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_custom_tables_delete_form', 6),
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.custom_tables.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/storage/chado/custom_tables/views/tables/enable'] = array(
- 'title' => 'Enable Custom Tables Administrative View',
- 'page callback' => 'tripal_enable_view',
- 'page arguments' => array('tripal_admin_custom_table', 'admin/tripal/storage/chado/custom_tables'),
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.custom_tables.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_CALLBACK,
- );
- //////////////////////////////////////////////////////////////////////////////
- // Data Loaders
- //////////////////////////////////////////////////////////////////////////////
- $items['admin/tripal/storage/chado/loaders'] = array(
- 'title' => 'Data Loaders',
- 'description' => t('Tools facilitating data import.'),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => 6
- );
- $items['admin/tripal/storage/chado/loaders/fasta_loader'] = array(
- 'title' => 'FASTA file Loader',
- 'description' => 'Load sequences from a multi-FASTA file into Chado',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_feature_fasta_load_form'),
- 'access arguments' => array('administer tripal feature'),
- 'file' => 'includes/loaders/tripal_chado.fasta_loader.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/storage/chado/loaders/gff3_load'] = array(
- 'title' => 'GFF3 file Loader',
- 'description' => 'Import a GFF3 file into Chado',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_feature_gff3_load_form'),
- 'access arguments' => array('administer tripal feature'),
- 'file' => 'includes/loaders/tripal_chado.gff_loader.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/storage/chado/loaders/pub'] = array(
- 'title' => t('Publication Importers'),
- 'description' => t('Create and modify importers that can connect to and retreive publications from remote databases.'),
- 'page callback' => 'tripal_pub_importers_list',
- 'access arguments' => array('administer tripal pub'),
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => 0
- );
- $items['admin/tripal/storage/chado/loaders/pub/new'] = array(
- 'title' => t('Add an Importer'),
- 'description' => t('Add a new publication importer.'),
- 'page callback' => 'tripal_pub_importer_setup_page',
- 'access arguments' => array('administer tripal pub'),
- 'type ' => MENU_CALLBACK,
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/loaders/pub/edit/%'] = array(
- 'page callback' => 'tripal_pub_importer_setup_page',
- 'page arguments' => array(6, 7),
- 'access arguments' => array('administer tripal pub'),
- 'type ' => MENU_CALLBACK,
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/loaders/pub/raw/%'] = array(
- 'title' => t('Raw Data From Publication Import'),
- 'page callback' => 'tripal_get_remote_pub_raw_page',
- 'page arguments' => array(6),
- 'access arguments' => array('administer tripal pub'),
- 'type ' => MENU_CALLBACK,
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- // add a second link for the importer on the data loaders page
- $items['admin/tripal/storage/chado/loaders/pub/import'] = array(
- 'title' => t('Publication Importers'),
- 'page callback' => 'tripal_pub_importers_list',
- 'access arguments' => array('administer tripal pub'),
- 'type' => MENU_CALLBACK,
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/loaders/pub/submit/%'] = array(
- 'page callback' => 'tripal_pub_importer_submit_job',
- 'page arguments' => array(7),
- 'access arguments' => array('administer tripal pub'),
- 'type ' => MENU_CALLBACK,
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/loaders/pub/delete/%'] = array(
- 'page callback' => 'tripal_pub_importer_delete',
- 'page arguments' => array(7),
- 'access arguments' => array('administer tripal pub'),
- 'type ' => MENU_CALLBACK,
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/loaders/pub/changedb'] = array(
- 'page callback' => 'tripal_pub_importer_setup_page_update_remotedb',
- 'page arguments' => array(),
- 'access arguments' => array('administer tripal pub'),
- 'type ' => MENU_CALLBACK,
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/loaders/pub/criteria/%/%'] = array(
- 'page callback' => 'tripal_pub_importer_setup_page_update_criteria',
- 'page arguments' => array(7, 8),
- 'access arguments' => array('administer tripal pub'),
- 'type ' => MENU_CALLBACK,
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- //////////////////////////////////////////////////////////////////////////////
- // Migrate Content
- //////////////////////////////////////////////////////////////////////////////
- $items['admin/tripal/storage/chado/migrate'] = array(
- 'title' => 'Migrate',
- 'description' => t('Migrate Tripal v2 content to Tripal v3'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_chado_migrate_form'),
- 'type' => MENU_NORMAL_ITEM,
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.migrate.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'weight' => 10
- );
- //////////////////////////////////////////////////////////////////////////////
- // Semantic Web Settings
- //////////////////////////////////////////////////////////////////////////////
- $items['admin/tripal/storage/chado/semweb'] = array(
- 'title' => 'Semantic Web',
- 'description' => t('Semantic web settings. Set terms used for the web services.'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_chado_semweb_form'),
- 'type' => MENU_NORMAL_ITEM,
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.semweb.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'weight' => 10
- );
- $items['admin/tripal/storage/chado/semweb/edit/%/%'] = array(
- 'title' => 'Edit Semantic Web Term',
- 'description' => t('Edit terms used for the web services.'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_chado_semweb_edit_form', 6, 7),
- 'type' => MENU_CALLBACK,
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.semweb.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- $items['admin/tripal/storage/chado/semweb/reset/%/%'] = array(
- 'title' => 'Reset Semantic Web Term',
- 'description' => t('Edit terms used for the web services.'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_chado_semweb_reset_form', 6, 7),
- 'type' => MENU_CALLBACK,
- 'access arguments' => array('administer tripal'),
- 'file' => 'includes/tripal_chado.semweb.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- );
- //////////////////////////////////////////////////////////////////////////////
- // Auto Completes
- //////////////////////////////////////////////////////////////////////////////
- $items['admin/tripal/storage/chado/auto_name/dbxref/%/%'] = array(
- 'page callback' => 'tripal_autocomplete_dbxref',
- 'page arguments' => array(6, 7),
- 'access arguments' => array('access content'),
- 'file' => 'api/modules/tripal_chado.db.api.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/storage/chado/auto_name/cvterm/%/%'] = array(
- 'page callback' => 'tripal_autocomplete_cvterm',
- 'page arguments' => array(6, 7),
- 'access arguments' => array('access content'),
- 'file' => 'api/modules/tripal_chado.db.api.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/storage/chado/auto_name/pub/%'] = array(
- 'page callback' => 'tripal_autocomplete_pub',
- 'page arguments' => array(6),
- 'access arguments' => array('access content'),
- 'file' => 'api/modules/tripal_chado.pub.api.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/storage/chado/auto_name/contact/%'] = array(
- 'page callback' => 'tripal_autocomplete_contact',
- 'page arguments' => array(6),
- 'access arguments' => array('access content'),
- 'file' => 'api/modules/tripal_chado.contact.api.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/storage/chado/auto_name/feature/%'] = array(
- 'page callback' => 'tripal_autocomplete_feature',
- 'page arguments' => array(6),
- 'access arguments' => array('access content'),
- 'file' => 'api/modules/tripal_chado.feature.api.inc',
- 'file path' => drupal_get_path('module', 'tripal_chado'),
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
- /**
- * Implements hook_permission().
- *
- * Set the permission types that the chado module uses. Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- *
- * @ingroup tripal
- */
- function tripal_chado_permission() {
- return array(
- 'install chado' => array(
- 'title' => t('Install Chado'),
- 'description' => t('Allow the user to install or upgrade a Chado database in the existing Drupal database.')
- ),
- 'view chado_ids' => array(
- 'title' => t('View Internal IDs'),
- 'description' => t('On content pages Tripal will typically provide
- a table of information pulled from the Chado database but the
- primary key IDs for that data is typically not shown. The
- default Tripal templates can show the primary key ID inside of a
- blue shaded table row if this permission is enabled. This can
- be useful for site developers who might want these IDs when working
- with the underlying database.'),
- 'restrict access' => TRUE,
- )
- );
- }
- /**
- * Implements hook_theme().
- */
- function tripal_chado_theme($existing, $type, $theme, $path) {
- $themes = array(
- // Theme fields.
- 'data__accession_widget' => array(
- 'render element' => 'element',
- 'file' => 'includes/TripalFields/data__accession/data__accession_widget.inc',
- ),
- 'sbo__database_cross_reference_widget' => array(
- 'render element' => 'element',
- 'file' => 'includes/TripalFields/sbo__database_cross_reference/sbo__database_cross_reference_widget.inc',
- ),
- // 'chado_linker__cvterm_widget' => array(
- // 'render element' => 'element',
- // 'file' => 'includes/TripalFields/chado_linker__cvterm.inc',
- // ),
- 'schema__alternate_name_widget' => array(
- 'render element' => 'element',
- 'file' => 'includes/TripalFields/schema__alternate_name/schema__alternate_name_widget.inc',
- ),
- // 'chado_linker__relationship_widget' => array(
- // 'render element' => 'element',
- // 'file' => 'includes/TripalFields/chado_linker__relationship.inc',
- // ),
- // 'chado_linker__relationship_instance_settings' => array(
- // 'render element' => 'element',
- // 'file' => 'includes/TripalFields/chado_linker__relationship.inc',
- // ),
- // 'chado_linker__pub_widget' => array(
- // 'render element' => 'element',
- // 'file' => 'includes/TripalFields/chado_linker__pub.inc',
- // ),
- // 'chado_linker__contact_widget' => array(
- // 'render element' => 'element',
- // 'file' => 'includes/TripalFields/chado_linker__contact.inc',
- // ),
- // 'chado_linker__prop_adder_widget' => array(
- // 'render element' => 'element',
- // 'file' => 'includes/TripalFields/chado_linker__prop_adder.inc',
- // ),
- 'tripal_chado_date_combo' => array(
- 'render element' => 'element',
- 'file' => 'theme/tripal_chado.theme.inc',
- ),
- // Themed forms
- 'tripal_pub_importer_setup_form_elements' => array(
- 'render element' => 'form',
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- ),
- 'tripal_pub_search_setup_form_elements' => array(
- 'render element' => 'form',
- 'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
- ),
- );
- // Override the theme for each entity to use the legacy modules
- // templates.
- if (module_exists('tripal_core')) {
- $core_path = drupal_get_path('module', 'tripal_core');
- // Get the list of node types that have legacy templates.
- $enabled_templates = variable_get('tripal_chado_enabled_legacy_templates', array());
- // Get the list of TripalEntity bundle.
- $bundles = db_select('tripal_bundle', 'tb')
- ->fields('tb')
- ->execute();
- // Iterate through all of the TripalEntity bundles and see which ones
- // map to tables that used had Tripal v2 nodes. For those, if the
- // legacy support is turned on then we want to use the legacy template.
- while ($bundle = $bundles->fetchObject()) {
- $term = tripal_load_term_entity(array('term_id' => $bundle->term_id));
- $vocab = $term->vocab;
- $params = array(
- 'vocabulary' => $vocab->vocabulary,
- 'accession' => $term->accession,
- );
- $mapped_table = chado_get_cvterm_mapping($params);
- $chado_table = $mapped_table->chado_table;
- $legacy_template = 'legacy_template--chado_' . $chado_table;
- if (key_exists($legacy_template, $enabled_templates) && $enabled_templates[$legacy_template]) {
- $themes['TripalEntity__' . $bundle->name] = array(
- 'template' => 'node--chado-generic',
- 'render element' => 'entity',
- 'base hook' => 'entity',
- 'path' => "$core_path/theme/templates",
- );
- }
- }
- }
- return $themes;
- }
- /**
- * Implements hook_preprocess().
- *
- * This function is used to support legacy Tripal v2 templates
- * for use with Tripal v3 entities.
- */
- function tripal_chado_preprocess(&$variables, $hook) {
- if ($hook == 'entity' and array_key_exists('TripalEntity', $variables)) {
- // The node--chado-generic template expets there to be a
- // teaser and node variables. So, we'll add them.
- $variables['teaser'] = FALSE;
- $variables['node'] = $variables['TripalEntity'];
- }
- }
- /**
- * 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 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 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 also watchdog entries of type
- * tripal stating the exact criteria evaluated. Criteria can
- * contain the following tokens:
- * - <field_name>
- * Replaced by the name of the field to be excluded
- * - <field_value>
- * Replaced by the value of the field in the current record
- * Also keep in mind that if your criteria doesn't contain the
- * >field_value< token then it will be evaluated before the query is
- * executed and if the field is excluded it won't be included in the
- * query.
- *
- * @return
- * An array of type => criteria where the type is excluded if the criteria
- * evaluates to TRUE
- *
- * @ingroup tripal
- */
- function tripal_chado_exclude_type_by_default() {
- return array('text' => 'strlen("<field_value> ") > 250');
- }
- /**
- * Implements hook_job_describe_args().
- *
- * Describes the arguements for the tripal_populate_mview job to allow for
- * greater readability in the jobs details pages.
- *
- * @param $callback
- * The callback of the current tripal job (this is the function that will be
- * executed when tripal_launch_jobs.php is run.
- * @param $args
- * An array of arguments passed in when the job was registered.
- *
- * @return
- * A more readable $args array
- *
- * @ingroup tripal
- */
- function tripal_chado_job_describe_args($callback, $args) {
- $new_args = array();
- if ($callback == 'tripal_populate_mview') {
- // get this mview details
- $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id ";
- $results = db_query($sql, array(':mview_id' => $args[0]));
- $mview = $results->fetchObject();
- $new_args['View Name'] = $mview->name;
- }
- elseif ($callback == 'tripal_install_chado') {
- $new_args['Action'] = $args[0];
- }
- return $new_args;
- }
- /**
- * Remove the nid from chado_entity if it exists when the node is deleted
- */
- function tripal_chado_node_delete($node) {
- $nid = $node->nid;
- $sql = "UPDATE chado_entity SET nid = NULL WHERE nid = :nid";
- db_query($sql, array('nid' => $nid));
- }
- /**
- *
- * Implements hook_form_FORM_ID_alter().
- *
- * The field_ui_field_edit_form is used for customizing the settings of
- * a field attached to an entity.
- *
- * This alter function disables some of the form widgets when the storage
- * backend indicates they are not appropriate.
- */
- function tripal_chado_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
- // For entity fields added by Tripal Entities we don't want the
- // the end-user to change the cardinality and the required fields
- // such that record can't be saved in Chado.
- // TODO: we shouldn't check for specific field types here
- // (e.g. chaod_linker_prop). That should be done via the TripalField
- // functions.
- if ($form['#instance']['entity_type'] == 'TripalEntity') {
- if ($form['#field']['storage']['type'] == 'field_chado_storage' and
- $form['#field']['type'] != 'chado_linker__prop') {
- $form['field']['cardinality']['#access'] = FALSE;
- $form['instance']['required']['#access'] = FALSE;
- }
- }
- // TODO: don't the the maximum length be larger than the field size.
- }
- /**
- * Implements hook_form_alter().
- */
- function tripal_chado_form_alter(&$form, $form_state, $form_id) {
- // If this is the field_ui_field_edit_form (i.e. the form that appears
- // when editing a field that is attached to an entity). Then we want
- // to add term settings for any field attached to a TripalEntity
- // content type.
- if ($form_id == 'field_ui_field_edit_form' and $form['#instance']['entity_type'] == 'TripalEntity') {
- tripal_chado_field_instance_settings_form_alter($form, $form_state);
- }
- }
|