stock.views.inc 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php
  2. /**
  3. * Purpose: this function returns the portion of the data array
  4. * which describes the stock table, it's fields and any joins between it and other tables
  5. * @see tripal_stock_views_data() --in tripal_stock.views.inc
  6. *
  7. * @todo add better support for is_obsolete -through a field handler
  8. * @todo Add support for the following tables: stock_cvterm, stock_pub, stock_genotype
  9. * @todo Add join to node table within if <chado/drupal same db>; also addd if not around nid field
  10. *
  11. * BASE TABLE: stock
  12. * @code
  13. * create table stock (
  14. * stock_id serial not null,
  15. * primary key (stock_id),
  16. * R dbxref_id int,
  17. * foreign key (dbxref_id) references dbxref (dbxref_id) on delete set null INITIALLY DEFERRED,
  18. * R organism_id int,
  19. * foreign key (organism_id) references organism (organism_id) on delete cascade INITIALLY DEFERRED,
  20. * F name varchar(255),
  21. * F uniquename text not null,
  22. * F description text,
  23. * R type_id int not null,
  24. * foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  25. * F is_obsolete boolean not null default 'false',
  26. * constraint stock_c1 unique (organism_id,uniquename,type_id)
  27. * );
  28. * @endcode
  29. */
  30. function retrieve_stock_views_data() {
  31. $data = array();
  32. // Basic table definition
  33. $data['stock']['table']['group'] = t('Chado Stock');
  34. $data['stock']['table']['base'] = array(
  35. 'field' => 'stock_id',
  36. 'title' => t('Chado Stock'),
  37. 'help' => t('Chado Stocks are a record of any material upon which an experiment can be done. For example, a DNA sample, an individual or a population.'),
  38. 'database' => 'chado'
  39. );
  40. // Define relationships between this table and others
  41. $data['stock']['table']['join'] = array(
  42. 'organism' => array(
  43. 'left_field' => 'organism_id',
  44. 'field' => 'organism_id',
  45. ),
  46. );
  47. // Table Field Definitions----------------------
  48. // Field: feature_id (primary key)
  49. $data['stock']['stock_id'] = array(
  50. 'title' => 'Stock ID',
  51. 'help' => 'The primary key of a stock',
  52. 'field' => array(
  53. 'handler' => 'views_handler_field_numeric',
  54. 'click sortable' => TRUE,
  55. ),
  56. 'filter' => array(
  57. 'handler' => 'views_handler_filter_numeric',
  58. ),
  59. 'sort' => array(
  60. 'handler' => 'views_handler_sort',
  61. ),
  62. );
  63. // Calculated Field: Node ID
  64. // use custom field handler to query drupal for the node ID
  65. // this is only needed if chado is in a separate database from drupal
  66. $data['stock']['nid'] = array(
  67. 'title' => 'Node ID',
  68. 'help' => 'This is the node ID of this feature. It can be used as a link to the node.',
  69. 'field' => array(
  70. 'handler' => 'views_handler_field_computed_nid',
  71. ),
  72. );
  73. //Field: unique name (text)
  74. $data['stock']['uniquename'] = array(
  75. 'title' => t('Unique Name'),
  76. 'help' => t('A unique name for this stock.'),
  77. 'field' => array(
  78. 'handler' => 'views_handler_field',
  79. 'click sortable' => TRUE,
  80. ),
  81. 'sort' => array(
  82. 'handler' => 'views_handler_sort',
  83. ),
  84. 'filter' => array(
  85. 'handler' => 'views_handler_filter_string',
  86. ),
  87. 'argument' => array(
  88. 'handler' => 'views_handler_argument_string',
  89. ),
  90. );
  91. //Field: name (varchar 255)
  92. $data['stock']['name'] = array(
  93. 'title' => t('Name'),
  94. 'help' => t('The human-readable name of this stock.'),
  95. 'field' => array(
  96. 'handler' => 'views_handler_field',
  97. 'click sortable' => TRUE,
  98. ),
  99. 'sort' => array(
  100. 'handler' => 'views_handler_sort',
  101. ),
  102. 'filter' => array(
  103. 'handler' => 'views_handler_filter_string',
  104. ),
  105. 'argument' => array(
  106. 'handler' => 'views_handler_argument_string',
  107. ),
  108. );
  109. //Field: description (varchar 255)
  110. $data['stock']['description'] = array(
  111. 'title' => t('Description'),
  112. 'help' => t('Provides a short description for a given stock.'),
  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: is_obsolete (boolean t/f)
  128. $data['stock']['is_obsolete'] = array(
  129. 'title' => t('Is Obsolete'),
  130. 'help' => t('A yes/no field indicating whether a given stock is obsolete or not.'),
  131. 'field' => array(
  132. 'handler' => 'views_handler_field',
  133. 'click sortable' => TRUE,
  134. ),
  135. 'sort' => array(
  136. 'handler' => 'views_handler_sort',
  137. ),
  138. );
  139. //Calculated Field: stock properties
  140. // uses a custom field handler which pulls results from the view
  141. // actual query performed in chado_stock_views_views_pre_render (&$view) -file:tripal_stock.views.inc
  142. $data['stock']['properties'] = array(
  143. 'title' => t('Stock Properties'),
  144. 'help' => t('Properties of the current stock.'),
  145. 'field' => array(
  146. 'title' => t('Properties'),
  147. 'help' => t('Display a given type of properties associated with a stock.'),
  148. 'handler' => 'views_handler_field_stockprop_by_type',
  149. ),
  150. );
  151. //Calculated Field: stock properties (ALL)
  152. // uses a custom field handler which pulls results from the view
  153. // actual query performed in chado_stock_views_views_pre_render (&$view) -file:tripal_stock.views.inc
  154. $data['stock']['all_properties'] = array(
  155. 'title' => t('All Stock Properties'),
  156. 'help' => t('Properties of the current stock.'),
  157. 'field' => array(
  158. 'title' => t('All Properties'),
  159. 'help' => t('Display all properties associated with a stock.'),
  160. 'handler' => 'views_handler_field_stockprop_all',
  161. ),
  162. );
  163. //Calculated Field: stock relationships
  164. // uses a custom field handler which pulls results from the view
  165. // actual query performed in chado_stock_views_views_pre_render (&$view) -file:tripal_stock.views.inc
  166. $data['stock']['relationships'] = array(
  167. 'title' => t('Stock Relationships'),
  168. 'help' => t('Relationships including the current stock.'),
  169. 'field' => array(
  170. 'title' => t('Relationships'),
  171. 'help' => t('Display a given type of relationships including the current stock.'),
  172. 'handler' => 'views_handler_field_stockrel_by_type',
  173. ),
  174. );
  175. //Calculated Field: stock relationships (ALL)
  176. // uses a custom field handler which pulls results from the view
  177. // actual query performed in chado_stock_views_views_pre_render (&$view) -file:tripal_stock.views.inc
  178. $data['stock']['all_relationships'] = array(
  179. 'title' => t('All Stock Relationships'),
  180. 'help' => t('Relationships including the current stock.'),
  181. 'field' => array(
  182. 'title' => t('All Relationships'),
  183. 'help' => t('Display all relationships including the stock.'),
  184. 'handler' => 'views_handler_field_stockrel_all',
  185. ),
  186. );
  187. //Calculated Field: stock dbxrefs
  188. // uses a custom field handler which pulls results from the view
  189. // actual query performed in chado_stock_views_views_pre_render (&$view) -file:tripal_stock.views.inc
  190. $data['stock']['dbxref'] = array(
  191. 'title' => t('Stock Database References'),
  192. 'help' => t('Database References associated with the current stock.'),
  193. 'field' => array(
  194. 'title' => t('Database References'),
  195. 'help' => t('Display database references from a given database for the current stock.'),
  196. 'handler' => 'views_handler_field_stock_dbxref_by_type',
  197. ),
  198. );
  199. //Calculated Field: stock dbxrefs (ALL)
  200. // uses a custom field handler which pulls results from the view
  201. // actual query performed in chado_stock_views_views_pre_render (&$view) -file:tripal_stock.views.inc
  202. $data['stock']['all_dbxref'] = array(
  203. 'title' => t('All Stock Database References'),
  204. 'help' => t('Database References associated with the current stock.'),
  205. 'field' => array(
  206. 'title' => t('All Database References'),
  207. 'help' => t('Display all database references for the current stock.'),
  208. 'handler' => 'views_handler_field_stock_dbxref_all',
  209. ),
  210. );
  211. return $data;
  212. }