Author: david
Date: Mon Feb 28 12:03:41 2011
New Revision: 9013

Log:
Pass database connection for proper execution from task interface.

Modified:
   trunk/lib/model/QubitDigitalObject.php

Modified: trunk/lib/model/QubitDigitalObject.php
==============================================================================
--- trunk/lib/model/QubitDigitalObject.php      Mon Feb 28 11:10:50 2011        
(r9012)
+++ trunk/lib/model/QubitDigitalObject.php      Mon Feb 28 12:03:41 2011        
(r9013)
@@ -307,7 +307,7 @@
     }
 
     parent::save($connection);
-
+    
     // Create child objects (derivatives)
     if (0 < count($this->assets) && $this->createDerivatives)
     {
@@ -322,13 +322,13 @@
 
         // We don't need reference image because a compound will be displayed 
instead of it
         // But thumbnails are necessary for image flow
-        $this->createThumbnail();
+        $this->createThumbnail($connection);
       }
       else
       {
         // If DO is a single object, create various representations based on
         // intended usage
-        $this->createRepresentations($this->usageId);
+        $this->createRepresentations($this->usageId, $connection);
       }
     }
 
@@ -726,7 +726,7 @@
     if (null === $compoundRep = 
$this->getRepresentationByUsage(QubitTerm::COMPOUND_ID))
     {
       // Generate a compound representation if one doesn't exist already
-      $compoundRep = self::createImageDerivative(QubitTerm::COMPOUND_ID);
+      $compoundRep = self::createImageDerivative(QubitTerm::COMPOUND_ID, 
$connection);
     }
 
     return $compoundRep;
@@ -900,20 +900,20 @@
    * @param integer $usageId intended use of asset
    * @return QubitDigitalObject this object
    */
-  public function createRepresentations($usageId)
+  public function createRepresentations($usageId, $connection = null)
   {
     // Scale images (and pdfs) and create derivatives
     if ($this->canThumbnail())
     {
       if ($usageId == QubitTerm::EXTERNAL_URI_ID || $usageId == 
QubitTerm::MASTER_ID)
       {
-        $this->createReferenceImage();
-        $this->createThumbnail();
+        $this->createReferenceImage($connection);
+        $this->createThumbnail($connection);
       }
       else if ($usageId == QubitTerm::REFERENCE_ID)
       {
         $this->resizeByUsageId(QubitTerm::REFERENCE_ID);
-        $this->createThumbnail();
+        $this->createThumbnail($connection);
       }
       else if ($usageId == QubitTerm::THUMBNAIL_ID)
       {
@@ -925,15 +925,15 @@
     {
       if ($usageId == QubitTerm::EXTERNAL_URI_ID || $usageId == 
QubitTerm::MASTER_ID)
       {
-        $this->createVideoDerivative(QubitTerm::REFERENCE_ID);
-        $this->createVideoDerivative(QubitTerm::THUMBNAIL_ID);
+        $this->createVideoDerivative(QubitTerm::REFERENCE_ID, $connection);
+        $this->createVideoDerivative(QubitTerm::THUMBNAIL_ID, $connection);
       }
     }
     else if ($this->mediaTypeId == QubitTerm::AUDIO_ID)
     {
       if ($usageId == QubitTerm::EXTERNAL_URI_ID || $usageId == 
QubitTerm::MASTER_ID)
       {
-        $this->createAudioDerivative(QubitTerm::REFERENCE_ID);
+        $this->createAudioDerivative(QubitTerm::REFERENCE_ID, $connection);
       }
     }
 
@@ -1119,7 +1119,7 @@
       $newDigiObject->save();
 
       // And finally create reference and thumb images for child asssets
-      $newDigiObject->createRepresentations($newDigiObject->getUsageId());
+      $newDigiObject->createRepresentations($newDigiObject->getUsageId(), 
$connection);
     }
 
     return $this;
@@ -1193,10 +1193,10 @@
    *
    * @return QubitDigitalObject
    */
-  public function createThumbnail()
+  public function createThumbnail($connection = null)
   {
     // Create a thumbnail
-    $derivative = $this->createImageDerivative(QubitTerm::THUMBNAIL_ID);
+    $derivative = $this->createImageDerivative(QubitTerm::THUMBNAIL_ID, 
$connection);
 
     return $derivative;
   }
@@ -1206,10 +1206,10 @@
    *
    * @return QubitDigitalObject  The new derived reference digital object
    */
-  public function createReferenceImage()
+  public function createReferenceImage($connection = null)
   {
     // Create derivative
-    $derivative = $this->createImageDerivative(QubitTerm::REFERENCE_ID);
+    $derivative = $this->createImageDerivative(QubitTerm::REFERENCE_ID, 
$connection);
 
     return $derivative;
   }
@@ -1220,7 +1220,7 @@
    * @param integer  $usageId  usage type id
    * @return QubitDigitalObject derivative object
    */
-  public function createImageDerivative($usageId)
+  public function createImageDerivative($usageId, $connection = null)
   {
     // Get max dimensions
     $maxDimensions = self::getImageMaxDimensions($usageId);
@@ -1250,7 +1250,7 @@
       $derivative->createDerivatives = false;
       $derivative->indexOnSave = false;
       $derivative->assets[] = new QubitAsset($derivativeName, $resizedImage);
-      $derivative->save();
+      $derivative->save($connection);
 
       return $derivative;
     }
@@ -1501,7 +1501,7 @@
    * VIDEO
    * -----------------------------------------------------------------------
    */
-  public function createAudioDerivative($usageId)
+  public function createAudioDerivative($usageId, $connection = null)
   {
     if (QubitTerm::REFERENCE_ID != $usageId)
     {
@@ -1529,7 +1529,7 @@
         $derivative->assets[] = new QubitAsset($derivativeName, 
file_get_contents($derivativeFullPath));
         $derivative->createDerivatives = false;
         $derivative->indexOnSave = false;
-        $derivative->save();
+        $derivative->save($connection);
       }
     }
     else
@@ -1602,7 +1602,7 @@
    * @param integer  $usageId  usage type id
    * @return QubitDigitalObject derivative object
    */
-  public function createVideoDerivative($usageId)
+  public function createVideoDerivative($usageId, $connection = null)
   {
     // Build new filename and path
     $originalFullPath = sfConfig::get('sf_web_dir').$this->getFullPath();
@@ -1635,7 +1635,7 @@
       $derivative->setMimeAndMediaType();
       $derivative->createDerivatives = false;
       $derivative->indexOnSave = false;
-      $derivative->save();
+      $derivative->save($connection);
 
       return $derivative;
     }

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