tripal_bulk_loader.views.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <?php
  2. /**
  3. * @file
  4. * Provides Drupal views integration excluding default views.
  5. *
  6. * @ingroup tripal_bulk_loader
  7. */
  8. /**
  9. * Generates a dynamic data array for Views
  10. *
  11. * Purpose: This function is a hook used by the Views module. It populates and
  12. * returns a data array that specifies for the Views module the base table,
  13. * the tables it joins with and handlers. The data array is populated
  14. * using the data stored in the tripal_views tables.
  15. *
  16. * @return a data array formatted for the Views module
  17. *
  18. * D7 @todo: Add support for materialized views relationships using the new
  19. * method
  20. *
  21. * @ingroup tripal_bulk_loader
  22. */
  23. function tripal_bulk_loader_views_data() {
  24. $data = [];
  25. // Tripal Bulk Loader *************************
  26. $data['tripal_bulk_loader']['table']['group'] = t('Tripal Bulk Loading Jobs');
  27. $data['tripal_bulk_loader']['table']['base'] = [
  28. 'field' => 'nid',
  29. 'title' => t('Tripal Bulk Loading Jobs'),
  30. 'help' => t('Jobs created to load chado data using a Tripal Bulk Loader Template.'),
  31. ];
  32. // This table references the {node} table. The declaration below creates an
  33. // 'implicit' relationship to the node table, so that when 'node' is the base
  34. // table, the fields are automatically available.
  35. $data['tripal_bulk_loader']['table']['join'] = [
  36. 'node' => [
  37. 'left_field' => 'nid',
  38. 'field' => 'nid',
  39. ],
  40. ];
  41. $data['tripal_bulk_loader']['table']['join']['tripal_bulk_loader_template'] = [
  42. 'left_field' => 'template_id',
  43. 'field' => 'template_id',
  44. ];
  45. $data['tripal_bulk_loader']['table']['join']['tripal_bulk_loader_constants'] = [
  46. 'left_field' => 'nid',
  47. 'field' => 'nid',
  48. ];
  49. // Node ID table field.
  50. $data['tripal_bulk_loader']['nid'] = [
  51. 'title' => t('Tripal Bulk Loading Jobs'),
  52. 'help' => t('Tripal Bulk Loading Jobs.'),
  53. // Define a relationship to the {node} table, so tripal_bulk_loader views can
  54. // add a relationship to nodes. If you want to define a relationship the
  55. // other direction, use hook_views_data_alter(), or use the 'implicit' join
  56. // method described above.
  57. 'relationship' => [
  58. 'base' => 'node',
  59. 'base field' => 'nid',
  60. 'handler' => 'views_handler_relationship',
  61. 'label' => t('Bulk Loading Job => Node'),
  62. 'title' => t('Bulk Loading Job => Node'),
  63. 'help' => t('Link Tripal Bulk loading jobs to their nodes.'),
  64. ],
  65. ];
  66. $data['tripal_bulk_loader']['loader_name'] = [
  67. 'title' => t('Name'),
  68. 'help' => t('The name of the loading job.'),
  69. 'field' => [
  70. 'handler' => 'views_handler_field',
  71. 'click sortable' => TRUE, // This is use by the table display plugin.
  72. ],
  73. 'sort' => [
  74. 'handler' => 'views_handler_sort',
  75. ],
  76. 'filter' => [
  77. 'handler' => 'views_handler_filter_string',
  78. ],
  79. 'argument' => [
  80. 'handler' => 'views_handler_argument_string',
  81. ],
  82. ];
  83. $data['tripal_bulk_loader']['template_id'] = [
  84. 'title' => t('Template ID'),
  85. 'help' => t('The template to be used for this bulk loading job.'),
  86. 'field' => [
  87. 'handler' => 'views_handler_field_numeric',
  88. 'click sortable' => TRUE,
  89. ],
  90. 'filter' => [
  91. 'handler' => 'views_handler_filter_numeric',
  92. ],
  93. 'sort' => [
  94. 'handler' => 'views_handler_sort',
  95. ],
  96. ];
  97. $data['tripal_bulk_loader']['file'] = [
  98. 'title' => t('File'),
  99. 'help' => t('The path to the file to be loaded.'),
  100. 'field' => [
  101. 'handler' => 'views_handler_field',
  102. 'click sortable' => TRUE, // This is use by the table display plugin.
  103. ],
  104. 'sort' => [
  105. 'handler' => 'views_handler_sort',
  106. ],
  107. 'filter' => [
  108. 'handler' => 'views_handler_filter_string',
  109. ],
  110. 'argument' => [
  111. 'handler' => 'views_handler_argument_string',
  112. ],
  113. ];
  114. $data['tripal_bulk_loader']['job_id'] = [
  115. 'title' => t('Tripal Job ID'),
  116. 'help' => t('The Tripal job ID corresponding to this Tripal Bulk Loading job.'),
  117. 'field' => [
  118. 'handler' => 'views_handler_field_numeric',
  119. 'click sortable' => TRUE,
  120. ],
  121. 'filter' => [
  122. 'handler' => 'views_handler_filter_numeric',
  123. ],
  124. 'sort' => [
  125. 'handler' => 'views_handler_sort',
  126. ],
  127. ];
  128. $data['tripal_bulk_loader']['job_status'] = [
  129. 'title' => t('Job Status'),
  130. 'help' => t('A description of the status of the loading job.'),
  131. 'field' => [
  132. 'handler' => 'views_handler_field',
  133. 'click sortable' => TRUE, // This is use by the table display plugin.
  134. ],
  135. 'sort' => [
  136. 'handler' => 'views_handler_sort',
  137. ],
  138. 'filter' => [
  139. 'handler' => 'views_handler_filter_string',
  140. ],
  141. 'argument' => [
  142. 'handler' => 'views_handler_argument_string',
  143. ],
  144. ];
  145. $data['tripal_bulk_loader']['file_has_header'] = [
  146. 'title' => t('File has a Header'),
  147. 'help' => t('Whether the file has a single header line or not.'),
  148. 'field' => [
  149. 'handler' => 'views_handler_field_boolean',
  150. 'click sortable' => TRUE,
  151. ],
  152. 'filter' => [
  153. 'handler' => 'views_handler_filter_boolean_operator',
  154. 'type' => 'yes-no',
  155. 'use equal' => TRUE,
  156. ],
  157. 'sort' => [
  158. 'handler' => 'views_handler_sort',
  159. ],
  160. ];
  161. $data['tripal_bulk_loader']['keep_track_inserted'] = [
  162. 'title' => t('Tracking Inserted IDs'),
  163. 'help' => t('Whether the loader is keeping track of inserted IDs to allow reverse of loading.'),
  164. 'field' => [
  165. 'handler' => 'views_handler_field_boolean',
  166. 'click sortable' => TRUE,
  167. ],
  168. 'filter' => [
  169. 'handler' => 'views_handler_filter_boolean_operator',
  170. 'type' => 'yes-no',
  171. 'use equal' => TRUE,
  172. ],
  173. 'sort' => [
  174. 'handler' => 'views_handler_sort',
  175. ],
  176. ];
  177. // Tripal Bulk Loader Template ****************
  178. $data['tripal_bulk_loader_template']['table']['group'] = t('Tripal Bulk Loader Templates');
  179. $data['tripal_bulk_loader_template']['table']['base'] = [
  180. 'field' => 'template_id',
  181. 'title' => t('Tripal Bulk Loader Templates'),
  182. 'help' => t('Tripal Bulk Loader Templates used to describe where to load data into chado.'),
  183. ];
  184. $data['tripal_bulk_loader_template']['table']['join']['tripal_bulk_loader'] = [
  185. 'left_field' => 'template_id',
  186. 'field' => 'template_id',
  187. ];
  188. $data['tripal_bulk_loader_template']['template_id'] = [
  189. 'title' => t('Template ID'),
  190. 'help' => t('The unique identifier for tripal bulk loader templates.'),
  191. 'field' => [
  192. 'handler' => 'views_handler_field_numeric',
  193. 'click sortable' => TRUE,
  194. ],
  195. 'filter' => [
  196. 'handler' => 'views_handler_filter_numeric',
  197. ],
  198. 'sort' => [
  199. 'handler' => 'views_handler_sort',
  200. ],
  201. 'relationship' => [
  202. 'base' => 'tripal_bulk_loader',
  203. 'base field' => 'template_id',
  204. 'handler' => 'views_handler_relationship',
  205. 'label' => t('Templates => TBL Jobs'),
  206. 'title' => t('Templates => TBL Jobs'),
  207. 'help' => t('Links each template to the jobs using it.'),
  208. ],
  209. ];
  210. $data['tripal_bulk_loader_template']['name'] = [
  211. 'title' => t('Name'),
  212. 'help' => t('The human-readable name of the template.'),
  213. 'field' => [
  214. 'handler' => 'views_handler_field',
  215. 'click sortable' => TRUE,
  216. ],
  217. 'sort' => [
  218. 'handler' => 'views_handler_sort',
  219. ],
  220. 'filter' => [
  221. 'handler' => 'views_handler_filter_string',
  222. ],
  223. 'argument' => [
  224. 'handler' => 'views_handler_argument_string',
  225. ],
  226. ];
  227. $data['tripal_bulk_loader_template']['created'] = [
  228. 'title' => t('Created'),
  229. 'help' => t('Date the template was created on.'),
  230. 'field' => [
  231. 'handler' => 'views_handler_field_date',
  232. 'click sortable' => TRUE,
  233. ],
  234. 'sort' => [
  235. 'handler' => 'views_handler_sort_date',
  236. ],
  237. 'filter' => [
  238. 'handler' => 'views_handler_filter_date',
  239. ],
  240. ];
  241. $data['tripal_bulk_loader_template']['changed'] = [
  242. 'title' => t('Updated'),
  243. 'help' => t('The date the template was last updated on.'),
  244. 'field' => [
  245. 'handler' => 'views_handler_field_date',
  246. 'click sortable' => TRUE,
  247. ],
  248. 'sort' => [
  249. 'handler' => 'views_handler_sort_date',
  250. ],
  251. 'filter' => [
  252. 'handler' => 'views_handler_filter_date',
  253. ],
  254. ];
  255. // Tripal Bulk Loader Constants ***************
  256. $data['tripal_bulk_loader_constants']['table']['group'] = t('Tripal Bulk Loader Constants');
  257. $data['tripal_bulk_loader_constants']['table'] = [
  258. 'field' => 'constant_id',
  259. 'title' => t('Tripal Bulk Loading Job Constants'),
  260. 'help' => t('Constants described for a particular Tripal Bulk Loading Job.'),
  261. ];
  262. $data['tripal_bulk_loader_constants']['table']['join']['tripal_bulk_loader'] = [
  263. 'left_field' => 'nid',
  264. 'field' => 'nid',
  265. ];
  266. $data['tripal_bulk_loader_constants']['group_id'] = [
  267. 'title' => t('Group ID'),
  268. 'help' => t('Constants are grouped together allowing for multiple values for the same field.'),
  269. 'field' => [
  270. 'handler' => 'views_handler_field_numeric',
  271. 'click sortable' => TRUE,
  272. ],
  273. 'filter' => [
  274. 'handler' => 'views_handler_filter_numeric',
  275. ],
  276. 'sort' => [
  277. 'handler' => 'views_handler_sort',
  278. ],
  279. ];
  280. $data['tripal_bulk_loader_constants']['chado_table'] = [
  281. 'title' => t('Chado Table'),
  282. 'help' => t('The table this constant applies to.'),
  283. 'field' => [
  284. 'handler' => 'views_handler_field',
  285. 'click sortable' => TRUE, // This is use by the table display plugin.
  286. ],
  287. 'sort' => [
  288. 'handler' => 'views_handler_sort',
  289. ],
  290. 'filter' => [
  291. 'handler' => 'views_handler_filter_string',
  292. ],
  293. 'argument' => [
  294. 'handler' => 'views_handler_argument_string',
  295. ],
  296. ];
  297. $data['tripal_bulk_loader_constants']['chado_field'] = [
  298. 'title' => t('Chado Field'),
  299. 'help' => t('The field in chado this constant applies to.'),
  300. 'field' => [
  301. 'handler' => 'views_handler_field',
  302. 'click sortable' => TRUE, // This is use by the table display plugin.
  303. ],
  304. 'sort' => [
  305. 'handler' => 'views_handler_sort',
  306. ],
  307. 'filter' => [
  308. 'handler' => 'views_handler_filter_string',
  309. ],
  310. 'argument' => [
  311. 'handler' => 'views_handler_argument_string',
  312. ],
  313. ];
  314. $data['tripal_bulk_loader_constants']['record_id'] = [
  315. 'title' => t('Record ID'),
  316. 'help' => t('Unique identifier of a record within the template.'),
  317. 'field' => [
  318. 'handler' => 'views_handler_field_numeric',
  319. 'click sortable' => TRUE,
  320. ],
  321. 'filter' => [
  322. 'handler' => 'views_handler_filter_numeric',
  323. ],
  324. 'sort' => [
  325. 'handler' => 'views_handler_sort',
  326. ],
  327. ];
  328. $data['tripal_bulk_loader_constants']['field_id'] = [
  329. 'title' => t('Field Index'),
  330. 'help' => t('Unique identifier of a field within a template record.'),
  331. 'field' => [
  332. 'handler' => 'views_handler_field_numeric',
  333. 'click sortable' => TRUE,
  334. ],
  335. 'filter' => [
  336. 'handler' => 'views_handler_filter_numeric',
  337. ],
  338. 'sort' => [
  339. 'handler' => 'views_handler_sort',
  340. ],
  341. ];
  342. $data['tripal_bulk_loader_constants']['value'] = [
  343. 'title' => t('Value'),
  344. 'help' => t('The value of the constant.'),
  345. 'field' => [
  346. 'handler' => 'views_handler_field',
  347. 'click sortable' => TRUE, // This is use by the table display plugin.
  348. ],
  349. 'sort' => [
  350. 'handler' => 'views_handler_sort',
  351. ],
  352. 'filter' => [
  353. 'handler' => 'views_handler_filter_string',
  354. ],
  355. 'argument' => [
  356. 'handler' => 'views_handler_argument_string',
  357. ],
  358. ];
  359. return $data;
  360. }