tripal_bulk_loader.views.inc 12 KB

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