dbxref.views.inc 4.2 KB

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