tripal_chado.views.inc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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. // MView 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. // Is Base
  105. $data['tripal_custom_tables']['is_base'] = [
  106. 'title' => t('Is Base?'),
  107. 'help' => t('Indicates if this custom table can be used as a base table for content creation.'),
  108. 'field' => [
  109. 'handler' => 'views_handler_field_numeric',
  110. 'click sortable' => TRUE,
  111. ],
  112. 'filter' => [
  113. 'handler' => 'views_handler_filter_numeric',
  114. ],
  115. 'sort' => [
  116. 'handler' => 'views_handler_sort',
  117. ],
  118. ];
  119. return $data;
  120. }
  121. /**
  122. * Provides the data array for the tripal custom tables management
  123. *
  124. * @param $data
  125. * Previously generated tripal views data array
  126. * return
  127. * $data array with custom tables management described
  128. *
  129. * @ingroup tripal
  130. */
  131. function tripal_chado_views_data_mviews($data) {
  132. $data['tripal_mviews']['table']['group'] = t('Tripal Materialized Views');
  133. $data['tripal_mviews']['table']['base'] = [
  134. 'field' => 'mview_id', // This is the identifier field for the view.
  135. 'title' => t('Tripal Materialized Views'),
  136. 'help' => t('Materialized Views in Chado created by this Tripal Installation.'),
  137. 'weight' => 10,
  138. ];
  139. // Implicit Join to Tripal Views
  140. $data['tripal_mviews']['table']['join'] = [
  141. 'tripal_views' => [
  142. 'left_field' => 'mview_id',
  143. 'field' => 'mview_id',
  144. ],
  145. ];
  146. // Mview ID
  147. $data['tripal_mviews']['mview_id'] = [
  148. 'title' => t('Materialized View ID'),
  149. 'help' => t('The primary key.'),
  150. 'field' => [
  151. 'handler' => 'views_handler_field_numeric',
  152. 'click sortable' => TRUE,
  153. ],
  154. 'filter' => [
  155. 'handler' => 'views_handler_filter_numeric',
  156. ],
  157. 'sort' => [
  158. 'handler' => 'views_handler_sort',
  159. ],
  160. ];
  161. // name
  162. $data['tripal_mviews']['name'] = [
  163. 'title' => t('Name'),
  164. 'help' => t('Human-readable name of the materialized view.'),
  165. 'field' => [
  166. 'handler' => 'views_handler_field',
  167. 'click sortable' => TRUE, // This is use by the table display plugin.
  168. ],
  169. 'sort' => [
  170. 'handler' => 'views_handler_sort',
  171. ],
  172. 'filter' => [
  173. 'handler' => 'views_handler_filter_string',
  174. ],
  175. 'argument' => [
  176. 'handler' => 'views_handler_argument_string',
  177. ],
  178. ];
  179. // modulename
  180. $data['tripal_mviews']['modulename'] = [
  181. 'title' => t('Module Name'),
  182. 'help' => t('The module that created the materialized view.'),
  183. 'field' => [
  184. 'handler' => 'views_handler_field',
  185. 'click sortable' => TRUE, // This is use by the table display plugin.
  186. ],
  187. 'sort' => [
  188. 'handler' => 'views_handler_sort',
  189. ],
  190. 'filter' => [
  191. 'handler' => 'views_handler_filter_string',
  192. ],
  193. 'argument' => [
  194. 'handler' => 'views_handler_argument_string',
  195. ],
  196. ];
  197. // mv_table
  198. $data['tripal_mviews']['mv_table'] = [
  199. 'title' => t('Table'),
  200. 'help' => t('The database table the materialized view is stored in.'),
  201. 'field' => [
  202. 'handler' => 'views_handler_field',
  203. 'click sortable' => TRUE, // This is use by the table display plugin.
  204. ],
  205. 'sort' => [
  206. 'handler' => 'views_handler_sort',
  207. ],
  208. 'filter' => [
  209. 'handler' => 'views_handler_filter_string',
  210. ],
  211. 'argument' => [
  212. 'handler' => 'views_handler_argument_string',
  213. ],
  214. ];
  215. // mv_specs
  216. $data['tripal_mviews']['mv_specs'] = [
  217. 'title' => t('Specification'),
  218. 'help' => t('Materialized View Specification.'),
  219. 'field' => [
  220. 'handler' => 'views_handler_field',
  221. 'click sortable' => TRUE, // This is use by the table display plugin.
  222. ],
  223. 'sort' => [
  224. 'handler' => 'views_handler_sort',
  225. ],
  226. 'filter' => [
  227. 'handler' => 'views_handler_filter_string',
  228. ],
  229. 'argument' => [
  230. 'handler' => 'views_handler_argument_string',
  231. ],
  232. ];
  233. // mv_schema
  234. $data['tripal_mviews']['mv_schema'] = [
  235. 'title' => t('Schema'),
  236. 'help' => t('Schema definition for the materialized view table.'),
  237. 'field' => [
  238. 'handler' => 'views_handler_field',
  239. 'click sortable' => TRUE, // This is use by the table display plugin.
  240. ],
  241. 'sort' => [
  242. 'handler' => 'views_handler_sort',
  243. ],
  244. 'filter' => [
  245. 'handler' => 'views_handler_filter_string',
  246. ],
  247. 'argument' => [
  248. 'handler' => 'views_handler_argument_string',
  249. ],
  250. ];
  251. // indexed
  252. $data['tripal_mviews']['indexed'] = [
  253. 'title' => t('Indices'),
  254. 'help' => t('Any indices for this materialized view.'),
  255. 'field' => [
  256. 'handler' => 'views_handler_field',
  257. 'click sortable' => TRUE, // This is use by the table display plugin.
  258. ],
  259. 'sort' => [
  260. 'handler' => 'views_handler_sort',
  261. ],
  262. 'filter' => [
  263. 'handler' => 'views_handler_filter_string',
  264. ],
  265. 'argument' => [
  266. 'handler' => 'views_handler_argument_string',
  267. ],
  268. ];
  269. // query
  270. $data['tripal_mviews']['query'] = [
  271. 'title' => t('Query'),
  272. 'help' => t('The query used to populate the materialized view.'),
  273. 'field' => [
  274. 'handler' => 'views_handler_field',
  275. 'click sortable' => TRUE, // This is use by the table display plugin.
  276. ],
  277. 'sort' => [
  278. 'handler' => 'views_handler_sort',
  279. ],
  280. 'filter' => [
  281. 'handler' => 'views_handler_filter_string',
  282. ],
  283. 'argument' => [
  284. 'handler' => 'views_handler_argument_string',
  285. ],
  286. ];
  287. // special_index
  288. $data['tripal_mviews']['special_index'] = [
  289. 'title' => t('Special Index'),
  290. 'help' => t('Any special indices for the materialized view.'),
  291. 'field' => [
  292. 'handler' => 'views_handler_field',
  293. 'click sortable' => TRUE, // This is use by the table display plugin.
  294. ],
  295. 'sort' => [
  296. 'handler' => 'views_handler_sort',
  297. ],
  298. 'filter' => [
  299. 'handler' => 'views_handler_filter_string',
  300. ],
  301. 'argument' => [
  302. 'handler' => 'views_handler_argument_string',
  303. ],
  304. ];
  305. // last_update
  306. $data['tripal_mviews']['last_update'] = [
  307. 'title' => t('Updated'),
  308. 'help' => t('Date Last Updated.'),
  309. 'field' => [
  310. 'handler' => 'views_handler_field_date',
  311. 'click sortable' => TRUE,
  312. ],
  313. 'sort' => [
  314. 'handler' => 'views_handler_sort_date',
  315. ],
  316. 'filter' => [
  317. 'handler' => 'views_handler_filter_date',
  318. ],
  319. ];
  320. // status
  321. $data['tripal_mviews']['status'] = [
  322. 'title' => t('Status'),
  323. 'help' => t('The status of the materialized view.'),
  324. 'field' => [
  325. 'handler' => 'views_handler_field',
  326. 'click sortable' => TRUE, // This is use by the table display plugin.
  327. ],
  328. 'sort' => [
  329. 'handler' => 'views_handler_sort',
  330. ],
  331. 'filter' => [
  332. 'handler' => 'views_handler_filter_string',
  333. ],
  334. 'argument' => [
  335. 'handler' => 'views_handler_argument_string',
  336. ],
  337. ];
  338. // comment
  339. $data['tripal_mviews']['comment'] = [
  340. 'title' => t('Description'),
  341. 'help' => t('Human-Readable Admin Description.'),
  342. 'field' => [
  343. 'handler' => 'views_handler_field',
  344. 'click sortable' => TRUE, // This is use by the table display plugin.
  345. ],
  346. 'sort' => [
  347. 'handler' => 'views_handler_sort',
  348. ],
  349. 'filter' => [
  350. 'handler' => 'views_handler_filter_string',
  351. ],
  352. 'argument' => [
  353. 'handler' => 'views_handler_argument_string',
  354. ],
  355. ];
  356. return $data;
  357. }