chado_linking.TMP.inc 12 KB

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