示例#1
0
 /**
  * Update the value for this Part.
  * 
  * @param object mixed $value (original type: java.io.Serializable)
  * 
  * @throws object RepositoryException An exception with one of
  *		   the following messages defined in
  *		   org.osid.repository.RepositoryException may be thrown: {@link
  *		   org.osid.repository.RepositoryException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.repository.RepositoryException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.repository.RepositoryException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.repository.RepositoryException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}
  * 
  * @access public
  */
 function updateValue($value)
 {
     throwError(new Error(RepositoryException::PERMISSION_DENIED(), "FileSizePart", true));
 }
 /**
  * Create a Part.  Records are composed of Parts. Parts can also contain
  * other Parts.	 Each Record is associated with a specific RecordStructure
  * and each Part is associated with a specific PartStructure.
  * 
  * @param object Id $partStructureId
  * @param object mixed $value (original type: java.io.Serializable)
  *	
  * @return object Part
  * 
  * @throws object RepositoryException An exception with one of
  *		   the following messages defined in
  *		   org.osid.repository.RepositoryException may be thrown: {@link
  *		   org.osid.repository.RepositoryException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.repository.RepositoryException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.repository.RepositoryException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.repository.RepositoryException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function createPart(Id $partStructureId, $value)
 {
     ArgumentValidator::validate($value, ExtendsValidatorRule::getRule("SObject"));
     $partID = $partStructureId->getIdString();
     // we need to find the label associated with this ID
     $schema = $this->_record->getSchema();
     $found = false;
     foreach ($schema->getAllIDs() as $id) {
         if ($partID == $id) {
             $found = true;
             $part = $schema->getField($id);
             break;
         }
     }
     if (!$found) {
         throwError(new Error(RepositoryException::UNKNOWN_ID() . ": {$partID}.", "HarmoniRecord", true));
     }
     $label = $schema->getFieldLabelFromID($id);
     $this->_record->makeFull();
     // make sure we have a full data representation.
     // If the value is deleted, add a new version to it.
     if ($this->_record->numValues($label, true) && $this->_record->isValueDeleted($label)) {
         $this->_record->undeleteValue($label);
         $this->_record->setValue($label, $value);
         // If the field is not multi-valued AND has a value AND that value is not deleted,
         // throw an error.
     } else {
         if (!$part->getMultFlag() && $this->_record->numValues($label) && $this->_record->getValue($label)) {
             throwError(new Error(RepositoryException::PERMISSION_DENIED() . ": Can't add another field to a\n\t\t\tnon-multi-valued part.", "HarmoniRecord", true));
             // If we dont' have an existing, deleted field to add to, create a new index.
         } else {
             $this->_record->setValue($label, $value, NEW_VALUE);
         }
     }
     $this->_record->commit(TRUE);
     $repository = $this->_asset->getRepository();
     $part = new HarmoniPart(new HarmoniPartStructure($this->manager, $this->_recordStructure, $part, $repository->getId()), $this->_record->getRecordFieldValue($id, $this->_record->numValues($label) - 1), $this->_asset);
     $this->_asset->updateModificationDate();
     return $part;
 }