chado_linking.TMP.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <?php
  2. /**
  3. * @file
  4. * This is a temporary function holding all the old-style views integration
  5. * needed to link the base tables to their node. This will remain to keep things working
  6. * until it has been best determined how to do this via the new tripal_views integration
  7. *
  8. * It's called att the bottom of tripal_views_views_data()
  9. */
  10. function tripal_views_TEMPORARY_chado_linking_data($data) {
  11. global $db_url;
  12. // if the chado database is not local to the drupal database
  13. // then we need to set the database name. This should always
  14. // be 'chado'.
  15. if (is_array($db_url) and array_key_exists('chado', $db_url)) {
  16. // return empty data array b/c if chado is external then no join to the nodetable can be made
  17. return $data;
  18. }
  19. // FEATURE ====================================
  20. if (module_exists('tripal_feature')) {
  21. // Basic table definition
  22. $data['chado_feature']['table'] = array(
  23. 'field' => 'nid',
  24. 'group' => 'Chado Feature'
  25. );
  26. $data['chado_feature']['nid'] = array(
  27. 'title' => t('Feature Node ID'),
  28. 'help' => t('The node ID for this feature'),
  29. 'field' => array(
  30. 'handler' => 'views_handler_field_numeric',
  31. 'click sortable' => TRUE,
  32. ),
  33. 'filter' => array(
  34. 'handler' => 'views_handler_filter_numeric',
  35. ),
  36. 'sort' => array(
  37. 'handler' => 'views_handler_sort',
  38. ),
  39. );
  40. // Note: No joins need to be made from $data['feature']['table']
  41. // Join the chado feature table to feature
  42. $data['chado_feature']['table']['join']['feature'] = array(
  43. 'left_field' => 'feature_id',
  44. 'field' => 'feature_id',
  45. );
  46. // Join the node table to chado feature
  47. $data['node']['table']['join']['chado_feature'] = array(
  48. 'left_field' => 'nid',
  49. 'field' => 'nid',
  50. );
  51. // Join the node table to feature
  52. $data['node']['table']['join']['feature'] = array(
  53. 'left_table' => 'chado_feature',
  54. 'left_field' => 'nid',
  55. 'field' => 'nid',
  56. );
  57. // Add relationship between chado_feature and feature
  58. $data['chado_feature']['feature_nid'] = array(
  59. 'group' => 'Feature',
  60. 'title' => 'Feature Node',
  61. 'help' => 'Links Chado Feature Fields/Data to the Nodes in the current View.',
  62. 'real field' => 'feature_id',
  63. 'relationship' => array(
  64. 'handler' => 'views_handler_relationship',
  65. 'title' => t('Chado => Feature'),
  66. 'label' => t('Chado => Feature'),
  67. 'real field' => 'feature_id',
  68. 'base' => 'feature',
  69. 'base field' => 'feature_id'
  70. ),
  71. );
  72. // Add node relationship to feature
  73. $data['chado_feature']['feature_chado_nid'] = array(
  74. 'group' => 'Feature',
  75. 'title' => 'Feature Node',
  76. 'help' => 'Links Chado Feature Fields/Data to the Nodes in the current View.',
  77. 'real field' => 'nid',
  78. 'relationship' => array(
  79. 'handler' => 'views_handler_relationship',
  80. 'title' => t('Chado => Node'),
  81. 'label' => t('Chado => Node'),
  82. 'real field' => 'nid',
  83. 'base' => 'node',
  84. 'base field' => 'nid'
  85. ),
  86. );
  87. }
  88. // ANALYSIS ===================================
  89. if (module_exists('tripal_analysis')) {
  90. // Basic table definition
  91. $data['chado_analysis']['table'] = array(
  92. 'field' => 'nid',
  93. 'group' => 'Chado Analysis'
  94. );
  95. $data['chado_analysis']['nid'] = array(
  96. 'title' => t('Analysis Node ID'),
  97. 'help' => t('The node ID for this analysis'),
  98. 'field' => array(
  99. 'handler' => 'views_handler_field_numeric',
  100. 'click sortable' => TRUE,
  101. ),
  102. 'filter' => array(
  103. 'handler' => 'views_handler_filter_numeric',
  104. ),
  105. 'sort' => array(
  106. 'handler' => 'views_handler_sort',
  107. ),
  108. );
  109. // Note: No joins need to be made from $data['analysis']['table']
  110. // Join the chado analysis table to analysis
  111. $data['chado_analysis']['table']['join']['analysis'] = array(
  112. 'left_field' => 'analysis_id',
  113. 'field' => 'analysis_id',
  114. );
  115. // Join the node table to chado analysis
  116. $data['node']['table']['join']['chado_analysis'] = array(
  117. 'left_field' => 'nid',
  118. 'field' => 'nid',
  119. );
  120. // Join the node table to analysis
  121. $data['node']['table']['join']['analysis'] = array(
  122. 'left_table' => 'chado_analysis',
  123. 'left_field' => 'nid',
  124. 'field' => 'nid',
  125. );
  126. // Add relationship between chado_analysis and analysis
  127. $data['chado_analysis']['analysis_nid'] = array(
  128. 'group' => 'Analysis',
  129. 'title' => 'Analysis Node',
  130. 'help' => 'Links Chado Analysis Fields/Data to the Nodes in the current View.',
  131. 'real field' => 'analysis_id',
  132. 'relationship' => array(
  133. 'handler' => 'views_handler_relationship',
  134. 'title' => t('Chado => Analysis'),
  135. 'label' => t('Chado => Analysis'),
  136. 'real field' => 'analysis_id',
  137. 'base' => 'analysis',
  138. 'base field' => 'analysis_id'
  139. ),
  140. );
  141. // Add node relationship to analysis
  142. $data['chado_analysis']['analysis_chado_nid'] = array(
  143. 'group' => 'Analysis',
  144. 'title' => 'Analysis Node',
  145. 'help' => 'Links Chado Analysis Fields/Data to the Nodes in the current View.',
  146. 'real field' => 'nid',
  147. 'relationship' => array(
  148. 'handler' => 'views_handler_relationship',
  149. 'title' => t('Chado => Node'),
  150. 'label' => t('Chado => Node'),
  151. 'real field' => 'nid',
  152. 'base' => 'node',
  153. 'base field' => 'nid'
  154. ),
  155. );
  156. }
  157. // ORGANISM ===================================
  158. if (module_exists('tripal_organism')) {
  159. // Basic table definition
  160. $data['chado_organism']['table'] = array(
  161. 'field' => 'nid',
  162. 'group' => 'Chado Organism'
  163. );
  164. $data['chado_organism']['nid'] = array(
  165. 'title' => t('Organism Node ID'),
  166. 'help' => t('The node ID for this organism'),
  167. 'field' => array(
  168. 'handler' => 'views_handler_field_numeric',
  169. 'click sortable' => TRUE,
  170. ),
  171. 'filter' => array(
  172. 'handler' => 'views_handler_filter_numeric',
  173. ),
  174. 'sort' => array(
  175. 'handler' => 'views_handler_sort',
  176. ),
  177. );
  178. // Note: No joins need to be made from $data['organism']['table']
  179. // Join the chado organism table to organism
  180. $data['chado_organism']['table']['join']['organism'] = array(
  181. 'left_field' => 'organism_id',
  182. 'field' => 'organism_id',
  183. );
  184. // Join the node table to chado organism
  185. $data['node']['table']['join']['chado_organism'] = array(
  186. 'left_field' => 'nid',
  187. 'field' => 'nid',
  188. );
  189. // Join the node table to organism
  190. $data['node']['table']['join']['organism'] = array(
  191. 'left_table' => 'chado_organism',
  192. 'left_field' => 'nid',
  193. 'field' => 'nid',
  194. );
  195. // Add relationship between chado_organism and organism
  196. $data['chado_organism']['organism_id'] = array(
  197. 'group' => 'Organism',
  198. 'title' => 'Organism Node',
  199. 'help' => 'Links Chado Organism Fields/Data to the Nodes in the current View.',
  200. 'real field' => 'organism_id',
  201. 'relationship' => array(
  202. 'handler' => 'views_handler_relationship',
  203. 'title' => t('Chado => Organism'),
  204. 'label' => t('Chado => Organism'),
  205. 'real field' => 'organism_id',
  206. 'base' => 'organism',
  207. 'base field' => 'organism_id'
  208. ),
  209. );
  210. /*
  211. // Add node relationship to organism
  212. $data['chado_organism']['nid'] = array(
  213. 'group' => 'Organism',
  214. 'title' => 'Organism Node',
  215. 'help' => 'Links Chado Organism Fields/Data to the Nodes in the current View.',
  216. 'real field' => 'nid',
  217. 'relationship' => array(
  218. 'handler' => 'views_handler_relationship',
  219. 'title' => t('Chado => Node'),
  220. 'label' => t('Chado => Node'),
  221. 'real field' => 'nid',
  222. 'base' => 'node',
  223. 'base field' => 'nid'
  224. ),
  225. );
  226. */
  227. }
  228. // LIBRARY ====================================
  229. if (module_exists('tripal_library')) {
  230. // Basic table definition
  231. $data['chado_library']['table'] = array(
  232. 'field' => 'nid',
  233. 'group' => 'Chado Library'
  234. );
  235. $data['chado_library']['nid'] = array(
  236. 'title' => t('Library Node ID'),
  237. 'help' => t('The node ID for this library'),
  238. 'field' => array(
  239. 'handler' => 'views_handler_field_numeric',
  240. 'click sortable' => TRUE,
  241. ),
  242. 'filter' => array(
  243. 'handler' => 'views_handler_filter_numeric',
  244. ),
  245. 'sort' => array(
  246. 'handler' => 'views_handler_sort',
  247. ),
  248. );
  249. // Note: No joins need to be made from $data['library']['table']
  250. // Join the chado library table to library
  251. $data['chado_library']['table']['join']['library'] = array(
  252. 'left_field' => 'library_id',
  253. 'field' => 'library_id',
  254. );
  255. // Join the node table to chado library
  256. $data['node']['table']['join']['chado_library'] = array(
  257. 'left_field' => 'nid',
  258. 'field' => 'nid',
  259. );
  260. // Join the node table to library
  261. $data['node']['table']['join']['library'] = array(
  262. 'left_table' => 'chado_library',
  263. 'left_field' => 'nid',
  264. 'field' => 'nid',
  265. );
  266. // Add relationship between chado_library and library
  267. $data['chado_library']['library_nid'] = array(
  268. 'group' => 'Library',
  269. 'title' => 'Library Node',
  270. 'help' => 'Links Chado Library Fields/Data to the Nodes in the current View.',
  271. 'real field' => 'library_id',
  272. 'relationship' => array(
  273. 'handler' => 'views_handler_relationship',
  274. 'title' => t('Chado => Library'),
  275. 'label' => t('Chado => Library'),
  276. 'real field' => 'library_id',
  277. 'base' => 'library',
  278. 'base field' => 'library_id'
  279. ),
  280. );
  281. // Add node relationship to library
  282. $data['chado_library']['library_chado_nid'] = array(
  283. 'group' => 'Library',
  284. 'title' => 'Library Node',
  285. 'help' => 'Links Chado Library Fields/Data to the Nodes in the current View.',
  286. 'real field' => 'nid',
  287. 'relationship' => array(
  288. 'handler' => 'views_handler_relationship',
  289. 'title' => t('Chado => Node'),
  290. 'label' => t('Chado => Node'),
  291. 'real field' => 'nid',
  292. 'base' => 'node',
  293. 'base field' => 'nid'
  294. ),
  295. );
  296. }
  297. // STOCK ======================================
  298. if (module_exists('tripal_stock')) {
  299. // Basic table definition
  300. $data['chado_stock']['table'] = array(
  301. 'field' => 'stock_id',
  302. 'group' => 'Chado Stock',
  303. );
  304. $data['chado_stock']['nid'] = array(
  305. 'title' => t('Stock Node ID'),
  306. 'help' => t('The node ID for this analysis'),
  307. 'field' => array(
  308. 'handler' => 'views_handler_field_numeric',
  309. 'click sortable' => TRUE,
  310. ),
  311. 'filter' => array(
  312. 'handler' => 'views_handler_filter_numeric',
  313. ),
  314. 'sort' => array(
  315. 'handler' => 'views_handler_sort',
  316. ),
  317. );
  318. // Note: No joins need to be made from $data['stock']['table']
  319. // Join the chado stock table to stock
  320. $data['chado_stock']['table']['join']['stock'] = array(
  321. 'left_field' => 'stock_id',
  322. 'field' => 'stock_id',
  323. );
  324. // Join the node table to chado stock
  325. $data['node']['table']['join']['chado_stock'] = array(
  326. 'left_field' => 'nid',
  327. 'field' => 'nid',
  328. );
  329. // Join the node table to stock
  330. $data['node']['table']['join']['stock'] = array(
  331. 'left_table' => 'chado_stock',
  332. 'left_field' => 'nid',
  333. 'field' => 'nid',
  334. );
  335. // Add relationship between chado_stock and stock
  336. $data['chado_stock']['stock_nid'] = array(
  337. 'group' => 'Stock',
  338. 'title' => 'Stock Node',
  339. 'help' => 'Links Chado Stock Fields/Data to the Nodes in the current View.',
  340. 'real field' => 'stock_id',
  341. 'relationship' => array(
  342. 'handler' => 'views_handler_relationship',
  343. 'title' => t('Chado => Stock'),
  344. 'label' => t('Chado => Stock'),
  345. 'real field' => 'stock_id',
  346. 'base' => 'stock',
  347. 'base field' => 'stock_id'
  348. ),
  349. );
  350. // Add node relationship to stock
  351. $data['chado_stock']['stock_chado_nid'] = array(
  352. 'group' => 'Stock',
  353. 'title' => 'Stock Node',
  354. 'help' => 'Links Chado Stock Fields/Data to the Nodes in the current View.',
  355. 'real field' => 'nid',
  356. 'relationship' => array(
  357. 'handler' => 'views_handler_relationship',
  358. 'title' => t('Chado => Node'),
  359. 'label' => t('Chado => Node'),
  360. 'real field' => 'nid',
  361. 'base' => 'node',
  362. 'base field' => 'nid'
  363. ),
  364. );
  365. }
  366. return $data;
  367. }