tripal_pub.install

  1. 2.x tripal_pub/tripal_pub.install
  2. 3.x legacy/tripal_pub/tripal_pub.install
  3. 1.x tripal_pub/tripal_pub.install

This file contains all the functions which describe and implement drupal database tables needed by this module. This module was developed by Chad N.A. Krilow and Lacey-Anne Sanderson, University of Saskatchewan.

The project manamgenet module allows you to sync data in a chado/Tripal instance with multiple project/mysql instances as well as manage and create such project instances

File

tripal_pub/tripal_pub.install
View source
  1. <?php
  2. /**
  3. * @file
  4. * This file contains all the functions which describe and implement drupal database tables
  5. * needed by this module. This module was developed by Chad N.A. Krilow and Lacey-Anne Sanderson,
  6. * University of Saskatchewan.
  7. *
  8. * The project manamgenet module allows you to sync data in a chado/Tripal instance with
  9. * multiple project/mysql instances as well as manage and create such project instances
  10. */
  11. /**
  12. * Implementation of hook_install().
  13. */
  14. function tripal_pub_install() {
  15. // create the module's data directory
  16. tripal_create_moddir('tripal_pub');
  17. // install the tripal_oub
  18. drupal_install_schema('tripal_pub');
  19. // add loading of the the tripal pub ontology to the job queue
  20. $obo_path = realpath('./') . '/' . drupal_get_path('module', 'tripal_pub') . '/files/tpub.obo';
  21. $obo_id = tripal_cv_add_obo_ref('Tripal Publication', $obo_path);
  22. tripal_cv_submit_obo_job($obo_id);
  23. // add the custom tables
  24. tripal_pub_add_custom_tables();
  25. }
  26. function tripal_pub_enable() {
  27. // make sure we have our supported databases
  28. tripal_db_add_db('PMID', 'PubMed', 'http://www.ncbi.nlm.nih.gov/pubmed', 'http://www.ncbi.nlm.nih.gov/pubmed/', TRUE);
  29. tripal_db_add_db('AGL', 'USDA National Agricultural Library', 'http://agricola.nal.usda.gov/', '', TRUE);
  30. variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));
  31. }
  32. /**
  33. * Implementation of hook_uninstall().
  34. */
  35. function tripal_pub_uninstall() {
  36. //Remove tables
  37. drupal_uninstall_schema('tripal_pub');
  38. }
  39. /**
  40. * Implementation of hook_schema().
  41. */
  42. function tripal_pub_schema() {
  43. $schema['chado_pub'] = array(
  44. 'fields' => array(
  45. 'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
  46. 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
  47. 'pub_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
  48. 'sync_date' => array('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer sync date/time'),
  49. ),
  50. 'indexes' => array(
  51. 'pub_id' => array('pub_id')
  52. ),
  53. 'unique keys' => array(
  54. 'nid_vid' => array('nid', 'vid'),
  55. 'vid' => array('vid')
  56. ),
  57. 'primary key' => array('nid'),
  58. );
  59. $schema['tripal_pub_import'] = array(
  60. 'fields' => array(
  61. 'pub_import_id' => array('type' => 'serial', 'not null' => TRUE),
  62. 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
  63. 'criteria' => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE, 'description' => 'Contains a serialized PHP array containing the search criteria'),
  64. 'disabled' => array('type' => 'int', 'unsigned' => TRUE, 'not NULL' => TRUE, 'default' => 0),
  65. 'do_contact' => array('type' => 'int', 'unsigned' => TRUE, 'not NULL' => TRUE, 'default' => 0),
  66. ),
  67. 'primary key' => array('pub_import_id'),
  68. 'indexes' => array(
  69. 'name' => array('name')
  70. ),
  71. );
  72. return $schema;
  73. }
  74. /**
  75. * Implementation of hook_requirements().
  76. */
  77. function tripal_pub_requirements($phase) {
  78. $requirements = array();
  79. if ($phase == 'install') {
  80. // make sure chado is installed
  81. if (!tripal_core_is_chado_installed()) {
  82. $requirements ['tripal_pub'] = array(
  83. 'title' => "tripal_pub",
  84. 'value' => "ERROR: Chado most be installed before this module can be enabled",
  85. 'severity' => REQUIREMENT_ERROR,
  86. );
  87. }
  88. }
  89. return $requirements;
  90. }
  91. /*
  92. *
  93. */
  94. function tripal_pub_add_custom_tables() {
  95. $schema = array (
  96. 'table' => 'pubauthor_contact',
  97. 'fields' => array (
  98. 'pubauthor_contact_id' => array (
  99. 'type' => 'serial',
  100. 'not null' => true,
  101. ),
  102. 'contact_id' => array (
  103. 'type' => 'int',
  104. 'not null' => true,
  105. ),
  106. 'pubauthor_id' => array (
  107. 'type' => 'int',
  108. 'not null' => true,
  109. ),
  110. ),
  111. 'primary key' => array (
  112. 0 => 'pubauthor_contact_id',
  113. ),
  114. 'unique keys' => array (
  115. 'pubauthor_contact_c1' => array (
  116. 0 => 'contact_id',
  117. 1 => 'pubauthor_id',
  118. ),
  119. ),
  120. 'foreign keys' => array (
  121. 'contact' => array (
  122. 'table' => 'contact',
  123. 'columns' => array (
  124. 'contact_id' => 'contact_id',
  125. ),
  126. ),
  127. 'pubauthor' => array (
  128. 'table' => 'pubauthor',
  129. 'columns' => array (
  130. 'pubauthor_id' => 'pubauthor_id',
  131. ),
  132. ),
  133. ),
  134. );
  135. tripal_core_create_custom_table($ret, 'pubauthor_contact', $schema, TRUE);
  136. }