Author: mcantelon
Date: Thu Mar 29 21:46:06 2012
New Revision: 11320

Log:
Fixed issues with event import tool.

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

Modified: trunk/lib/task/import/csvEventImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvEventImportTask.class.php  Thu Mar 29 21:01:10 
2012        (r11319)
+++ trunk/lib/task/import/csvEventImportTask.class.php  Thu Mar 29 21:46:06 
2012        (r11320)
@@ -72,24 +72,17 @@
       QubitTaxonomy::EVENT_TYPE_ID => 'eventTypes'
     ));
 
-    // add new event types
-    foreach(array('Authored', 'Edited', 'Compiled') as $termName)
-    {
-      QubitFlatfileImport::createOrFetchTerm(
-        QubitTaxonomy::EVENT_TYPE_ID,
-        $termName
-      );
-    }
-
     $subjectTable       = 'actor_i18n';
     $subjectKeyColumn   = 'authorized_form_of_name';
-    $subjectValueColumn = 'Actor';
+    $subjectValueColumn = 'eventActorName';
+    $subjectIdColumn    = 'id';
 
-    $objectTable        = 'information_object_i18n';
-    $objectKeyColumn    = 'sources';
-    $objectValueColumn  = 'CS_RecordID';
+    $objectTable        = 'keymap';
+    $objectKeyColumn    = 'source_id';
+    $objectValueColumn  = 'legacyId';
+    $objectIdColumn     = 'target_id';
 
-    $relationTypeColumn = 'ActorRole';
+    $relationTypeColumn = 'eventType';
 
     $import = new QubitFlatfileImport(array(
 
@@ -98,9 +91,11 @@
         'subjectTable'       => $subjectTable,
         'subjectKeyColumn'   => $subjectKeyColumn,
         'subjectValueColumn' => $subjectValueColumn,
+        'subjectIdColumn'    => $subjectIdColumn,
         'objectTable'        => $objectTable,
         'objectKeyColumn'    => $objectKeyColumn,
         'objectValueColumn'  => $objectValueColumn,
+        'objectIdColumn'     => $objectIdColumn,
         'relationTypeColumn' => $relationTypeColumn,
         'dataCached'         => FALSE,
         'subjectKeys'        => array(),
@@ -122,6 +117,7 @@
             $self,
             $self->status['subjectTable'],
             $self->status['subjectKeyColumn'],
+            $self->status['subjectIdColumn'],
             'id'
           );
 
@@ -129,12 +125,14 @@
             $self,
             $self->status['objectTable'],
             $self->status['objectKeyColumn'],
+            $self->status['objectIdColumn'],
             'id'
           );
 
           $self->status['dataCached'] = TRUE;
         }
 
+        // attempt to use pre-cached actor ID
         $subjectKey = 
trim($self->columnValue($self->status['subjectValueColumn']));
         $subjectId = FALSE;
         if ($subjectKey)
@@ -145,6 +143,14 @@
           }
         }
 
+        // if actor ID not found, create
+        if (!$subjectId)
+        {
+          // create actor
+          $actor = $self->createOrFetchActor($subjectKey);
+          $subjectId = $actor->id;
+        }
+
         if ($subjectId)
         {
           $self->status['goodSubjects']++;
@@ -169,8 +175,13 @@
 
             if (!$typeId)
             {
-              print "Term does not exist.\n";
-              exit();
+              print "Term does not exist... adding.\n";
+              $term = QubitFlatfileImport::createOrFetchTerm(
+                QubitTaxonomy::EVENT_TYPE_ID,
+                $type
+              );
+              $typeId = $term->id;
+              $self->status['eventTypes'][$typeId] = $type;
             }
 
             $event = new QubitEvent;
@@ -215,10 +226,9 @@
     print 'DB error'; exit();
   }
 
-  $actors = array();
   while($subject = $statement->fetch(PDO::FETCH_OBJ))
   {
-    $names[$subject->$keyColumn] = $subject->id;
+    $names[$subject->$keyColumn] = $subject->$idColumn;
   }
   return $names;
 } 

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