Author: peter
Date: 2008-10-20 14:22:33 -0700 (Mon, 20 Oct 2008)
New Revision: 1478

Modified:
   
trunk/qubit/apps/qubit/modules/informationobject/actions/createAction.class.php
   trunk/qubit/apps/qubit/modules/informationobject/actions/editAction.class.php
   trunk/qubit/apps/qubit/modules/informationobject/actions/showAction.class.php
   
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php
   trunk/qubit/lib/model/QubitInformationObject.php
Log:
update informationobject module to do add 'material type' to CRUD, read RAD 
notes, and clean-up Notes CRUD functions to use  array as per coding standard

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/actions/createAction.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/actions/createAction.class.php 
    2008-10-20 19:04:10 UTC (rev 1477)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/actions/createAction.class.php 
    2008-10-20 21:22:33 UTC (rev 1478)
@@ -87,10 +87,12 @@
         $this->setTemplate('editISAD');
         break;
       case 'rad' :
-        $this->setTemplate('editRAD');
-        // initialize variables used only in RAD template
+        // set variables used only in RAD template
         $this->radNotes = null;
+        $this->newRadNote = new QubitNote;
         $this->radTitleNotes = null;
+        $this->newRadTitleNote = new QubitNote;
+        $this->setTemplate('editRAD');
         break;        
       case 'mods' :
         $this->setTemplate('editMODS');

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/actions/editAction.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/actions/editAction.class.php   
    2008-10-20 19:04:10 UTC (rev 1477)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/actions/editAction.class.php   
    2008-10-20 21:22:33 UTC (rev 1478)
@@ -56,9 +56,9 @@
     //Notes
     $this->notes = $this->informationObject->getNotes();
     $this->newNote = new QubitNote;
-    $this->titleNotes = $this->informationObject->getNotesByType($noteTypeId = 
QubitTerm::TITLE_NOTE_ID, $exclude = null);
+    $this->titleNotes = $this->informationObject->getNotesByType($options = 
array ('noteTypeId' => QubitTerm::TITLE_NOTE_ID, 'dog' => 2));
     $this->newTitleNote = new QubitNote;
-    $this->publicationNotes = 
$this->informationObject->getNotesByType($noteTypeId = 
QubitTerm::PUBLICATION_NOTE_ID, $exclude = null);
+    $this->publicationNotes = 
$this->informationObject->getNotesByType($options = array ('noteTypeId' => 
QubitTerm::PUBLICATION_NOTE_ID));
     $this->newPublicationNote = new QubitNote;
 
     //Access Points
@@ -77,6 +77,10 @@
       }
     }
     
+    // Material Type
+    $this->newMaterialType = new QubitObjectTermRelation;
+    $this->materialTypes = $this->informationObject->getMaterialTypes();
+    
     // Count related digital objects for warning message when deleting info 
object
     // Note: This should only be 0 or 1 digital objects.
     $this->digitalObjectCount = 0;
@@ -99,6 +103,13 @@
       case 'isad' :
         $this->setTemplate('editISAD');
         break;
+      case 'rad' :
+        $this->radNotes = 
$this->informationObject->getNotesByTaxonomy($options = array('noteTypeId' => 
QubitTaxonomy::RAD_NOTE_ID));
+        $this->newRadNote = new QubitNote;
+        $this->radTitleNotes = 
$this->informationObject->getNotesByTaxonomy($options = array('noteTypeId' => 
QubitTaxonomy::RAD_TITLE_NOTE_ID));
+        $this->newRadTitleNote = new QubitNote;        
+        $this->setTemplate('editRAD');
+        break;        
       case 'mods' :
         $this->setTemplate('editMODS');
         break;

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/actions/showAction.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/actions/showAction.class.php   
    2008-10-20 19:04:10 UTC (rev 1477)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/actions/showAction.class.php   
    2008-10-20 21:22:33 UTC (rev 1478)
@@ -51,6 +51,9 @@
         $this->nameAccessPoints[] = $event;
       }
     }
+    
+    $this->materialTypes = $this->informationObject->getMaterialTypes();
+    
     $this->physicalObjects = 
QubitRelation::getRelatedSubjectsByObjectId($this->informationObject->getId(),
       array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
 
@@ -75,6 +78,12 @@
       case 'isad' :
         $this->setTemplate('showISAD');
         break;
+      case 'rad' :
+        // set variables used only in RAD template
+        $this->radNotes = 
$this->informationObject->getNotesByTaxonomy($options = array('noteTypeId' => 
'QubitTaxonomy::RAD_NOTE_ID'));
+        $this->radTitleNotes = 
$this->informationObject->getNotesByTaxonomy($options = array('noteTypeId' => 
'QubitTaxonomy::RAD_TITLE_NOTE_ID'));        
+        $this->setTemplate('showRAD');
+        break;
       case 'mods' :
         $this->setTemplate('showMODS');
         break;

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php 
    2008-10-20 19:04:10 UTC (rev 1477)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php 
    2008-10-20 21:22:33 UTC (rev 1478)
@@ -262,17 +262,17 @@
   {
     if ($this->getRequestParameter('new_title_note'))
     {
-      $informationObject->setNote($this->getUser()->getAttribute('user_id'), 
$this->getRequestParameter('new_title_note'), QubitTerm::TITLE_NOTE_ID);
+      $informationObject->setNote($options = array('userId' => 
$this->getUser()->getAttribute('user_id'), 'note' => 
$this->getRequestParameter('new_title_note'), 'noteTypeId' => 
QubitTerm::TITLE_NOTE_ID));
     }
 
     if ($this->getRequestParameter('new_publication_note'))
     {
-      $informationObject->setNote($this->getUser()->getAttribute('user_id'), 
$this->getRequestParameter('new_publication_note'), 
QubitTerm::PUBLICATION_NOTE_ID);
+      $informationObject->setNote($options = array('userId' => 
$this->getUser()->getAttribute('user_id'), 'note' => 
$this->getRequestParameter('new_publication_note'), 'noteTypeId' => 
QubitTerm::PUBLICATION_NOTE_ID));
     }
 
     if ($this->getRequestParameter('content'))
     {
-      $informationObject->setNote($this->getUser()->getAttribute('user_id'), 
$this->getRequestParameter('content'), 
$this->getRequestParameter('note_type_id'));
+      $informationObject->setNote($options = array('userId' => 
$this->getUser()->getAttribute('user_id'), 'note' => 
$this->getRequestParameter('content'), 'noteTypeId' => 
$this->getRequestParameter('note_type_id')));
     }
   }
 
@@ -288,7 +288,7 @@
       foreach ($language_codes as $language_code) {
         if (strlen($language_code)) {
           $informationObject->addProperty($name = 
'information_object_language', $language_code, $scope = 'languages');
-               $this->foreignKeyUpdate = true;
+          $this->foreignKeyUpdate = true;
         }
       }
     }
@@ -364,11 +364,26 @@
       
       foreach ($place_ids as $place_id) {
         if (intval($place_id)) {
-               $informationObject->addTermRelation($place_id, 
QubitTaxonomy::PLACE_ID);
-                     $this->foreignKeyUpdate = true;
+          $informationObject->addTermRelation($place_id, 
QubitTaxonomy::PLACE_ID);
+          $this->foreignKeyUpdate = true;
         }
       }
     }
+    
+    if ($material_type_ids = $this->getRequestParameter('material_type_id'))
+    {
+      // Make sure that $material_type_id is an array, even if it's only got 
one value
+      $material_type_ids = (is_array($material_type_ids)) ? $material_type_ids 
: array($material_type_ids);
+      
+      foreach ($material_type_ids as $material_type_id) {
+        if (intval($material_type_id)) {
+          $informationObject->addTermRelation($material_type_id, 
QubitTaxonomy::MATERIAL_TYPE_ID);
+          $this->foreignKeyUpdate = true;
+      
+        }
+      }
+    }
+    
   }
 
   public function updateActorEvents($informationObject)
@@ -429,8 +444,8 @@
       
       foreach ($name_ids as $name_id) {
         if (intval($name_id)) {
-               $informationObject->addNameAccessPoint($name_id, 
QubitTerm::SUBJECT_ID);
-               $this->foreignKeyUpdate = true;
+          $informationObject->addNameAccessPoint($name_id, 
QubitTerm::SUBJECT_ID);
+          $this->foreignKeyUpdate = true;
         }
       }
     }

Modified: trunk/qubit/lib/model/QubitInformationObject.php
===================================================================
--- trunk/qubit/lib/model/QubitInformationObject.php    2008-10-20 19:04:10 UTC 
(rev 1477)
+++ trunk/qubit/lib/model/QubitInformationObject.php    2008-10-20 21:22:33 UTC 
(rev 1478)
@@ -203,34 +203,49 @@
     return $this->getAncestors()->orderBy('lft')->offsetGet(1, 
array('defaultValue' => $this));
   }
 
-  public function setNote($userId, $note, $noteTypeId)
+  public function setNote(array $options = array())
   {
     $newNote = new QubitNote;
     $newNote->setObject($this);
     $newNote->setScope('QubitInformationObject');
-    $newNote->setUserId($userId);
-    $newNote->setContent($note);
-    $newNote->setTypeId($noteTypeId);
+    $newNote->setUserId($options['userId']);
+    $newNote->setContent($options['note']);
+    $newNote->setTypeId($options['noteTypeId']);
     $newNote->save();
   }
 
-  public function getNotesByType($noteTypeId = null, $excludeNoteTypeId = null)
+  public function getNotesByType(array $options = array())
   {
     $criteria = new Criteria;
     $criteria->addJoin(QubitNote::TYPE_ID, QubitTerm::ID);
     $criteria->add(QubitNote::OBJECT_ID, $this->getId());
-    if ($noteTypeId)
+    if (isset($options['noteTypeId']))
       {
-      $criteria->add(QubitNote::TYPE_ID, $noteTypeId);
+      $criteria->add(QubitNote::TYPE_ID, $options['noteTypeId']);
       }
-    if ($excludeNoteTypeId)
+    if (isset($options['excludeNoteTypeId']))
       {
-      $criteria->add(QubitNote::TYPE_ID, $excludeNoteTypeId, 
Criteria::NOT_EQUAL);
+      $criteria->add(QubitNote::TYPE_ID, $options['excludeNoteTypeId'], 
Criteria::NOT_EQUAL);
       }
 
     return QubitNote::get($criteria);
   }
+  
+  
+  public function getNotesByTaxonomy(array $options = array())
+  {
+    $criteria = new Criteria;
+    $criteria->addJoin(QubitNote::TYPE_ID, QubitTerm::ID);
+    $criteria->add(QubitNote::OBJECT_ID, $this->getId());
+    if (isset($options['taxonomyId']))
+      {
+      $criteria->add(QubitTerm::TAXONOMY_ID, $options['taxonomyId']);
+      }
 
+    return QubitNote::get($criteria);
+  }
+  
+
   //Actor-Event Relations
   public function getActors($actorRoleTypeId = null)
   {
@@ -365,12 +380,12 @@
     // Don't add a term relation to this information object that already 
exists. 
     if ($this->getTermRelation($termId) === NULL)
     {
-           $newTermRelation = new QubitObjectTermRelation;
-           $newTermRelation->setObject($this);
-           $newTermRelation->setTermId($termId);
-       //TODO: move to QubitNote
-       //  $newTermRelation->setRelationNote($relationNote);
-           $newTermRelation->save();
+      $newTermRelation = new QubitObjectTermRelation;
+      $newTermRelation->setObject($this);
+      $newTermRelation->setTermId($termId);
+  //TODO: move to QubitNote
+  //  $newTermRelation->setRelationNote($relationNote);
+      $newTermRelation->save();
     }
     
     return $this;
@@ -416,12 +431,12 @@
   {
     // Only add this property if an identical one does NOT exist already
     if ($this->getProperty($name, $value, $scope) === null) {
-           $newCode = new QubitProperty;
-           $newCode->setObjectId($this->getId());
-           $newCode->setName($name);
-           $newCode->setValue($value);
-           $newCode->setScope($scope);
-           $newCode->save();
+      $newCode = new QubitProperty;
+      $newCode->setObjectId($this->getId());
+      $newCode->setName($name);
+      $newCode->setValue($value);
+      $newCode->setScope($scope);
+      $newCode->save();
     }
     
     return $this;
@@ -472,15 +487,15 @@
 
   public function setSubjectAccessPoint($subject)
   {
-         // add the subject to term list (assuming it's a new subject)
-         // TODO: check first to see if this term exists, in which case, just 
get its ID
-         $newTerm = new QubitTerm;
-         $newTerm->setTaxonomyId(QubitTaxonomy::SUBJECT_ID);
-         $newTerm->setName($subject);
-         $newTerm->save();
-       
-         // associate this new subject term with this information object
-         $this->addTermRelation($newTerm->getId());
+    // add the subject to term list (assuming it's a new subject)
+    // TODO: check first to see if this term exists, in which case, just get 
its ID
+    $newTerm = new QubitTerm;
+    $newTerm->setTaxonomyId(QubitTaxonomy::SUBJECT_ID);
+    $newTerm->setName($subject);
+    $newTerm->save();
+  
+    // associate this new subject term with this information object
+    $this->addTermRelation($newTerm->getId());
   }
 
   public function getSubjectAccessPoints()
@@ -506,11 +521,11 @@
     // doesn't already exist
     if ($this->getNameAccessPoint($actorId, $actorRoleId) === NULL)
     {
-           $newNameAccessPoint = new QubitEvent;
-           $newNameAccessPoint->setActorId($actorId);
-           $newNameAccessPoint->setActorRoleId($actorRoleId);
-           $newNameAccessPoint->setInformationObjectId($this->getId());
-           $newNameAccessPoint->save();
+      $newNameAccessPoint = new QubitEvent;
+      $newNameAccessPoint->setActorId($actorId);
+      $newNameAccessPoint->setActorRoleId($actorRoleId);
+      $newNameAccessPoint->setInformationObjectId($this->getId());
+      $newNameAccessPoint->save();
     }
     
     return $this;
@@ -556,7 +571,26 @@
   {
     //TO DO: get via linked digital objects & physical objects
   }
+  
+  
+  public function setMaterialType($materialType)
+  {
+    // add the materialType to term list (assuming it's a new subject)
+    // TODO: check first to see if this term exists, in which case, just get 
its ID
+    $newTerm = new QubitTerm;
+    $newTerm->setTaxonomyId(QubitTaxonomy::MATERIAL_TYPE_ID);
+    $newTerm->setName($materialType);
+    $newTerm->save();
+  
+    // associate this new subject term with this information object
+    $this->addTermRelation($newTerm->getId());
+  }
 
+  public function getMaterialTypes()
+  {
+    return $this->getTermRelations(QubitTaxonomy::MATERIAL_TYPE_ID);
+  }
+
   public function getReferenceCode(array $options = array())
   {
     // set default value
@@ -738,11 +772,11 @@
     // Don't add an identical info object -> physical object relationship
     if (get_class($physicalObject) == 'QubitPhysicalObject' && 
$this->getPhysicalObject($physicalObject->getId()) === null)
     {
-           $relation = new QubitRelation;
-           $relation->setObject($this);
-           $relation->setSubject($physicalObject);
-           $relation->setTypeId(QubitTerm::HAS_PHYSICAL_OBJECT_ID);
-           $relation->save();
+      $relation = new QubitRelation;
+      $relation->setObject($this);
+      $relation->setSubject($physicalObject);
+      $relation->setTypeId(QubitTerm::HAS_PHYSICAL_OBJECT_ID);
+      $relation->save();
     }
 
     return $this;


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to