Author: mj
Date: Tue Nov  1 10:16:20 2011
New Revision: 10238

Log:
Closes #140.  CSV import complete for 1.2 release.

Modified:
   trunk/lib/QubitCsvImport.class.php
   
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/eventComponent.class.php

Modified: trunk/lib/QubitCsvImport.class.php
==============================================================================
--- trunk/lib/QubitCsvImport.class.php  Mon Oct 31 17:12:45 2011        (r10237)
+++ trunk/lib/QubitCsvImport.class.php  Tue Nov  1 10:16:20 2011        (r10238)
@@ -453,6 +453,50 @@
 
   protected function mapIsad($parameters)
   {
+    // dates of creation
+    $creationTerm = new QubitTerm();
+    $creationTerm->id = QubitTerm::CREATION_ID;
+    $termType = $this->context->routing->generate(null, array($creationTerm, 
'module' => 'term'));
+
+    $n = 0;
+    foreach (explode('|', $parameters['datesOfCreation']) as $new_date)
+    {
+      // TODO: validate date/range format somehow
+      if (!empty($new_date))
+      {
+        $new_dates['new'.$n] = array('type' => $termType, 'date' => $new_date);
+        $n++;
+      }
+    }
+    $parameters['datesOfCreation'] = $new_dates;
+
+    // name access points
+    if (!isset($this->names))
+    {
+      foreach (QubitActor::getOnlyActors() as $name)
+      {
+        $this->names[$name->__toString()] = $name;
+      }
+    }
+
+    $n = 0;
+    foreach (explode('|', $parameters['creators']) as $new_creator)
+    {
+      // if the name does not exist, create it
+      if (!in_array($new_creator, $this->names) && !empty($new_creator))
+      {
+        $name = new QubitActor();
+        $name->authorizedFormOfName = $new_creator;
+        $name->save();
+
+        $this->names[$name->__toString()] = $name;
+      }
+
+      $new_creators['new'.$n] = $this->context->routing->generate(null, 
array($this->names[$new_creator], 'module' => 'actor'));
+      $n++;
+    }
+    $parameters['creators'] = $new_creators;
+
     // convert pipe-delimited values into multi-value
     $n = 0;
     foreach (explode('|', $parameters['newArchivistNote']) as 
$new_archivistNote)

Modified: 
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/eventComponent.class.php
==============================================================================
--- 
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/eventComponent.class.php
    Mon Oct 31 17:12:45 2011        (r10237)
+++ 
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/eventComponent.class.php
    Tue Nov  1 10:16:20 2011        (r10238)
@@ -58,6 +58,14 @@
   // TODO Refactor with parent::processForm()
   public function processForm()
   {
+    if ($this->request->hasParameter('csvimport'))
+    {
+      if ($this->request->getParameterHolder()->has('datesOfCreation'))
+      {
+        $this->request->editEvents = 
$this->request->getParameterHolder()->get('datesOfCreation');
+      }
+    }
+
     $params = array($this->request->editEvent);
     if (isset($this->request->editEvents))
     {

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