genotype.views.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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_genetic.views.inc --in tripal_genetic_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 genotype table, it's fields and any joins between it and other tables
  15. * @see tripal_genetic_views_data() --in tripal_genetic.views.inc
  16. *
  17. * Table: genotype
  18. * @code
  19. * genotype-Copy/Paste Table SQL code here-genotype
  20. * @endcode
  21. */
  22. function retrieve_genotype_views_data() {
  23. global $db_url;
  24. $data = array();
  25. // if the chado database is not local to the drupal database
  26. // then we need to set the database name. This should always
  27. // be 'chado'.
  28. if (is_array($db_url) and array_key_exists('chado', $db_url)) {
  29. $database = 'chado';
  30. }
  31. //Basic table definition-----------------------------------
  32. $data['genotype']['table']['group'] = t('Chado Genotype');
  33. $data['genotype']['table']['base'] = array(
  34. 'field' => 'genotype_id',
  35. 'title' => t('Chado Genotype'),
  36. 'help' => t('A genotype is defined by a collection of features, mutations, balancers, deficiencies, haplotype blocks, or engineered constructs.'),
  37. );
  38. if ($database) {
  39. $data['genotype']['table']['base']['database'] = $database;
  40. }
  41. //Relationship Definitions---------------------------------
  42. //Join: feature => feature_genotype => feature
  43. // This relationship should be described in both directions
  44. // in the appropriate files (ie: for feature => library
  45. // describe in both feature.views.inc and library.views.inc)
  46. $data['feature']['table']['join']['feature_genotype'] = array(
  47. 'left_field' => 'feature_id',
  48. 'field' => 'feature_id',
  49. );
  50. $data['feature']['table']['join']['genotype'] = array(
  51. 'left_table' => 'feature_genotype',
  52. 'left_field' => 'feature_id',
  53. 'field' => 'feature_id',
  54. );
  55. $data['feature_genotype']['table']['join']['genotype'] = array(
  56. 'left_field' => 'genotype_id',
  57. 'field' => 'genotype_id',
  58. );
  59. //Join: feature => feature_genotype => feature
  60. // This relationship should be described in both directions
  61. // in the appropriate files (ie: for feature => library
  62. // describe in both feature.views.inc and library.views.inc)
  63. $data['genotype']['table']['join']['feature_genotype'] = array(
  64. 'left_field' => 'genotype_id',
  65. 'field' => 'genotype_id',
  66. );
  67. $data['genotype']['table']['join']['feature'] = array(
  68. 'left_table' => 'feature_genotype',
  69. 'left_field' => 'genotype_id',
  70. 'field' => 'genotype_id',
  71. );
  72. $data['feature_genotype']['table']['join']['feature'] = array(
  73. 'left_field' => 'feature_id',
  74. 'field' => 'feature_id',
  75. );
  76. //Join: stock => stock_genotype => stock
  77. // This relationship should be described in both directions
  78. // in the appropriate files (ie: for stock => library
  79. // describe in both stock.views.inc and library.views.inc)
  80. $data['stock']['table']['join']['stock_genotype'] = array(
  81. 'left_field' => 'stock_id',
  82. 'field' => 'stock_id',
  83. );
  84. $data['stock']['table']['join']['genotype'] = array(
  85. 'left_table' => 'stock_genotype',
  86. 'left_field' => 'stock_id',
  87. 'field' => 'stock_id',
  88. );
  89. $data['stock_genotype']['table']['join']['genotype'] = array(
  90. 'left_field' => 'genotype_id',
  91. 'field' => 'genotype_id',
  92. );
  93. //Table Field Definitions----------------------------------
  94. //Field: genotype_id (primary key)
  95. $data['genotype']['genotype_id'] = array(
  96. 'title' => t('Genotype Primary Key'),
  97. 'help' => t('A unique index for every genotype.'),
  98. 'field' => array(
  99. 'handler' => 'views_handler_field_numeric',
  100. 'click sortable' => TRUE,
  101. ),
  102. 'sort' => array(
  103. 'handler' => 'views_handler_sort',
  104. ),
  105. 'filter' => array(
  106. 'handler' => 'views_handler_filter_numeric',
  107. ),
  108. );
  109. //Field: name (text)
  110. $data['genotype']['name'] = array(
  111. 'title' => t('Name'),
  112. 'help' => t('Human-readable Name of the genotype.'),
  113. 'field' => array(
  114. 'handler' => 'views_handler_field',
  115. 'click sortable' => TRUE,
  116. ),
  117. 'sort' => array(
  118. 'handler' => 'views_handler_sort',
  119. ),
  120. 'filter' => array(
  121. 'handler' => 'views_handler_filter_string',
  122. ),
  123. 'argument' => array(
  124. 'handler' => 'views_handler_argument_string',
  125. ),
  126. );
  127. //Field: uniquename (text)
  128. $data['genotype']['uniquename'] = array(
  129. 'title' => t('Unique Name'),
  130. 'help' => t('Unique Name of the genotype.'),
  131. 'field' => array(
  132. 'handler' => 'views_handler_field',
  133. 'click sortable' => TRUE,
  134. ),
  135. 'sort' => array(
  136. 'handler' => 'views_handler_sort',
  137. ),
  138. 'filter' => array(
  139. 'handler' => 'views_handler_filter_string',
  140. ),
  141. 'argument' => array(
  142. 'handler' => 'views_handler_argument_string',
  143. ),
  144. );
  145. //Field: description (varchar -255)
  146. $data['genotype']['description'] = array(
  147. 'title' => t('Description/Value'),
  148. 'help' => t('A Description of the genotype.'),
  149. 'field' => array(
  150. 'handler' => 'views_handler_field',
  151. 'click sortable' => TRUE,
  152. ),
  153. 'sort' => array(
  154. 'handler' => 'views_handler_sort',
  155. ),
  156. 'filter' => array(
  157. 'handler' => 'views_handler_filter_string',
  158. ),
  159. 'argument' => array(
  160. 'handler' => 'views_handler_argument_string',
  161. ),
  162. );
  163. return $data;
  164. }