tripal_views.api.inc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <?php
  2. /**
  3. * @file
  4. * API functions for Tripal Views Integration
  5. */
  6. /**
  7. * Retrieve the views integration setup with the lightest priority for a given table
  8. *
  9. * NOTE: Uses lightest priority (drupal-style) where the range is from -10 to 10
  10. * and -10 is of highest priority.
  11. *
  12. * @param $table_name
  13. * The name of the table to retrieve the setup ID for. This can be either a materialized
  14. * view or a chado table
  15. *
  16. * @return
  17. * On success, the setup_id to use for integration of this table; otherwise FALSE
  18. */
  19. function tripal_views_get_lightest_priority_setup($table_name) {
  20. $sql = "SELECT setup_id FROM {tripal_views} WHERE table_name='%s' ORDER BY priority ASC";
  21. $setup = db_fetch_object(db_query($sql, $table_name));
  22. if ($setup) {
  23. return $setup->setup_id;
  24. }
  25. else {
  26. return FALSE;
  27. }
  28. }
  29. /**
  30. * Check to see if this table already has an integration record with the given priority
  31. *
  32. * @param $table_name
  33. * The name of the table to check for integration
  34. * @param $priority (optional)
  35. * The priority of record to check for
  36. *
  37. * @return
  38. * If the table is already integrated, the setup_id of the existing integration
  39. * record is returned (If priority is not specified this will be the lightest record);
  40. * Otherwise the table is not already integrated and FALSE is returned.
  41. */
  42. function tripal_views_is_integrated($table_name, $priority = NULL) {
  43. if ($priority) {
  44. $sql = "SELECT setup_id FROM {tripal_views} WHERE table_name='%s' AND priority=%d";
  45. $setup = db_fetch_object(db_query($sql, $table_name, $priority));
  46. }
  47. else {
  48. $sql = "SELECT setup_id FROM {tripal_views} WHERE table_name='%s' ORDER BY priority ASC";
  49. $setup = db_fetch_object(db_query($sql, $table_name));
  50. }
  51. if ($setup) {
  52. return $setup->setup_id;
  53. }
  54. else {
  55. return FALSE;
  56. }
  57. }
  58. /**
  59. * Checks if you are dealing with the lightest priority setup for a given table
  60. *
  61. * @param $setup_id
  62. * The ID of the setup to check (is this setup the lightest one?)
  63. * @param $table_name
  64. * The name of the table associated with this setup
  65. *
  66. * @return TRUE is this is the lightest priority; FALSE otherwise
  67. */
  68. function tripal_views_is_lightest_priority_setup($setup_id, $table_name) {
  69. $lightest_priority_setup_id = tripal_views_get_lightest_priority_setup($table_name);
  70. if ($lightest_priority_setup_id == $setup_id) {
  71. return TRUE;
  72. }
  73. else {
  74. return FALSE;
  75. }
  76. }
  77. /**
  78. * Add views integration records into the tripal_views* tables
  79. *
  80. * @param $defn_array
  81. * An array describing the structure and fields of the table
  82. *
  83. * @return
  84. * True/False if completed successfully/not
  85. *
  86. * Example usage (in hook_install()):
  87. * @code
  88. $defn_array = array(
  89. 'table' => 'feature', //tablename or materialized view name
  90. 'name' => 'Sequence Features', // Human readable name
  91. 'type' => 'chado', //either chado or mview depending on tablename
  92. 'description' => 'Create a listing of features.', //description seen when creating a view of this type
  93. 'priority' => 10, //For Base tripal modules: 10; custom modules: 9 to 0;
  94. 'base_table' => TRUE //either TRUE or FALSE depending on whether the current table should show up in the add view list
  95. 'fields' => array(
  96. 'feature_id' => array(
  97. 'name' => 'feature_id', //field name in database
  98. 'title' => 'Feature ID', //human-readable name -seen in Views UI
  99. 'description' => 'This is the unique identifier for features', //help/description seen in Views UI
  100. 'type' => 'int', // the type of field
  101. 'handlers' => array( //possible keys are field, filter, sort, argument, relationship
  102. 'field' => array(
  103. 'name' => 'chado_views_handler_numeric' //name of handler
  104. ),
  105. 'filter' => array( ... ),
  106. ...
  107. ),
  108. 'join' => array( //describe a table that joins to this one via this field
  109. 'table' => 'featureprop', //table to join to
  110. 'field' => 'feature_id', //field in above table (featureprop)
  111. 'handler' => 'views_handler_join_chado_aggregator', //handler to use
  112. ),
  113. )
  114. ),
  115. );
  116. tripal_views_integration_add_entry($defn_array);
  117. * @endcode
  118. */
  119. function tripal_views_integration_add_entry($defn_array) {
  120. $no_errors = TRUE;
  121. // First insert into tripal_views
  122. $view_record = array(
  123. 'table_name' => $defn_array['table'],
  124. 'name' => $defn_array['name'],
  125. 'comment' => $defn_array['description'],
  126. 'priority' => $defn_array['priority'],
  127. 'base_table' => $defn_array['base_table'],
  128. );
  129. if ($defn_array['type'] == 'mview') {
  130. $mview = db_fetch_object(db_query("SELECT mview_id FROM {tripal_mviews} WHERE mv_table='%s'", $defn_array['table']));
  131. $view_record['mview_id'] = $mview->mview_id;
  132. if (!$mview->mview_id) {
  133. return FALSE;
  134. }
  135. }
  136. if ($view_record['name'] && $view_record['comment']) {
  137. if ($defn_array['additional_content']) {
  138. $setup = db_fetch_object(db_query("SELECT * FROM {tripal_views} WHERE table_name='%s' AND priority=%d",$view_record['table_name'], $view_record['priority']));
  139. if (empty($setup->setup_id)) {
  140. $status = drupal_write_record('tripal_views', $view_record);
  141. }
  142. else {
  143. $view_record['setup_id'] = $setup->setup_id;
  144. $status = drupal_write_record('tripal_views', $view_record, 'setup_id');
  145. }
  146. }
  147. else {
  148. $status = drupal_write_record('tripal_views', $view_record);
  149. }
  150. }
  151. else {
  152. $status = FALSE;
  153. drupal_set_message(t('Unable to integrate %table table due to a missing name or comment field.', array('%table' => $defn_array['table'])), 'error');
  154. }
  155. if ($status) {
  156. // Need to update the tripal_views record so base_table can be false
  157. // this is a fix because drupal_write_record() puts in defaults if !isset()
  158. // and a variable is considered not set if it's null!
  159. db_query(
  160. "UPDATE {tripal_views} SET base_table=%d WHERE table_name='%s' AND priority=%d",
  161. $defn_array['base_table'],
  162. $defn_array['table'],
  163. $defn_array['priority']
  164. );
  165. // Insert Field Definitions
  166. foreach ($defn_array['fields'] as $field) {
  167. $field_record = array(
  168. 'setup_id' => $view_record['setup_id'],
  169. 'column_name' => $field['name'],
  170. 'name' => $field['title'],
  171. 'description' => $field['description'],
  172. 'type' => $field['type'],
  173. );
  174. if ($view_record['setup_id'] && $field['name'] && $field['title'] && $field['description'] && $field['type']) {
  175. if ($defn_array['additional_content']) {
  176. $is = db_fetch_object(db_query("SELECT true as present FROM {tripal_views_field} WHERE column_name='%s' AND setup_id=%d",$field_record['column_name'], $field_record['setup_id']));
  177. if (!$is->present) {
  178. $status = drupal_write_record('tripal_views_field', $field_record);
  179. }
  180. else {
  181. $status = drupal_write_record('tripal_views_field', $field_record, array('setup_id', 'column_name'));
  182. }
  183. }
  184. else {
  185. $status = drupal_write_record('tripal_views_field', $field_record);
  186. }
  187. }
  188. else {
  189. drupal_set_message(t('Unable to integrate %name field due to missing required fields.', array('%name' => $field['name'])), 'error');
  190. $status = FALSE;
  191. }
  192. if ($status) {
  193. // Insert Handler Definitions
  194. foreach ($field['handlers'] as $handler_type => $handler) {
  195. $handler_record = array(
  196. 'setup_id' => $view_record['setup_id'],
  197. 'column_name' => $field['name'],
  198. 'handler_type' => $handler_type,
  199. 'handler_name' => $handler['name'],
  200. 'arguments' => serialize($handler)
  201. );
  202. if ($view_record['setup_id'] && $field['name'] && $handler_type && $handler['name'] && $handler) {
  203. $status = drupal_write_record('tripal_views_handlers', $handler_record);
  204. }
  205. else {
  206. $status = FALSE;
  207. }
  208. if (!$status) {
  209. drupal_set_message(t('Unable to integrate %handler_type handler: %handler_name', array('%handler_type' => $handler_type, '%handler_name' => $handler['name'])), 'error');
  210. $no_errors = FALSE;
  211. }
  212. }
  213. // Insert Joins
  214. if (!is_array($field['joins'])) {
  215. $field['joins'] = array();
  216. }
  217. foreach ($field['joins'] as $join) {
  218. $join_record = array(
  219. 'setup_id' => $view_record['setup_id'],
  220. 'base_table' => $defn_array['table'],
  221. 'base_field' => $field['name'],
  222. 'left_table' => $join['table'],
  223. 'left_field' => $join['field'],
  224. );
  225. if (!empty($join['handler'])) {
  226. $join_record['handler'] = $join['handler'];
  227. }
  228. else {
  229. $join_record['handler'] = 'views_join';
  230. }
  231. if ($view_record['setup_id'] && $defn_array['table'] && $field['name'] && $join['table'] && $join['field']) {
  232. $status = drupal_write_record('tripal_views_join', $join_record);
  233. }
  234. else {
  235. $status = FALSE;
  236. }
  237. if (!$status) {
  238. drupal_set_message(
  239. t(
  240. 'Unable to join %left_table.%left_field with %table.%field',
  241. array(
  242. '%left_table' => $join['table'],
  243. '%left_field' => $join['field'],
  244. '%table' => $defn_array['table'],
  245. '%field' => $field['name']
  246. )
  247. ),
  248. 'error'
  249. );
  250. $no_errors = FALSE;
  251. }
  252. }
  253. }
  254. else {
  255. drupal_set_message(t('Unable to integrate %field_name field', array('%field_name' => $field['name'])), 'error');
  256. $no_errors = FALSE;
  257. }
  258. }
  259. }
  260. else {
  261. drupal_set_message(t('Unable to set default tripal views integration'), 'error');
  262. $no_errors = FALSE;
  263. }
  264. return $no_errors;
  265. }
  266. /**
  267. * Export Views integration records
  268. *
  269. * @param $setup_id
  270. * The unique setup id of the tripal views integration
  271. *
  272. * @return
  273. * A views integration definition array as used by tripal_views_integration_add_entry()
  274. */
  275. function tripal_views_integration_export_entry($setup_id) {
  276. // Main setup details
  277. $r = db_fetch_object(db_query("SELECT * FROM {tripal_views} WHERE setup_id=%d", $setup_id));
  278. $defn_array = array(
  279. 'table' => $r->table_name,
  280. 'name' => $r->name,
  281. 'type' => ($r->mview_id) ? 'mview' : 'chado',
  282. 'description' => $r->comment,
  283. 'priority' => $r->priority,
  284. 'base_table' => $r->base_table,
  285. 'fields' => array(),
  286. );
  287. // Add fields
  288. $resource = db_query("SELECT * FROM {tripal_views_field} WHERE setup_id=%d", $setup_id);
  289. while ($r = db_fetch_object($resource)) {
  290. $defn_array['fields'][ $r->column_name ] = array(
  291. 'name' => $r->column_name,
  292. 'title' => $r->name,
  293. 'description' => $r->description,
  294. 'type' => $r->type,
  295. 'handlers' => array(),
  296. 'joins' => array()
  297. );
  298. }
  299. // Add handlers
  300. $resource = db_query("SELECT * FROM {tripal_views_handlers} WHERE setup_id=%d", $setup_id);
  301. while ($r = db_fetch_object($resource)) {
  302. $defn_array['fields'][ $r->column_name ]['handlers'][ $r->handler_type ] = array(
  303. 'name' => $r->handler_name
  304. );
  305. }
  306. // Add joins
  307. $resource = db_query("SELECT * FROM {tripal_views_join} WHERE setup_id=%d", $setup_id);
  308. while ($r = db_fetch_object($resource)) {
  309. $defn_array['fields'][ $r->base_field ]['joins'][ $r->left_table ] = array(
  310. 'table' => $r->left_table,
  311. 'field' => $r->left_field,
  312. 'handler' => $r->handler,
  313. );
  314. }
  315. return $defn_array;
  316. }
  317. /**
  318. * Removes a View Integration Entry
  319. *
  320. * @param $table_name
  321. * The name of the table to remove a views integration entry for
  322. * @param $priority
  323. * The priority of the of views integration entry
  324. *
  325. * @return
  326. * TRUE on Success; FALSE otherwise
  327. */
  328. function tripal_views_integration_remove_entry_by_table_name($table_name, $priority) {
  329. $views = db_fetch_object(db_query(
  330. "SELECT * FROM {tripal_views} WHERE table_name='%s' AND priority=%d",
  331. $table_name,
  332. $priority
  333. ));
  334. if ($views->setup_id) {
  335. tripal_views_integration_remove_entry_by_setup_id($views->setup_id);
  336. return TRUE;
  337. }
  338. else {
  339. return FALSE;
  340. }
  341. }
  342. /**
  343. * Removes a View Integration Entry
  344. *
  345. * @param $setup_id
  346. * The setup ID of the views integration entry to remove
  347. */
  348. function tripal_views_integration_remove_entry_by_setup_id($setup_id) {
  349. db_query('DELETE FROM {tripal_views} WHERE setup_id=%d', $setup_id);
  350. db_query('DELETE FROM {tripal_views_field} WHERE setup_id=%d', $setup_id);
  351. db_query('DELETE FROM {tripal_views_handlers} WHERE setup_id=%d', $setup_id);
  352. db_query('DELETE FROM {tripal_views_join} WHERE setup_id=%d', $setup_id);
  353. }
  354. /**
  355. * Integrate all chado tables in the schema api
  356. */
  357. function tripal_views_integrate_all_chado_tables() {
  358. $tables = tripal_core_get_chado_tables(TRUE);
  359. foreach ($tables as $tablename) {
  360. if (!tripal_views_is_integrated($tablename, 10)) {
  361. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, 10);
  362. if ($table_integration_array) {
  363. tripal_views_integration_add_entry($table_integration_array);
  364. }
  365. }
  366. }
  367. }
  368. /**
  369. * Returns the array needed to integrate a given chado table with views
  370. *
  371. * @param $tablename
  372. * The table to generate the tripal views integration array for
  373. * @return
  374. * The tripal views integration array which is the parameter for
  375. * tripal_views_integration_add_entry($defn_array)
  376. */
  377. function tripal_views_get_integration_array_for_chado_table($table_name, $base_table = TRUE, $priority = 9) {
  378. // Get the schema for this table (via the chado schema api)
  379. $schema = tripal_core_get_chado_table_schema($table_name);
  380. // Base definition array
  381. $defn_array = array(
  382. 'table' => $table_name,
  383. 'type' => 'chado',
  384. 'name' => 'Chado ' . ucwords(str_replace('_', ' ', $table_name)),
  385. 'description' => (!empty($schema['description'])) ? $schema['description'] : ' ',
  386. 'priority' => $priority,
  387. 'base_table' => $base_table,
  388. 'fields' => array(),
  389. );
  390. // Add fields
  391. if (!isset($schema['fields'])) {
  392. watchdog('tripal_views', 'There are no fields defined for %table in the Chado Schema API.', array('%table' => $table_name), WATCHDOG_NOTICE);
  393. return FALSE;
  394. }
  395. foreach ($schema['fields'] as $field_name => $field_schema) {
  396. // Base field definition
  397. if (!empty($field_name) && !empty($field_schema['type'])) {
  398. $defn_array['fields'][$field_name] = array(
  399. 'name' => $field_name,
  400. 'title' => ucwords(str_replace('_', ' ', $field_name)),
  401. 'type' => $field_schema['type'],
  402. 'description' => ($field_schema['description']) ? $field_schema['description'] : ucwords(str_replace('_', ' ', $field_name)),
  403. 'handlers' => array(),
  404. 'joins' => array()
  405. );
  406. // Add handlers based on type
  407. if (preg_match('/^int/', $field_schema['type'])) {
  408. $defn_array['fields'][$field_name]['handlers'] = array(
  409. 'field' => array('name' => 'chado_views_handler_field_numeric'),
  410. 'filter' => array('name' => 'chado_views_handler_filter_numeric'),
  411. 'sort' => array('name' => 'chado_views_handler_sort'),
  412. );
  413. }
  414. elseif (preg_match('/^serial/', $field_schema['type'])) {
  415. $defn_array['fields'][$field_name]['handlers'] = array(
  416. 'field' => array('name' => 'chado_views_handler_field_numeric'),
  417. 'filter' => array('name' => 'chado_views_handler_filter_numeric'),
  418. 'sort' => array('name' => 'chado_views_handler_sort'),
  419. );
  420. $defn_array['fields'][$field_name]['type'] = 'int';
  421. }
  422. elseif (preg_match('/^varchar/', $field_schema['type'])) {
  423. $defn_array['fields'][$field_name]['handlers'] = array(
  424. 'field' => array('name' => 'chado_views_handler_field'),
  425. 'filter' => array('name' => 'chado_views_handler_filter_string'),
  426. 'sort' => array('name' => 'chado_views_handler_sort'),
  427. );
  428. }
  429. elseif (preg_match('/^text/', $field_schema['type'])) {
  430. $defn_array['fields'][$field_name]['handlers'] = array(
  431. 'field' => array('name' => 'chado_views_handler_field'),
  432. 'filter' => array('name' => 'chado_views_handler_filter_string'),
  433. 'sort' => array('name' => 'chado_views_handler_sort'),
  434. );
  435. }
  436. elseif (preg_match('/^boolean/', $field_schema['type'])) {
  437. $defn_array['fields'][$field_name]['handlers'] = array(
  438. 'field' => array('name' => 'chado_views_handler_field_boolean'),
  439. 'filter' => array('name' => 'chado_views_handler_filter_boolean_operator'),
  440. 'sort' => array('name' => 'chado_views_handler_sort'),
  441. );
  442. }
  443. elseif (preg_match('/^datetime/', $field_schema['type'])) {
  444. $defn_array['fields'][$field_name]['handlers'] = array(
  445. 'field' => array('name' => 'chado_views_handler_field_date'),
  446. 'filter' => array('name' => 'chado_views_handler_filter_date'),
  447. 'sort' => array('name' => 'views_handler_sort_date'),
  448. );
  449. }
  450. else {
  451. $defn_array['fields'][$field_name]['handlers'] = array(
  452. 'field' => array('name' => 'chado_views_handler_field'),
  453. 'filter' => array('name' => 'chado_views_handler_filter_string'),
  454. 'sort' => array('name' => 'chado_views_handler_sort'),
  455. );
  456. }
  457. // Specify specialty handlers
  458. if ($field_name == 'type_id' OR $field_name == 'cvterm_id') {
  459. $defn_array['fields'][$field_name]['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_cvterm';
  460. }
  461. }
  462. }
  463. // Add Joins & Relationship Handlers to fields
  464. if (!isset($schema['foreign keys'])) {
  465. $schema['foreign keys'] = array();
  466. watchdog('tripal_views', 'There are no foreign keys defined for %table in the Chado Schema API.', array('%table' => $table_name), WATCHDOG_WARNING);
  467. }
  468. foreach ($schema['foreign keys'] as $foreign_key_schema) {
  469. foreach ($foreign_key_schema['columns'] as $left_field => $right_field) {
  470. // Join
  471. $defn_array['fields'][$left_field]['joins'][ $foreign_key_schema['table'] ] = array(
  472. 'table' => $foreign_key_schema['table'],
  473. 'field' => $right_field,
  474. 'handler' => 'views_handler_join_chado_aggregator'
  475. );
  476. // Relationship Handler
  477. $defn_array['fields'][$left_field]['handlers']['relationship'] = array(
  478. 'name' => 'chado_views_handler_relationship',
  479. 'base' => $foreign_key_schema['table'],
  480. 'base field' => $right_field,
  481. 'label' => $table_name . ' ' . $left_field . ' to ' . $foreign_key_schema['table'] . ' ' . $right_field
  482. );
  483. }
  484. }
  485. return $defn_array;
  486. }
  487. /**
  488. * Adds the joins necessary to link a chado table to it's node counterpart
  489. *
  490. * @param &$defn_array
  491. * The current definition array for a given table
  492. */
  493. function tripal_views_add_node_relationship_to_chado_table_integration($defn_array) {
  494. $integrations[$defn_array['table']] = $defn_array;
  495. $primary_key = $defn_array['table'] . '_id';
  496. $chado_linking = 'chado_' . $defn_array['table'];
  497. // Add table.primary_key => chado_table.primary key join to $defn_array
  498. $integrations[$defn_array['table']]['fields'][$primary_key]['joins'][$chado_linking] = array(
  499. 'table' => $chado_linking,
  500. 'field' => $primary_key,
  501. );
  502. // Create chado_table defn_array
  503. $integrations[$chado_linking] = array(
  504. 'table' => $chado_linking,
  505. 'type' => 'drupal',
  506. 'name' => 'Chado ' . $defn_array['table'] . ' Node',
  507. 'description' => 'Links chado content to its drupal node counterpart',
  508. 'priority' => $defn_array['priority'],
  509. 'base_table' => FALSE,
  510. 'fields' => array(
  511. $primary_key => array(
  512. 'name' => $primary_key,
  513. 'title' => ucwords(str_replace('_', ' ', $primary_key)),
  514. 'type' => 'int',
  515. 'description' => 'The primary key of the chado ' . $defn_array['table'] . ' table',
  516. 'handlers' => array(),
  517. 'joins' => array(
  518. $defn_array['table'] => array(
  519. 'table' => $defn_array['table'],
  520. 'field' => $primary_key,
  521. )
  522. ),
  523. ),
  524. 'nid' => array(
  525. 'name' => 'nid',
  526. 'title' => 'Node ID',
  527. 'type' => 'int',
  528. 'description' => 'Link ' . ucfirst($defn_array['table']) . ' to it\'s node',
  529. 'handlers' => array(
  530. 'relationship' => array(
  531. 'name' => 'chado_views_handler_relationship_to_node',
  532. 'title' => ucfirst($defn_array['table']) . ' to Node',
  533. 'label' => ucfirst($defn_array['table']) . ' to Node',
  534. 'base table' => $defn_array['table'],
  535. 'base field' => $primary_key
  536. )
  537. ),
  538. 'joins' => array(
  539. 'node' => array(
  540. 'table' => 'node',
  541. 'field' => 'nid',
  542. ),
  543. ),
  544. )
  545. ),
  546. );
  547. // Create node defn_array
  548. $integrations['node'] = array(
  549. 'table' => 'node',
  550. 'name' => 'Node',
  551. 'description' => 'Primary Drupal Content',
  552. 'priority' => $defn_array['priority'],
  553. 'additional_content' => TRUE, // Allows multiple modules to add to the node setup
  554. 'fields' => array(
  555. 'nid' => array(
  556. 'name' => 'nid',
  557. 'title' => 'Node ID',
  558. 'type' => 'int',
  559. 'description' => 'the primary key of the drupal node table',
  560. 'handlers' => array(),
  561. 'joins' => array(
  562. $defn_array['table'] => array(
  563. 'table' => $defn_array['table'],
  564. 'field' => 'nid',
  565. ),
  566. $chado_linking => array(
  567. 'table' => $chado_linking,
  568. 'field' => 'nid',
  569. ),
  570. ),
  571. ),
  572. ),
  573. );
  574. return $integrations;
  575. }