tripal_library.api.inc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. /**
  3. * @defgroup tripal_library_api Library Module API
  4. * @ingroup tripal_api
  5. * @ingroup tripal_library
  6. */
  7. /**
  8. * Implements hook_chado_library_schema()
  9. * Purpose: To add descriptions and foreign keys to default table description
  10. * Note: This array will be merged with the array from all other implementations
  11. *
  12. * @return
  13. * Array describing the library table
  14. *
  15. * @ingroup tripal_schema_api
  16. */
  17. function tripal_library_chado_library_schema() {
  18. $description = array();
  19. // Default table description in tripal_core.schema.api.inc: tripal_core_chado_feature_schema()
  20. $description['foreign keys']['organism'] = array(
  21. 'table' => 'organism',
  22. 'columns' => array(
  23. 'organism_id' => 'organism_id',
  24. ),
  25. );
  26. $description['foreign keys']['cvterm'] = array(
  27. 'table' => 'cvterm',
  28. 'columns' => array(
  29. 'type_id' => 'cvterm_id',
  30. ),
  31. );
  32. $referring_tables = array(
  33. 'library_cvterm',
  34. 'library_feature',
  35. 'library_pub',
  36. 'library_synonym',
  37. 'libraryprop'
  38. );
  39. $description['referring_tables'] = $referring_tables;
  40. return $description;
  41. }
  42. /**
  43. * Implements hook_chado_library_feature_schema()
  44. * Purpose: To add descriptions and foreign keys to default table description
  45. * Note: This array will be merged with the array from all other implementations
  46. *
  47. * @return
  48. * Array describing the library_feature table
  49. *
  50. * @ingroup tripal_schema_api
  51. */
  52. function tripal_library_chado_library_feature_schema() {
  53. $description = array();
  54. // Default table description in tripal_core.schema.api.inc: tripal_core_chado_library_feature_schema()
  55. $description['foreign keys']['library'] = array(
  56. 'table' => 'library',
  57. 'columns' => array(
  58. 'library_id' => 'library_id',
  59. ),
  60. );
  61. $description['foreign keys']['feature'] = array(
  62. 'table' => 'feature',
  63. 'columns' => array(
  64. 'feature_id' => 'feature_id',
  65. ),
  66. );
  67. return $description;
  68. }
  69. /**
  70. * Implements hook_chado_libraryprop_schema()
  71. * Purpose: To add descriptions and foreign keys to default table description
  72. * Note: This array will be merged with the array from all other implementations
  73. *
  74. * @return
  75. * Array describing the libraryprop table
  76. *
  77. * @ingroup tripal_schema_api
  78. */
  79. function tripal_library_chado_libraryprop_schema() {
  80. $description = array();
  81. // Default table description in tripal_core.schema.api.inc: tripal_core_chado_library_feature_schema()
  82. $description['foreign keys']['library'] = array(
  83. 'table' => 'library',
  84. 'columns' => array(
  85. 'library_id' => 'library_id',
  86. ),
  87. );
  88. $description['foreign keys']['cvterm'] = array(
  89. 'table' => 'cvterm',
  90. 'columns' => array(
  91. 'type_id' => 'cvterm_id',
  92. ),
  93. );
  94. return $description;
  95. }
  96. /**
  97. * Retrieve properties of a given type for a given library
  98. *
  99. * @param $library_id
  100. * The library_id of the properties you would like to retrieve
  101. * @param $property
  102. * The cvterm name of the properties to retrieve
  103. *
  104. * @return
  105. * An library chado variable with the specified properties expanded
  106. *
  107. * @ingroup tripal_library_api
  108. */
  109. function tripal_library_get_property($library_id,$property){
  110. return tripal_core_get_property('library',$library_id,$property,'tripal');
  111. }
  112. /**
  113. * Insert a given property
  114. *
  115. * @param $library_id
  116. * The library_id of the property to insert
  117. * @param $property
  118. * The cvterm name of the property to insert
  119. * @param $value
  120. * The value of the property to insert
  121. * @param $update_if_present
  122. * A boolean indicated whether to update the record if it's already present
  123. *
  124. * @return
  125. * True of success, False otherwise
  126. *
  127. * @ingroup tripal_library_api
  128. */
  129. function tripal_library_insert_property($library_id,$property,$value,$update_if_present = 0){
  130. return tripal_core_insert_property('library',$library_id,$property,'tripal',$value,$update_if_present);
  131. }
  132. /**
  133. * Update a given property
  134. *
  135. * @param $library_id
  136. * The library_id of the property to update
  137. * @param $property
  138. * The cvterm name of the property to update
  139. * @param $value
  140. * The value of the property to update
  141. * @param $insert_if_missing
  142. * A boolean indicated whether to insert the record if it's absent
  143. *
  144. * Note: The property will be identified using the unique combination of the $library_id and $property
  145. * and then it will be updated with the supplied value
  146. *
  147. * @return
  148. * True of success, False otherwise
  149. *
  150. * @ingroup tripal_library_api
  151. */
  152. function tripal_library_update_property($library_id,$property,$value,$insert_if_missing = 0){
  153. return tripal_core_update_property('library',$library_id,$property,'tripal',$value, $insert_if_missing);
  154. }
  155. /**
  156. * Delete a given property
  157. *
  158. * @param $library_id
  159. * The library_id of the property to delete
  160. * @param $property
  161. * The cvterm name of the property to delete
  162. *
  163. * Note: The property will be identified using the unique combination of the $library_id and $property
  164. * and then it will be deleted
  165. *
  166. * @return
  167. * True of success, False otherwise
  168. *
  169. * @ingroup tripal_library_api
  170. */
  171. function tripal_library_delete_property($library_id,$property){
  172. return tripal_core_delete_property('library',$library_id,$property,'tripal');
  173. }