cvterm.views.inc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /**
  3. * @file
  4. * Purpose: this function returns the portion of the data array
  5. * which describes the cv table, it's fields and any joins between it and other tables
  6. * @see tripal_cv_views_data()
  7. *
  8. * BASE TABLE: cvterm
  9. * @code
  10. * create table cvterm (
  11. * cvterm_id serial not null,
  12. * primary key (cvterm_id),
  13. * cv_id int not null,
  14. * foreign key (cv_id) references cv (cv_id) on delete cascade INITIALLY DEFERRED,
  15. * name varchar(1024) not null,
  16. * definition text,
  17. * dbxref_id int not null,
  18. * foreign key (dbxref_id) references dbxref (dbxref_id) on delete set null INITIALLY DEFERRED,
  19. * is_obsolete int not null default 0,
  20. * is_relationshiptype int not null default 0,
  21. * constraint cvterm_c1 unique (name,cv_id,is_obsolete),
  22. * constraint cvterm_c2 unique (dbxref_id)
  23. * );
  24. * @endcode
  25. *
  26. * @ingroup tripal_cv_views
  27. */
  28. function retrieve_cvterm_views_data() {
  29. // Basic table definition
  30. $data['cvterm']['table']['group'] = 'Chado CV Terms';
  31. $data['cvterm']['table']['base'] = array(
  32. 'field' => 'cvterm_id',
  33. 'title' => 'Chado CV Terms (Controlled Vocabulary)',
  34. 'help' => 'Controlled Vocabularies (CVs) are the main way Chado controls content.',
  35. 'database' => 'chado'
  36. );
  37. // Define relationships between this table and others
  38. $data['cvterm']['table']['join'] = array(
  39. 'feature' => array(
  40. 'left_field' => 'type_id',
  41. 'field' => 'cvterm_id',
  42. ),
  43. 'library' => array(
  44. 'left_field' => 'type_id',
  45. 'field' => 'cvterm_id',
  46. ),
  47. 'stock' => array(
  48. 'left_field' => 'type_id',
  49. 'field' => 'cvterm_id',
  50. ),
  51. 'nd_reagent' => array(
  52. 'left_field' => 'type_id',
  53. 'field' => 'cvterm_id',
  54. ),
  55. );
  56. // Table Field Definitions----------------------
  57. // Field: cvterm_id (primary key)
  58. $data['cvterm']['cvterm_id'] = array(
  59. 'title' => t('CV Term ID'),
  60. 'help' => t('The primary kep of controlled vocabulary terms.'),
  61. 'field' => array(
  62. 'handler' => 'views_handler_field_numeric',
  63. 'click sortable' => TRUE,
  64. ),
  65. 'filter' => array(
  66. 'handler' => 'views_handler_filter_numeric',
  67. ),
  68. 'sort' => array(
  69. 'handler' => 'views_handler_sort',
  70. ),
  71. );
  72. //Field: cv_id (foreign key: cv)
  73. // join between cv table and this one in cv.views.inc
  74. // Field: Name (varchar 1024)
  75. $data['cvterm']['name'] = array(
  76. 'title' => 'Name',
  77. 'help' => 'The term name',
  78. 'field' => array(
  79. 'handler' => 'views_handler_field',
  80. 'click sortable' => TRUE,
  81. ),
  82. 'sort' => array(
  83. 'handler' => 'views_handler_sort',
  84. ),
  85. 'filter' => array(
  86. 'handler' => 'views_handler_filter_string',
  87. ),
  88. 'argument' => array(
  89. 'handler' => 'views_handler_argument_string',
  90. ),
  91. );
  92. // Field: Definition (text)
  93. $data['cvterm']['definition'] = array(
  94. 'title' => 'Definition',
  95. 'help' => 'A definition of this term',
  96. 'field' => array(
  97. 'handler' => 'views_handler_field',
  98. 'click sortable' => TRUE,
  99. ),
  100. 'filter' => array(
  101. 'handler' => 'views_handler_filter_string',
  102. ),
  103. 'argument' => array(
  104. 'handler' => 'views_handler_argument_string',
  105. ),
  106. );
  107. // Field: dbxref_id (foreign key: dbxref)
  108. // join between dbxref table and this one in tripal_db/views/dbxref.views.inc
  109. // Field: is_obsolete (integer: 1/0)
  110. $data['cvterm']['is_obsolete'] = array(
  111. 'title' => 'Is Obsolete',
  112. 'help' => 'Whether this term is obsolete or not.',
  113. 'field' => array(
  114. 'handler' => 'views_handler_field_boolean',
  115. 'click sortable' => TRUE,
  116. ),
  117. 'filter' => array(
  118. 'handler' => 'views_handler_filter_string',
  119. 'label' => t('Is Obsolete?'),
  120. 'type' => 'yes-no',
  121. ),
  122. 'sort' => array(
  123. 'handler' => 'views_handler_sort',
  124. ),
  125. );
  126. // Field: is_relationshiptype (integer: 1/0)
  127. $data['cvterm']['is_relationshiptype'] = array(
  128. 'title' => 'Is Relationship',
  129. 'help' => 'Whether this term describes a relationship or not.',
  130. 'field' => array(
  131. 'handler' => 'views_handler_field_boolean',
  132. 'click sortable' => TRUE,
  133. ),
  134. 'filter' => array(
  135. 'handler' => 'views_handler_filter_chado_boolean',
  136. 'label' => t('Is Relationship Type?'),
  137. 'type' => 'yes-no',
  138. ),
  139. 'sort' => array(
  140. 'handler' => 'views_handler_sort',
  141. ),
  142. );
  143. return $data;
  144. }