Author: david
Date: Mon Feb 13 12:44:55 2012
New Revision: 10866

Log:
Update dip import script based on CVA state

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

Modified: trunk/lib/task/archivematicaDipImportTask.class.php
==============================================================================
--- trunk/lib/task/archivematicaDipImportTask.class.php Mon Feb 13 00:03:08 
2012        (r10865)
+++ trunk/lib/task/archivematicaDipImportTask.class.php Mon Feb 13 12:44:55 
2012        (r10866)
@@ -37,8 +37,7 @@
   protected function configure()
   {
     $this->addArguments(array(
-      new sfCommandArgument('filename', sfCommandArgument::REQUIRED, 'The 
input file (csv format).'),
-      new sfCommandArgument('path', sfCommandArgument::REQUIRED, 'Path to 
digital objects.')
+      new sfCommandArgument('dip', sfCommandArgument::REQUIRED, 'The DIP 
directory.'),
     ));
 
     $this->addOptions(array(
@@ -76,24 +75,23 @@
 
     sfConfig::set('app_upload_dir', self::getUploadDir($conn));
 
-    if (false === $fh = fopen($arguments['filename'], 'rb'))
+    if (!is_dir($arguments['dip']))
     {
-      throw new sfException('You must specify a valid filename');
+      throw new sfException('You must specify a DIP directory');
     }
 
-    $this->logSection("Link digital objects from {$arguments['filename']}...");
+    $csvs = 
sfFinder::type('file')->maxdepth(0)->in($arguments['dip'].'/objects/')->name('*.csv');
+    if (0 == count($csvs) || false === $fh = fopen($csvs[0], 'rb'))
+    {
+      throw new sfException('You must specify a DIP that contains a csv 
linking file');
+    }
+
+    $this->logSection("Link digital objects from {$arguments['dip']}...");
 
     // If DIP directory is specified then digital objects will be in the
     // "objects" subfolder. Capture dipUUID.
-    if (file_exists(rtrim($arguments['path'], '/').'/objects'))
-    {
-      $dipUUID = $this->getUUID(basename($arguments['path']));
-      $arguments['path'] = rtrim($arguments['path'], '/').'/objects';
-    }
-    else
-    {
-      $dipUUID = $this->getUUID(dirname($arguments['path']));
-    }
+    $dipUUID = $this->getUUID(basename($arguments['dip']));
+    $assetPath = rtrim($arguments['path'], '/').'/objects';
 
     if (null === $dipUUID)
     {
@@ -108,7 +106,7 @@
     // object has multiple digital objects attached 
     while ($row = fgetcsv($fh, 1000))
     {
-      $filepath = rtrim($arguments['path'], '/').'/'.$row[1];
+      $filepath = rtrim($arguments['dip'], '/').'/'.$row[1];
 
       // Check if filename has been changed by Archivematica
       if (!file_exists($filepath))
@@ -143,6 +141,8 @@
     // Loop through $digitalObject hash and add digital objects to db
     foreach ($digitalObjects as $key => $item)
     {
+      $this->logSection("Add '$key'...");
+
       $criteria = new Criteria;
       $criteria->add(QubitInformationObject::IDENTIFIER, $key);
 

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