tripal_library.api.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /**
  3. * @file
  4. * @todo Add file header description
  5. */
  6. /**
  7. * @defgroup tripal_library_api Library Module API
  8. * @ingroup tripal_api
  9. * @ingroup tripal_library
  10. */
  11. /**
  12. * Implements hook_chado_schema_v1_11_table()
  13. * Purpose: To add descriptions and foreign keys to default table description
  14. * Note: This array will be merged with the array from all other implementations
  15. *
  16. * @return
  17. * Array describing the library table
  18. *
  19. * @ingroup tripal_schema_api
  20. */
  21. function tripal_library_chado_schema_v1_11_library() {
  22. $description = array();
  23. $referring_tables = array(
  24. 'library_cvterm',
  25. 'library_feature',
  26. 'library_pub',
  27. 'library_synonym',
  28. 'libraryprop'
  29. );
  30. $description['referring_tables'] = $referring_tables;
  31. return $description;
  32. }
  33. /**
  34. * Implements hook_chado_schema_v1_2_table()
  35. * Purpose: To add descriptions and foreign keys to default table description
  36. * Note: This array will be merged with the array from all other implementations
  37. *
  38. * @return
  39. * Array describing the library table
  40. *
  41. * @ingroup tripal_schema_api
  42. */
  43. function tripal_library_chado_schema_v1_2_library() {
  44. $description = array();
  45. $referring_tables = array(
  46. 'library_cvterm',
  47. 'library_feature',
  48. 'library_pub',
  49. 'library_synonym',
  50. 'libraryprop'
  51. );
  52. $description['referring_tables'] = $referring_tables;
  53. return $description;
  54. }
  55. /**
  56. * Retrieve properties of a given type for a given library
  57. *
  58. * @param $library_id
  59. * The library_id of the properties you would like to retrieve
  60. * @param $property
  61. * The cvterm name of the properties to retrieve
  62. *
  63. * @return
  64. * An library chado variable with the specified properties expanded
  65. *
  66. * @ingroup tripal_library_api
  67. */
  68. function tripal_library_get_property($library_id, $property) {
  69. return tripal_core_get_property('library', $library_id, $property, 'tripal');
  70. }
  71. /**
  72. * Insert a given property
  73. *
  74. * @param $library_id
  75. * The library_id of the property to insert
  76. * @param $property
  77. * The cvterm name of the property to insert
  78. * @param $value
  79. * The value of the property to insert
  80. * @param $update_if_present
  81. * A boolean indicated whether to update the record if it's already present
  82. *
  83. * @return
  84. * True of success, False otherwise
  85. *
  86. * @ingroup tripal_library_api
  87. */
  88. function tripal_library_insert_property($library_id, $property, $value, $update_if_present = 0) {
  89. return tripal_core_insert_property('library', $library_id, $property, 'tripal', $value, $update_if_present);
  90. }
  91. /**
  92. * Update a given property
  93. *
  94. * @param $library_id
  95. * The library_id of the property to update
  96. * @param $property
  97. * The cvterm name of the property to update
  98. * @param $value
  99. * The value of the property to update
  100. * @param $insert_if_missing
  101. * A boolean indicated whether to insert the record if it's absent
  102. *
  103. * Note: The property will be identified using the unique combination of the $library_id and $property
  104. * and then it will be updated with the supplied value
  105. *
  106. * @return
  107. * True of success, False otherwise
  108. *
  109. * @ingroup tripal_library_api
  110. */
  111. function tripal_library_update_property($library_id, $property, $value, $insert_if_missing = 0) {
  112. return tripal_core_update_property('library', $library_id, $property, 'tripal', $value, $insert_if_missing);
  113. }
  114. /**
  115. * Delete a given property
  116. *
  117. * @param $library_id
  118. * The library_id of the property to delete
  119. * @param $property
  120. * The cvterm name of the property to delete
  121. *
  122. * Note: The property will be identified using the unique combination of the $library_id and $property
  123. * and then it will be deleted
  124. *
  125. * @return
  126. * True of success, False otherwise
  127. *
  128. * @ingroup tripal_library_api
  129. */
  130. function tripal_library_delete_property($library_id, $property) {
  131. return tripal_core_delete_property('library', $library_id, $property, 'tripal');
  132. }