|
@@ -12,10 +12,10 @@
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_disable() {
|
|
function tripal_example_disable() {
|
|
-
|
|
|
|
|
|
+
|
|
// EXPLANATION: If you are using Drupal Views you want to ensure
|
|
// EXPLANATION: If you are using Drupal Views you want to ensure
|
|
// that any default views that your module provides are disabled
|
|
// that any default views that your module provides are disabled
|
|
- // when the module is disabled. Default views are specified in the
|
|
|
|
|
|
+ // when the module is disabled. Default views are specified in the
|
|
// [module name].views.default.inc file. The following code will disable
|
|
// [module name].views.default.inc file. The following code will disable
|
|
// these views. If your module does not create any default views you
|
|
// these views. If your module does not create any default views you
|
|
// can remove the following code.
|
|
// can remove the following code.
|
|
@@ -24,30 +24,30 @@ function tripal_example_disable() {
|
|
require_once("tripal_example.views_default.inc");
|
|
require_once("tripal_example.views_default.inc");
|
|
$views = tripal_example_views_default_views();
|
|
$views = tripal_example_views_default_views();
|
|
foreach (array_keys($views) as $view_name) {
|
|
foreach (array_keys($views) as $view_name) {
|
|
- tripal_views_admin_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
|
|
|
|
|
|
+ tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Implements hook_requirements().
|
|
* Implements hook_requirements().
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Performs check to see if all required dependencies are met. Drupal will
|
|
* Performs check to see if all required dependencies are met. Drupal will
|
|
- * automatically check for module dependencies but here you can check for
|
|
|
|
- * other requirements.
|
|
|
|
|
|
+ * automatically check for module dependencies but here you can check for
|
|
|
|
+ * other requirements.
|
|
*
|
|
*
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_requirements($phase) {
|
|
function tripal_example_requirements($phase) {
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
$requirements = array();
|
|
$requirements = array();
|
|
if ($phase == 'install') {
|
|
if ($phase == 'install') {
|
|
// EXPLANATION: It is essential that Chado be installed for almost all
|
|
// EXPLANATION: It is essential that Chado be installed for almost all
|
|
// Tripal modules. Therefore, the following code checks to ensure Chado
|
|
// Tripal modules. Therefore, the following code checks to ensure Chado
|
|
// is installed and available. If your module does not require that
|
|
// is installed and available. If your module does not require that
|
|
// Chado be installed, you can remove the following check.
|
|
// Chado be installed, you can remove the following check.
|
|
-
|
|
|
|
|
|
+
|
|
// make sure chado is installed
|
|
// make sure chado is installed
|
|
if (!$GLOBALS["chado_is_installed"]) {
|
|
if (!$GLOBALS["chado_is_installed"]) {
|
|
$requirements ['tripal_example'] = array(
|
|
$requirements ['tripal_example'] = array(
|
|
@@ -62,57 +62,57 @@ function tripal_example_requirements($phase) {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Implements hook_install().
|
|
* Implements hook_install().
|
|
- *
|
|
|
|
- * Performs actions when the modules is first installed.
|
|
|
|
|
|
+ *
|
|
|
|
+ * Performs actions when the modules is first installed.
|
|
*
|
|
*
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_install() {
|
|
function tripal_example_install() {
|
|
-
|
|
|
|
|
|
+
|
|
// EXPLANATION: If your module will making data publicly available for
|
|
// EXPLANATION: If your module will making data publicly available for
|
|
// download or use by the site you can create the directory using the
|
|
// download or use by the site you can create the directory using the
|
|
// tripal_create_files_dir() function. This will create a directory
|
|
// tripal_create_files_dir() function. This will create a directory
|
|
// in the public access directory which will typcially be in
|
|
// in the public access directory which will typcially be in
|
|
// sites/default/files/tripal/[module name]/
|
|
// sites/default/files/tripal/[module name]/
|
|
-
|
|
|
|
|
|
+
|
|
// create the module's data directory
|
|
// create the module's data directory
|
|
tripal_create_files_dir('tripal_example');
|
|
tripal_create_files_dir('tripal_example');
|
|
|
|
|
|
- // EXPLANATION: Here is a good place to add any materialized views,
|
|
|
|
|
|
+ // EXPLANATION: Here is a good place to add any materialized views,
|
|
// controlled vocabularies CV, databases or CV terms needed by your module.
|
|
// controlled vocabularies CV, databases or CV terms needed by your module.
|
|
// To keep this module code short, create functions to do each of those
|
|
// To keep this module code short, create functions to do each of those
|
|
// tasks
|
|
// tasks
|
|
-
|
|
|
|
|
|
+
|
|
// add any materialized view
|
|
// add any materialized view
|
|
tripal_example_add_mviews();
|
|
tripal_example_add_mviews();
|
|
|
|
|
|
// add any external databases used by the example module.
|
|
// add any external databases used by the example module.
|
|
tripal_example_add_dbs();
|
|
tripal_example_add_dbs();
|
|
-
|
|
|
|
|
|
+
|
|
// add any controlled vocabularies used by the example module. You may need
|
|
// add any controlled vocabularies used by the example module. You may need
|
|
// to add a vocabulary if you to set it as default (see next lines of code).
|
|
// to add a vocabulary if you to set it as default (see next lines of code).
|
|
// For example, the Sequence Ontology (SO) is used by the feature module as the
|
|
// For example, the Sequence Ontology (SO) is used by the feature module as the
|
|
// default vocabulary for the feature type_id field. But, that vocabulary
|
|
// default vocabulary for the feature type_id field. But, that vocabulary
|
|
- // does not yet exist in Chado until after the SO is loaded using the
|
|
|
|
|
|
+ // does not yet exist in Chado until after the SO is loaded using the
|
|
// Tripal OBO loader. But, we can add it here as a placeholder so that we can
|
|
// Tripal OBO loader. But, we can add it here as a placeholder so that we can
|
|
// then set it as a default vocabulary (see below).
|
|
// then set it as a default vocabulary (see below).
|
|
tripal_example_add_cvs();
|
|
tripal_example_add_cvs();
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
// add any controlled vocabulary terms
|
|
// add any controlled vocabulary terms
|
|
tripal_example_add_cvterms();
|
|
tripal_example_add_cvterms();
|
|
-
|
|
|
|
|
|
+
|
|
// EXPLANATION: Many tables in Chado have a 'type_id' column which allows for
|
|
// EXPLANATION: Many tables in Chado have a 'type_id' column which allows for
|
|
// association of controlled vocabulries to describe the record. Chado
|
|
// association of controlled vocabulries to describe the record. Chado
|
|
// places no restrictions on which vocabularies can be used, but Tripal can
|
|
// places no restrictions on which vocabularies can be used, but Tripal can
|
|
- // be instructed to provide a default vocabulary for any given field. For
|
|
|
|
|
|
+ // be instructed to provide a default vocabulary for any given field. For
|
|
// example, the feature.type_id column will typically use the Sequence Ontology
|
|
// example, the feature.type_id column will typically use the Sequence Ontology
|
|
// In that case, we can use the tripal_set_default_cv() function to specify
|
|
// In that case, we can use the tripal_set_default_cv() function to specify
|
|
- // the Sequence Ontology (sequence) as the default vocabulary.
|
|
|
|
|
|
+ // the Sequence Ontology (sequence) as the default vocabulary.
|
|
tripal_set_default_cv('example', 'type_id', 'example_type');
|
|
tripal_set_default_cv('example', 'type_id', 'example_type');
|
|
tripal_set_default_cv('exampleprop', 'type_id', 'example_property');
|
|
tripal_set_default_cv('exampleprop', 'type_id', 'example_property');
|
|
tripal_set_default_cv('example_relationship', 'type_id', 'example_relationship');
|
|
tripal_set_default_cv('example_relationship', 'type_id', 'example_relationship');
|
|
-
|
|
|
|
|
|
+
|
|
// add any custom tables. For this case we will add an 'example' table to the
|
|
// add any custom tables. For this case we will add an 'example' table to the
|
|
// chado schema
|
|
// chado schema
|
|
tripal_example_add_custom_tables();
|
|
tripal_example_add_custom_tables();
|
|
@@ -121,9 +121,9 @@ function tripal_example_install() {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Implements hook_uninstall().
|
|
* Implements hook_uninstall().
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Performs actions when the modules is uninstalled.
|
|
* Performs actions when the modules is uninstalled.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_uninstall() {
|
|
function tripal_example_uninstall() {
|
|
@@ -132,11 +132,11 @@ function tripal_example_uninstall() {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Implementation of hook_schema().
|
|
* Implementation of hook_schema().
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Provides a list of tables to be created inside of the Drupal schema
|
|
* Provides a list of tables to be created inside of the Drupal schema
|
|
* (the 'public' schema by default). It uses the Drupal Schema API
|
|
* (the 'public' schema by default). It uses the Drupal Schema API
|
|
* array structure to define the table, its indexes and constraints.
|
|
* array structure to define the table, its indexes and constraints.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Schema API documentation is here:
|
|
* Schema API documentation is here:
|
|
* https://api.drupal.org/api/drupal/includes%21database%21schema.inc/group/schemaapi/7
|
|
* https://api.drupal.org/api/drupal/includes%21database%21schema.inc/group/schemaapi/7
|
|
*
|
|
*
|
|
@@ -195,12 +195,12 @@ function tripal_example_schema() {
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_add_mviews() {
|
|
function tripal_example_add_mviews() {
|
|
-
|
|
|
|
|
|
+
|
|
// EXPLANATION: use the tripal_add_mview() function to add a materialized
|
|
// EXPLANATION: use the tripal_add_mview() function to add a materialized
|
|
// view needed by your module. If you have more than one materialized view
|
|
// view needed by your module. If you have more than one materialized view
|
|
// it is best to create a single function for each one and call each
|
|
// it is best to create a single function for each one and call each
|
|
// function here. Otherwise this function can become quite long.
|
|
// function here. Otherwise this function can become quite long.
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* Add cvs related to publications
|
|
* Add cvs related to publications
|
|
@@ -211,7 +211,7 @@ function tripal_example_add_dbs() {
|
|
// EXPLANATION: use the tripal_db_add_db() function to add any
|
|
// EXPLANATION: use the tripal_db_add_db() function to add any
|
|
// external databases needed by your module. If the database already
|
|
// external databases needed by your module. If the database already
|
|
// exists then the function will gracefully return.
|
|
// exists then the function will gracefully return.
|
|
-
|
|
|
|
|
|
+
|
|
tripal_db_add_db(
|
|
tripal_db_add_db(
|
|
'example_db',
|
|
'example_db',
|
|
'An example database.'
|
|
'An example database.'
|
|
@@ -224,26 +224,26 @@ function tripal_example_add_dbs() {
|
|
*/
|
|
*/
|
|
function tripal_example_add_cvs() {
|
|
function tripal_example_add_cvs() {
|
|
|
|
|
|
- // EXPLANATION: use the tripal_cv_add_cv() function to add any
|
|
|
|
|
|
+ // EXPLANATION: use the tripal_cv_add_cv() function to add any
|
|
// controlled vocabularies needed by your module. If the vocabulary already
|
|
// controlled vocabularies needed by your module. If the vocabulary already
|
|
// exists then the function will gracefully return. Chado convensions
|
|
// exists then the function will gracefully return. Chado convensions
|
|
// use a singluar name for CV names (not plural)/
|
|
// use a singluar name for CV names (not plural)/
|
|
-
|
|
|
|
|
|
+
|
|
tripal_cv_add_cv(
|
|
tripal_cv_add_cv(
|
|
'example_property',
|
|
'example_property',
|
|
'Contains property terms for examples.'
|
|
'Contains property terms for examples.'
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
tripal_cv_add_cv(
|
|
tripal_cv_add_cv(
|
|
'example_type',
|
|
'example_type',
|
|
'Contains terms describing types of examples.'
|
|
'Contains terms describing types of examples.'
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
tripal_cv_add_cv(
|
|
tripal_cv_add_cv(
|
|
'example_relationship',
|
|
'example_relationship',
|
|
'Contains terms for describing relationship types between examples.'
|
|
'Contains terms for describing relationship types between examples.'
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -252,7 +252,7 @@ function tripal_example_add_cvs() {
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_add_cvterms() {
|
|
function tripal_example_add_cvterms() {
|
|
-
|
|
|
|
|
|
+
|
|
// EXPLANATION: for our test module to work we need to add some terms to our example_type
|
|
// EXPLANATION: for our test module to work we need to add some terms to our example_type
|
|
// controlled vocabulary. Ideally we should have a full OBO file for loading
|
|
// controlled vocabulary. Ideally we should have a full OBO file for loading
|
|
// but sometimes we just have a small list that won't really change so
|
|
// but sometimes we just have a small list that won't really change so
|
|
@@ -268,11 +268,11 @@ function tripal_example_add_cvterms() {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Add custom tables to Chado that are required by this module
|
|
* Add custom tables to Chado that are required by this module
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_add_custom_tables() {
|
|
function tripal_example_add_custom_tables() {
|
|
-
|
|
|
|
|
|
+
|
|
// EXPLANATION: for this example module we will create a set of example tables
|
|
// EXPLANATION: for this example module we will create a set of example tables
|
|
// that mimic Chado tables. These tables are:
|
|
// that mimic Chado tables. These tables are:
|
|
//
|
|
//
|
|
@@ -281,9 +281,9 @@ function tripal_example_add_custom_tables() {
|
|
// 3) example_relationship (for storing relationships about examples)
|
|
// 3) example_relationship (for storing relationships about examples)
|
|
// 4) example_dbxref (for storing cross-references about an example)
|
|
// 4) example_dbxref (for storing cross-references about an example)
|
|
//
|
|
//
|
|
- // To make the code easier to read, each table is created by a separte
|
|
|
|
|
|
+ // To make the code easier to read, each table is created by a separte
|
|
// function called here:
|
|
// function called here:
|
|
-
|
|
|
|
|
|
+
|
|
tripal_example_add_example_table();
|
|
tripal_example_add_example_table();
|
|
tripal_example_add_exampleprop_table();
|
|
tripal_example_add_exampleprop_table();
|
|
tripal_example_add_example_relationship_table();
|
|
tripal_example_add_example_relationship_table();
|
|
@@ -291,7 +291,7 @@ function tripal_example_add_custom_tables() {
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* Adds the 'example' custom table to Chado.
|
|
* Adds the 'example' custom table to Chado.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_add_example_table() {
|
|
function tripal_example_add_example_table() {
|
|
@@ -354,7 +354,7 @@ function tripal_example_add_example_table() {
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// EXPLANATION: the 'referring_tables' array is the list of tables
|
|
// EXPLANATION: the 'referring_tables' array is the list of tables
|
|
- // that have a foreign key relationships with this table. This
|
|
|
|
|
|
+ // that have a foreign key relationships with this table. This
|
|
// information is required for the Tripal API to be able to expand
|
|
// information is required for the Tripal API to be able to expand
|
|
// tables in templates.
|
|
// tables in templates.
|
|
'referring_tables' => array(
|
|
'referring_tables' => array(
|
|
@@ -367,13 +367,13 @@ function tripal_example_add_example_table() {
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* Adds the 'example_relationship' custom table to Chado.
|
|
* Adds the 'example_relationship' custom table to Chado.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_add_exampleprop_table() {
|
|
function tripal_example_add_exampleprop_table() {
|
|
// EXPLANATION: use the Drupal Schema API to describe the custom table. Then
|
|
// EXPLANATION: use the Drupal Schema API to describe the custom table. Then
|
|
// add the table using the chado_create_custom_table() function.
|
|
// add the table using the chado_create_custom_table() function.
|
|
-
|
|
|
|
|
|
+
|
|
// Add the exampleprop table
|
|
// Add the exampleprop table
|
|
$schema = array(
|
|
$schema = array(
|
|
'table' => 'exampleprop',
|
|
'table' => 'exampleprop',
|
|
@@ -429,13 +429,13 @@ function tripal_example_add_exampleprop_table() {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Adds the 'example_relationship' custom table to Chado.
|
|
* Adds the 'example_relationship' custom table to Chado.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_add_example_relationship_table() {
|
|
function tripal_example_add_example_relationship_table() {
|
|
// EXPLANATION: use the Drupal Schema API to describe the custom table. Then
|
|
// EXPLANATION: use the Drupal Schema API to describe the custom table. Then
|
|
// add the table using the chado_create_custom_table() function.
|
|
// add the table using the chado_create_custom_table() function.
|
|
-
|
|
|
|
|
|
+
|
|
$schema = array(
|
|
$schema = array(
|
|
'table' => 'example_relationship',
|
|
'table' => 'example_relationship',
|
|
'fields' => array(
|
|
'fields' => array(
|
|
@@ -508,11 +508,11 @@ function tripal_example_add_example_relationship_table() {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Adds the 'example_dbxref' custom table to Chado.
|
|
* Adds the 'example_dbxref' custom table to Chado.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @ingroup tripal_example
|
|
* @ingroup tripal_example
|
|
*/
|
|
*/
|
|
function tripal_example_add_example_dbxref_table() {
|
|
function tripal_example_add_example_dbxref_table() {
|
|
-
|
|
|
|
|
|
+
|
|
// EXPLANATION: use the Drupal Schema API to describe the custom table. Then
|
|
// EXPLANATION: use the Drupal Schema API to describe the custom table. Then
|
|
// add the table using the chado_create_custom_table() function.
|
|
// add the table using the chado_create_custom_table() function.
|
|
|
|
|
|
@@ -576,14 +576,14 @@ function tripal_example_add_example_dbxref_table() {
|
|
* This is the required update for tripal_example.
|
|
* This is the required update for tripal_example.
|
|
*/
|
|
*/
|
|
function tripal_example_update_7200() {
|
|
function tripal_example_update_7200() {
|
|
- // EXPLANATION: as you create new releases of your module you may find that
|
|
|
|
- // tables your module created, or data may need to be adjusted. This function
|
|
|
|
- // allows you to do that. This function is executed using the
|
|
|
|
|
|
+ // EXPLANATION: as you create new releases of your module you may find that
|
|
|
|
+ // tables your module created, or data may need to be adjusted. This function
|
|
|
|
+ // allows you to do that. This function is executed using the
|
|
// http://[your site]/update.php URL or using the drush command 'updatedb'.
|
|
// http://[your site]/update.php URL or using the drush command 'updatedb'.
|
|
- // This function should be named according to the instructions provided here:
|
|
|
|
|
|
+ // This function should be named according to the instructions provided here:
|
|
// https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_update_N/7
|
|
// https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_update_N/7
|
|
//
|
|
//
|
|
- // It is best not to use Tripal API calls inside of this function because an
|
|
|
|
|
|
+ // It is best not to use Tripal API calls inside of this function because an
|
|
// upgarde from Drupal 6 to Drupal 7 requires that all modules be disabled
|
|
// upgarde from Drupal 6 to Drupal 7 requires that all modules be disabled
|
|
// which means the Tripal API is not available. This is an unfortunate
|
|
// which means the Tripal API is not available. This is an unfortunate
|
|
// requirement, but will prevent errors during a major upgrade.
|
|
// requirement, but will prevent errors during a major upgrade.
|
|
@@ -607,9 +607,9 @@ function tripal_example_update_dependencies() {
|
|
|
|
|
|
// EXPLANATION: here we can specify which modules must be updated prior
|
|
// EXPLANATION: here we can specify which modules must be updated prior
|
|
// to applying the updates in this module. This is useful because it
|
|
// to applying the updates in this module. This is useful because it
|
|
- // prevents updates from being executed out of order. The following
|
|
|
|
|
|
+ // prevents updates from being executed out of order. The following
|
|
// example code shows that the 'tripal_example' module update number 7200
|
|
// example code shows that the 'tripal_example' module update number 7200
|
|
- // must be executed after the 'tripal_cv' module's 7200 update.
|
|
|
|
|
|
+ // must be executed after the 'tripal_cv' module's 7200 update.
|
|
$dependencies['tripal_example'][7200] = array(
|
|
$dependencies['tripal_example'][7200] = array(
|
|
'tripal_cv' => 7200
|
|
'tripal_cv' => 7200
|
|
);
|
|
);
|