Skip to content

Commit

Permalink
pkp/pkp-lib#10922 fix handling for identification codes
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitlinnewson committed Feb 12, 2025
1 parent aeb524e commit 7d4ea1b
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions plugins/importexport/onix30/filter/MonographONIX30XmlFilter.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,9 @@ function createSubmissionNode($doc, $rootNode, $submission) {
$deployment->addError(ASSOC_TYPE_MONOGRAPH, $submission->getId(), __('plugins.importExport.onix30.common.error.monographWithNoPublicationFormats', ['monographId' => $submission->getId()]));
}

// 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 @@ -149,7 +139,7 @@ function createHeaderNode($doc) {
* @param $publicationFormat PublicationFormat
* @return DOMElement
*/
function createProductNode($doc, $submission, $publicationFormat, $identificationCodes) {
function createProductNode($doc, $submission, $publicationFormat) {

$deployment = $this->getDeployment();
$context = $deployment->getContext();
Expand All @@ -164,6 +154,19 @@ function createProductNode($doc, $submission, $publicationFormat, $identificatio

$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 $publicationFormat) {
$pubIdentificationCodes = $publicationFormat->getIdentificationCodes();
$pubId = $publicationFormat->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 @@ -256,7 +259,6 @@ function createProductNode($doc, $submission, $publicationFormat, $identificatio

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

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

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

0 comments on commit 7d4ea1b

Please sign in to comment.