cvterm.views.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. function retrieve_cvterm_views_data() {
  26. // Basic table definition
  27. $data['cvterm']['table']['group'] = 'Chado CV Terms';
  28. $data['cvterm']['table']['base'] = array(
  29. 'field' => 'cvterm_id',
  30. 'title' => 'Chado CV Terms (Controlled Vocabulary)',
  31. 'help' => 'Controlled Vocabularies (CVs) are the main way Chado controls content.',
  32. 'database' => 'chado'
  33. );
  34. // Define relationships between this table and others
  35. $data['cvterm']['table']['join'] = array(
  36. 'feature' => array(
  37. 'left_field' => 'type_id',
  38. 'field' => 'cvterm_id',
  39. ),
  40. 'library' => array(
  41. 'left_field' => 'type_id',
  42. 'field' => 'cvterm_id',
  43. ),
  44. 'stock' => array(
  45. 'left_field' => 'type_id',
  46. 'field' => 'cvterm_id',
  47. ),
  48. 'nd_reagent' => array(
  49. 'left_field' => 'type_id',
  50. 'field' => 'cvterm_id',
  51. ),
  52. );
  53. // Table Field Definitions----------------------
  54. // Field: cvterm_id (primary key)
  55. $data['cvterm']['cvterm_id'] = array(
  56. 'title' => t('CV Term ID'),
  57. 'help' => t('The primary kep of controlled vocabulary terms.'),
  58. 'field' => array(
  59. 'handler' => 'views_handler_field_numeric',
  60. 'click sortable' => TRUE,
  61. ),
  62. 'filter' => array(
  63. 'handler' => 'views_handler_filter_numeric',
  64. ),
  65. 'sort' => array(
  66. 'handler' => 'views_handler_sort',
  67. ),
  68. );
  69. //Field: cv_id (foreign key: cv)
  70. // join between cv table and this one in cv.views.inc
  71. // Field: Name (varchar 1024)
  72. $data['cvterm']['name'] = array(
  73. 'title' => 'Name',
  74. 'help' => 'The term name',
  75. 'field' => array(
  76. 'handler' => 'views_handler_field',
  77. 'click sortable' => TRUE,
  78. ),
  79. 'sort' => array(
  80. 'handler' => 'views_handler_sort',
  81. ),
  82. 'filter' => array(
  83. 'handler' => 'views_handler_filter_chado_select_string',
  84. ),
  85. 'argument' => array(
  86. 'handler' => 'views_handler_argument_string',
  87. ),
  88. );
  89. // Field: Definition (text)
  90. $data['cvterm']['definition'] = array(
  91. 'title' => 'Definition',
  92. 'help' => 'A definition of this term',
  93. 'field' => array(
  94. 'handler' => 'views_handler_field',
  95. 'click sortable' => TRUE,
  96. ),
  97. 'filter' => array(
  98. 'handler' => 'views_handler_filter_string',
  99. ),
  100. 'argument' => array(
  101. 'handler' => 'views_handler_argument_string',
  102. ),
  103. );
  104. // Field: dbxref_id (foreign key: dbxref)
  105. // join between dbxref table and this one in tripal_db/views/dbxref.views.inc
  106. // Field: is_obsolete (integer: 1/0)
  107. $data['cvterm']['is_obsolete'] = array(
  108. 'title' => 'Is Obsolete',
  109. 'help' => 'Whether this term is obsolete or not.',
  110. 'field' => array(
  111. 'handler' => 'views_handler_field_boolean',
  112. 'click sortable' => TRUE,
  113. ),
  114. 'filter' => array(
  115. 'handler' => 'views_handler_filter_boolean_operator',
  116. 'label' => t('Is Obsolete?'),
  117. 'type' => 'yes-no',
  118. ),
  119. 'sort' => array(
  120. 'handler' => 'views_handler_sort',
  121. ),
  122. );
  123. // Field: is_relationshiptype (integer: 1/0)
  124. $data['cvterm']['is_relationshiptype'] = array(
  125. 'title' => 'Is Relationship',
  126. 'help' => 'Whether this term describes a relationship or not.',
  127. 'field' => array(
  128. 'handler' => 'views_handler_field_boolean',
  129. 'click sortable' => TRUE,
  130. ),
  131. 'filter' => array(
  132. 'handler' => 'views_handler_filter_boolean_operator',
  133. 'label' => t('Published'),
  134. 'type' => 'yes-no',
  135. ),
  136. 'sort' => array(
  137. 'handler' => 'views_handler_sort',
  138. ),
  139. );
  140. return $data;
  141. }