tripal_bulk_loader.views.inc 12 KB

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