Author: mcantelon
Date: Tue Sep  4 14:39:22 2012
New Revision: 12260

Log:
Added support for multiple types of authority record aliases.

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

Modified: trunk/lib/task/import/csvAuthorityRecordImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvAuthorityRecordImportTask.class.php        Tue Sep 
 4 13:55:56 2012        (r12259)
+++ trunk/lib/task/import/csvAuthorityRecordImportTask.class.php        Tue Sep 
 4 14:39:22 2012        (r12260)
@@ -93,23 +93,23 @@
           'status' => array(
             'aliases' => array()
           ),
-          'ignoreColumns' => array(
-            'RecordID'
-          ),
           'variableColumns' => array(
-            'parentAuthority',
-            'OtherName',
-            'email'
+            'parentAuthorizedFormOfName',
+            'alternateForm',
+            'formType'
           ),
           'saveLogic' => function(&$self)
           {
-            if (trim($self->rowStatusVars['OtherName']))
+            if (trim($self->rowStatusVars['alternateForm']))
             {
               $aliases = $self->getStatus('aliases');
+
               $aliases[] = array(
-                'authoritative' => $self->rowStatusVars['parentAuthority'],
-                'otherName'     =>$self->rowStatusVars['OtherName']
+                'parentAuthorizedFormOfName' => 
$self->rowStatusVars['parentAuthorizedFormOfName'],
+                'alternateForm'              => 
$self->rowStatusVars['alternateForm'],
+                'formType'                   => 
$self->rowStatusVars['formType']
               );
+
               $self->setStatus('aliases', $aliases);
             }
           }
@@ -276,16 +276,33 @@
 
           // cycle through aliases looking for other names
           $otherNames = array();
+
           $aliases = $self->getStatus('aliases');
+
           foreach($aliases as $alias)
           {
-            if ($self->object->authorizedFormOfName == $alias['authoritative'])
+            if ($self->object->authorizedFormOfName == 
$alias['parentAuthorizedFormOfName'])
             {
+              $typeIds = array(
+                'parallel'     => QubitTerm::PARALLEL_FORM_OF_NAME_ID,
+                'standardized' => QubitTerm::STANDARDIZED_FORM_OF_NAME_ID,
+                'other'        => QubitTerm::OTHER_FORM_OF_NAME_ID
+              );
+
+              $normalizedType = strtolower($alias['formType']);
+
+              if ($typeIds[$normalizedType])
+              {
+                $typeId = $typeIds[$normalizedType];
+              } else {
+                throw new sfException('Invalid alias type"'. 
$alias['formType'] .'".');
+              }
+
               // add other name
               $otherName = new QubitOtherName;
               $otherName->objectId = $self->object->id;
-              $otherName->name     = $alias['otherName'];
-              $otherName->typeId   = QubitTerm::OTHER_FORM_OF_NAME_ID;
+              $otherName->name     = $alias['alternateForm'];
+              $otherName->typeId   = $typeId;
               $otherName->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