tripal_natural_diversity.install 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * @file
  4. * Implements hooks from the Schema API
  5. */
  6. /**
  7. * Implementation of hook_install().
  8. */
  9. function tripal_natural_diversity_install() {
  10. // create the module's data directory
  11. tripal_create_moddir('tripal_natural_diversity');
  12. // add cvterms
  13. tripal_natural_diversity_add_cvterms();
  14. // add chado_nd_geolocation table
  15. if (!db_table_exists('chado_nd_geolocation')) {
  16. drupal_install_schema('tripal_natural_diversity_nd_geolocation');
  17. }
  18. }
  19. /**
  20. * Update for Drupal 6.x, Tripal 1.1, Natural Diversity Module 1.1
  21. * This update adds new cvterms for experiment types
  22. *
  23. */
  24. function tripal_natural_diversity_update_6100() {
  25. // add cvterms
  26. tripal_natural_diversity_add_cvterms();
  27. $ret = array(
  28. '#finished' => 1,
  29. );
  30. return $ret;
  31. }
  32. /*
  33. *
  34. */
  35. function tripal_natural_diversity_add_cvterms(){
  36. // add cvterms for the nd_experiment_types
  37. tripal_cv_add_cvterm(array('name' => 'Genotyping','def' => 'An experiment where genotypes of individuals are identified.'),
  38. 'nd_experiment_types', 0, 1, 'tripal');
  39. tripal_cv_add_cvterm(array('name' => 'Phenotyping','def' => 'An experiment where phenotypes of individuals are identified.'),
  40. 'nd_experiment_types', 0, 1, 'tripal');
  41. tripal_cv_add_cvterm(array('name' => 'Location','def' => 'The name of the location.'),
  42. 'nd_geolocation_property', 0, 1, 'tripal');
  43. }
  44. /**
  45. * Implementation of hook_uninstall().
  46. */
  47. function tripal_natural_diversity_uninstall() {
  48. }
  49. /**
  50. * Implementation of hook_requirements().
  51. */
  52. function tripal_natural_diversity_requirements($phase) {
  53. $requirements = array();
  54. if ($phase == 'install') {
  55. // make sure chado is installed
  56. if (!tripal_core_is_chado_installed()) {
  57. $requirements ['tripal_natural_diversity'] = array(
  58. 'title' => "tripal_natural_diversity",
  59. 'value' => "ERROR: Chado most be installed before this module can be enabled",
  60. 'severity' => REQUIREMENT_ERROR,
  61. );
  62. }
  63. }
  64. return $requirements;
  65. }
  66. /**
  67. * Update for Drupal 6.x, Tripal 1.1, Natural Diversity Module 1.1
  68. * This update adds new chado_nd_geolocation table
  69. *
  70. */
  71. function tripal_natural_diversity_update_6101() {
  72. // add chado_nd_geolocation table
  73. drupal_install_schema('tripal_natural_diversity_nd_geolocation');
  74. $ret = array(
  75. '#finished' => 1,
  76. );
  77. return $ret;
  78. }
  79. /**
  80. * Implementation of hook_schema().
  81. */
  82. function tripal_natural_diversity_nd_geolocation_schema() {
  83. $schema['chado_nd_geolocation'] = array(
  84. 'fields' => array(
  85. 'nid' => array(
  86. 'type' => 'int',
  87. 'unsigned' => TRUE,
  88. 'not null' => TRUE,
  89. ),
  90. 'vid' => array(
  91. 'type' => 'int',
  92. 'not null' => TRUE,
  93. ),
  94. 'nd_geolocation_id' => array(
  95. 'type' => 'int',
  96. 'unsigned' => TRUE,
  97. 'not null' => TRUE,
  98. ),
  99. ),
  100. 'primary key' => array('nid', 'vid', 'nd_geolocation_id'),
  101. );
  102. return $schema;
  103. }