Author: sevein
Date: Sun Nov  6 18:51:47 2011
New Revision: 10275

Log:
Helper function to import access points by name

Modified:
   trunk/lib/model/QubitInformationObject.php

Modified: trunk/lib/model/QubitInformationObject.php
==============================================================================
--- trunk/lib/model/QubitInformationObject.php  Sun Nov  6 18:00:42 2011        
(r10274)
+++ trunk/lib/model/QubitInformationObject.php  Sun Nov  6 18:51:47 2011        
(r10275)
@@ -1116,15 +1116,46 @@
     }
   }
 
+  /**
+   * Import access points (only subjects and places)
+   */
+  public function setAccessPointByName($name, $options = array())
+  {
+    // Only create an linked access point if the type is indicated
+    if (!isset($options['type_id']))
+    {
+      return;
+    }
+
+    // See if the access point record already exists, if not create it
+    $criteria = new Criteria;
+    $criteria->addJoin(QubitTerm::ID, QubitTermI18n::ID);
+    $criteria->add(QubitTermI18n::NAME, $name);
+    $criteria->add(QubitTerm::TAXONOMY_ID, $options['type_id']);
+
+    if (null === $accessPoint = QubitTerm::getOne($criteria))
+    {
+      $accessPoint = new QubitTerm;
+      $accessPoint->setName($name);
+      $accessPoint->setTaxonomyId($options['type_id']);
+      $accessPoint->save();
+    }
+
+    $relation = new QubitObjectTermRelation;
+    $relation->term = $accessPoint;
+
+    $this->objectTermRelationsRelatedByobjectId[] = $relation;
+  }
+
   public function setActorByName($name, $options)
   {
-    // only create an linked Actor if the event or relation type is indicated
+    // Only create an linked Actor if the event or relation type is indicated
     if (!isset($options['event_type_id']) && 
!isset($options['relation_type_id']))
     {
       return;
     }
 
-    // see if the Actor record already exists, if not create it
+    // See if the Actor record already exists, if not create it
     $criteria = new Criteria;
     $criteria->addJoin(QubitActor::ID, QubitActorI18n::ID);
     $criteria->add(QubitActorI18n::AUTHORIZED_FORM_OF_NAME, $name);

-- 
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.com/group/qubit-commits?hl=en.

Reply via email to