dbxref.views.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /**
  3. * Purpose: this function returns the portion of the data array
  4. * which describes the db table, it's fields and any joins between it and other tables
  5. * @see tripal_db_views_data() --in tripal_db.views.inc
  6. *
  7. * BASE TABLE: dbxref
  8. * @code
  9. * create table dbxref (
  10. * dbxref_id serial not null,
  11. * primary key (dbxref_id),
  12. * db_id int not null,
  13. * foreign key (db_id) references db (db_id) on delete cascade INITIALLY DEFERRED,
  14. * accession varchar(255) not null,
  15. * version varchar(255) not null default '',
  16. * description text,
  17. * constraint dbxref_c1 unique (db_id,accession,version)
  18. * );
  19. * @endcode
  20. *
  21. * @ingroup tripal_db_views
  22. */
  23. function retrieve_dbxref_views_data() {
  24. // Basic table definition
  25. $data['dbxref']['table']['group'] = 'Chado Database Reference';
  26. $data['dbxref']['table']['base'] = array(
  27. 'field' => 'dbxref_id',
  28. 'title' => 'Chado Database Reference',
  29. 'help' => 'A Reference to another database. Allows easy linking between becords in one database to those in another.',
  30. 'database' => 'chado'
  31. );
  32. // Define relationships between this table and others
  33. $data['dbxref']['table']['join'] = array(
  34. 'cvterm' => array(
  35. 'left_field' => 'dbxref_id',
  36. 'field' => 'dbxref_id',
  37. ),
  38. 'feature' => array(
  39. 'left_field' => 'dbxref_id',
  40. 'field' => 'dbxref_id',
  41. ),
  42. 'stock' => array(
  43. 'left_field' => 'dbxref_id',
  44. 'field' => 'dbxref_id',
  45. ),
  46. );
  47. // Table Field Definitions----------------------
  48. // Field: dbxref_id (primary key)
  49. $data['dbxref']['dbxref_id'] = array(
  50. 'title' => t('Database Reference ID'),
  51. 'help' => t('The primary key of Database References.'),
  52. 'field' => array(
  53. 'handler' => 'views_handler_field_numeric',
  54. 'click sortable' => TRUE,
  55. ),
  56. 'filter' => array(
  57. 'handler' => 'views_handler_filter_numeric',
  58. ),
  59. 'sort' => array(
  60. 'handler' => 'views_handler_sort',
  61. ),
  62. );
  63. //Field: cv_id (foreign key: cv)
  64. // join between cv table and this one in cv.views.inc
  65. // Field: accession (varchar 255)
  66. $data['dbxref']['accession'] = array(
  67. 'title' => 'Accession',
  68. 'help' => 'The accession from the database.',
  69. 'field' => array(
  70. 'handler' => 'views_handler_field',
  71. 'click sortable' => TRUE,
  72. ),
  73. 'sort' => array(
  74. 'handler' => 'views_handler_sort',
  75. ),
  76. 'filter' => array(
  77. 'handler' => 'views_handler_filter_string',
  78. ),
  79. 'argument' => array(
  80. 'handler' => 'views_handler_argument_string',
  81. ),
  82. );
  83. // Field: version (varchar 255)
  84. $data['dbxref']['version'] = array(
  85. 'title' => 'Version',
  86. 'help' => 'The version of the database reference.',
  87. 'field' => array(
  88. 'handler' => 'views_handler_field',
  89. 'click sortable' => TRUE,
  90. ),
  91. 'sort' => array(
  92. 'handler' => 'views_handler_sort',
  93. ),
  94. 'filter' => array(
  95. 'handler' => 'views_handler_filter_string',
  96. ),
  97. 'argument' => array(
  98. 'handler' => 'views_handler_argument_string',
  99. ),
  100. );
  101. // Field: description (text)
  102. $data['dbxref']['description'] = array(
  103. 'title' => 'Description',
  104. 'help' => 'a description of the database reference.',
  105. 'field' => array(
  106. 'handler' => 'views_handler_field',
  107. 'click sortable' => TRUE,
  108. ),
  109. 'filter' => array(
  110. 'handler' => 'views_handler_filter_string',
  111. ),
  112. 'argument' => array(
  113. 'handler' => 'views_handler_argument_string',
  114. ),
  115. );
  116. // Calculated Field: Accession Link
  117. // uses custom field handler to pull db urlprefix and concatenate with accession
  118. // solves the problem of not being able to add urlprefix to tables which only
  119. // join to dbxref table (not db)
  120. $data['dbxref']['accession_link'] = array(
  121. 'title' => 'Accession Link',
  122. 'help' => 'Provides a link to the record in the external database.',
  123. 'field' => array(
  124. 'handler' => 'views_handler_field_dbxref_accession_link',
  125. 'click sortable' => TRUE,
  126. ),
  127. 'sort' => array(
  128. 'handler' => 'views_handler_sort',
  129. ),
  130. 'filter' => array(
  131. 'handler' => 'views_handler_filter_string',
  132. ),
  133. 'argument' => array(
  134. 'handler' => 'views_handler_argument_string',
  135. ),
  136. );
  137. return $data;
  138. }