16 import(
'plugins.importexport.medra.filter.O4DOIXmlFilter');
26 parent::__construct($filterGroup);
33 return $plugin->getSetting($context->getId(),
'exportIssuesAs') == O4DOI_ISSUE_AS_WORK;
43 return 'plugins.importexport.medra.filter.IssueMedraXmlFilter';
56 $doc =
new DOMDocument(
'1.0',
'utf-8');
57 $doc->preserveWhiteSpace =
false;
58 $doc->formatOutput =
true;
60 $context = $deployment->getContext();
61 $plugin = $deployment->getPlugin();
64 $rootNodename = $this->
isWork($context, $plugin) ?
'ONIXDOISerialIssueWorkRegistrationMessage' :
'ONIXDOISerialIssueVersionRegistrationMessage';
66 $doc->appendChild($rootNode);
72 foreach($pubObjects as $pubObject) {
86 $context = $deployment->getContext();
87 $cache = $deployment->getCache();
88 $plugin = $deployment->getPlugin();
90 $router = $request->getRouter();
92 $issueNodeName = $this->
isWork($context, $plugin) ?
'DOISerialIssueWork' :
'DOISerialIssueVersion';
93 $issueNode = $doc->createElementNS($deployment->getNamespace(), $issueNodeName);
95 $doi = $pubObject->getStoredPubId(
'doi');
96 $registeredDoi = $pubObject->getData(
'medra::registeredDoi');
97 assert(empty($registeredDoi) || $registeredDoi == $doi);
98 $notificationType = (empty($registeredDoi) ? O4DOI_NOTIFICATION_TYPE_NEW : O4DOI_NOTIFICATION_TYPE_UPDATE);
99 $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'NotificationType', $notificationType));
101 $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'DOI', htmlspecialchars($doi, ENT_COMPAT,
'UTF-8')));
103 $url = $router->url($request, $context->getPath(),
'issue',
'view', $pubObject->getBestIssueId(),
null,
null,
true);
104 if ($plugin->isTestMode($context)) {
108 $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'DOIWebsiteLink', $url));
110 $structuralType = $this->
isWork($context, $plugin) ?
'Abstraction' :
'DigitalFixation';
111 $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'DOIStructuralType', $structuralType));
113 $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'RegistrantName', htmlspecialchars($plugin->getSetting($context->getId(),
'registrantName'), ENT_COMPAT,
'UTF-8')));
115 $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'RegistrationAuthority',
'mEDRA'));
117 $pubObjectProprietaryId = $context->getId() .
'-' . $pubObject->getId();
118 $workOrProduct = $this->
isWork($context, $plugin) ?
'Work' :
'Product';
119 $issueNode->appendChild($this->
createIdentifierNode($doc, $workOrProduct, O4DOI_ID_TYPE_PROPRIETARY, $pubObjectProprietaryId));
125 $issueId = $pubObject->getId();
126 if (!$cache->isCached(
'issues', $issueId)) {
127 $cache->add($pubObject,
null);
132 foreach ($descriptions as $locale => $description) {
139 $submissionsIterator =
Services::get(
'submission')->getMany([
140 'contextId' => $pubObject->getJournalId(),
141 'issueIds' => $pubObject->getId(),
142 'status' => STATUS_PUBLISHED,
145 $relatedGalleys = [];
146 foreach ($submissionsIterator as $relatedSubmission) {
147 $articleProprietaryId = $context->getId() .
'-' . $pubObject->getId() .
'-' . $relatedSubmission->getId();
148 $relatedSubmissionIds = array(O4DOI_ID_TYPE_PROPRIETARY => $articleProprietaryId);
149 $doi = $relatedSubmission->getStoredPubId(
'doi');
150 if (!empty($doi)) $relatedSubmissionIds[O4DOI_ID_TYPE_DOI] = $doi;
151 $issueNode->appendChild($this->
createRelatedNode($doc,
'Work', O4DOI_RELATION_INCLUDES, $relatedSubmissionIds));
154 $galleys = (array) $relatedSubmission->getCurrentPublication()->getData(
'galleys');
155 foreach ($galleys as $galley) {
156 $galleyProprietaryId = $context->getId() .
'-' . $pubObject->getId() .
'-' . $relatedSubmission->getId() .
'-g' . $galley->getId();
157 $relatedGalleyIds = array(O4DOI_ID_TYPE_PROPRIETARY => $galleyProprietaryId);
158 $doi = $galley->getStoredPubId(
'doi');
159 if (!empty($doi)) $relatedGalleyIds[O4DOI_ID_TYPE_DOI] = $doi;
160 $issueNode->appendChild($this->
createRelatedNode($doc,
'Product', O4DOI_RELATION_INCLUDES, $relatedGalleyIds));
161 unset($galley, $relatedGalleyIds);
164 unset($relatedSubmission, $relatedSubmissionIds);
175 $context = $deployment->getContext();
176 $plugin = $deployment->getPlugin();
178 $journalIssueNode = parent::createJournalIssueNode($doc, $issue, $journalLocalePrecedence);
181 $datePublished = $issue->getDatePublished();
182 if (!empty($datePublished)) {
183 $journalIssueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(),
'PublicationDate', date(
'Ymd', strtotime($datePublished))));
188 foreach($localizedTitles as $locale => $localizedTitle)
break;
189 if (empty($localizedTitle)) {
192 foreach($localizedTitles as $locale => $localizedTitle)
break;
193 assert(!empty($localizedTitle));
196 $showTitle = $issue->getShowTitle();
197 $issue->setShowTitle(0);
198 $localizedTitle = $localizedTitle .
', ' . $issue->getIssueIdentification();
199 $issue->setShowTitle($showTitle);
201 $journalIssueNode->appendChild($this->
createTitleNode($doc, $locale, $localizedTitle, O4DOI_TITLE_TYPE_ISSUE));
204 if (!$this->
isWork($context, $plugin)) {
206 $issueGalleys = $issueGalleyDao->getByIssueId($issue->getId());
207 if (!empty($issueGalleys)) {
208 foreach($issueGalleys as $issueGalley) {
209 $journalIssueNode->appendChild($this->
createExtentNode($doc, $issueGalley));
214 return $journalIssueNode;