Source for file HarmoniAsset.class.php

Documentation is available at HarmoniAsset.class.php

  1. <?php
  2. /**
  3. * @package harmoni.osid_v2.repository
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: HarmoniAsset.class.php,v 1.49 2007/09/17 16:44:36 adamfranco Exp $
  9. */
  10.  
  11. require_once(HARMONI."oki2/repository/HarmoniAsset.interface.php");
  12. require_once(HARMONI."oki2/repository/HarmoniRecord.class.php");
  13. require_once(HARMONI."oki2/repository/HarmoniRecordIterator.class.php");
  14. require_once(HARMONI."oki2/shared/HarmoniIterator.class.php");
  15.  
  16. require_once(dirname(__FILE__)."/FromNodesAssetIterator.class.php");
  17.  
  18. /**
  19. * Asset manages the Asset itself. Assets have content as well as Records
  20. * appropriate to the AssetType and RecordStructures for the Asset. Assets
  21. * may also contain other Assets.
  22. *
  23. *
  24. * @package harmoni.osid_v2.repository
  25. *
  26. * @copyright Copyright &copy;2005, Middlebury College
  27. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
  28. *
  29. * @version $Id: HarmoniAsset.class.php,v 1.49 2007/09/17 16:44:36 adamfranco Exp $
  30. */
  31.  
  32. class HarmoniAsset
  33. extends HarmoniAssetInterface
  34. { // begin Asset
  35. var $_configuration;
  36. var $_versionControlAll = FALSE;
  37. var $_versionControlTypes;
  38. var $_hierarchy;
  39. var $_node;
  40. var $_repository;
  41. var $_recordIDs;
  42. var $_createdRecords;
  43. var $_createdRecordStructures;
  44. var $_effectiveDate;
  45. var $_expirationDate;
  46. var $_datesInDB = FALSE;
  47. /**
  48. * Constructor
  49. */
  50. function HarmoniAsset ($hierarchy, $repository, $id, $configuration) {
  51. // Get the node coresponding to our id
  52. $this->_hierarchy =$hierarchy;
  53. $this->_node =$this->_hierarchy->getNode($id);
  54. $this->_repository =$repository;
  55. $this->_recordIDs = array();
  56. $this->_createdRecords = array();
  57. $this->_createdRecordStructures = array();
  58. // Store our configuration
  59. $this->_configuration =$configuration;
  60. $this->_versionControlAll = ($configuration->getProperty('version_control_all'))?TRUE:FALSE;
  61. if (is_array($configuration->getProperty('version_control_types'))) {
  62. ArgumentValidator::validate($configuration->getProperty('version_control_types'), ArrayValidatorRuleWithRule::getRule( ExtendsValidatorRule::getRule("Type")));
  63. $this->_versionControlTypes =$configuration->getProperty('version_control_types');
  64. } else {
  65. $this->_versionControlTypes = array();
  66. }
  67. $this->_dbIndex = $configuration->getProperty('database_index');
  68. }
  69.  
  70. /**
  71. * Get the display name for this Asset.
  72. *
  73. * @return string
  74. *
  75. * @throws object RepositoryException An exception with one of
  76. * the following messages defined in
  77. * org.osid.repository.RepositoryException may be thrown: {@link }
  78. * org.osid.repository.RepositoryException#OPERATION_FAILED
  79. * OPERATION_FAILED}, {@link }
  80. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  81. * PERMISSION_DENIED}, {@link }
  82. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  83. * CONFIGURATION_ERROR}, {@link }
  84. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  85. * UNIMPLEMENTED}
  86. *
  87. * @access public
  88. */
  89. function getDisplayName () {
  90. return $this->_node->getDisplayName();
  91. }
  92.  
  93. /**
  94. * Update the display name for this Asset.
  95. *
  96. * @param string $displayName
  97. *
  98. * @throws object RepositoryException An exception with one of
  99. * the following messages defined in
  100. * org.osid.repository.RepositoryException may be thrown: {@link }
  101. * org.osid.repository.RepositoryException#OPERATION_FAILED
  102. * OPERATION_FAILED}, {@link }
  103. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  104. * PERMISSION_DENIED}, {@link }
  105. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  106. * CONFIGURATION_ERROR}, {@link }
  107. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  108. * UNIMPLEMENTED}, {@link }
  109. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  110. * NULL_ARGUMENT}
  111. *
  112. * @access public
  113. */
  114. function updateDisplayName ( $displayName ) {
  115. $this->_node->updateDisplayName($displayName);
  116. $this->updateModificationDate();
  117. }
  118.  
  119. /**
  120. * Get the description for this Asset.
  121. *
  122. * @return string
  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 getDescription () {
  139. return $this->_node->getDescription();
  140. }
  141.  
  142. /**
  143. * Update the description for this Asset.
  144. *
  145. * @param string $description
  146. *
  147. * @throws object RepositoryException An exception with one of
  148. * the following messages defined in
  149. * org.osid.repository.RepositoryException may be thrown: {@link }
  150. * org.osid.repository.RepositoryException#OPERATION_FAILED
  151. * OPERATION_FAILED}, {@link }
  152. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  153. * PERMISSION_DENIED}, {@link }
  154. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  155. * CONFIGURATION_ERROR}, {@link }
  156. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  157. * UNIMPLEMENTED}, {@link }
  158. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  159. * NULL_ARGUMENT}
  160. *
  161. * @access public
  162. */
  163. function updateDescription ( $description ) {
  164. $this->_node->updateDescription($description);
  165. $this->updateModificationDate();
  166. }
  167.  
  168. /**
  169. * Get the unique Id for this Asset.
  170. *
  171. * @return object Id
  172. *
  173. * @throws object RepositoryException An exception with one of
  174. * the following messages defined in
  175. * org.osid.repository.RepositoryException may be thrown: {@link }
  176. * org.osid.repository.RepositoryException#OPERATION_FAILED
  177. * OPERATION_FAILED}, {@link }
  178. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  179. * PERMISSION_DENIED}, {@link }
  180. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  181. * CONFIGURATION_ERROR}, {@link }
  182. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  183. * UNIMPLEMENTED}
  184. *
  185. * @access public
  186. */
  187. function getId () {
  188. return $this->_node->getId();
  189. }
  190. /**
  191. * Get the Id of the Repository in which this Asset resides. This is set
  192. * by the Repository's createAsset method.
  193. *
  194. * WARNING::IMPLEMENTATION AND DOCUMENTATION DIFFER
  195. *
  196. * @return object Id
  197. *
  198. * @throws object RepositoryException An exception with one of
  199. * the following messages defined in
  200. * org.osid.repository.RepositoryException may be thrown: {@link }
  201. * org.osid.repository.RepositoryException#OPERATION_FAILED
  202. * OPERATION_FAILED}, {@link }
  203. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  204. * PERMISSION_DENIED}, {@link }
  205. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  206. * CONFIGURATION_ERROR}, {@link }
  207. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  208. * UNIMPLEMENTED}
  209. *
  210. * @access public
  211. */
  212. function getRepository () {
  213.  
  214. return $this->_repository;
  215. }
  216.  
  217. /**
  218. * Get an Asset's content. This method can be a convenience if one is not
  219. * interested in all the structure of the Records.
  220. *
  221. * @return object mixed (original type: java.io.Serializable)
  222. *
  223. * @throws object RepositoryException An exception with one of
  224. * the following messages defined in
  225. * org.osid.repository.RepositoryException may be thrown: {@link }
  226. * org.osid.repository.RepositoryException#OPERATION_FAILED
  227. * OPERATION_FAILED}, {@link }
  228. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  229. * PERMISSION_DENIED}, {@link }
  230. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  231. * CONFIGURATION_ERROR}, {@link }
  232. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  233. * UNIMPLEMENTED}
  234. *
  235. * @access public
  236. */
  237. function getContent () {
  238. $idManager = Services::getService("Id");
  239. $recordMgr = Services::getService("RecordManager");
  240. // Ready our type for comparisson
  241. $contentType = "edu.middlebury.harmoni.repository.asset_content";
  242. $myId =$this->_node->getId();
  243. // Get the content DataSet.
  244. $myRecordSet =$recordMgr->fetchRecordSet($myId->getIdString());
  245. $myRecordSet->loadRecords();
  246. $contentRecords =$myRecordSet->getRecordsByType($contentType);
  247. if (isset($contentRecords[0]) && $contentRecords[0])
  248. return $contentRecords[0]->getValue("Content");
  249. else
  250. return new Blob();
  251. }
  252.  
  253. /**
  254. * Update an Asset's content.
  255. *
  256. * @param object mixed $content (original type: java.io.Serializable)
  257. *
  258. * @throws object RepositoryException An exception with one of
  259. * the following messages defined in
  260. * org.osid.repository.RepositoryException may be thrown: {@link }
  261. * org.osid.repository.RepositoryException#OPERATION_FAILED
  262. * OPERATION_FAILED}, {@link }
  263. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  264. * PERMISSION_DENIED}, {@link }
  265. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  266. * CONFIGURATION_ERROR}, {@link }
  267. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  268. * UNIMPLEMENTED}, {@link }
  269. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  270. * NULL_ARGUMENT}
  271. *
  272. * @access public
  273. */
  274. function updateContent ( $content ) {
  275. ArgumentValidator::validate($content, ExtendsValidatorRule::getRule("Blob"));
  276. $idManager = Services::getService("Id");
  277. $recordMgr = Services::getService("RecordManager");
  278. // Ready our type for comparisson
  279. $contentType = "edu.middlebury.harmoni.repository.asset_content";
  280. $myId =$this->_node->getId();
  281. // Get the content DataSet.
  282. $myRecordSet =$recordMgr->fetchRecordSet($myId->getIdString());
  283. $myRecordSet->loadRecords();
  284. $contentRecords =$myRecordSet->getRecordsByType($contentType);
  285.  
  286. if (count($contentRecords)) {
  287. $contentRecord =$contentRecords[0];
  288. $contentRecord->setValue("Content", $content);
  289. $contentRecord->commit(TRUE);
  290. } else {
  291. // Set up and create our new record
  292. $schemaMgr = Services::getService("SchemaManager");
  293. $contentSchema =$schemaMgr->getSchemaByID($contentType);
  294. $contentSchema->load();
  295. // printpre($contentSchema->getAllLabels());
  296. // Decide if we want to version-control this field.
  297. $versionControl = $this->_versionControlAll;
  298. if (!$versionControl) {
  299. foreach ($this->_versionControlTypes as $key => $val) {
  300. if ($contentType == $this->_versionControlTypes[$key]) {
  301. $versionControl = TRUE;
  302. break;
  303. }
  304. }
  305. }
  306. $contentRecord =$recordMgr->createRecord($contentType, $versionControl);
  307. $contentRecord->setValue("Content", $content);
  308. $contentRecord->commit(TRUE);
  309. // Add the record to our group
  310. $myRecordSet->add($contentRecord);
  311. $myRecordSet->commit(TRUE);
  312. }
  313. $this->updateModificationDate();
  314. }
  315.  
  316. /**
  317. * Get the date at which this Asset is effective.
  318. *
  319. * @return object DateAndTime
  320. *
  321. * @throws object RepositoryException An exception with one of
  322. * the following messages defined in
  323. * org.osid.repository.RepositoryException may be thrown: {@link }
  324. * org.osid.repository.RepositoryException#OPERATION_FAILED
  325. * OPERATION_FAILED}, {@link }
  326. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  327. * PERMISSION_DENIED}, {@link }
  328. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  329. * CONFIGURATION_ERROR}, {@link }
  330. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  331. * UNIMPLEMENTED}
  332. *
  333. * @access public
  334. */
  335. function getEffectiveDate () {
  336. if (!isset($this->_effectiveDate)) {
  337. $this->_loadDates();
  338. }
  339. return $this->_effectiveDate;
  340. }
  341.  
  342. /**
  343. * Update the date at which this Asset is effective.
  344. *
  345. * @param object DateAndTime $effectiveDate OR NULL
  346. *
  347. * @throws object RepositoryException An exception with one of
  348. * the following messages defined in
  349. * org.osid.repository.RepositoryException may be thrown: {@link }
  350. * org.osid.repository.RepositoryException#OPERATION_FAILED
  351. * OPERATION_FAILED}, {@link }
  352. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  353. * PERMISSION_DENIED}, {@link }
  354. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  355. * CONFIGURATION_ERROR}, {@link }
  356. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  357. * UNIMPLEMENTED}, {@link }
  358. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  359. * NULL_ARGUMENT}, {@link }
  360. * org.osid.repository.RepositoryException#EFFECTIVE_PRECEDE_EXPIRATION}
  361. *
  362. * @access public
  363. */
  364. function updateEffectiveDate ( $effectiveDate ) {
  365. ArgumentValidator::validate($effectiveDate,
  366. OptionalRule::getRule(
  367. HasMethodsValidatorRule::getRule("asDateAndTime")));
  368. // Make sure that we have dates from the DB if they exist.
  369. $this->_loadDates();
  370. // Update our date in preparation for DB updating
  371. $this->_effectiveDate =$effectiveDate;
  372. // Store the dates
  373. $this->_storeDates();
  374. }
  375.  
  376. /**
  377. * Get the date at which this Asset expires.
  378. *
  379. * @return object DateAndTime
  380. *
  381. * @throws object RepositoryException An exception with one of
  382. * the following messages defined in
  383. * org.osid.repository.RepositoryException may be thrown: {@link }
  384. * org.osid.repository.RepositoryException#OPERATION_FAILED
  385. * OPERATION_FAILED}, {@link }
  386. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  387. * PERMISSION_DENIED}, {@link }
  388. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  389. * CONFIGURATION_ERROR}, {@link }
  390. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  391. * UNIMPLEMENTED}
  392. *
  393. * @access public
  394. */
  395. function getExpirationDate () {
  396. if (!$this->_expirationDate) {
  397. $this->_loadDates();
  398. }
  399. return $this->_expirationDate;
  400. }
  401.  
  402. /**
  403. * Update the date at which this Asset expires.
  404. *
  405. * @param object DateAndTime $expirationDate
  406. *
  407. * @throws object RepositoryException An exception with one of
  408. * the following messages defined in
  409. * org.osid.repository.RepositoryException may be thrown: {@link }
  410. * org.osid.repository.RepositoryException#OPERATION_FAILED
  411. * OPERATION_FAILED}, {@link }
  412. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  413. * PERMISSION_DENIED}, {@link }
  414. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  415. * CONFIGURATION_ERROR}, {@link }
  416. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  417. * UNIMPLEMENTED}, {@link }
  418. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  419. * NULL_ARGUMENT}, {@link }
  420. * org.osid.repository.RepositoryException#EFFECTIVE_PRECEDE_EXPIRATION}
  421. *
  422. * @access public
  423. */
  424. function updateExpirationDate ( $expirationDate ) {
  425. ArgumentValidator::validate($expirationDate,
  426. OptionalRule::getRule(
  427. HasMethodsValidatorRule::getRule("asDateAndTime")));
  428. // Make sure that we have dates from the DB if they exist.
  429. $this->_loadDates();
  430. // Update our date in preparation for DB updating
  431. $this->_expirationDate =$expirationDate;
  432. // Store the dates
  433. $this->_storeDates();
  434. }
  435.  
  436. /**
  437. * Add an Asset to this Asset.
  438. *
  439. * @param object Id $assetId
  440. *
  441. * @throws object RepositoryException An exception with one of
  442. * the following messages defined in
  443. * org.osid.repository.RepositoryException may be thrown: {@link }
  444. * org.osid.repository.RepositoryException#OPERATION_FAILED
  445. * OPERATION_FAILED}, {@link }
  446. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  447. * PERMISSION_DENIED}, {@link }
  448. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  449. * CONFIGURATION_ERROR}, {@link }
  450. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  451. * UNIMPLEMENTED}, {@link }
  452. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  453. * NULL_ARGUMENT}, {@link }
  454. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID},
  455. * {@link org.osid.repository.RepositoryException#ALREADY_ADDED}
  456. * ALREADY_ADDED}
  457. *
  458. * @access public
  459. */
  460. function addAsset ( $assetId ) {
  461. $node =$this->_hierarchy->getNode($assetId);
  462. $oldParents =$node->getParents();
  463. // We are assuming a single-parent hierarchy
  464. $oldParent =$oldParents->next();
  465. $node->changeParent($oldParent->getId(), $this->_node->getId());
  466. $this->save();
  467. $this->updateModificationDate();
  468. }
  469.  
  470. /**
  471. * Remove an Asset from this Asset. This method does not delete the Asset
  472. * from the Repository.
  473. *
  474. * @param object Id $assetId
  475. * @param boolean $includeChildren
  476. *
  477. * @throws object RepositoryException An exception with one of
  478. * the following messages defined in
  479. * org.osid.repository.RepositoryException may be thrown: {@link }
  480. * org.osid.repository.RepositoryException#OPERATION_FAILED
  481. * OPERATION_FAILED}, {@link }
  482. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  483. * PERMISSION_DENIED}, {@link }
  484. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  485. * CONFIGURATION_ERROR}, {@link }
  486. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  487. * UNIMPLEMENTED}, {@link }
  488. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  489. * NULL_ARGUMENT}, {@link }
  490. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  491. *
  492. * @access public
  493. */
  494. function removeAsset ( $assetId, $includeChildren = FALSE ) {
  495. $node =$this->_hierarchy->getNode($assetId);
  496. if (!$includeChildren) {
  497. // Move the children to the current asset before moving
  498. // the asset to the repository root
  499. $children =$node->getChildren();
  500. while ($children->hasNext()) {
  501. $child =$children->next();
  502. $child->changeParent($node->getId(), $this->_node->getId());
  503. }
  504. }
  505. // Move the asset to the repository root.
  506. $node->changeParent($this->_node->getId(), $this->_repository->getId());
  507. $this->save();
  508. $this->updateModificationDate();
  509. }
  510.  
  511. /**
  512. * Get all the Assets in this Asset. Iterators return a set, one at a
  513. * time.
  514. *
  515. * @return object AssetIterator
  516. *
  517. * @throws object RepositoryException An exception with one of
  518. * the following messages defined in
  519. * org.osid.repository.RepositoryException may be thrown: {@link }
  520. * org.osid.repository.RepositoryException#OPERATION_FAILED
  521. * OPERATION_FAILED}, {@link }
  522. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  523. * PERMISSION_DENIED}, {@link }
  524. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  525. * CONFIGURATION_ERROR}, {@link }
  526. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  527. * UNIMPLEMENTED}
  528. *
  529. * @access public
  530. */
  531. function getAssets () {
  532. // create an AssetIterator and return it
  533. $assetIterator = new FromNodesAssetIterator(
  534. $this->_node->getChildren(),
  535. $this->_repository);
  536. return $assetIterator;
  537. }
  538. /**
  539. * Get the parents of this asset, Iterators return a set one at a time.
  540. *
  541. * WARNING: NOT IN OSID
  542. *
  543. * @return object AssetIterator
  544. *
  545. * @throws object RepositoryException An exception with one of
  546. * the following messages defined in
  547. * org.osid.repository.RepositoryException may be thrown: {@link }
  548. * org.osid.repository.RepositoryException#OPERATION_FAILED
  549. * OPERATION_FAILED}, {@link }
  550. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  551. * PERMISSION_DENIED}, {@link }
  552. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  553. * CONFIGURATION_ERROR}, {@link }
  554. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  555. * UNIMPLEMENTED}
  556. *
  557. * @access public
  558. */
  559. function getParents () {
  560. $assets = array();
  561. $parents =$this->_node->getParents();
  562. $manager = Services::getService("Repository");
  563. $repositoryKeyType =$manager->repositoryKeyType;
  564. while ($parents->hasNext()) {
  565. $parent =$parents->next();
  566. if (!$repositoryKeyType->isEqual($parent->getType()))
  567. $assets[] =$this->_repository->getAsset($parent->getId());
  568. }
  569. // create an AssetIterator and return it
  570. $assetIterator = new HarmoniAssetIterator($assets);
  571. return $assetIterator;
  572. }
  573. /**
  574. * Answer an iterator of the TraversalInfo of the decendent Assets
  575. * (children, grandchildren, etc).
  576. * WARNING: NOT IN OSID
  577. *
  578. * @return object TraversalInfoIterator
  579. * @access public
  580. * @since 12/15/05
  581. */
  582. function getDescendentInfo () {
  583. $traversalInfo =$this->_hierarchy->traverse(
  584. $this->getId(),
  585. Hierarchy::TRAVERSE_MODE_DEPTH_FIRST(),
  586. Hierarchy::TRAVERSE_DIRECTION_DOWN(),
  587. Hierarchy::TRAVERSE_LEVELS_ALL());
  588. return $traversalInfo;
  589. }
  590. /**
  591. * Get the parents of this asset, Iterators return a set one at a time.
  592. *
  593. * WARNING: NOT IN OSID
  594. *
  595. * @param object Type $assetType
  596. *
  597. * @return object AssetIterator
  598. *
  599. * @throws object RepositoryException An exception with one of
  600. * the following messages defined in
  601. * org.osid.repository.RepositoryException may be thrown: {@link }
  602. * org.osid.repository.RepositoryException#OPERATION_FAILED
  603. * OPERATION_FAILED}, {@link }
  604. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  605. * PERMISSION_DENIED}, {@link }
  606. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  607. * CONFIGURATION_ERROR}, {@link }
  608. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  609. * UNIMPLEMENTED}, {@link }
  610. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  611. * NULL_ARGUMENT}, {@link }
  612. * org.osid.repository.RepositoryException#UNKNOWN_TYPE
  613. * UNKNOWN_TYPE}
  614. *
  615. * @access public
  616. */
  617. function getParentsByType ( $assetType ) {
  618. $assets = array();
  619. $parents =$this->_node->getParents();
  620. while ($parents->hasNext()) {
  621. $parent =$parents->next();
  622. if ($assetType->isEqual($parent->getType()))
  623. $assets[] =$this->_repository->getAsset($parent->getId());
  624. }
  625. // create an AssetIterator and return it
  626. $assetIterator = new HarmoniAssetIterator($assets);
  627. return $assetIterator;
  628. }
  629. /**
  630. * Get all the Assets of the specified AssetType in this Repository.
  631. * Iterators return a set, one at a time.
  632. *
  633. * @param object Type $assetType
  634. *
  635. * @return object AssetIterator
  636. *
  637. * @throws object RepositoryException An exception with one of
  638. * the following messages defined in
  639. * org.osid.repository.RepositoryException may be thrown: {@link }
  640. * org.osid.repository.RepositoryException#OPERATION_FAILED
  641. * OPERATION_FAILED}, {@link }
  642. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  643. * PERMISSION_DENIED}, {@link }
  644. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  645. * CONFIGURATION_ERROR}, {@link }
  646. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  647. * UNIMPLEMENTED}, {@link }
  648. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  649. * NULL_ARGUMENT}, {@link }
  650. * org.osid.repository.RepositoryException#UNKNOWN_TYPE
  651. * UNKNOWN_TYPE}
  652. *
  653. * @access public
  654. */
  655. function getAssetsByType ( $assetType ) {
  656. $assets = array();
  657. $children =$this->_node->getChildren();
  658. while ($children->hasNext()) {
  659. $child =$children->next();
  660. if ($assetType->isEqual($child->getType()))
  661. $assets[] =$this->_repository->getAsset($child->getId());
  662. }
  663. $obj = new HarmoniAssetIterator($assets);
  664. return $obj;
  665. }
  666.  
  667. /**
  668. * Create a new Asset Record of the specified RecordStructure. The
  669. * implementation of this method sets the Id for the new object.
  670. *
  671. * @param object Id $recordStructureId
  672. *
  673. * @return object Record
  674. *
  675. * @throws object RepositoryException An exception with one of
  676. * the following messages defined in
  677. * org.osid.repository.RepositoryException may be thrown: {@link }
  678. * org.osid.repository.RepositoryException#OPERATION_FAILED
  679. * OPERATION_FAILED}, {@link }
  680. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  681. * PERMISSION_DENIED}, {@link }
  682. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  683. * CONFIGURATION_ERROR}, {@link }
  684. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  685. * UNIMPLEMENTED}, {@link }
  686. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  687. * NULL_ARGUMENT}, {@link }
  688. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  689. *
  690. * @access public
  691. */
  692. function createRecord ( $recordStructureId ) {
  693. ArgumentValidator::validate($recordStructureId, ExtendsValidatorRule::getRule("Id"));
  694. // If this is a schema that is hard coded into our implementation, create
  695. // a record for that schema.
  696. if (in_array($recordStructureId->getIdString(), array_keys($this->_repository->_builtInTypes)))
  697. {
  698. // Create an Id for the record;
  699. $idManager = Services::getService("Id");
  700. $newId =$idManager->createId();
  701. // instantiate the new record.
  702. $recordClass = $this->_repository->_builtInTypes[$recordStructureId->getIdString()];
  703. $recordStructure =$this->_repository->getRecordStructure($recordStructureId);
  704. $record = new $recordClass($recordStructure, $newId, $this->_configuration, $this);
  705. // store a relation to the record
  706. $dbHandler = Services::getService("DatabaseManager");
  707. $query = new InsertQuery;
  708. $query->setTable("dr_asset_record");
  709. $query->setColumns(array("fk_asset", "fk_record", "structure_id"));
  710. $myId =$this->getId();
  711. $query->addRowOfValues(array(
  712. "'".$myId->getIdString()."'",
  713. "'".$newId->getIdString()."'",
  714. "'".$recordStructureId->getIdString()."'"));
  715. $result =$dbHandler->query($query, $this->_dbIndex);
  716. }
  717. // Otherwise use the data manager
  718. else {
  719. // Get the DataSetGroup for this Asset
  720. $recordMgr = Services::getService("RecordManager");
  721. $myId =$this->_node->getId();
  722. $myGroup =$recordMgr->fetchRecordSet($myId->getIdString());
  723. // Get the recordStructure needed.
  724. $recordStructures =$this->_repository->getRecordStructures();
  725. while ($recordStructures->hasNext()) {
  726. $structure =$recordStructures->next();
  727. if ($recordStructureId->isEqual($structure->getId()))
  728. break;
  729. }
  730. // get the type for the new data set.
  731. $schemaMgr = Services::getService("SchemaManager");
  732. $schemaID = $recordStructureId->getIdString();
  733. // $type =$schemaMgr->getSchemaByID($recordStructureId->getIdString());
  734. // Set up and create our new dataset
  735. // Decide if we want to version-control this field.
  736. $versionControl = $this->_versionControlAll;
  737. if (!$versionControl) {
  738. foreach ($this->_versionControlTypes as $key => $val) {
  739. if ($schemaID == $this->_versionControlTypes[$key]) {
  740. $versionControl = TRUE;
  741. break;
  742. }
  743. }
  744. }
  745. $newRecord =$recordMgr->createRecord($schemaID, $versionControl);
  746. // The ignoreMandatory Allows this record to be created without checking for
  747. // values on mandatory fields. These constraints should be checked when
  748. // validateAsset() is called.
  749. $newRecord->commit(TRUE);
  750. // Add the DataSet to our group
  751. $myGroup->add($newRecord);
  752. // us the RecordStructure and the dataSet to create a new Record
  753. $record = new HarmoniRecord($structure, $newRecord, $this);
  754. }
  755. // Add the record to our createdRecords array, so we can pass out references to it.
  756. $recordId =$record->getId();
  757. $this->_createdRecords[$recordId->getIdString()] =$record;
  758. $this->save();
  759. $this->updateModificationDate();
  760. return $record;
  761. }
  762.  
  763. /**
  764. * Add the specified RecordStructure and all the related Records from the
  765. * specified asset. The current and future content of the specified
  766. * Record is synchronized automatically.
  767. *
  768. * @param object Id $assetId
  769. * @param object Id $recordStructureId
  770. *
  771. * @throws object RepositoryException An exception with one of
  772. * the following messages defined in
  773. * org.osid.repository.RepositoryException may be thrown: {@link }
  774. * org.osid.repository.RepositoryException#OPERATION_FAILED
  775. * OPERATION_FAILED}, {@link }
  776. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  777. * PERMISSION_DENIED}, {@link }
  778. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  779. * CONFIGURATION_ERROR}, {@link }
  780. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  781. * UNIMPLEMENTED}, {@link }
  782. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  783. * NULL_ARGUMENT}, {@link }
  784. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID},
  785. * {@link }
  786. * org.osid.repository.RepositoryException#ALREADY_INHERITING_STRUCTURE
  787. * ALREADY_INHERITING_STRUCTURE}
  788. *
  789. * @access public
  790. */
  791. function inheritRecordStructure ( $assetId, $recordStructureId ) {
  792. // Check the arguments
  793. ArgumentValidator::validate($recordStructureId, ExtendsValidatorRule::getRule("Id"));
  794. ArgumentValidator::validate($assetId, ExtendsValidatorRule::getRule("Id"));
  795. // If this is a schema that is hard coded into our implementation, create
  796. // a record for that schema.
  797. if (in_array($recordStructureId->getIdString(), array_keys($this->_repository->_builtInTypes)))
  798. {
  799. // Create an Id for the record;
  800. $idManager = Services::getService("Id");
  801. $dbHandler = Services::getService("DatabaseManager");
  802. // get the record ids that we want to inherit
  803. $query = new SelectQuery();
  804. $query->addTable("dr_asset_record");
  805. $query->addColumn("fk_record");
  806. $query->addWhere("fk_asset = '".$assetId->getIdString()."'");
  807. $query->addWhere("structure_id = '".$recordStructureId->getIdString()."'", _AND);
  808. $result =$dbHandler->query($query, $this->_dbIndex);
  809. // store a relation to the record
  810. $dbHandler = Services::getService("DatabaseManager");
  811. $query = new InsertQuery;
  812. $query->setTable("dr_asset_record");
  813. $query->setColumns(array("fk_asset", "fk_record", "structure_id"));
  814. $myId =$this->getId();
  815. while ($result->hasMoreRows()) {
  816. $query->addRowOfValues(array(
  817. "'".$myId->getIdString()."'",
  818. "'".$result->field("fk_record")."'",
  819. "'".$recordStructureId->getIdString()."'"));
  820. $dbHandler->query($query, $this->_dbIndex);
  821. $result->advanceRow();
  822. }
  823. $result->free();
  824. }
  825. // Otherwise use the data manager
  826. else {
  827. // Get our managers:
  828. $recordMgr = Services::getService("RecordManager");
  829. $idMgr = Services::getService("Id");
  830. // Get the DataSetGroup for this Asset
  831. $myId =$this->_node->getId();
  832. $mySet =$recordMgr->fetchRecordSet($myId->getIdString());
  833. // Get the DataSetGroup for the source Asset
  834. $otherSet =$recordMgr->fetchRecordSet($assetId->getIdString());
  835. $otherSet->loadRecords(RECORD_FULL);
  836. $records =$otherSet->getRecords();
  837. // Add all of DataSets (Records) of the specified RecordStructure and Asset
  838. // to our RecordSet.
  839. foreach (array_keys($records) as $key) {
  840. // Get the ID of the current DataSet's TypeDefinition
  841. $schema =$records[$key]->getSchema();
  842. $schemaId =$idMgr->getId($schema->getID());
  843. // If the current DataSet's DataSetTypeDefinition's ID is the same as
  844. // the RecordStructure ID that we are looking for, add that dataSet to our
  845. // DataSetGroup.
  846. if ($recordStructureId->isEqual($schemaId)) {
  847. $mySet->add($records[$key]);
  848. }
  849. }
  850. // Save our DataSetGroup
  851. $mySet->commit(TRUE);
  852. }
  853. $this->updateModificationDate();
  854. }
  855.  
  856. /**
  857. * Add the specified RecordStructure and all the related Records from the
  858. * specified asset.
  859. *
  860. * @param object Id $assetId
  861. * @param object Id $recordStructureId
  862. *
  863. * @throws object RepositoryException An exception with one of
  864. * the following messages defined in
  865. * org.osid.repository.RepositoryException may be thrown: {@link }
  866. * org.osid.repository.RepositoryException#OPERATION_FAILED
  867. * OPERATION_FAILED}, {@link }
  868. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  869. * PERMISSION_DENIED}, {@link }
  870. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  871. * CONFIGURATION_ERROR}, {@link }
  872. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  873. * UNIMPLEMENTED}, {@link }
  874. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  875. * NULL_ARGUMENT}, {@link }
  876. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID},
  877. * {@link }
  878. * org.osid.repository.RepositoryException#CANNOT_COPY_OR_INHERIT_SELF
  879. * CANNOT_COPY_OR_INHERIT_SELF}
  880. *
  881. * @access public
  882. */
  883. function copyRecordStructure ( $assetId, $recordStructureId ) {
  884. // Check the arguments
  885. ArgumentValidator::validate($recordStructureId, ExtendsValidatorRule::getRule("Id"));
  886. ArgumentValidator::validate($assetId, ExtendsValidatorRule::getRule("Id"));
  887. // Get our managers:
  888. $recordMgr = Services::getService("RecordManager");
  889. $idMgr = Services::getService("Id");
  890. // Get the RecordSet for this Asset
  891. $myId =$this->_node->getId();
  892. $set =$recordMgr->fetchRecordSet($myId->getIdString());
  893. // Get the DataSetGroup for the source Asset
  894. $otherSet =$recordMgr->fetchRecordSet($assetId->getIdString());
  895. $otherSet->loadRecords(RECORD_FULL);
  896. $records =$otherSet->getRecords();
  897. // Add all of Records (Records) of the specified RecordStructure and Asset
  898. // to our RecordSet.
  899. foreach (array_keys($records) as $key) {
  900. // Get the ID of the current DataSet's TypeDefinition
  901. $schema =$records[$key]->getSchema();
  902. $schemaId =$idMgr->getId($schema->getID());
  903. // If the current Record's Schema ID is the same as
  904. // the RecordStructure ID that we are looking for, add replicates of that Record
  905. // to our RecordSet.
  906. if ($recordStructureId->isEqual($schemaId)) {
  907. $newRecord =$records[$key]->replicate();
  908. $set->add($newRecord);
  909. }
  910. }
  911. // Save our RecordSet
  912. $set->commit(TRUE);
  913. $this->updateModificationDate();
  914. }
  915.  
  916. /**
  917. * Delete a Record. If the specified Record has content that is inherited
  918. * by other Records, those other Records will not be deleted, but they
  919. * will no longer have a source from which to inherit value changes.
  920. *
  921. * @param object Id $recordId
  922. *
  923. * @throws object RepositoryException An exception with one of
  924. * the following messages defined in
  925. * org.osid.repository.RepositoryException may be thrown: {@link }
  926. * org.osid.repository.RepositoryException#OPERATION_FAILED
  927. * OPERATION_FAILED}, {@link }
  928. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  929. * PERMISSION_DENIED}, {@link }
  930. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  931. * CONFIGURATION_ERROR}, {@link }
  932. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  933. * UNIMPLEMENTED}, {@link }
  934. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  935. * NULL_ARGUMENT}, {@link }
  936. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  937. *
  938. * @access public
  939. */
  940. function deleteRecord ( $recordId ) {
  941. ArgumentValidator::validate($recordId, ExtendsValidatorRule::getRule("Id"));
  942. $record =$this->getRecord($recordId);
  943. $structure =$record->getRecordStructure();
  944. $structureId =$structure->getId();
  945. // If this is a schema that is hard coded into our implementation, create
  946. // a record for that schema.
  947. if (in_array($structureId->getIdString(), array_keys($this->_repository->_builtInTypes)))
  948. {
  949. // Delete all of the Parts for the record
  950. $parts =$record->getParts();
  951. while ($parts->hasNext()) {
  952. $part =$parts->next();
  953. $record->deletePart($part->getId());
  954. }
  955. // Delete the relation for the record.
  956. $dbHandler = Services::getService("DatabaseManager");
  957. $query = new DeleteQuery;
  958. $query->setTable("dr_asset_record");
  959. $myId =$this->getId();
  960. $query->addWhere("fk_asset = '".$myId->getIdString()."'");
  961. $query->addWhere("fk_record = '".$recordId->getIdString()."'");
  962. $result =$dbHandler->query($query, $this->_dbIndex);
  963. }
  964. // Otherwise use the data manager
  965. else {
  966. $recordMgr = Services::getService("RecordManager");
  967. $record =$recordMgr->fetchRecord($recordId->getIdString(),RECORD_FULL);
  968. // Check if the record is part of other record sets (assets via inheretance)
  969. $myId =$this->getId();
  970. $setsContaining = $recordMgr->getRecordSetIDsContaining($record);
  971. $myRecordSet =$recordMgr->fetchRecordSet($myId->getIdString());
  972. // If this is the last asset referencing this record, delete it.
  973. $idManager = Services::getService('Id');
  974. if (count($setsContaining) == 1 && $myId->isEqual($idManager->getId($setsContaining[0]))) {
  975. $myRecordSet->removeRecord($record);
  976. $myRecordSet->commit(TRUE);
  977. $record->delete();
  978. $record->commit(TRUE);
  979. }
  980. // If this record is used by other assets, remove the record from this set,
  981. // but leave it in the rest.
  982. else {
  983. $myRecordSet =$recordMgr->fetchRecordSet($myId->getIdString());
  984. $myRecordSet->removeRecord($record);
  985. $myRecordSet->commit(TRUE);
  986. }
  987. }
  988. $this->updateModificationDate();
  989. }
  990.  
  991. /**
  992. * Get the Record for this Asset that matches this Record's unique Id.
  993. *
  994. * @param object Id $recordId
  995. *
  996. * @return object Record
  997. *
  998. * @throws object RepositoryException An exception with one of
  999. * the following messages defined in
  1000. * org.osid.repository.RepositoryException may be thrown: {@link }
  1001. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1002. * OPERATION_FAILED}, {@link }
  1003. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1004. * PERMISSION_DENIED}, {@link }
  1005. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1006. * CONFIGURATION_ERROR}, {@link }
  1007. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1008. * UNIMPLEMENTED}, {@link }
  1009. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  1010. * NULL_ARGUMENT}, {@link }
  1011. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  1012. *
  1013. * @access public
  1014. */
  1015. function getRecord ( $recordId ) {
  1016. ArgumentValidator::validate($recordId, ExtendsValidatorRule::getRule("Id"));
  1017. // Check to see if the record is in our cache.
  1018. // If so, return it. If not, create it, then return it.
  1019. if (!isset($this->_createdRecords[$recordId->getIdString()])) {
  1020. // Check for the record in our non-datamanager records;
  1021. $idManager = Services::getService("Id");
  1022. $dbHandler = Services::getService("DatabaseManager");
  1023. $myId =$this->getId();
  1024.  
  1025. // get the record ids that we want to inherit
  1026. $query = new SelectQuery();
  1027. $query->addTable("dr_asset_record");
  1028. $query->addColumn("structure_id");
  1029. $query->addWhere("fk_asset = '".$myId->getIdString()."'");
  1030. $query->addWhere("fk_record = '".$recordId->getIdString()."'", _AND);
  1031. $result =$dbHandler->query($query, $this->_dbIndex);
  1032. if ($result->getNumberOfRows()) {
  1033. $structureIdString = $result->field("structure_id");
  1034. $recordClass = $this->_repository->_builtInTypes[$structureIdString];
  1035. $recordStructureId =$idManager->getId($structureIdString);
  1036. $recordStructure =$this->_repository->getRecordStructure($recordStructureId);
  1037. $this->_createdRecords[$recordId->getIdString()] = new $recordClass(
  1038. $recordStructure,
  1039. $recordId,
  1040. $this->_configuration,
  1041. $this
  1042. );
  1043. }
  1044. // Otherwise use the data manager
  1045. else {
  1046. // Get the DataSet.
  1047. $recordMgr = Services::getService("RecordManager");
  1048. // Specifying TRUE for editable because it is unknown whether or not editing will
  1049. // be needed. @todo Change this if we wish to re-fetch the $dataSet when doing
  1050. // editing functions.
  1051. $record =$recordMgr->fetchRecord($recordId->getIdString());
  1052. // Make sure that we have a valid dataSet
  1053. $rule = ExtendsValidatorRule::getRule("Record");
  1054. if (!$rule->check($record))
  1055. throwError(new Error(RepositoryException::UNKNOWN_ID(), "Repository :: Asset", TRUE));
  1056. // Get the record structure.
  1057. $schema =$record->getSchema();
  1058. if (!isset($this->_createdRecordStructures[$schema->getID()])) {
  1059. $repository =$this->getRepository();
  1060. $this->_createdRecordStructures[$schema->getID()] = new HarmoniRecordStructure($schema, $repository->getId());
  1061. }
  1062. // Create the Record in our cache.
  1063. $this->_createdRecords[$recordId->getIdString()] = new HarmoniRecord (
  1064. $this->_createdRecordStructures[$schema->getID()], $record, $this);
  1065. }
  1066. $result->free();
  1067. }
  1068. return $this->_createdRecords[$recordId->getIdString()];
  1069. }
  1070.  
  1071. /**
  1072. * Get all the Records for this Asset. Iterators return a set, one at a
  1073. * time.
  1074. *
  1075. * @return object RecordIterator
  1076. *
  1077. * @throws object RepositoryException An exception with one of
  1078. * the following messages defined in
  1079. * org.osid.repository.RepositoryException may be thrown: {@link }
  1080. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1081. * OPERATION_FAILED}, {@link }
  1082. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1083. * PERMISSION_DENIED}, {@link }
  1084. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1085. * CONFIGURATION_ERROR}, {@link }
  1086. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1087. * UNIMPLEMENTED}
  1088. *
  1089. * @access public
  1090. */
  1091. function getRecords () {
  1092. $id =$this->getId();
  1093. $recordMgr = Services::getService("RecordManager");
  1094. $idManager = Services::getService("Id");
  1095. $records = array();
  1096. // Get the records from the data manager.
  1097. if ($recordSet =$recordMgr->fetchRecordSet($id->getIdString())) {
  1098. // fetching as editable since we don't know if it will be edited.
  1099. $recordSet->loadRecords();
  1100. $dmRecords =$recordSet->getRecords();
  1101. // create records for each dataSet as needed.
  1102. foreach (array_keys($dmRecords) as $key) {
  1103. $recordIdString = $dmRecords[$key]->getID();
  1104. $recordId =$idManager->getId($recordIdString);
  1105. $record =$this->getRecord($recordId);
  1106. $structure =$record->getRecordStructure();
  1107. // Add the record to our array
  1108. $records[] =$record;
  1109. }
  1110. }
  1111. // get the record ids that we want to inherit
  1112. $dbHandler = Services::getService("DatabaseManager");
  1113. $myId =$this->getId();
  1114. $query = new SelectQuery();
  1115. $query->addTable("dr_asset_record");
  1116. $query->addColumn("fk_record");
  1117. $query->addWhere("fk_asset = '".$myId->getIdString()."'");
  1118. $result =$dbHandler->query($query, $this->_dbIndex);
  1119. while ($result->hasMoreRows()) {
  1120. $recordId =$idManager->getId($result->field("fk_record"));
  1121. $records[] =$this->getRecord($recordId);
  1122. $result->advanceRow();
  1123. }
  1124. $result->free();
  1125. // Create an iterator and return it.
  1126. $recordIterator = new HarmoniRecordIterator($records);
  1127. return $recordIterator;
  1128. }
  1129. /**
  1130. * Get all the Records of the specified RecordStructure for this Asset.
  1131. * Iterators return a set, one at a time.
  1132. *
  1133. * @param object Id $recordStructureId
  1134. *
  1135. * @return object RecordIterator
  1136. *
  1137. * @throws object RepositoryException An exception with one of
  1138. * the following messages defined in
  1139. * org.osid.repository.RepositoryException may be thrown: {@link }
  1140. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1141. * OPERATION_FAILED}, {@link }
  1142. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1143. * PERMISSION_DENIED}, {@link }
  1144. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1145. * CONFIGURATION_ERROR}, {@link }
  1146. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1147. * UNIMPLEMENTED}, {@link }
  1148. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  1149. * NULL_ARGUMENT}, {@link }
  1150. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  1151. *
  1152. * @access public
  1153. */
  1154. function getRecordsByRecordStructure ( $recordStructureId ) {
  1155. ArgumentValidator::validate($recordStructureId, ExtendsValidatorRule::getRule("Id"));
  1156. $id =$this->getId();
  1157. $recordMgr = Services::getService("RecordManager");
  1158. $idManager = Services::getService("Id");
  1159. $records = array();
  1160. // Get our non-datamanager records
  1161. if (in_array($recordStructureId->getIdString(), array_keys($this->_repository->_builtInTypes)))
  1162. {
  1163. // get the record ids that we want to inherit
  1164. $dbHandler = Services::getService("DatabaseManager");
  1165. $myId =$this->getId();
  1166. $query = new SelectQuery();
  1167. $query->addTable("dr_asset_record");
  1168. $query->addColumn("fk_record");
  1169. $query->addWhere("fk_asset = '".$myId->getIdString()."'");
  1170. $query->addWhere("structure_id = '".$recordStructureId->getIdString()."'", _AND);
  1171. $result =$dbHandler->query($query, $this->_dbIndex);
  1172. while ($result->hasMoreRows()) {
  1173. $recordId =$idManager->getId($result->field("fk_record"));
  1174. $records[] =$this->getRecord($recordId);
  1175. $result->advanceRow();
  1176. }
  1177. $result->free();
  1178. }
  1179. // Get the records from the data manager.
  1180. else if ($recordSet =$recordMgr->fetchRecordSet($id->getIdString())) {
  1181. // fetching as editable since we don't know if it will be edited.
  1182. $recordSet->loadRecords();
  1183. $dmRecords =$recordSet->getRecords();
  1184. // create records for each dataSet as needed.
  1185. foreach (array_keys($dmRecords) as $key) {
  1186. $recordIdString = $dmRecords[$key]->getID();
  1187. $recordId =$idManager->getId($recordIdString);
  1188. $record =$this->getRecord($recordId);
  1189. $structure =$record->getRecordStructure();
  1190. // Add the record to our array
  1191. if ($recordStructureId->isEqual($structure->getId()))
  1192. $records[] =$record;
  1193. }
  1194. }
  1195. // Create an iterator and return it.
  1196. $recordIterator = new HarmoniRecordIterator($records);
  1197. return $recordIterator;
  1198. }
  1199. /**
  1200. * Get all the Records of the specified RecordStructureType for this Asset.
  1201. * Iterators return a set, one at a time.
  1202. *
  1203. * @param object Type $recordStructureType
  1204. *
  1205. * @return object RecordIterator
  1206. *
  1207. * @throws object RepositoryException An exception with one of
  1208. * the following messages defined in
  1209. * org.osid.repository.RepositoryException may be thrown: {@link }
  1210. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1211. * OPERATION_FAILED}, {@link }
  1212. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1213. * PERMISSION_DENIED}, {@link }
  1214. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1215. * CONFIGURATION_ERROR}, {@link }
  1216. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1217. * UNIMPLEMENTED}, {@link }
  1218. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  1219. * NULL_ARGUMENT}, {@link }
  1220. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  1221. *
  1222. * @access public
  1223. */
  1224. function getRecordsByRecordStructureType ( $recordStructureType ) {
  1225. throwError(new Error(RepositoryException::UNIMPLEMENTED(), "Repository :: Asset", TRUE));
  1226. }
  1227. /**
  1228. * Get the AssetType of this Asset. AssetTypes are used to categorize
  1229. * Assets.
  1230. *
  1231. * @return object Type
  1232. *
  1233. * @throws object RepositoryException An exception with one of
  1234. * the following messages defined in
  1235. * org.osid.repository.RepositoryException may be thrown: {@link }
  1236. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1237. * OPERATION_FAILED}, {@link }
  1238. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1239. * PERMISSION_DENIED}, {@link }
  1240. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1241. * CONFIGURATION_ERROR}, {@link }
  1242. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1243. * UNIMPLEMENTED}
  1244. *
  1245. * @access public
  1246. */
  1247. function getAssetType () {
  1248. return $this->_node->getType();
  1249. }
  1250.  
  1251. /**
  1252. * Get all the RecordStructures for this Asset. RecordStructures are used
  1253. * to categorize information about Assets. Iterators return a set, one at
  1254. * a time.
  1255. *
  1256. * @return object RecordStructureIterator
  1257. *
  1258. * @throws object RepositoryException An exception with one of
  1259. * the following messages defined in
  1260. * org.osid.repository.RepositoryException may be thrown: {@link }
  1261. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1262. * OPERATION_FAILED}, {@link }
  1263. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1264. * PERMISSION_DENIED}, {@link }
  1265. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1266. * CONFIGURATION_ERROR}, {@link }
  1267. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1268. * UNIMPLEMENTED}
  1269. *
  1270. * @access public
  1271. */
  1272. function getRecordStructures () {
  1273. // cycle through all our DataSets, get their type and make a RecordStructure for each.
  1274. $recordStructures = array();
  1275. $records =$this->getRecords();
  1276. while ($records->hasNext()) {
  1277. $record =$records->next();
  1278. $structure =$record->getRecordStructure();
  1279. $structureId =$structure->getId();
  1280. if (!isset($recordStructures[$structureId->getIdString()]))
  1281. $recordStructures[$structureId->getIdString()] =$structure;
  1282. }
  1283. $obj = new HarmoniIterator($recordStructures);
  1284. return $obj;
  1285. }
  1286.  
  1287. /**
  1288. * Get the RecordStructure associated with this Asset's content.
  1289. *
  1290. * @return object RecordStructure
  1291. *
  1292. * @throws object RepositoryException An exception with one of
  1293. * the following messages defined in
  1294. * org.osid.repository.RepositoryException may be thrown: {@link }
  1295. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1296. * OPERATION_FAILED}, {@link }
  1297. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1298. * PERMISSION_DENIED}, {@link }
  1299. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1300. * CONFIGURATION_ERROR}, {@link }
  1301. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1302. * UNIMPLEMENTED}
  1303. *
  1304. * @access public
  1305. */
  1306. function getContentRecordStructure () {
  1307. $idManager = Services::getService("Id");
  1308. $schemaMgr = Services::getService("SchemaManager");
  1309. $recordStructures =$this->_repository->getRecordStructures();
  1310.  
  1311. // Get the id of the Content DataSetTypeDef
  1312. $contentType = "edu.middlebury.harmoni.repository.asset_content";
  1313. $contentTypeId =$idManager->getId($contentType);
  1314. while ($recordStructures->hasNext()) {
  1315. $structure =$recordStructures->next();
  1316. if ($contentTypeId->isEqual($structure->getId()))
  1317. return $structure;
  1318. }
  1319. throwError(new Error(RepositoryException::OPERATION_FAILED(), "Repository :: Asset", TRUE));
  1320. }
  1321. /**
  1322. * Get the Part for a Record for this Asset that matches this Part's unique
  1323. * Id.
  1324. *
  1325. * @param object Id $partId
  1326. *
  1327. * @return object Part
  1328. *
  1329. * @throws object RepositoryException An exception with one of
  1330. * the following messages defined in
  1331. * org.osid.repository.RepositoryException may be thrown: {@link }
  1332. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1333. * OPERATION_FAILED}, {@link }
  1334. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1335. * PERMISSION_DENIED}, {@link }
  1336. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1337. * CONFIGURATION_ERROR}, {@link }
  1338. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1339. * UNIMPLEMENTED}, {@link }
  1340. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  1341. * NULL_ARGUMENT}, {@link }
  1342. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  1343. *
  1344. * @access public
  1345. */
  1346. function getPart ( $partId ) {
  1347. $records =$this->getRecords();
  1348. while ($records->hasNext()) {
  1349. $record =$records->next();
  1350. $parts =$record->getParts();
  1351. while ($parts->hasNext()) {
  1352. $part =$parts->next();
  1353. if ($partId->isEqual($part->getId()))
  1354. return $part;
  1355. }
  1356. }
  1357. // Throw an error if we didn't find the part.
  1358. throwError(new Error(RepositoryException::UNKNOWN_ID(), "Repository :: Asset", TRUE));
  1359. }
  1360. /**
  1361. * Get the Value of the Part of the Record for this Asset that matches this
  1362. * Part's unique Id.
  1363. *
  1364. * @param object Id $partId
  1365. *
  1366. * @return object mixed (original type: java.io.Serializable)
  1367. *
  1368. * @throws object RepositoryException An exception with one of
  1369. * the following messages defined in
  1370. * org.osid.repository.RepositoryException may be thrown: {@link }
  1371. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1372. * OPERATION_FAILED}, {@link }
  1373. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1374. * PERMISSION_DENIED}, {@link }
  1375. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1376. * CONFIGURATION_ERROR}, {@link }
  1377. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1378. * UNIMPLEMENTED}, {@link }
  1379. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  1380. * NULL_ARGUMENT}, {@link }
  1381. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  1382. *
  1383. * @access public
  1384. */
  1385. function getPartValue ( $partId ) {
  1386. $part =$this->getPart($partId);
  1387. return $part->getValue();
  1388. }
  1389. /**
  1390. * Get the Parts of the Records for this Asset that are based on this
  1391. * RecordStructure PartStructure's unique Id.
  1392. *
  1393. * @param object Id $partStructureId
  1394. *
  1395. * @return object PartIterator
  1396. *
  1397. * @throws object RepositoryException An exception with one of
  1398. * the following messages defined in
  1399. * org.osid.repository.RepositoryException may be thrown: {@link }
  1400. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1401. * OPERATION_FAILED}, {@link }
  1402. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1403. * PERMISSION_DENIED}, {@link }
  1404. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1405. * CONFIGURATION_ERROR}, {@link }
  1406. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1407. * UNIMPLEMENTED}, {@link }
  1408. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  1409. * NULL_ARGUMENT}, {@link }
  1410. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  1411. *
  1412. * @access public
  1413. */
  1414. function getPartsByPartStructure ( $partStructureId ) {
  1415. $returnParts = array();
  1416. $records =$this->getRecords();
  1417. while ($records->hasNext()) {
  1418. $record =$records->next();
  1419. $parts =$record->getParts();
  1420. while ($parts->hasNext()) {
  1421. $part =$parts->next();
  1422. $partStructure =$part->getPartStructure();
  1423. if ($partStructureId->isEqual($partStructure->getId()))
  1424. $returnParts[] =$part;
  1425. }
  1426. }
  1427. $obj = new HarmoniIterator($returnParts);
  1428. return $obj;
  1429. }
  1430. /**
  1431. * Get the Values of the Parts of the Records for this Asset that are based
  1432. * on this RecordStructure PartStructure's unique Id.
  1433. *
  1434. * @param object Id $partStructureId
  1435. *
  1436. * @return object ObjectIterator
  1437. *
  1438. * @throws object RepositoryException An exception with one of
  1439. * the following messages defined in
  1440. * org.osid.repository.RepositoryException may be thrown: {@link }
  1441. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1442. * OPERATION_FAILED}, {@link }
  1443. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1444. * PERMISSION_DENIED}, {@link }
  1445. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1446. * CONFIGURATION_ERROR}, {@link }
  1447. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1448. * UNIMPLEMENTED}, {@link }
  1449. * org.osid.repository.RepositoryException#NULL_ARGUMENT
  1450. * NULL_ARGUMENT}, {@link }
  1451. * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  1452. *
  1453. * @access public
  1454. */
  1455. function getPartValuesByPartStructure ( $partStructureId ) {
  1456. $partIterator =$this->getPartsByPartStructure($partStructureId);
  1457. $partValues = array();
  1458. // print $partStructureId->getIdString()."<br />";
  1459. while ($partIterator->hasNext()) {
  1460. $part =$partIterator->next();
  1461. $partValues[] =$part->getValue();
  1462. }
  1463. $obj = new HarmoniIterator($partValues);
  1464. return $obj;
  1465. }
  1466.  
  1467. /**
  1468. * Store the effective and expiration Dates. getEffectiveDate or getExpirationDate
  1469. * should be called first to set the datesInDB flag.
  1470. *
  1471. * @return void
  1472. * @access public
  1473. * @since 8/10/04
  1474. */
  1475. function _storeDates () {
  1476. $dbHandler = Services::getService("DatabaseManager");
  1477. $id =$this->_node->getId();
  1478. // If we have stored dates for this asset set them
  1479. if ($this->_datesInDB) {
  1480. $query = new UpdateQuery;
  1481. $query->addWhereEqual("asset_id", $id->getIdString());
  1482. }
  1483. // Otherwise, insert Them
  1484. else {
  1485. $query = new InsertQuery;
  1486. }
  1487. $query->addValue("asset_id", $id->getIdString());
  1488. if (is_object($this->_effectiveDate))
  1489. $query->addValue("effective_date", $dbHandler->toDBDate($this->_effectiveDate, $this->_dbIndex));
  1490. else
  1491. $query->addRawValue("effective_date", "NULL");
  1492. if (is_object($this->_expirationDate))
  1493. $query->addValue("expiration_date", $dbHandler->toDBDate($this->_expirationDate, $this->_dbIndex));
  1494. else
  1495. $query->addRawValue("expiration_date", "NULL");
  1496. if (is_object($this->_createDate) && $this->_createDate->isNotEqualTo(DateAndTime::epoch())) {
  1497. $query->addValue("create_timestamp", $dbHandler->toDBDate($this->_createDate, $this->_dbIndex));
  1498. $query->addRawValue("modify_timestamp", "NOW()");
  1499. }
  1500. // We are creating the asset.
  1501. else {
  1502. $query->addRawValue("create_timestamp", "NOW()");
  1503. $query->addRawValue("modify_timestamp", "NOW()");
  1504. // Add the creator
  1505. $agentId = $this->_getCurrentAgent();
  1506. $query->addValue("creator", $agentId->getIdString());
  1507. }
  1508. $query->setTable("dr_asset_info");
  1509. $result =$dbHandler->query($query, $this->_dbIndex);
  1510. }
  1511. /**
  1512. * Answer the current agent id
  1513. *
  1514. * @return object Id
  1515. * @access private
  1516. * @since 7/9/07
  1517. */
  1518. function _getCurrentAgent () {
  1519. $authN = Services::getService("AuthN");
  1520. $agentM = Services::getService("Agent");
  1521. $idM = Services::getService("Id");
  1522. $authTypes =$authN->getAuthenticationTypes();
  1523. while ($authTypes->hasNext()) {
  1524. $authType =$authTypes->next();
  1525. $id =$authN->getUserId($authType);
  1526. if (!$id->isEqual($idM->getId('edu.middlebury.agents.anonymous'))) {
  1527. return $id;
  1528. }
  1529. }
  1530. // If we didn't find an agent, return the anonymous id.
  1531. return $idM->getId('edu.middlebury.agents.anonymous');
  1532. }
  1533. /**
  1534. * Loads dates from the database and sets the _datesInDB flag
  1535. *
  1536. * @return void
  1537. * @access public
  1538. * @since 8/10/04
  1539. */
  1540. function _loadDates () {
  1541. $dbHandler = Services::getService("DatabaseManager");
  1542. // Get the content DataSet.
  1543. $id =$this->_node->getId();
  1544. $query = new SelectQuery;
  1545. $query->addTable("dr_asset_info");
  1546. $query->addColumn("effective_date");
  1547. $query->addColumn("expiration_date");
  1548. $query->addColumn("create_timestamp");
  1549. $query->addColumn("creator");
  1550. $query->addColumn("modify_timestamp");
  1551. $query->addWhere("asset_id='".$id->getIdString()."'");
  1552. $result =$dbHandler->query($query, $this->_dbIndex);
  1553. // If we have stored dates for this asset set them
  1554. if ($result->getNumberOfRows()) {
  1555. $this->_effectiveDate =$dbHandler->fromDBDate($result->field("effective_date"), $this->_dbIndex);
  1556. $this->_expirationDate =$dbHandler->fromDBDate($result->field("expiration_date"), $this->_dbIndex);
  1557. $this->_createDate =$dbHandler->fromDBDate($result->field("create_timestamp"), $this->_dbIndex);
  1558. $this->_creator = $result->field("creator");
  1559. $this->_modifyDate =$dbHandler->fromDBDate($result->field("modify_timestamp"), $this->_dbIndex);
  1560. $this->_datesInDB = TRUE;
  1561. if (!$this->_createDate)
  1562. $this->_createDate = DateAndTime::epoch();
  1563. if (!$this->_modifyDate)
  1564. $this->_modifyDate = DateAndTime::epoch();
  1565. }
  1566. else {
  1567. $this->_effectiveDate = NULL;
  1568. $this->_expirationDate = NULL;
  1569. $this->_createDate = DateAndTime::epoch();
  1570. $this->_modifyDate = DateAndTime::epoch();
  1571. $this->_creator = NULL;
  1572. $this->_datesInDB = FALSE;
  1573. }
  1574. $result->free();
  1575. }
  1576. /**
  1577. * Update the modification date and set the creation date if needed.
  1578. *
  1579. * WARNING: NOT IN OSID
  1580. *
  1581. * @return void
  1582. * @access public
  1583. * @since 5/4/06
  1584. */
  1585. function updateModificationDate () {
  1586. // Only update our modification time if we will be adding more than a
  1587. // minute (to save on many repeated updates while changing lots of values
  1588. // at once).
  1589. if (isset($this->_modifyDate) && is_object($this->_modifyDate)) {
  1590. $now = DateAndTime::now();
  1591. $minute = Duration::withSeconds(60);
  1592. if ($minute->isGreaterThan($now->minus($this->_modifyDate)))
  1593. return;
  1594. }
  1595. $this->_loadDates();
  1596. $this->_storeDates();
  1597. }
  1598. /**
  1599. * Get the date at which this Asset was created.
  1600. *
  1601. * WARNING: NOT IN OSID
  1602. *
  1603. * @return object DateAndTime
  1604. *
  1605. * @throws object RepositoryException An exception with one of
  1606. * the following messages defined in
  1607. * org.osid.repository.RepositoryException may be thrown: {@link }
  1608. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1609. * OPERATION_FAILED}, {@link }
  1610. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1611. * PERMISSION_DENIED}, {@link }
  1612. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1613. * CONFIGURATION_ERROR}, {@link }
  1614. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1615. * UNIMPLEMENTED}
  1616. *
  1617. * @access public
  1618. */
  1619. function getCreationDate () {
  1620. if (!isset($this->_createDate) || $this->_createDate->isEqualTo(DateAndTime::epoch())) {
  1621. $this->_loadDates();
  1622. }
  1623. return $this->_createDate;
  1624. }
  1625. /**
  1626. * Answer the Id of the agent that created the asset
  1627. *
  1628. * WARNING: NOT IN OSID
  1629. *
  1630. * @return object Id
  1631. * @access public
  1632. * @since 7/9/07
  1633. */
  1634. function getCreator () {
  1635. if (!isset($this->_creator)) {
  1636. $this->_loadDates();
  1637. }
  1638. if (is_null($this->_creator)) {
  1639. $null = null;
  1640. return $null;
  1641. } else {
  1642. $idManager = Services::getService("Id");
  1643. return $idManager->getId($this->_creator);
  1644. }
  1645. }
  1646. /**
  1647. * Get the date at which this Asset was created.
  1648. *
  1649. * WARNING: NOT IN OSID
  1650. *
  1651. * @return object DateAndTime
  1652. *
  1653. * @throws object RepositoryException An exception with one of
  1654. * the following messages defined in
  1655. * org.osid.repository.RepositoryException may be thrown: {@link }
  1656. * org.osid.repository.RepositoryException#OPERATION_FAILED
  1657. * OPERATION_FAILED}, {@link }
  1658. * org.osid.repository.RepositoryException#PERMISSION_DENIED
  1659. * PERMISSION_DENIED}, {@link }
  1660. * org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  1661. * CONFIGURATION_ERROR}, {@link }
  1662. * org.osid.repository.RepositoryException#UNIMPLEMENTED
  1663. * UNIMPLEMENTED}
  1664. *
  1665. * @access public
  1666. */
  1667. function getModificationDate () {
  1668. if (!isset($this->_modifyDate) || $this->_modifyDate->isEqualTo(DateAndTime::epoch())) {
  1669. $this->_loadDates();
  1670. }
  1671. return $this->_modifyDate;
  1672. }
  1673. /**
  1674. * Saves this object to persistable storage.
  1675. * @access protected
  1676. */
  1677. function save () {
  1678. // Save the dataManager
  1679. $recordMgr = Services::getService("RecordManager");
  1680. $nodeId =$this->_node->getId();
  1681. $group =$recordMgr->fetchRecordSet($nodeId->getIdString(), true);
  1682. // The ignoreMandatory Allows this record to be created without checking for
  1683. // values on mandatory fields. These constraints should be checked when
  1684. // validateAsset() is called.
  1685. if ($group) $group->commit(TRUE);
  1686. }
  1687.  
  1688. } // end Asset
  1689. ?>

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