library.views.inc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. /**
  3. * Purpose: this function returns the portion of the data array
  4. * which describes the library table, it's fields and any joins between it and other tables
  5. * @see tripal_library_views_data() --in tripal_library.views.inc
  6. *
  7. * BASE TABLE: library
  8. * @code
  9. * create table library (
  10. * library_id serial not null,
  11. * primary key (library_id),
  12. * organism_id int not null,
  13. * foreign key (organism_id) references organism (organism_id),
  14. * name varchar(255),
  15. * uniquename text not null,
  16. * type_id int not null,
  17. * foreign key (type_id) references cvterm (cvterm_id),
  18. * is_obsolete int not null default 0,
  19. * timeaccessioned timestamp not null default current_timestamp,
  20. * timelastmodified timestamp not null default current_timestamp,
  21. * constraint library_c1 unique (organism_id,uniquename,type_id)
  22. * );
  23. * @endcode
  24. */
  25. function retrieve_library_views_data() {
  26. // Basic table definition
  27. $data['library']['table']['group'] = 'Chado Library';
  28. $data['library']['table']['base'] = array(
  29. 'field' => 'library_id',
  30. 'title' => 'Chado Library',
  31. 'help' => 'Library existing in the Chado Database',
  32. 'database' => 'chado'
  33. );
  34. // Define relationships between this table and others
  35. $data['library']['table']['join'] = array(
  36. 'library_feature' => array(
  37. 'left_field' => 'library_id',
  38. 'field' => 'library_id',
  39. ),
  40. 'feature' => array(
  41. 'left_table' => 'library_feature',
  42. 'left_field' => 'feature_id',
  43. 'field' => 'library_id',
  44. ),
  45. );
  46. // Describe the joins with the library_feature table
  47. $data['library_feature']['table']['join'] = array(
  48. 'feature' => array(
  49. 'left_field' => 'feature_id',
  50. 'field' => 'feature_id',
  51. ),
  52. 'library' => array(
  53. 'left_field' => 'library_id',
  54. 'field' => 'library_id',
  55. ),
  56. );
  57. // Table Field Definitions----------------------
  58. // Field: library_id (primary key)
  59. $data['library']['library_id'] = array(
  60. 'title' => 'Library ID',
  61. 'help' => 'The primary key of the library table.',
  62. 'field' => array(
  63. 'handler' => 'views_handler_field_numeric',
  64. 'click sortable' => TRUE,
  65. ),
  66. 'filter' => array(
  67. 'handler' => 'views_handler_filter_numeric',
  68. ),
  69. 'sort' => array(
  70. 'handler' => 'views_handler_sort',
  71. ),
  72. );
  73. // Field: Node ID (foreign key)
  74. $data['library']['nid'] = array(
  75. 'title' => 'Node ID',
  76. 'help' => 'The node ID for the current library',
  77. 'field' => array(
  78. 'handler' => 'views_handler_field_library_nid',
  79. ),
  80. );
  81. // Field: Name (varchar 255)
  82. $data['library']['name'] = array(
  83. 'title' => 'Name',
  84. 'help' => 'The human-readable name of the current library.',
  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: Unique name (text)
  100. $data['library']['uniquename'] = array(
  101. 'title' => 'Unique Name',
  102. 'help' => 'The unique name of the current library.',
  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. // Field: Is obsolete (integer 0/1)
  115. $data['library']['is_obsolete'] = array(
  116. 'title' => t('Is Obsolete?'),
  117. 'help' => t('Indicates whether a given library is obsolete or not.'),
  118. 'field' => array(
  119. 'handler' => 'views_handler_field_boolean',
  120. 'click sortable' => TRUE,
  121. ),
  122. 'filter' => array(
  123. 'handler' => 'views_handler_filter_boolean_operator',
  124. 'label' => t('Is Obsolete?'),
  125. 'type' => 'yes-no',
  126. ),
  127. 'sort' => array(
  128. 'handler' => 'views_handler_sort',
  129. ),
  130. );
  131. // Field: time accessioned (datetime)
  132. $data['library']['timeaccessioned'] = array(
  133. 'title' => t('Date Accessioned'),
  134. 'help' => t('Indicates the date a given library was accessioned (entered into the database).'),
  135. 'field' => array(
  136. 'handler' => 'views_handler_field_readable_date',
  137. 'click sortable' => TRUE,
  138. ),
  139. 'sort' => array(
  140. 'handler' => 'views_handler_sort_date',
  141. ),
  142. );
  143. // Field: time last modified (datetime)
  144. $data['library']['timelastmodified'] = array(
  145. 'title' => t('Date Last Modified'),
  146. 'help' => t('Indicates the date that a given library was last modified.'),
  147. 'field' => array(
  148. 'handler' => 'views_handler_field_readable_date',
  149. 'click sortable' => TRUE,
  150. ),
  151. 'sort' => array(
  152. 'handler' => 'views_handler_sort_date',
  153. ),
  154. );
  155. return $data;
  156. }