Author: mcantelon
Date: Wed Jan 18 16:14:43 2012
New Revision: 10718

Log:
Added import handling for the 10 processing note-related fields.

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

Modified: trunk/lib/task/import/csvAccessionImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvAccessionImportTask.class.php      Wed Jan 18 
15:37:45 2012        (r10717)
+++ trunk/lib/task/import/csvAccessionImportTask.class.php      Wed Jan 18 
16:14:43 2012        (r10718)
@@ -105,7 +105,6 @@
       'columnMap' => array(
         'TITLE'          => 'title',
         'LOCATION'       => 'locationInformation',
-        'ACCESSION NOTE' => 'processingNotes'
       ),
 
       /* these values get stored to the rowStatusVars array */
@@ -146,6 +145,11 @@
           {
             $self->object->receivedExtentUnits = 
$self->rowStatusVars['extents'];
           }
+
+          if (isset($self->rowStatusVars['processingNotes']))
+          {
+            $self->object->processingNotes = 
$self->rowStatusVars['processingNotes'];
+          }
         }
       },
 
@@ -161,6 +165,7 @@
     ));
 
     $this->setUpExtentColumnHandling($import);
+    $this->setUpProcessingNoteColumnHandling($import);
 
     $import->addColumnHandler('TYPE', function(&$self, $data)
     {
@@ -183,6 +188,29 @@
       }
     });
 
+    $import->addColumnHandler('ACQUISITION METHOD', function(&$self, $data)
+    {
+      if ($data)
+      {
+        $cvaToQubit = array(
+          'Copy Loan'          => 'Deposit', // is this correct?
+          'Donation'           => 'Gift',
+          'Direct Transfer'    => 'Transfer',
+          'Scheduled Transfer' => 'Transfer'
+        );
+
+        if (isset($self->object) && is_object($self->object))
+        {
+          $self->object->resourceTypeId = $self->translateNameToTermId(
+            'acquisition type',
+            $data,
+            $cvaToQubit,
+            $self->getStatus('acquisitionTypes')
+          );
+        }
+      }
+    });
+
     $import->csv($fh, $skipRows);
   }
 
@@ -216,18 +244,15 @@
     {
       if ($data)
       {
-        if (strpos($self->status['currentColumn'], 'IN') === 0)
-        {
-          $self->rowStatusVars['extents'] = 
(isset($self->rowStatusVars['extents']))
-            ? $self->rowStatusVars['extents']
-            : '';
+        $self->rowStatusVars['extents'] = 
(isset($self->rowStatusVars['extents']))
+          ? $self->rowStatusVars['extents']
+          : '';
              
-          $extentColumnsAndPrefixes = 
$self->getStatus('extentColumnsAndPrefixes');
-          $self->rowStatusVars['extents'] = $self->appendWithLineBreakIfNeeded(
-            $self->rowStatusVars['extents'],
-            $extentColumnsAndPrefixes[($self->status['currentColumn'])] . $data
-          );
-        }
+        $extentColumnsAndPrefixes = 
$self->getStatus('extentColumnsAndPrefixes');
+        $self->rowStatusVars['extents'] = $self->appendWithLineBreakIfNeeded(
+          $self->rowStatusVars['extents'],
+          $extentColumnsAndPrefixes[($self->status['currentColumn'])] . $data
+        );
       }
     };
 
@@ -237,27 +262,53 @@
       $import->addColumnHandler($column, $extentColumnHandler);
     }
 
-    $import->addColumnHandler('ACQUISITION METHOD', function(&$self, $data)
+  }
+
+  protected function setUpProcessingNoteColumnHandling(&$import)
+  {
+    // map of extent-related column names to their corresponding prefixes
+    $processingNoteColumnsAndPrefixes = array(
+      'ACCESSION NOTE'     => "",
+      'ACKNOWLEDGMENT'     => "Acknowledge Donor in Description? (Y/N): ",
+      'ARCHIVIST'          => "Registered by: ",
+      'CVA NUMBER'         => "CVA #: ",
+      'ItemNumberTracking' => "Last Item #: ",
+      'PR SERIES NUMBER'   => "PR Series #: ",
+      'PRI REC NO'         => "Private Rec. #: ",
+      'RECORD ID'          => "CS Record ID: ",
+      'TRANSFER NUMBER'    => "RM Transfer #: ",
+      'VanRims Number'     => "Classification #: "
+    );
+
+    $import->setStatus('processingNoteColumnsAndPrefixes', 
$processingNoteColumnsAndPrefixes);
+
+    // handling logic for extent columns
+    $processingNoteColumnHandler = function(&$self, $data)
     {
       if ($data)
       {
-        $cvaToQubit = array(
-          'Copy Loan'          => 'Deposit', // is this correct?
-          'Donation'           => 'Gift',
-          'Direct Transfer'    => 'Transfer',
-          'Scheduled Transfer' => 'Transfer'
-        );
-
-        if (isset($self->object) && is_object($self->object))
-        {
-          $self->object->resourceTypeId = $self->translateNameToTermId(
-            'acquisition type',
-            $data,
-            $cvaToQubit,
-            $self->getStatus('acquisitionTypes')
+        $self->rowStatusVars['processingNotes'] = 
(isset($self->rowStatusVars['processingNotes']))
+          ? $self->rowStatusVars['processingNotes']
+          : '';
+             
+        $processingNoteColumnsAndPrefixes = 
$self->getStatus('processingNoteColumnsAndPrefixes');
+        $prefix = 
$processingNoteColumnsAndPrefixes[($self->status['currentColumn'])];
+        $appendValue = ($prefix) ? $prefix . $data : $data;
+        if ($prefix)
+        {
+          $self->rowStatusVars['processingNotes'] = 
$self->appendWithLineBreakIfNeeded(
+            $self->rowStatusVars['processingNotes'],
+            $appendValue
           );
         }
       }
-    });
+    };
+
+    // add handler for each extent-related column
+    foreach($processingNoteColumnsAndPrefixes as $column => $junk)
+    {
+      $import->addColumnHandler($column, $processingNoteColumnHandler);
+    }
+
   }
 }

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