tripal_chado.views.inc 9.5 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 = [];
  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'] = [
  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'] = [
  40. 'title' => t('Custom Table ID'),
  41. 'help' => t('Custom table primary key.'),
  42. 'field' => [
  43. 'handler' => 'views_handler_field_numeric',
  44. 'click sortable' => TRUE,
  45. ],
  46. 'filter' => [
  47. 'handler' => 'views_handler_filter_numeric',
  48. ],
  49. 'sort' => [
  50. 'handler' => 'views_handler_sort',
  51. ],
  52. ];
  53. // Table Name
  54. $data['tripal_custom_tables']['table_name'] = [
  55. 'title' => t('Table Name'),
  56. 'help' => t('The name of the table in the database.'),
  57. 'field' => [
  58. 'handler' => 'views_handler_field',
  59. 'click sortable' => TRUE, // This is use by the table display plugin.
  60. ],
  61. 'sort' => [
  62. 'handler' => 'views_handler_sort',
  63. ],
  64. 'filter' => [
  65. 'handler' => 'views_handler_filter_string',
  66. ],
  67. 'argument' => [
  68. 'handler' => 'views_handler_argument_string',
  69. ],
  70. ];
  71. // Schema
  72. $data['tripal_custom_tables']['schema'] = [
  73. 'title' => t('Table Schema'),
  74. 'help' => t('The schema definition of the table.'),
  75. 'field' => [
  76. 'handler' => 'views_handler_field',
  77. 'click sortable' => TRUE, // This is use by the table display plugin.
  78. ],
  79. 'sort' => [
  80. 'handler' => 'views_handler_sort',
  81. ],
  82. 'filter' => [
  83. 'handler' => 'views_handler_filter_string',
  84. ],
  85. 'argument' => [
  86. 'handler' => 'views_handler_argument_string',
  87. ],
  88. ];
  89. // Table ID
  90. $data['tripal_custom_tables']['mview_id'] = [
  91. 'title' => t('Materialized View ID'),
  92. 'help' => t('Foreign key to tripal_mviews table for the materialized view.'),
  93. 'field' => [
  94. 'handler' => 'views_handler_field_numeric',
  95. 'click sortable' => TRUE,
  96. ],
  97. 'filter' => [
  98. 'handler' => 'views_handler_filter_numeric',
  99. ],
  100. 'sort' => [
  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'] = [
  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'] = [
  126. 'tripal_views' => [
  127. 'left_field' => 'mview_id',
  128. 'field' => 'mview_id',
  129. ],
  130. ];
  131. // Mview ID
  132. $data['tripal_mviews']['mview_id'] = [
  133. 'title' => t('Materialized View ID'),
  134. 'help' => t('The primary key.'),
  135. 'field' => [
  136. 'handler' => 'views_handler_field_numeric',
  137. 'click sortable' => TRUE,
  138. ],
  139. 'filter' => [
  140. 'handler' => 'views_handler_filter_numeric',
  141. ],
  142. 'sort' => [
  143. 'handler' => 'views_handler_sort',
  144. ],
  145. ];
  146. // name
  147. $data['tripal_mviews']['name'] = [
  148. 'title' => t('Name'),
  149. 'help' => t('Human-readable name of the materialized view.'),
  150. 'field' => [
  151. 'handler' => 'views_handler_field',
  152. 'click sortable' => TRUE, // This is use by the table display plugin.
  153. ],
  154. 'sort' => [
  155. 'handler' => 'views_handler_sort',
  156. ],
  157. 'filter' => [
  158. 'handler' => 'views_handler_filter_string',
  159. ],
  160. 'argument' => [
  161. 'handler' => 'views_handler_argument_string',
  162. ],
  163. ];
  164. // modulename
  165. $data['tripal_mviews']['modulename'] = [
  166. 'title' => t('Module Name'),
  167. 'help' => t('The module that created the materialized view.'),
  168. 'field' => [
  169. 'handler' => 'views_handler_field',
  170. 'click sortable' => TRUE, // This is use by the table display plugin.
  171. ],
  172. 'sort' => [
  173. 'handler' => 'views_handler_sort',
  174. ],
  175. 'filter' => [
  176. 'handler' => 'views_handler_filter_string',
  177. ],
  178. 'argument' => [
  179. 'handler' => 'views_handler_argument_string',
  180. ],
  181. ];
  182. // mv_table
  183. $data['tripal_mviews']['mv_table'] = [
  184. 'title' => t('Table'),
  185. 'help' => t('The database table the materialized view is stored in.'),
  186. 'field' => [
  187. 'handler' => 'views_handler_field',
  188. 'click sortable' => TRUE, // This is use by the table display plugin.
  189. ],
  190. 'sort' => [
  191. 'handler' => 'views_handler_sort',
  192. ],
  193. 'filter' => [
  194. 'handler' => 'views_handler_filter_string',
  195. ],
  196. 'argument' => [
  197. 'handler' => 'views_handler_argument_string',
  198. ],
  199. ];
  200. // mv_specs
  201. $data['tripal_mviews']['mv_specs'] = [
  202. 'title' => t('Specification'),
  203. 'help' => t('Materialized View Specification.'),
  204. 'field' => [
  205. 'handler' => 'views_handler_field',
  206. 'click sortable' => TRUE, // This is use by the table display plugin.
  207. ],
  208. 'sort' => [
  209. 'handler' => 'views_handler_sort',
  210. ],
  211. 'filter' => [
  212. 'handler' => 'views_handler_filter_string',
  213. ],
  214. 'argument' => [
  215. 'handler' => 'views_handler_argument_string',
  216. ],
  217. ];
  218. // mv_schema
  219. $data['tripal_mviews']['mv_schema'] = [
  220. 'title' => t('Schema'),
  221. 'help' => t('Schema definition for the materialized view table.'),
  222. 'field' => [
  223. 'handler' => 'views_handler_field',
  224. 'click sortable' => TRUE, // This is use by the table display plugin.
  225. ],
  226. 'sort' => [
  227. 'handler' => 'views_handler_sort',
  228. ],
  229. 'filter' => [
  230. 'handler' => 'views_handler_filter_string',
  231. ],
  232. 'argument' => [
  233. 'handler' => 'views_handler_argument_string',
  234. ],
  235. ];
  236. // indexed
  237. $data['tripal_mviews']['indexed'] = [
  238. 'title' => t('Indices'),
  239. 'help' => t('Any indices for this materialized view.'),
  240. 'field' => [
  241. 'handler' => 'views_handler_field',
  242. 'click sortable' => TRUE, // This is use by the table display plugin.
  243. ],
  244. 'sort' => [
  245. 'handler' => 'views_handler_sort',
  246. ],
  247. 'filter' => [
  248. 'handler' => 'views_handler_filter_string',
  249. ],
  250. 'argument' => [
  251. 'handler' => 'views_handler_argument_string',
  252. ],
  253. ];
  254. // query
  255. $data['tripal_mviews']['query'] = [
  256. 'title' => t('Query'),
  257. 'help' => t('The query used to populate the materialized view.'),
  258. 'field' => [
  259. 'handler' => 'views_handler_field',
  260. 'click sortable' => TRUE, // This is use by the table display plugin.
  261. ],
  262. 'sort' => [
  263. 'handler' => 'views_handler_sort',
  264. ],
  265. 'filter' => [
  266. 'handler' => 'views_handler_filter_string',
  267. ],
  268. 'argument' => [
  269. 'handler' => 'views_handler_argument_string',
  270. ],
  271. ];
  272. // special_index
  273. $data['tripal_mviews']['special_index'] = [
  274. 'title' => t('Special Index'),
  275. 'help' => t('Any special indices for the materialized view.'),
  276. 'field' => [
  277. 'handler' => 'views_handler_field',
  278. 'click sortable' => TRUE, // This is use by the table display plugin.
  279. ],
  280. 'sort' => [
  281. 'handler' => 'views_handler_sort',
  282. ],
  283. 'filter' => [
  284. 'handler' => 'views_handler_filter_string',
  285. ],
  286. 'argument' => [
  287. 'handler' => 'views_handler_argument_string',
  288. ],
  289. ];
  290. // last_update
  291. $data['tripal_mviews']['last_update'] = [
  292. 'title' => t('Updated'),
  293. 'help' => t('Date Last Updated.'),
  294. 'field' => [
  295. 'handler' => 'views_handler_field_date',
  296. 'click sortable' => TRUE,
  297. ],
  298. 'sort' => [
  299. 'handler' => 'views_handler_sort_date',
  300. ],
  301. 'filter' => [
  302. 'handler' => 'views_handler_filter_date',
  303. ],
  304. ];
  305. // status
  306. $data['tripal_mviews']['status'] = [
  307. 'title' => t('Status'),
  308. 'help' => t('The status of the materialized view.'),
  309. 'field' => [
  310. 'handler' => 'views_handler_field',
  311. 'click sortable' => TRUE, // This is use by the table display plugin.
  312. ],
  313. 'sort' => [
  314. 'handler' => 'views_handler_sort',
  315. ],
  316. 'filter' => [
  317. 'handler' => 'views_handler_filter_string',
  318. ],
  319. 'argument' => [
  320. 'handler' => 'views_handler_argument_string',
  321. ],
  322. ];
  323. // comment
  324. $data['tripal_mviews']['comment'] = [
  325. 'title' => t('Description'),
  326. 'help' => t('Human-Readable Admin Description.'),
  327. 'field' => [
  328. 'handler' => 'views_handler_field',
  329. 'click sortable' => TRUE, // This is use by the table display plugin.
  330. ],
  331. 'sort' => [
  332. 'handler' => 'views_handler_sort',
  333. ],
  334. 'filter' => [
  335. 'handler' => 'views_handler_filter_string',
  336. ],
  337. 'argument' => [
  338. 'handler' => 'views_handler_argument_string',
  339. ],
  340. ];
  341. return $data;
  342. }