cvterm.views.inc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. );
  49. // Table Field Definitions----------------------
  50. // Field: cvterm_id (primary key)
  51. // mentioned as index above but not displayable in a view
  52. //Field: cv_id (foreign key: cv)
  53. // join between cv table and this one in cv.views.inc
  54. // Field: Name (varchar 1024)
  55. $data['cvterm']['name'] = array(
  56. 'title' => 'Name',
  57. 'help' => 'The term name',
  58. 'field' => array(
  59. 'handler' => 'views_handler_field',
  60. 'click sortable' => TRUE,
  61. ),
  62. 'sort' => array(
  63. 'handler' => 'views_handler_sort',
  64. ),
  65. 'filter' => array(
  66. 'handler' => 'views_handler_filter_string',
  67. ),
  68. 'argument' => array(
  69. 'handler' => 'views_handler_argument_string',
  70. ),
  71. );
  72. // Field: Definition (text)
  73. $data['cvterm']['definition'] = array(
  74. 'title' => 'Definition',
  75. 'help' => 'A definition of this term',
  76. 'field' => array(
  77. 'handler' => 'views_handler_field',
  78. 'click sortable' => TRUE,
  79. ),
  80. 'sort' => array(
  81. 'handler' => 'views_handler_sort',
  82. ),
  83. 'filter' => array(
  84. 'handler' => 'views_handler_filter_string',
  85. ),
  86. 'argument' => array(
  87. 'handler' => 'views_handler_argument_string',
  88. ),
  89. );
  90. // Field: dbxref_id (foreign key: dbxref)
  91. // join between dbxref table and this one in tripal_db/views/dbxref.views.inc
  92. // Field: is_obsolete (integer: 1/0)
  93. $data['cvterm']['is_obsolete'] = array(
  94. 'title' => 'Is Obsolete',
  95. 'help' => 'Whether this term is obsolete or not.',
  96. 'field' => array(
  97. 'handler' => 'views_handler_field_boolean',
  98. 'click sortable' => TRUE,
  99. ),
  100. 'filter' => array(
  101. 'handler' => 'views_handler_filter_boolean_operator',
  102. 'label' => t('Is Obsolete?'),
  103. 'type' => 'yes-no',
  104. ),
  105. 'sort' => array(
  106. 'handler' => 'views_handler_sort',
  107. ),
  108. );
  109. // Field: is_relationshiptype (integer: 1/0)
  110. $data['cvterm']['is_relationshiptype'] = array(
  111. 'title' => 'Is Relationship',
  112. 'help' => 'Whether this term describes a relationship or not.',
  113. 'field' => array(
  114. 'handler' => 'views_handler_field_boolean',
  115. 'click sortable' => TRUE,
  116. ),
  117. 'filter' => array(
  118. 'handler' => 'views_handler_filter_boolean_operator',
  119. 'label' => t('Published'),
  120. 'type' => 'yes-no',
  121. ),
  122. 'sort' => array(
  123. 'handler' => 'views_handler_sort',
  124. ),
  125. );
  126. return $data;
  127. }