dbxref.views.inc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. function retrieve_dbxref_views_data() {
  22. // Basic table definition
  23. $data['dbxref']['table']['group'] = 'Chado Database Reference';
  24. $data['dbxref']['table']['base'] = array(
  25. 'field' => 'dbxref_id',
  26. 'title' => 'Chado Database Reference',
  27. 'help' => 'A Reference to another database. Allows easy linking between becords in one database to those in another.',
  28. 'database' => 'chado'
  29. );
  30. // Define relationships between this table and others
  31. $data['dbxref']['table']['join'] = array(
  32. 'cvterm' => array(
  33. 'left_field' => 'dbxref_id',
  34. 'field' => 'dbxref_id',
  35. ),
  36. 'feature' => array(
  37. 'left_field' => 'dbxref_id',
  38. 'field' => 'dbxref_id',
  39. ),
  40. 'stock' => array(
  41. 'left_field' => 'dbxref_id',
  42. 'field' => 'dbxref_id',
  43. ),
  44. );
  45. // Table Field Definitions----------------------
  46. // Field: dbxref_id (primary key)
  47. $data['dbxref']['dbxref_id'] = array(
  48. 'title' => t('Database Reference ID'),
  49. 'help' => t('The primary key of Database References.'),
  50. 'field' => array(
  51. 'handler' => 'views_handler_field_numeric',
  52. 'click sortable' => TRUE,
  53. ),
  54. 'filter' => array(
  55. 'handler' => 'views_handler_filter_numeric',
  56. ),
  57. 'sort' => array(
  58. 'handler' => 'views_handler_sort',
  59. ),
  60. );
  61. //Field: cv_id (foreign key: cv)
  62. // join between cv table and this one in cv.views.inc
  63. // Field: accession (varchar 255)
  64. $data['dbxref']['accession'] = array(
  65. 'title' => 'Accession',
  66. 'help' => 'The accession from the database.',
  67. 'field' => array(
  68. 'handler' => 'views_handler_field',
  69. 'click sortable' => TRUE,
  70. ),
  71. 'sort' => array(
  72. 'handler' => 'views_handler_sort',
  73. ),
  74. 'filter' => array(
  75. 'handler' => 'views_handler_filter_string',
  76. ),
  77. 'argument' => array(
  78. 'handler' => 'views_handler_argument_string',
  79. ),
  80. );
  81. // Field: version (varchar 255)
  82. $data['dbxref']['version'] = array(
  83. 'title' => 'Version',
  84. 'help' => 'The version of the database reference.',
  85. 'field' => array(
  86. 'handler' => 'views_handler_field',
  87. 'click sortable' => TRUE,
  88. ),
  89. 'sort' => array(
  90. 'handler' => 'views_handler_sort',
  91. ),
  92. 'filter' => array(
  93. 'handler' => 'views_handler_filter_string',
  94. ),
  95. 'argument' => array(
  96. 'handler' => 'views_handler_argument_string',
  97. ),
  98. );
  99. // Field: description (text)
  100. $data['dbxref']['description'] = array(
  101. 'title' => 'Description',
  102. 'help' => 'a description of the database reference.',
  103. 'field' => array(
  104. 'handler' => 'views_handler_field',
  105. 'click sortable' => TRUE,
  106. ),
  107. 'filter' => array(
  108. 'handler' => 'views_handler_filter_string',
  109. ),
  110. 'argument' => array(
  111. 'handler' => 'views_handler_argument_string',
  112. ),
  113. );
  114. // Calculated Field: Accession Link
  115. // uses custom field handler to pull db urlprefix and concatenate with accession
  116. // solves the problem of not being able to add urlprefix to tables which only
  117. // join to dbxref table (not db)
  118. $data['dbxref']['accession_link'] = array(
  119. 'title' => 'Accession Link',
  120. 'help' => 'Provides a link to the record in the external database.',
  121. 'field' => array(
  122. 'handler' => 'views_handler_field_dbxref_accession_link',
  123. 'click sortable' => TRUE,
  124. ),
  125. 'sort' => array(
  126. 'handler' => 'views_handler_sort',
  127. ),
  128. 'filter' => array(
  129. 'handler' => 'views_handler_filter_string',
  130. ),
  131. 'argument' => array(
  132. 'handler' => 'views_handler_argument_string',
  133. ),
  134. );
  135. return $data;
  136. }