Source for file FileRecordStructure.class.php

Documentation is available at FileRecordStructure.class.php

  1. <?php
  2.  
  3. require_once(dirname(__FILE__)."/Fields/FileDataPartStructure.class.php");
  4. require_once(dirname(__FILE__)."/Fields/FileNamePartStructure.class.php");
  5. require_once(dirname(__FILE__)."/Fields/FileSizePartStructure.class.php");
  6. require_once(dirname(__FILE__)."/Fields/MimeTypePartStructure.class.php");
  7. require_once(dirname(__FILE__)."/Fields/DimensionsPartStructure.class.php");
  8. require_once(dirname(__FILE__)."/Fields/ThumbnailDataPartStructure.class.php");
  9. require_once(dirname(__FILE__)."/Fields/ThumbnailMimeTypePartStructure.class.php");
  10. require_once(HARMONI."/oki2/repository/HarmoniPartStructureIterator.class.php");
  11.  
  12. /**
  13. * Each Asset has one of the AssetType supported by the Repository. There are
  14. * also zero or more RecordStructures required by the Repository for each
  15. * AssetType. RecordStructures provide structural information. The values for
  16. * a given Asset's RecordStructure are stored in a Record. RecordStructures
  17. * can contain sub-elements which are referred to as PartStructures. The
  18. * structure defined in the RecordStructure and its PartStructures is used in
  19. * for any Records for the Asset. Records have Parts which parallel
  20. * PartStructures.
  21. *
  22. * <p>
  23. * OSID Version: 2.0
  24. * </p>
  25. *
  26. * @package harmoni.osid_v2.repository
  27. *
  28. * @copyright Copyright &copy;2005, Middlebury College
  29. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
  30. *
  31. * @version $Id: FileRecordStructure.class.php,v 1.14 2007/09/04 20:25:44 adamfranco Exp $
  32. */
  33. class HarmoniFileRecordStructure
  34. extends RecordStructure
  35. {
  36. var $_partStructures;
  37. function HarmoniFileRecordStructure() {
  38. // create an array of created PartStructures so we can return references to
  39. // them instead of always making new ones.
  40. if (!is_array($this->_partStructures))
  41. $this->_partStructures = array();
  42. $this->_partStructures['FILE_DATA'] = new FileDataPartStructure($this);
  43. $this->_partStructures['FILE_NAME'] = new FileNamePartStructure($this);
  44. $this->_partStructures['MIME_TYPE'] = new MimeTypePartStructure($this);
  45. $this->_partStructures['FILE_SIZE'] = new FileSizePartStructure($this);
  46. $this->_partStructures['DIMENSIONS'] = new DimensionsPartStructure($this, 'DIMENSIONS');
  47. $this->_partStructures['THUMBNAIL_DATA'] = new ThumbnailDataPartStructure($this);
  48. $this->_partStructures['THUMBNAIL_MIME_TYPE'] = new ThumbnailMimeTypePartStructure($this);
  49. $this->_partStructures['THUMBNAIL_DIMENSIONS'] = new DimensionsPartStructure($this, 'THUMBNAIL_DIMENSIONS');
  50. }
  51. /**
  52. * Get the display name for this RecordStructure.
  53. *
  54. * @return string
  55. *
  56. * @throws object RepositoryException An exception with one of
  57. * the following messages defined in
  58. * org.osid.repository.RepositoryException may be thrown: {@link }
  59. * org.osid.repository.RepositoryException#OPERATION_FAILED
  60. * OPERATION_FAILED}, {@link }
  61. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  62. * PERMISSION_DENIED}, {@link }
  63. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  64. * CONFIGURATION_ERROR}, {@link }
  65. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  66. * UNIMPLEMENTED}
  67. *
  68. * @access public
  69. */
  70. function getDisplayName() {
  71. return "File";
  72. }
  73. /**
  74. * Get the description for this RecordStructure.
  75. *
  76. * @return string
  77. *
  78. * @throws object RepositoryException An exception with one of
  79. * the following messages defined in
  80. * org.osid.repository.RepositoryException may be thrown: {@link }
  81. * org.osid.repository.RepositoryException#OPERATION_FAILED
  82. * OPERATION_FAILED}, {@link }
  83. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  84. * PERMISSION_DENIED}, {@link }
  85. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  86. * CONFIGURATION_ERROR}, {@link }
  87. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  88. * UNIMPLEMENTED}
  89. *
  90. * @access public
  91. */
  92. function getDescription() {
  93. return "A structure for storing binary files.";
  94. }
  95.  
  96. /**
  97. * Get the unique Id for this RecordStructure.
  98. *
  99. * @return object Id
  100. *
  101. * @throws object RepositoryException An exception with one of
  102. * the following messages defined in
  103. * org.osid.repository.RepositoryException may be thrown: {@link }
  104. * org.osid.repository.RepositoryException#OPERATION_FAILED
  105. * OPERATION_FAILED}, {@link }
  106. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  107. * PERMISSION_DENIED}, {@link }
  108. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  109. * CONFIGURATION_ERROR}, {@link }
  110. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  111. * UNIMPLEMENTED}
  112. *
  113. * @access public
  114. */
  115. function getId() {
  116. $idManager = Services::getService("Id");
  117. return $idManager->getId('FILE');
  118. }
  119. /**
  120. * Get the Type for this RecordStructure.
  121. *
  122. * @return object Type
  123. *
  124. * @throws object RepositoryException An exception with one of
  125. * the following messages defined in
  126. * org.osid.repository.RepositoryException may be thrown: {@link }
  127. * org.osid.repository.RepositoryException#OPERATION_FAILED
  128. * OPERATION_FAILED}, {@link }
  129. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  130. * PERMISSION_DENIED}, {@link }
  131. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  132. * CONFIGURATION_ERROR}, {@link }
  133. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  134. * UNIMPLEMENTED}
  135. *
  136. * @access public
  137. */
  138. function getType () {
  139. $type = new Type("RecordStructures", "edu.middlebury.harmoni", "File", "RecordStructures that store files.");
  140. return $type;
  141. }
  142.  
  143. /**
  144. * Get all the PartStructures in the RecordStructure. Iterators return a
  145. * set, one at a time.
  146. *
  147. * @return object PartStructureIterator
  148. *
  149. * @throws object RepositoryException An exception with one of
  150. * the following messages defined in
  151. * org.osid.repository.RepositoryException may be thrown: {@link }
  152. * org.osid.repository.RepositoryException#OPERATION_FAILED
  153. * OPERATION_FAILED}, {@link }
  154. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  155. * PERMISSION_DENIED}, {@link }
  156. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  157. * CONFIGURATION_ERROR}, {@link }
  158. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  159. * UNIMPLEMENTED}
  160. *
  161. * @access public
  162. */
  163. function getPartStructure($partStructureId) {
  164. if ($this->_partStructures[$partStructureId->getIdString()]) {
  165. return $this->_partStructures[$partStructureId->getIdString()];
  166. } else {
  167. throwError(new Error(RepositoryException::UNKNOWN_ID(), "Repository :: FileRecordStructure", TRUE));
  168. }
  169. }
  170.  
  171. /**
  172. * Get all the PartStructures in the RecordStructure. Iterators return a
  173. * set, one at a time.
  174. *
  175. * @return object PartStructureIterator
  176. *
  177. * @throws object RepositoryException An exception with one of
  178. * the following messages defined in
  179. * org.osid.repository.RepositoryException may be thrown: {@link }
  180. * org.osid.repository.RepositoryException#OPERATION_FAILED
  181. * OPERATION_FAILED}, {@link }
  182. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  183. * PERMISSION_DENIED}, {@link }
  184. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  185. * CONFIGURATION_ERROR}, {@link }
  186. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  187. * UNIMPLEMENTED}
  188. *
  189. * @access public
  190. */
  191. function getPartStructures() {
  192. $obj = new HarmoniPartStructureIterator($this->_partStructures);
  193. return $obj;
  194. }
  195.  
  196. /**
  197. * Get the schema for this RecordStructure. The schema is defined by the
  198. * implementation, e.g. Dublin Core.
  199. *
  200. * @return string
  201. *
  202. * @throws object RepositoryException An exception with one of
  203. * the following messages defined in
  204. * org.osid.repository.RepositoryException may be thrown: {@link }
  205. * org.osid.repository.RepositoryException#OPERATION_FAILED
  206. * OPERATION_FAILED}, {@link }
  207. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  208. * PERMISSION_DENIED}, {@link }
  209. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  210. * CONFIGURATION_ERROR}, {@link }
  211. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  212. * UNIMPLEMENTED}
  213. *
  214. * @access public
  215. */
  216. function getSchema() {
  217. return "Harmoni File Schema";
  218. }
  219.  
  220. /**
  221. * Get the format for this RecordStructure. The format is defined by the
  222. * implementation, e.g. XML.
  223. *
  224. * @return string
  225. *
  226. * @throws object RepositoryException An exception with one of
  227. * the following messages defined in
  228. * org.osid.repository.RepositoryException may be thrown: {@link }
  229. * org.osid.repository.RepositoryException#OPERATION_FAILED
  230. * OPERATION_FAILED}, {@link }
  231. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  232. * PERMISSION_DENIED}, {@link }
  233. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  234. * CONFIGURATION_ERROR}, {@link }
  235. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  236. * UNIMPLEMENTED}
  237. *
  238. * @access public
  239. */
  240. function getFormat() {
  241. return "Harmoni File";
  242. }
  243.  
  244. /**
  245. * Validate a Record against its RecordStructure. Return true if valid;
  246. * false otherwise. The status of the Asset holding this Record is not
  247. * changed through this method. The implementation may throw an Exception
  248. * for any validation failures and use the Exception's message to identify
  249. * specific causes.
  250. *
  251. * @param object Record $record
  252. *
  253. * @return boolean
  254. *
  255. * @throws object RepositoryException An exception with one of
  256. * the following messages defined in
  257. * org.osid.repository.RepositoryException may be thrown: {@link }
  258. * org.osid.repository.RepositoryException#OPERATION_FAILED
  259. * OPERATION_FAILED}, {@link }
  260. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  261. * PERMISSION_DENIED}, {@link }
  262. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  263. * CONFIGURATION_ERROR}, {@link }
  264. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  265. * UNIMPLEMENTED}, {@link }
  266. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  267. * NULL_ARGUMENT}
  268. *
  269. * @access public
  270. */
  271. function validateRecord($record) {
  272. // all we can really do is make sure the DataSet behind the Record is of the correct
  273. // type to match this RecordStructure (DataSetTypeDefinition).
  274. return true; // for now
  275. }
  276.  
  277. /**
  278. * Get the possible types for PartStructures.
  279. *
  280. * @return object TypeIterator The Types supported in this implementation.
  281. */
  282. function getPartStructureTypes() {
  283. $types = array();
  284. $obj = new HarmoniIterator($types);
  285. return $obj;
  286. }
  287. }

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