tripal_bulk_loader.views.inc 11 KB

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