Author: mcantelon
Date: Fri Jun  1 21:00:44 2012
New Revision: 11721

Log:
Added ability to include multiple containers in a column.

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

Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php       Fri Jun  1 00:02:49 
2012        (r11720)
+++ trunk/lib/task/import/csvImportTask.class.php       Fri Jun  1 21:00:44 
2012        (r11721)
@@ -460,29 +460,56 @@
               && $self->rowStatusVars['physicalObjectLocation']
             )
             {
-              // create/fetch container
-              $type = (
-                isset($self->rowStatusVars['physicalObjectType'])
-                && $self->rowStatusVars['physicalObjectType']
-              )
-                ? $self->rowStatusVars['physicalObjectType']
-                : 'Box';
-
-              $container = $self->createOrFetchPhysicalObject(
-                $self->rowStatusVars['physicalObjectName'],
-                $self->rowStatusVars['physicalObjectLocation'],
-                array_search(
-                  $type,
-                  $self->getStatus('physicalObjectTypes')
-                )
-              );
+              $names = explode('|', 
$self->rowStatusVars['physicalObjectName']);
+              $locations = explode('|', 
$self->rowStatusVars['physicalObjectLocation']);
+              $types = explode('|', 
$self->rowStatusVars['physicalObjectType']);
 
-              // associate container with information object
-              $self->createRelation(
-                $container->id,
-                $self->object->id,
-                QubitTerm::HAS_PHYSICAL_OBJECT_ID
-              );
+              foreach($names as $index => $name)
+              {
+                // if location column populated
+                if ($self->rowStatusVars['physicalObjectLocation'])
+                {
+                  // if current index applicable
+                  if (isset($locations[$index]))
+                  {
+                    $location = $locations[$index];
+                  } else {
+                    $location = $locations[0];
+                  }
+                } else {
+                  $location = $name;
+                }
+
+                // if location column populated
+                if ($self->rowStatusVars['physicalObjectTypes'])
+                {
+                  // if current index applicable
+                  if (isset($types[$index]))
+                  {
+                    $type = $types[$index];
+                  } else {
+                    $type = $types[0];
+                  }
+                } else {
+                  $type = 'Box';
+                }
+
+                $container = $self->createOrFetchPhysicalObject(
+                  $name,
+                  $location,
+                  array_search(
+                    $type,
+                    $self->getStatus('physicalObjectTypes')
+                  )
+                );
+
+                // associate container with information object
+                $self->createRelation(
+                  $container->id,
+                  $self->object->id,
+                  QubitTerm::HAS_PHYSICAL_OBJECT_ID
+                );
+              }
             } else {
               $error = 'Both physicalObjectName and physicalObjectLocation '
                      + 'required to create a physical object.';

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