Skip to content

Commit

Permalink
pkp/pkp-lib#10922 fix handling for identification codes (#1840)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitlinnewson authored Feb 18, 2025
1 parent 409aa56 commit bd59055
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions plugins/importexport/onix30/filter/MonographONIX30XmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,9 @@ public function createSubmissionNode(DOMDocument $doc, DOMElement $rootNode, Sub
{
$publicationFormats = $submission->getCurrentPublication()->getData('publicationFormats');

// Collect identifiers for all publication formats to connect related products
$identificationCodes = [];
foreach ($publicationFormats as $publicationFormat) {
$pubIdentificationCodes = $publicationFormat->getIdentificationCodes();
$pubId = $publicationFormat->getId();
while ($code = $pubIdentificationCodes->next()) {
$identificationCodes[$pubId][$code->getCode()] = $code->getValue();
}
}

// Append all publication formats as Product nodes.
foreach ($publicationFormats as $publicationFormat) {
$rootNode->appendChild($this->createProductNode($doc, $submission, $publicationFormat, $identificationCodes));
$rootNode->appendChild($this->createProductNode($doc, $submission, $publicationFormat));
}
}

Expand Down Expand Up @@ -168,7 +158,7 @@ public function createHeaderNode($doc)
* @throws DOMException
* @throws Exception
*/
public function createProductNode(DOMDocument $doc, Submission $submission, PublicationFormat $publicationFormat, array $identificationCodes): DOMElement
public function createProductNode(DOMDocument $doc, Submission $submission, PublicationFormat $publicationFormat): DOMElement
{
/** @var Onix30ExportDeployment $deployment */
$deployment = $this->getDeployment();
Expand All @@ -192,6 +182,19 @@ public function createProductNode(DOMDocument $doc, Submission $submission, Publ

$identifierGiven = false;

$publication = $submission->getCurrentPublication();
$publicationFormats = $publication->getData('publicationFormats');

// Collect identifiers for all publication formats to connect related products (see Related Material)
$identificationCodes = [];
foreach ($publicationFormats as $pubFormat) {
$pubIdentificationCodes = $pubFormat->getIdentificationCodes();
$pubId = $pubFormat->getId();
while ($code = $pubIdentificationCodes->next()) {
$identificationCodes[$pubId][$code->getCode()] = $code->getValue();
}
}

if (array_key_exists($publicationFormat->getId(), $identificationCodes)) {
foreach ($identificationCodes[$publicationFormat->getId()] as $code => $value) {
$productIdentifierNode = $doc->createElementNS($deployment->getNamespace(), 'ProductIdentifier');
Expand Down Expand Up @@ -280,7 +283,6 @@ public function createProductNode(DOMDocument $doc, Submission $submission, Publ

/* --- License information --- */

$publication = $submission->getCurrentPublication();
$pubLocale = $publication->getData('locale');

if ($publication->isCCLicense()) {
Expand Down

0 comments on commit bd59055

Please sign in to comment.