Author: mcantelon
Date: Thu Feb  2 11:29:10 2012
New Revision: 10795

Log:
Added creation of QubitOtherName objects.

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

Modified: trunk/lib/task/import/csvAuthorityRecordImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvAuthorityRecordImportTask.class.php        Thu Feb 
 2 07:36:15 2012        (r10794)
+++ trunk/lib/task/import/csvAuthorityRecordImportTask.class.php        Thu Feb 
 2 11:29:10 2012        (r10795)
@@ -86,10 +86,15 @@
           ),
           'saveLogic' => function(&$self)
           {
-            $aliases = $self->getStatus('aliases');
-            $aliases[($self->rowStatusVars['parentAuthority'])]
-              = $self->rowStatusVars['OtherName'];
-            $self->setStatus('aliases', $aliases);
+            if (trim($self->rowStatusVars['OtherName']))
+            {
+              $aliases = $self->getStatus('aliases');
+              $aliases[] = array(
+                'authoritative' => $self->rowStatusVars['parentAuthority'],
+                'otherName'     =>$self->rowStatusVars['OtherName']
+              );
+              $self->setStatus('aliases', $aliases);
+            }
           }
         ));
       }
@@ -173,7 +178,7 @@
         'EntityType'
       ),
 
-      /* import logic to execute before saving accession */
+      /* import logic to execute before saving actor */
       'preSaveLogic' => function(&$self)
       {
         if ($self->object)
@@ -190,14 +195,31 @@
               throw new sfException($entityType .' is not a valid actor entity 
type.');
             }
           }
+        }
+      },
 
+      /* import logic to execute after saving actor */
+      'postSaveLogic' => function(&$self)
+      {
+        if ($self->object)
+        {
+          // cycle through aliases looking for other names
+          $otherNames = array();
           $aliases = $self->getStatus('aliases');
-          if (array_search($self->object->authorizedFormOfName, $aliases))
+          foreach($aliases as $alias)
           {
-print 'found';exit();
+            if ($self->object->authorizedFormOfName == $alias['authoritative'])
+            {
+              // add other name
+              $otherName = new QubitOtherName;
+              $otherName->objectId = $self->object->id;
+              $otherName->name = $alias['otherName'];
+              $otherName->typeId = 149;
+              $otherName->save();
+            }
           }
         }
-      },
+      }
     ));
 
     $import->csv($fh, $skipRows);

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