Source for file HarmoniPart.class.php

Documentation is available at HarmoniPart.class.php

  1. <?php
  2. require(OKI2."osid/repository/Part.php");
  3. /**
  4. * Each Asset has one of the AssetType supported by the Repository. There are
  5. * also zero or more RecordStructures required by the Repository for each
  6. * AssetType. RecordStructures provide structural information. The values for
  7. * a given Asset's RecordStructure are stored in a Record. RecordStructures
  8. * can contain sub-elements which are referred to as PartStructures. The
  9. * structure defined in the RecordStructure and its PartStructures is used in
  10. * for any Records for the Asset. Records have Parts which parallel
  11. * PartStructures.
  12. *
  13. * <p>
  14. * OSID Version: 2.0
  15. * </p>
  16. *
  17. * @package harmoni.osid_v2.repository
  18. *
  19. * @copyright Copyright &copy;2005, Middlebury College
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
  21. *
  22. * @version $Id: HarmoniPart.class.php,v 1.20 2007/09/04 20:25:43 adamfranco Exp $
  23. */
  24. class HarmoniPart
  25. extends Part
  26. // extends java.io.Serializable
  27.  
  28. {
  29.  
  30. var $_recordFieldValue;
  31. var $_partStructure;
  32. function HarmoniPart( $partStructure, $recordFieldValue, $asset ) {
  33. $this->_recordFieldValue =$recordFieldValue;
  34. $this->_partStructure =$partStructure;
  35. $this->_asset =$asset;
  36. }
  37. /**
  38. * Update the display name for this Part.
  39. *
  40. * @param string $displayName
  41. *
  42. * @throws object RepositoryException An exception with one of
  43. * the following messages defined in
  44. * org.osid.repository.RepositoryException may be thrown: {@link }
  45. * org.osid.repository.RepositoryException#OPERATION_FAILED
  46. * OPERATION_FAILED}, {@link }
  47. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  48. * PERMISSION_DENIED}, {@link }
  49. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  50. * CONFIGURATION_ERROR}, {@link }
  51. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  52. * UNIMPLEMENTED}, {@link }
  53. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  54. * NULL_ARGUMENT}
  55. *
  56. * @access public
  57. */
  58. function updateDisplayName ( $displayName ) {
  59. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  60. }
  61. /**
  62. * Get the display name for this Part.
  63. *
  64. * @return string
  65. *
  66. * @throws object RepositoryException An exception with one of
  67. * the following messages defined in
  68. * org.osid.repository.RepositoryException may be thrown: {@link }
  69. * org.osid.repository.RepositoryException#OPERATION_FAILED
  70. * OPERATION_FAILED}, {@link }
  71. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  72. * PERMISSION_DENIED}, {@link }
  73. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  74. * CONFIGURATION_ERROR}, {@link }
  75. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  76. * UNIMPLEMENTED}
  77. *
  78. * @access public
  79. */
  80. function getDisplayName () {
  81. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  82. }
  83. /**
  84. * Get the PartStructure associated with this Part.
  85. *
  86. * @return object PartStructure
  87. *
  88. * @throws object RepositoryException An exception with one of
  89. * the following messages defined in
  90. * org.osid.repository.RepositoryException may be thrown: {@link }
  91. * org.osid.repository.RepositoryException#OPERATION_FAILED
  92. * OPERATION_FAILED}, {@link }
  93. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  94. * PERMISSION_DENIED}, {@link }
  95. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  96. * CONFIGURATION_ERROR}, {@link }
  97. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  98. * UNIMPLEMENTED}
  99. *
  100. * @access public
  101. */
  102. function getPartStructure () {
  103. return $this->_partStructure;
  104. }
  105. /**
  106. * Get the unique Id for this Part.
  107. *
  108. * @return object Id
  109. *
  110. * @throws object RepositoryException An exception with one of
  111. * the following messages defined in
  112. * org.osid.repository.RepositoryException may be thrown: {@link }
  113. * org.osid.repository.RepositoryException#OPERATION_FAILED
  114. * OPERATION_FAILED}, {@link }
  115. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  116. * PERMISSION_DENIED}, {@link }
  117. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  118. * CONFIGURATION_ERROR}, {@link }
  119. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  120. * UNIMPLEMENTED}
  121. *
  122. * @access public
  123. */
  124. function getId () {
  125. // The unique ID for the part should be the
  126. // RecordID::RecordFieldLabel::RecordFieldIndex
  127. return $this->_recordFieldValue->getId();
  128. }
  129.  
  130. /**
  131. * Create a Part. Records are composed of Parts. Parts can also contain
  132. * other Parts. Each Record is associated with a specific RecordStructure
  133. * and each Part is associated with a specific PartStructure.
  134. *
  135. * @param object Id $partStructureId
  136. * @param object mixed $value (original type: java.io.Serializable)
  137. *
  138. * @return object Part
  139. *
  140. * @throws object RepositoryException An exception with one of
  141. * the following messages defined in
  142. * org.osid.repository.RepositoryException may be thrown: {@link }
  143. * org.osid.repository.RepositoryException#OPERATION_FAILED
  144. * OPERATION_FAILED}, {@link }
  145. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  146. * PERMISSION_DENIED}, {@link }
  147. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  148. * CONFIGURATION_ERROR}, {@link }
  149. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  150. * UNIMPLEMENTED}, {@link }
  151. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  152. * NULL_ARGUMENT}, {@link }
  153. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  154. *
  155. * @access public
  156. */
  157. function createPart ( $partStructureId, $value ) {
  158. throwError(
  159. new Error(RepositoryException::UNIMPLEMENTED(), "HarmoniPart", true));
  160. $this->_asset->updateModificationDate();
  161. }
  162.  
  163. /**
  164. * Delete a Part and all its Parts.
  165. *
  166. * @param object Id $partId
  167. *
  168. * @throws object RepositoryException An exception with one of
  169. * the following messages defined in
  170. * org.osid.repository.RepositoryException may be thrown: {@link }
  171. * org.osid.repository.RepositoryException#OPERATION_FAILED
  172. * OPERATION_FAILED}, {@link }
  173. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  174. * PERMISSION_DENIED}, {@link }
  175. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  176. * CONFIGURATION_ERROR}, {@link }
  177. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  178. * UNIMPLEMENTED}, {@link }
  179. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  180. * NULL_ARGUMENT}, {@link }
  181. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  182. *
  183. * @access public
  184. */
  185. function deletePart ( $partId ) {
  186. throwError(
  187. new Error(RepositoryException::UNIMPLEMENTED(), "HarmoniPart", true));
  188. $this->_asset->updateModificationDate();
  189. }
  190.  
  191. /**
  192. * Get all the Parts in this Part. Iterators return a set, one at a time.
  193. *
  194. * @return object PartIterator
  195. *
  196. * @throws object RepositoryException An exception with one of
  197. * the following messages defined in
  198. * org.osid.repository.RepositoryException may be thrown: {@link }
  199. * org.osid.repository.RepositoryException#OPERATION_FAILED
  200. * OPERATION_FAILED}, {@link }
  201. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  202. * PERMISSION_DENIED}, {@link }
  203. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  204. * CONFIGURATION_ERROR}, {@link }
  205. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  206. * UNIMPLEMENTED}
  207. *
  208. * @access public
  209. */
  210. function getParts () {
  211. throwError(
  212. new Error(RepositoryException::UNIMPLEMENTED(), "HarmoniPart", true));
  213. }
  214.  
  215. /**
  216. * Get the value for this Part.
  217. *
  218. * @return object mixed (original type: java.io.Serializable)
  219. *
  220. * @throws object RepositoryException An exception with one of
  221. * the following messages defined in
  222. * org.osid.repository.RepositoryException may be thrown: {@link }
  223. * org.osid.repository.RepositoryException#OPERATION_FAILED
  224. * OPERATION_FAILED}, {@link }
  225. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  226. * PERMISSION_DENIED}, {@link }
  227. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  228. * CONFIGURATION_ERROR}, {@link }
  229. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  230. * UNIMPLEMENTED}
  231. *
  232. * @access public
  233. */
  234. function getValue () {
  235. // NOTE: if no active versions exist, false will be returned here.
  236. $actValue =$this->_recordFieldValue->getActiveVersion();
  237. if ($actValue) return $actValue->getPrimitive();
  238. return ($null=null);
  239. }
  240. /**
  241. * updates the part with a string
  242. *
  243. * WARNING: NOT IN OSID
  244. *
  245. * @param string $value this is the string value that needs to get in a part
  246. * @param Id $id this is the id of the part
  247. * @return false on failed update
  248. * @access public
  249. * @since 7/21/05
  250. */
  251. function updateValueFromString ( $value ) {
  252. $partStructure =$this->getPartStructure();
  253. $dtm = Services::getService("DataTypeManager");
  254.  
  255. $type = $partStructure->getType();
  256. $class = $dtm->primitiveClassForType($type->getKeyword());
  257. eval('$object = '.$class.'::fromString($value);');
  258. if (!is_object($object))
  259. return false;
  260.  
  261. $this->updateValue($object);
  262. }
  263. /**
  264. * Update the value for this Part.
  265. *
  266. * @param object mixed $value (original type: java.io.Serializable)
  267. *
  268. * @throws object RepositoryException An exception with one of
  269. * the following messages defined in
  270. * org.osid.repository.RepositoryException may be thrown: {@link }
  271. * org.osid.repository.RepositoryException#OPERATION_FAILED
  272. * OPERATION_FAILED}, {@link }
  273. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  274. * PERMISSION_DENIED}, {@link }
  275. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  276. * CONFIGURATION_ERROR}, {@link }
  277. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  278. * UNIMPLEMENTED}, {@link }
  279. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  280. * NULL_ARGUMENT}
  281. *
  282. * @access public
  283. */
  284. function updateValue ( $value ) {
  285. ArgumentValidator::validate($value,
  286. ExtendsValidatorRule::getRule("SObject"));
  287. // Get the type for the field.
  288.  
  289. $this->_recordFieldValue->setValueFromPrimitive($value);
  290. $this->_recordFieldValue->commit();
  291. $this->_asset->updateModificationDate();
  292. }
  293. }

Documentation generated on Wed, 19 Sep 2007 10:24:08 -0400 by phpDocumentor 1.3.0RC3