nd_experiment.views.inc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /**
  3. * @file
  4. * This file defines the data array for a given chado table. This array
  5. * is merged into a larger array containing definitions of all tables associated
  6. * with this module in:
  7. * @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  8. *
  9. * Documentation on views integration can be found at
  10. * http://views2.logrus.com/doc/html/index.html.
  11. */
  12. /*************************************************************************
  13. * Purpose: this function returns the portion of the data array
  14. * which describes the nd_experiment table, it's fields and any joins between it and other tables
  15. * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  16. *
  17. * @todo Add relationship to nd_geolocations.views.inc
  18. *
  19. * Table: nd_experiment
  20. * @code
  21. CREATE TABLE nd_experiment (
  22. nd_experiment_id serial PRIMARY KEY NOT NULL,
  23. nd_geolocation_id integer NOT NULL references nd_geolocation (nd_geolocation_id) on delete cascade INITIALLY DEFERRED,
  24. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
  25. );
  26. * @endcode
  27. */
  28. function retrieve_nd_experiment_views_data() {
  29. global $db_url;
  30. $data = array();
  31. // if the chado database is not local to the drupal database
  32. // then we need to set the database name. This should always
  33. // be 'chado'.
  34. if(is_array($db_url) and array_key_exists('chado',$db_url)){
  35. $database = 'chado';
  36. }
  37. //Basic table definition-----------------------------------
  38. $data['nd_experiment']['table']['group'] = t('Chado ND Experiment');
  39. $data['nd_experiment']['table']['base'] = array(
  40. 'field' => 'nd_experiment_id',
  41. 'title' => t('Chado Natural Diversity Experiment'),
  42. 'help' => t('Represents one data point in a natural diversity project.'),
  43. );
  44. if($database){
  45. $data['nd_experiment']['table']['database'] = $database;
  46. }
  47. //Relationship Definitions---------------------------------
  48. //Join: nd_experiment => nd_geolocation
  49. // In nd_experiment.views.inc
  50. //Join: nd_experiment => nd_experiment_contact => contact
  51. $data['nd_experiment']['table']['join']['nd_experiment_contact'] = array(
  52. 'left_field' => 'nd_experiment_id',
  53. 'field' => 'nd_experiment_id',
  54. );
  55. $data['nd_experiment']['table']['join']['contact'] = array(
  56. 'left_table' => 'nd_experiment_contact',
  57. 'left_field' => 'nd_experiment_id',
  58. 'field' => 'nd_experiment_id',
  59. );
  60. $data['nd_experiment_contact']['table']['join']['contact'] = array(
  61. 'left_field' => 'contact_id',
  62. 'field' => 'contact_id',
  63. );
  64. //Join: nd_experiment => nd_experiment_dbxref => dbxref
  65. $data['nd_experiment']['table']['join']['nd_experiment_dbxref'] = array(
  66. 'left_field' => 'nd_experiment_id',
  67. 'field' => 'nd_experiment_id',
  68. );
  69. $data['nd_experiment']['table']['join']['dbxref'] = array(
  70. 'left_table' => 'nd_experiment_dbxref',
  71. 'left_field' => 'nd_experiment_id',
  72. 'field' => 'nd_experiment_id',
  73. );
  74. $data['nd_experiment_dbxref']['table']['join']['dbxref'] = array(
  75. 'left_field' => 'dbxref_id',
  76. 'field' => 'dbxref_id',
  77. );
  78. //Join: nd_experiment => nd_experiment_genotype => genotype
  79. $data['nd_experiment']['table']['join']['nd_experiment_genotype'] = array(
  80. 'left_field' => 'nd_experiment_id',
  81. 'field' => 'nd_experiment_id',
  82. );
  83. $data['nd_experiment']['table']['join']['genotype'] = array(
  84. 'left_table' => 'nd_experiment_genotype',
  85. 'left_field' => 'nd_experiment_id',
  86. 'field' => 'nd_experiment_id',
  87. );
  88. $data['nd_experiment_genotype']['table']['join']['genotype'] = array(
  89. 'left_field' => 'genotype_id',
  90. 'field' => 'genotype_id',
  91. );
  92. //Join: nd_experiment => nd_experiment_phenotype => phenotype
  93. $data['nd_experiment']['table']['join']['nd_experiment_phenotype'] = array(
  94. 'left_field' => 'nd_experiment_id',
  95. 'field' => 'nd_experiment_id',
  96. );
  97. $data['nd_experiment']['table']['join']['phenotype'] = array(
  98. 'left_table' => 'nd_experiment_phenotype',
  99. 'left_field' => 'nd_experiment_id',
  100. 'field' => 'nd_experiment_id',
  101. );
  102. $data['nd_experiment_phenotype']['table']['join']['phenotype'] = array(
  103. 'left_field' => 'phenotype_id',
  104. 'field' => 'phenotype_id',
  105. );
  106. //Join: nd_experiment => nd_experiment_project => project
  107. $data['nd_experiment']['table']['join']['nd_experiment_project'] = array(
  108. 'left_field' => 'nd_experiment_id',
  109. 'field' => 'nd_experiment_id',
  110. );
  111. $data['nd_experiment']['table']['join']['project'] = array(
  112. 'left_table' => 'nd_experiment_project',
  113. 'left_field' => 'nd_experiment_id',
  114. 'field' => 'nd_experiment_id',
  115. );
  116. $data['nd_experiment_project']['table']['join']['project'] = array(
  117. 'left_field' => 'project_id',
  118. 'field' => 'project_id',
  119. );
  120. //Join: nd_experiment => nd_experiment_pub => pub
  121. $data['nd_experiment']['table']['join']['nd_experiment_pub'] = array(
  122. 'left_field' => 'nd_experiment_id',
  123. 'field' => 'nd_experiment_id',
  124. );
  125. $data['nd_experiment']['table']['join']['pub'] = array(
  126. 'left_table' => 'nd_experiment_pub',
  127. 'left_field' => 'nd_experiment_id',
  128. 'field' => 'nd_experiment_id',
  129. );
  130. $data['nd_experiment_pub']['table']['join']['pub'] = array(
  131. 'left_field' => 'pub_id',
  132. 'field' => 'pub_id',
  133. );
  134. //Join: nd_experiment => nd_experiment_stock => YYY
  135. $data['nd_experiment']['table']['join']['nd_experiment_stock'] = array(
  136. 'left_field' => 'nd_experiment_id',
  137. 'field' => 'nd_experiment_id',
  138. );
  139. $data['nd_experiment']['table']['join']['stock'] = array(
  140. 'left_table' => 'nd_experiment_stock',
  141. 'left_field' => 'nd_experiment_id',
  142. 'field' => 'nd_experiment_id',
  143. );
  144. $data['nd_experiment_stock']['table']['join']['stock'] = array(
  145. 'left_field' => 'stock_id',
  146. 'field' => 'stock_id',
  147. );
  148. //Table Field Definitions----------------------------------
  149. //Field: nd_experiment_id (primary key)
  150. $data['nd_experiment']['nd_experiment_id'] = array(
  151. 'title' => t('ND Experiment Primary Key'),
  152. 'help' => t('A unique index for every nd_experiment.'),
  153. 'field' => array(
  154. 'handler' => 'views_handler_field_numeric',
  155. 'click sortable' => TRUE,
  156. ),
  157. 'sort' => array(
  158. 'handler' => 'views_handler_sort',
  159. ),
  160. 'filter' => array(
  161. 'handler' => 'views_handler_filter_numeric',
  162. ),
  163. );
  164. return $data;
  165. }