Author: mcantelon
Date: Tue Dec 20 14:09:16 2011
New Revision: 10444

Log:
Commenting and code cleanup of CSV import core logic.

Modified:
   trunk/lib/task/csvImportTask.class.php

Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php      Tue Dec 20 13:56:20 2011        
(r10443)
+++ trunk/lib/task/csvImportTask.class.php      Tue Dec 20 14:09:16 2011        
(r10444)
@@ -127,23 +127,23 @@
 
         // add create event if specified
         if (
-          isset($self->status['start_year'])
-          || (isset($self->status['start_year']) && 
isset($self->status['end_year']))
+          isset($self->rowStatusVars['start_year'])
+          || (
+            isset($self->rowStatusVars['start_year'])
+            && isset($self->rowStatusVars['end_year'])
+          )
         ) {
           $date = new QubitEvent;
           $date->informationObjectId = $self->information_object->id;
           $date->typeId = QubitTerm::CREATION_ID;
-          $date->startDate = $self->status['start_year'] .'-00-00';
-          if (isset($self->status['end_year'])) {
-            $date->endDate = $self->status['start_year'] .'-00-00';
+          $date->startDate = $self->rowStatusVars['start_year'] .'-00-00';
+          if (isset($self->rowStatusVars['end_year'])) {
+            $date->endDate = $self->rowStatusVars['start_year'] .'-00-00';
           }
           if (!isset($self->testing) || !$self->testing) {
             $date->save();
           }
         }
-
-        // increment number of completed rows
-        $self->status['rows']++;
       }
     ));
 
@@ -152,11 +152,11 @@
     });
 
     $import->addColumnHandler('START YEAR', function(&$self, $data) {
-      $self->status['start_year'] = $data;
+      $self->rowStatusVars['start_year'] = $data;
     });
 
     $import->addColumnHandler('START YEAR', function(&$self, $data) {
-      $self->status['start_year'] = $data;
+      $self->rowStatusVars['start_year'] = $data;
     });
 
     $import->addColumnHandler('Rad note – conservation', function(&$self, 
$data) {
@@ -184,6 +184,7 @@
       'columnMap'
     );
 
+    // set properties from options, halting upon invalid option
     foreach($options as $option => $value) {
       if (in_array($option, $allowed_options)) {
         $this->$option = $value;
@@ -193,6 +194,7 @@
       }
     }
 
+    // initialize bookkeeping of rows processed
     $this->status = array(
       'rows' => 0
     );
@@ -203,6 +205,8 @@
   }
 
   protected function executeClosurePropertyIfSet($property) {
+    // attempting to directly call an object property that's a
+    // closure results in "Fatal error: Call to undefined method"
     if ($this->$property) {
       call_user_func_array($this->$property, array(&$this));
     }
@@ -240,6 +244,7 @@
 
   public function csv($fh) {
 
+    // inform user of any columns not included in import
     print $this->ignored_render();
 
     // import each row
@@ -254,8 +259,10 @@
     // execute row initialization logic
     $this->executeClosurePropertyIfSet('rowInit');
 
+    // deal with data in each of row's columns
     for ($index = 0; $index < sizeof($row); $index++) {
 
+      // determine what type of data should be in this column
       $columnName = $this->columns[$index];
 
       // if column maps to an attribute, set the attribute
@@ -290,6 +297,9 @@
     // execute row completion logic
     $this->executeClosurePropertyIfSet('rowComplete');
 
+    // increment number of completed rows
+    $this->status['rows']++;
+
     // get rid of row-specific status variables
     if ($this->rowStatusVars) {
       foreach($this->rowStatusVars as $var) {

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