tripal_chado.views.inc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <?php
  2. /**
  3. * @file
  4. * Integrates many of the core database tables with drupal views
  5. */
  6. /**
  7. * Describe various Tripal Core systems to Views for the creation of
  8. * administrative views.
  9. *
  10. * @ingroup tripal
  11. */
  12. function tripal_chado_views_data() {
  13. $data = array();
  14. // Custom Tables Management
  15. $data = tripal_chado_views_data_custom_tables($data);
  16. // Materialized Views Management
  17. $data = tripal_chado_views_data_mviews($data);
  18. return $data;
  19. }
  20. /**
  21. * Provides the data array for the tripal custom tables management
  22. *
  23. * @param $data
  24. * Previously generated tripal views data array
  25. * return
  26. * $data array with custom tables management described
  27. *
  28. * @ingroup tripal
  29. */
  30. function tripal_chado_views_data_custom_tables($data) {
  31. $data['tripal_custom_tables']['table']['group'] = t('Tripal Custom Tables');
  32. $data['tripal_custom_tables']['table']['base'] = array(
  33. 'field' => 'table_id', // This is the identifier field for the view.
  34. 'title' => t('Tripal Custom Tables'),
  35. 'help' => t('Custom Tables in Chado created by this Tripal Installation.'),
  36. 'weight' => 10,
  37. );
  38. // Table ID
  39. $data['tripal_custom_tables']['table_id'] = array(
  40. 'title' => t('Custom Table ID'),
  41. 'help' => t('Custom table primary key.'),
  42. 'field' => array(
  43. 'handler' => 'views_handler_field_numeric',
  44. 'click sortable' => TRUE,
  45. ),
  46. 'filter' => array(
  47. 'handler' => 'views_handler_filter_numeric',
  48. ),
  49. 'sort' => array(
  50. 'handler' => 'views_handler_sort',
  51. ),
  52. );
  53. // Table Name
  54. $data['tripal_custom_tables']['table_name'] = array(
  55. 'title' => t('Table Name'),
  56. 'help' => t('The name of the table in the database.'),
  57. 'field' => array(
  58. 'handler' => 'views_handler_field',
  59. 'click sortable' => TRUE, // This is use by the table display plugin.
  60. ),
  61. 'sort' => array(
  62. 'handler' => 'views_handler_sort',
  63. ),
  64. 'filter' => array(
  65. 'handler' => 'views_handler_filter_string',
  66. ),
  67. 'argument' => array(
  68. 'handler' => 'views_handler_argument_string',
  69. ),
  70. );
  71. // Schema
  72. $data['tripal_custom_tables']['schema'] = array(
  73. 'title' => t('Table Schema'),
  74. 'help' => t('The schema definition of the table.'),
  75. 'field' => array(
  76. 'handler' => 'views_handler_field',
  77. 'click sortable' => TRUE, // This is use by the table display plugin.
  78. ),
  79. 'sort' => array(
  80. 'handler' => 'views_handler_sort',
  81. ),
  82. 'filter' => array(
  83. 'handler' => 'views_handler_filter_string',
  84. ),
  85. 'argument' => array(
  86. 'handler' => 'views_handler_argument_string',
  87. ),
  88. );
  89. // Table ID
  90. $data['tripal_custom_tables']['mview_id'] = array(
  91. 'title' => t('Materialized View ID'),
  92. 'help' => t('Foreign key to tripal_mviews table for the materialized view.'),
  93. 'field' => array(
  94. 'handler' => 'views_handler_field_numeric',
  95. 'click sortable' => TRUE,
  96. ),
  97. 'filter' => array(
  98. 'handler' => 'views_handler_filter_numeric',
  99. ),
  100. 'sort' => array(
  101. 'handler' => 'views_handler_sort',
  102. ),
  103. );
  104. return $data;
  105. }
  106. /**
  107. * Provides the data array for the tripal custom tables management
  108. *
  109. * @param $data
  110. * Previously generated tripal views data array
  111. * return
  112. * $data array with custom tables management described
  113. *
  114. * @ingroup tripal
  115. */
  116. function tripal_chado_views_data_mviews($data) {
  117. $data['tripal_mviews']['table']['group'] = t('Tripal Materialized Views');
  118. $data['tripal_mviews']['table']['base'] = array(
  119. 'field' => 'mview_id', // This is the identifier field for the view.
  120. 'title' => t('Tripal Materialized Views'),
  121. 'help' => t('Materialized Views in Chado created by this Tripal Installation.'),
  122. 'weight' => 10,
  123. );
  124. // Implicit Join to Tripal Views
  125. $data['tripal_mviews']['table']['join'] = array(
  126. 'tripal_views' => array(
  127. 'left_field' => 'mview_id',
  128. 'field' => 'mview_id',
  129. ),
  130. );
  131. // Mview ID
  132. $data['tripal_mviews']['mview_id'] = array(
  133. 'title' => t('Materialized View ID'),
  134. 'help' => t('The primary key.'),
  135. 'field' => array(
  136. 'handler' => 'views_handler_field_numeric',
  137. 'click sortable' => TRUE,
  138. ),
  139. 'filter' => array(
  140. 'handler' => 'views_handler_filter_numeric',
  141. ),
  142. 'sort' => array(
  143. 'handler' => 'views_handler_sort',
  144. ),
  145. );
  146. // name
  147. $data['tripal_mviews']['name'] = array(
  148. 'title' => t('Name'),
  149. 'help' => t('Human-readable name of the materialized view.'),
  150. 'field' => array(
  151. 'handler' => 'views_handler_field',
  152. 'click sortable' => TRUE, // This is use by the table display plugin.
  153. ),
  154. 'sort' => array(
  155. 'handler' => 'views_handler_sort',
  156. ),
  157. 'filter' => array(
  158. 'handler' => 'views_handler_filter_string',
  159. ),
  160. 'argument' => array(
  161. 'handler' => 'views_handler_argument_string',
  162. ),
  163. );
  164. // modulename
  165. $data['tripal_mviews']['modulename'] = array(
  166. 'title' => t('Module Name'),
  167. 'help' => t('The module that created the materialized view.'),
  168. 'field' => array(
  169. 'handler' => 'views_handler_field',
  170. 'click sortable' => TRUE, // This is use by the table display plugin.
  171. ),
  172. 'sort' => array(
  173. 'handler' => 'views_handler_sort',
  174. ),
  175. 'filter' => array(
  176. 'handler' => 'views_handler_filter_string',
  177. ),
  178. 'argument' => array(
  179. 'handler' => 'views_handler_argument_string',
  180. ),
  181. );
  182. // mv_table
  183. $data['tripal_mviews']['mv_table'] = array(
  184. 'title' => t('Table'),
  185. 'help' => t('The database table the materialized view is stored in.'),
  186. 'field' => array(
  187. 'handler' => 'views_handler_field',
  188. 'click sortable' => TRUE, // This is use by the table display plugin.
  189. ),
  190. 'sort' => array(
  191. 'handler' => 'views_handler_sort',
  192. ),
  193. 'filter' => array(
  194. 'handler' => 'views_handler_filter_string',
  195. ),
  196. 'argument' => array(
  197. 'handler' => 'views_handler_argument_string',
  198. ),
  199. );
  200. // mv_specs
  201. $data['tripal_mviews']['mv_specs'] = array(
  202. 'title' => t('Specification'),
  203. 'help' => t('Materialized View Specification.'),
  204. 'field' => array(
  205. 'handler' => 'views_handler_field',
  206. 'click sortable' => TRUE, // This is use by the table display plugin.
  207. ),
  208. 'sort' => array(
  209. 'handler' => 'views_handler_sort',
  210. ),
  211. 'filter' => array(
  212. 'handler' => 'views_handler_filter_string',
  213. ),
  214. 'argument' => array(
  215. 'handler' => 'views_handler_argument_string',
  216. ),
  217. );
  218. // mv_schema
  219. $data['tripal_mviews']['mv_schema'] = array(
  220. 'title' => t('Schema'),
  221. 'help' => t('Schema definition for the materialized view table.'),
  222. 'field' => array(
  223. 'handler' => 'views_handler_field',
  224. 'click sortable' => TRUE, // This is use by the table display plugin.
  225. ),
  226. 'sort' => array(
  227. 'handler' => 'views_handler_sort',
  228. ),
  229. 'filter' => array(
  230. 'handler' => 'views_handler_filter_string',
  231. ),
  232. 'argument' => array(
  233. 'handler' => 'views_handler_argument_string',
  234. ),
  235. );
  236. // indexed
  237. $data['tripal_mviews']['indexed'] = array(
  238. 'title' => t('Indices'),
  239. 'help' => t('Any indices for this materialized view.'),
  240. 'field' => array(
  241. 'handler' => 'views_handler_field',
  242. 'click sortable' => TRUE, // This is use by the table display plugin.
  243. ),
  244. 'sort' => array(
  245. 'handler' => 'views_handler_sort',
  246. ),
  247. 'filter' => array(
  248. 'handler' => 'views_handler_filter_string',
  249. ),
  250. 'argument' => array(
  251. 'handler' => 'views_handler_argument_string',
  252. ),
  253. );
  254. // query
  255. $data['tripal_mviews']['query'] = array(
  256. 'title' => t('Query'),
  257. 'help' => t('The query used to populate the materialized view.'),
  258. 'field' => array(
  259. 'handler' => 'views_handler_field',
  260. 'click sortable' => TRUE, // This is use by the table display plugin.
  261. ),
  262. 'sort' => array(
  263. 'handler' => 'views_handler_sort',
  264. ),
  265. 'filter' => array(
  266. 'handler' => 'views_handler_filter_string',
  267. ),
  268. 'argument' => array(
  269. 'handler' => 'views_handler_argument_string',
  270. ),
  271. );
  272. // special_index
  273. $data['tripal_mviews']['special_index'] = array(
  274. 'title' => t('Special Index'),
  275. 'help' => t('Any special indices for the materialized view.'),
  276. 'field' => array(
  277. 'handler' => 'views_handler_field',
  278. 'click sortable' => TRUE, // This is use by the table display plugin.
  279. ),
  280. 'sort' => array(
  281. 'handler' => 'views_handler_sort',
  282. ),
  283. 'filter' => array(
  284. 'handler' => 'views_handler_filter_string',
  285. ),
  286. 'argument' => array(
  287. 'handler' => 'views_handler_argument_string',
  288. ),
  289. );
  290. // last_update
  291. $data['tripal_mviews']['last_update'] = array(
  292. 'title' => t('Updated'),
  293. 'help' => t('Date Last Updated.'),
  294. 'field' => array(
  295. 'handler' => 'views_handler_field_date',
  296. 'click sortable' => TRUE,
  297. ),
  298. 'sort' => array(
  299. 'handler' => 'views_handler_sort_date',
  300. ),
  301. 'filter' => array(
  302. 'handler' => 'views_handler_filter_date',
  303. ),
  304. );
  305. // status
  306. $data['tripal_mviews']['status'] = array(
  307. 'title' => t('Status'),
  308. 'help' => t('The status of the materialized view.'),
  309. 'field' => array(
  310. 'handler' => 'views_handler_field',
  311. 'click sortable' => TRUE, // This is use by the table display plugin.
  312. ),
  313. 'sort' => array(
  314. 'handler' => 'views_handler_sort',
  315. ),
  316. 'filter' => array(
  317. 'handler' => 'views_handler_filter_string',
  318. ),
  319. 'argument' => array(
  320. 'handler' => 'views_handler_argument_string',
  321. ),
  322. );
  323. // comment
  324. $data['tripal_mviews']['comment'] = array(
  325. 'title' => t('Description'),
  326. 'help' => t('Human-Readable Admin Description.'),
  327. 'field' => array(
  328. 'handler' => 'views_handler_field',
  329. 'click sortable' => TRUE, // This is use by the table display plugin.
  330. ),
  331. 'sort' => array(
  332. 'handler' => 'views_handler_sort',
  333. ),
  334. 'filter' => array(
  335. 'handler' => 'views_handler_filter_string',
  336. ),
  337. 'argument' => array(
  338. 'handler' => 'views_handler_argument_string',
  339. ),
  340. );
  341. return $data;
  342. }