Author: david
Date: Tue Jan 24 12:04:40 2012
New Revision: 10748
Log:
Match creators to creator dates and history based on position in delimited list
Modified:
trunk/lib/task/import/csvImportTask.class.php
Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php Tue Jan 24 10:57:23
2012 (r10747)
+++ trunk/lib/task/import/csvImportTask.class.php Tue Jan 24 12:04:40
2012 (r10748)
@@ -190,23 +190,23 @@
'variableColumns' => array(
'UNIQUE_ID',
'PARENT_ID',
- 'datesOfCreation',
'copyrightStatus',
'copyrightExpires',
'copyrightHolder',
- 'datesOfCreationNote',
- 'datesOfCreationStart',
- 'datesOfCreationEnd'
),
/* these values get exploded and stored to the rowStatusVars array */
'arrayColumns' => array(
- 'accessionNumber' => '|',
- 'creators' => '|',
- 'creatorHistory' => '|',
- 'subjectAccessPoints' => '|',
- 'placeAccessPoints' => '|',
- 'nameAccessPoints' => '|'
+ 'accessionNumber' => '|',
+ 'creators' => '|',
+ 'creatorHistory' => '|',
+ 'datesOfCreation' => '|',
+ 'datesOfCreationNote' => '|',
+ 'datesOfCreationStart' => '|',
+ 'datesOfCreationEnd' => '|',
+ 'nameAccessPoints' => '|',
+ 'placeAccessPoints' => '|',
+ 'subjectAccessPoints' => '|'
),
/* import logic to execute before saving information object */
@@ -413,51 +413,59 @@
if (isset($self->rowStatusVars['creators'])
&& count($self->rowStatusVars['creators']))
{
- foreach($self->rowStatusVars['creators'] as $creator)
+ foreach($self->rowStatusVars['creators'] as $index => $creator)
{
- // add create event if specified
+ // Init eventData array and add creator name
+ $eventData = array('actorName' => $creator);
+
+ // add dates if specified
if (
- isset($self->rowStatusVars['datesOfCreationStart'])
+ isset($self->rowStatusVars['datesOfCreationStart'][$index])
|| (
- isset($self->rowStatusVars['datesOfCreationStart'])
- && isset($self->rowStatusVars['datesOfCreationEnd'])
+ isset($self->rowStatusVars['datesOfCreationStart'][$index])
+ && isset($self->rowStatusVars['datesOfCreationEnd'][$index])
)
)
{
- $endDate = (isset($self->rowStatusVars['datesOfCreationEnd']))
- ? $self->rowStatusVars['datesOfCreationEnd'] .'-00-00'
- : false;
-
- $eventData = array(
- 'startDate' => $self->rowStatusVars['datesOfCreationStart']
.'-00-00',
- 'endDate' => $endDate,
- 'actorName' => $creator
- );
-
+ // Start and end date
foreach(array(
- 'datesOfCreationNote' => 'description',
- 'datesOfCreation' => 'date'
+ 'datesOfCreationEnd' => 'endDate',
+ 'datesOfCreationStart' => 'startDate'
)
as $statusVar => $eventProperty
)
{
- $eventData[$eventProperty] =
$self->rowStatusVars[$statusVar];
+ if (isset($self->rowStatusVars[$statusVar][$index])) {
+ $eventData[$eventProperty] =
$self->rowStatusVars[$statusVar][$index] .'-00-00';
+ }
}
- if(isset($self->rowStatusVars['creatorHistory']))
+ // Other date info
+ foreach(array(
+ 'datesOfCreationNote' => 'description',
+ 'datesOfCreation' => 'date'
+ )
+ as $statusVar => $eventProperty
+ )
{
- $creatorPosition = array_search($creator,
$self->rowStatusVars['creators']);
- if
(isset($self->rowStatusVars['creatorHistory'][$creatorPosition]))
+ if (isset($self->rowStatusVars[$statusVar][$index]))
{
- $eventData['actorHistory'] =
$self->rowStatusVars['creatorHistory'][$creatorPosition];
+ $eventData[$eventProperty] =
$self->rowStatusVars[$statusVar][$index];
}
}
+ }
- $event = $self->createEvent(
- QubitTerm::CREATION_ID,
- $eventData
- );
+ // Add creator history if specified
+ if(isset($self->rowStatusVars['creatorHistory'][$index]))
+ {
+ $eventData['actorHistory'] =
$self->rowStatusVars['creatorHistory'][$index];
}
+
+ // Create event
+ $event = $self->createEvent(
+ QubitTerm::CREATION_ID,
+ $eventData
+ );
}
}
--
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.