Author: mcantelon
Date: Thu May 24 16:10:46 2012
New Revision: 11704

Log:
Added logic to import scope for subject/place access points.

Modified:
   trunk/lib/task/import/csvImportTask.class.php

Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php       Thu May 24 14:21:05 
2012        (r11703)
+++ trunk/lib/task/import/csvImportTask.class.php       Thu May 24 16:10:46 
2012        (r11704)
@@ -292,7 +292,7 @@
         'placeAccessPoints'    => '|',
         'placeAccessPointHistories' => '|', // not yet implemented
         'subjectAccessPoints'  => '|',
-        'subjectAccessPointHistories' => '|', // not yet implemented
+        'subjectAccessPointScopes' => '|', // not yet implemented
 
         'eventActors'          => '|',
         'eventTypes'           => '|',
@@ -500,9 +500,60 @@
           {
             if (isset($self->rowStatusVars[$columnName]))
             {
+              $index = 0;
               foreach($self->rowStatusVars[$columnName] as $subject)
               {
+                $scope = FALSE;
+                if 
(isset($self->rowStatusVars['subjectAccessPointScopes'][$index]))
+                {
+                  $scope = 
$self->rowStatusVars['subjectAccessPointScopes'][$index];
+                }
+
                 $self->createAccessPoint($taxonomyId, $subject);
+
+                if ($scope)
+                {
+                  // get term ID
+                  $query = "SELECT t.id FROM term t \r
+                    INNER JOIN term_i18n i ON t.id=i.id \r
+                    WHERE i.name=? AND t.taxonomy_id=? AND culture='en'";
+
+                  $statement = QubitFlatfileImport::sqlQuery(
+                    $query,
+                    array($subject, $taxonomyId)
+                  );
+
+                  $result = $statement->fetch(PDO::FETCH_OBJ);
+
+                  if ($result)
+                  {
+                    $termId = $result->id;
+
+                    // check if a scope note already exists for this term
+                    $query = "SELECT n.id FROM note n INNER JOIN note_i18n i 
ON n.id=i.id WHERE n.object_id=? AND n.type_id=?";
+
+                    $statement = QubitFlatfileImport::sqlQuery(
+                      $query,
+                      array($termId, QubitTerm::SCOPE_NOTE_ID)
+                    );
+
+                    $result = $statement->fetch(PDO::FETCH_OBJ);
+
+                    if (!$result)
+                    {
+                      // add scope note if it doesn't exist
+                      $note = new QubitNote;
+                      $note->objectId = $termId;
+                      $note->typeId = QubitTerm::SCOPE_NOTE_ID;
+                      $note->content = $self->content($scope);
+                      $note->scope = 'QubitTerm'; # not sure if this is needed
+                      $note->save();
+                    }
+                  } else {
+                    throw new sfException('Could not find term "'. $subject 
.'"');
+                  }
+                }
+                $index++;
               }
             }
           }

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