Author: david
Date: Thu Dec 8 15:06:53 2011
New Revision: 10382
Log:
Don't check column headings (implicit order) and match information objects by
identifier
Modified:
trunk/lib/task/archivematicaDipImportTask.class.php
Modified: trunk/lib/task/archivematicaDipImportTask.class.php
==============================================================================
--- trunk/lib/task/archivematicaDipImportTask.class.php Thu Dec 8 14:34:41
2011 (r10381)
+++ trunk/lib/task/archivematicaDipImportTask.class.php Thu Dec 8 15:06:53
2011 (r10382)
@@ -83,51 +83,39 @@
$this->logSection("Link digital objects from {$arguments['filename']}...");
- // Get header (first) row
- $header = fgetcsv($fh, 1000);
-
- if (in_array('information_object_id', $header) && in_array('filename',
$header))
- {
- $idKey = array_search('information_object_id', $header);
- $fileKey = array_search('filename', $header);
- }
- else
- {
- // Assume first column is information_object_id and second is filename
- $idKey = 0;
- $fileKey = 1;
- }
-
// Build hash on information_object.id, with array value if information
// object has multiple digital objects attached
- while ($item = fgetcsv($fh, 1000))
+ while ($row = fgetcsv($fh, 1000))
{
- $filepath = $item[$fileKey];
+ $filepath = $row[1];
if (isset($options['path']))
{
$filepath = rtrim($options['path'], '/').'/'.$filepath;
}
- if (!isset($digitalObjects[$item[$idKey]]))
+ if (!isset($digitalObjects[$row[0]]))
{
- $digitalObjects[$item[$idKey]] = $filepath;
+ $digitalObjects[$row[0]] = $filepath;
}
- else if (!is_array($digitalObjects[$item[$idKey]]))
+ else if (!is_array($digitalObjects[$row[0]]))
{
- $digitalObjects[$item[$idKey]] = array($digitalObjects[$item[$idKey]],
$filepath);
+ $digitalObjects[$row[0]] = array($digitalObjects[$row[0]], $filepath);
}
else
{
- $digitalObjects[$item[$idKey]][] = $filepath;
+ $digitalObjects[$row[0]][] = $filepath;
}
}
// Loop through $digitalObject hash and add digital objects to db
foreach ($digitalObjects as $key => $item)
{
- if (null === $informationObject = QubitInformationObject::getById($key))
+ $criteria = new Criteria;
+ $criteria->add(QubitInformationObject::IDENTIFIER, $key);
+
+ if (null === $informationObject =
QubitInformationObject::getOne($criteria))
{
- $this->log("Invalid information_object id $key");
+ $this->log("Invalid information object identifier '$key'");
continue;
}
--
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.