Author: mcantelon
Date: Thu Feb  9 15:56:32 2012
New Revision: 10830

Log:
Added methods to QubitFlatfileImport to create or fetch physical objects.

Modified:
   trunk/lib/QubitFlatfileImport.class.php

Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php     Thu Feb  9 13:04:44 2012        
(r10829)
+++ trunk/lib/QubitFlatfileImport.class.php     Thu Feb  9 15:56:32 2012        
(r10830)
@@ -880,6 +880,29 @@
   }
 
   /**
+   * Create a Qubit physical object or, if one already exists, fetch it
+   *
+   * @param string $name  name of physical object
+   * @param string $location  location of physical object
+   *
+   * @return QubitPhysicalObject  created or fetched physical object
+   */
+  public function createOrFetchPhysicalObject($name, $location)
+  {
+    $query = "SELECT id FROM physical_object_i18n WHERE name=? AND location=?";
+
+    $statement = QubitFlatfileImport::sqlQuery($query, array($name, 
$location));
+    $result = $statement->fetch(PDO::FETCH_OBJ);
+
+    if ($result)
+    {
+      return QubitPhysicalOject::getById($result->id);
+    } else {
+      return $this->createPhysicalObject($name, $history);
+    }
+  }
+
+  /**
    * Create a Qubit actor or, if one already exists, fetch it
    *
    * @param string $name  name of actor
@@ -1031,6 +1054,23 @@
   }
 
   /**
+   * Create a Qubit physical object
+   *
+   * @param string $name  name of physical object
+   * @param string $location  location of physical object
+   *
+   * @return QubitPhysicalObject  created physical object
+   */
+  public function createPhysicalObject($name, $location)
+  {
+    $object = new QubitPhysicalObject;
+    $object->name = $name;
+    $object->location = $location;
+    $object->save();
+    return $object;
+  }
+
+  /**
    * Create a Qubit actor
    *
    * @param string $name  name of actor

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