Skip to content

Commit

Permalink
Fixes in EAD bioghist import/export, refs #7124
Browse files Browse the repository at this point in the history
  - Don't add empty bioghist elements in EAD export
  - Don't create new 'Untitled' actors if bioghist value match
    the history value of the creator in the same position
  - Improve comments showing different options on import

Squashed commit of the following:

commit ec49f3f
Author: José Raddaoui Marín <[email protected]>
Date:   Fri Dec 12 23:58:27 2014 +0100

    Add @param to function comments

commit 907d5d2
Author: José Raddaoui Marín <[email protected]>
Date:   Fri Dec 12 00:12:33 2014 +0100

    Fixes in EAD bioghist import/export, refs #7124

    - Don't add empty bioghist elements in EAD export
    - Don't create new 'Untitled' actors if bioghist value match
      the history value of the creator in the same position
    - Improve comments showing different options on import

    See #7124, updates #7 and #8
  • Loading branch information
jraddaoui committed Dec 12, 2014
1 parent 4056131 commit 16a3089
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 28 deletions.
4 changes: 2 additions & 2 deletions lib/QubitXmlImport.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ private function processMethods(&$domNode, &$importDOM, $methods, &$currentObjec

foreach ($childNode as $pNode)
{
// A <p> node inside <processinfo> with no other children,
// A <p> node inside <processinfo> with no other children,
// this is part of an archivist's note.
if ($pNode->childNodes->length === 1 && $pNode->firstChild->nodeType === XML_TEXT_NODE)
{
Expand Down Expand Up @@ -826,7 +826,7 @@ public static function normalizeNodeValue($node)
$nodeValue .= $node->nodeValue;
}

return $nodeValue;
return trim($nodeValue);
}

/**
Expand Down
48 changes: 30 additions & 18 deletions lib/model/QubitInformationObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,7 @@ public function importDCLanguage($code)
* Import creation-related data from an <bioghist> tag in EAD2002
*
* @param $biogHistNode DOMNode EAD bioghist DOM node
* @param $key Position of the current bioghist node
*/
public function importBioghistEadData($biogHistNode, $key)
{
Expand Down Expand Up @@ -1800,26 +1801,37 @@ public function importBioghistEadData($biogHistNode, $key)
}
}

// Add bioghist if there is a creator in the position and it doesn't have history
if (isset($creators[$key]) && !isset($creators[$key]->history))
{
$creators[$key]->history = QubitXmlImport::normalizeNodeValue($biogHistNode);
$creators[$key]->save();
}
else
{
// Otherwise create new 'Untitled' actor
$actor = new QubitActor;
$actor->parentId = QubitActor::ROOT_ID;
$actor->setHistory(QubitXmlImport::normalizeNodeValue($biogHistNode));
$actor->save();
// Add bioghist
if (strlen($history = QubitXmlImport::normalizeNodeValue($biogHistNode)) > 0)
{
// Options:
// 1. If there isn't an actor in the current position:
// - Create new 'Untitled' actor with bioghist value as history and new event
// 2. If the actor in the current position doesn't have history:
// - Add bioghist value to the actor's history
// 3. If the actor in the current position has history and it's different to the bioghist value:
// - Create new 'Untitled' actor with bioghist value as history and new event
// 4. If the actor in the current position has history and it's equal to the bioghist value:
// - Do nothing
if (!isset($creators[$key]) ||
(isset($creators[$key]->history) && $creators[$key]->history !== $history))
{
$actor = new QubitActor;
$actor->parentId = QubitActor::ROOT_ID;
$actor->setHistory($history);
$actor->save();

// And add it to a new creation event for the resource
$event = new QubitEvent;
$event->setActorId($actor->id);
$event->setTypeId(QubitTerm::CREATION_ID);
$event = new QubitEvent;
$event->setActorId($actor->id);
$event->setTypeId(QubitTerm::CREATION_ID);

$this->events[] = $event;
$this->events[] = $event;
}
else if (!isset($creators[$key]->history))
{
$creators[$key]->history = $history;
$creators[$key]->save();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
<?php endif; ?>
</origination>

<bioghist id="<?php echo 'md5-' . md5(url_for(array($creator, 'module' => 'actor'), true)) ?>" encodinganalog="<?php echo $ead->getMetadataParameter('bioghist') ?>">
<?php if ($value = $creator->getHistory(array('cultureFallback' => true))): ?>
<note><p><?php echo escape_dc(esc_specialchars($value)) ?></p></note>
<?php endif; ?>
<?php if ($creator->datesOfExistence): ?>
<date type="existence"><?php echo escape_dc(esc_specialchars($creator->datesOfExistence)) ?></date>
<?php endif; ?>
</bioghist>
<?php if (($value = $creator->getHistory(array('cultureFallback' => true))) || $creator->datesOfExistence): ?>
<bioghist id="<?php echo 'md5-' . md5(url_for(array($creator, 'module' => 'actor'), true)) ?>" encodinganalog="<?php echo $ead->getMetadataParameter('bioghist') ?>">
<?php if ($value): ?>
<note><p><?php echo escape_dc(esc_specialchars($value)) ?></p></note>
<?php endif; ?>
<?php if ($creator->datesOfExistence): ?>
<date type="existence"><?php echo escape_dc(esc_specialchars($creator->datesOfExistence)) ?></date>
<?php endif; ?>
</bioghist>
<?php endif; ?>

<?php endforeach; ?>
<?php endif; ?>

0 comments on commit 16a3089

Please sign in to comment.