Author: mcantelon
Date: Mon Jan  2 17:34:40 2012
New Revision: 10527

Log:
Added duplication prevention to access point creation method.

Modified:
   trunk/lib/QubitFlatfileImport.class.php

Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php     Mon Jan  2 17:22:19 2012        
(r10526)
+++ trunk/lib/QubitFlatfileImport.class.php     Mon Jan  2 17:34:40 2012        
(r10527)
@@ -319,14 +319,23 @@
 
   public function createAccessPoint($taxonomyId, $name, $culture = 'en')
   {
-    $term = new QubitTerm();
-    $term->taxonomyId = $taxonomyId;
-    $term->name = $name;
-    $term->culture = $culture;
-    $term->save();
+
+    $query = "SELECT t.id FROM term t \r
+      LEFT JOIN term_i18n ti ON t.id=ti.id \r
+      WHERE t.taxonomy_id=? AND ti.name=? AND ti.culture=?";
+    $statement = $this->sqlQuery($query, array($taxonomyId, $name, $culture));
+
+    if (!($term = $statement->fetch(PDO::FETCH_OBJ)))
+    {
+      $term = new QubitTerm();
+      $term->taxonomyId = $taxonomyId;
+      $term->name = $name;
+      $term->culture = $culture;
+      $term->save();
+    }
 
     $relation = new QubitObjectTermRelation;
-    $relation->term = $term;
+    $relation->termId = $term->id;
     $relation->objectId = $this->informationObject->id;
     $relation->save();
   }

-- 
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