cvterm.views.inc 4.4 KB

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