Skip to content

Commit

Permalink
Merge branch 'changeIssuesOrderImportExport-821' into 'main'
Browse files Browse the repository at this point in the history
Change issues order import/export method

See merge request softwares-pkp/plugins_ojs/fullJournalTransfer!56
  • Loading branch information
thiagolepidus committed May 10, 2024
2 parents 778909d + fffa87f commit 0036102
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 16 deletions.
28 changes: 22 additions & 6 deletions filter/export/ExtendedIssueNativeXmlFilter.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function &process(&$issues)
$doc->preserveWhiteSpace = false;
$doc->formatOutput = true;
$deployment = $this->getDeployment();
$journal = $deployment->getContext();

if (count($issues) == 1) {
$rootNode = $this->createIssueNode($doc, $issues[0]);
Expand All @@ -24,6 +25,14 @@ public function &process(&$issues)
$rootNode->appendChild($this->createIssueNode($doc, $issue));
}
}

$issueDao = DAORegistry::getDAO('IssueDAO');
if ($issueDao->customIssueOrderingExists($journal->getId())) {
foreach ($issues as $issue) {
$rootNode->appendChild($this->createCustomOrderNode($doc, $issue, $journal));
}
}

$doc->appendChild($rootNode);
$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$rootNode->setAttribute('xsi:schemaLocation', $deployment->getNamespace() . ' ' . $deployment->getSchemaFilename());
Expand All @@ -45,12 +54,6 @@ public function createIssueNode($doc, $issue)
$issueNode->setAttribute('access_status', $issue->getAccessStatus());
$issueNode->setAttribute('url_path', $issue->getData('urlPath'));

$issueDAO = DAORegistry::getDAO('IssueDAO');
$issueOrder = $issueDAO->getCustomIssueOrder($journal->getId(), $issue->getId());
if ($issueOrder) {
$issueNode->setAttribute('order', $issueOrder);
}

$this->createLocalizedNodes($doc, $issueNode, 'description', $issue->getDescription(null));
import('plugins.importexport.native.filter.NativeFilterHelper');
$nativeFilterHelper = new NativeFilterHelper();
Expand Down Expand Up @@ -100,4 +103,17 @@ public function addArticles($doc, $issueNode, $issue)
$issueNode->appendChild($clone);
}
}

public function createCustomOrderNode($doc, $issue, $journal)
{
$deployment = $this->getDeployment();

$issueDao = DAORegistry::getDAO('IssueDAO');
$order = $issueDao->getCustomIssueOrder($journal->getId(), $issue->getId());

$customOrderNode = $doc->createElementNS($deployment->getNamespace(), 'custom_order', $order);
$customOrderNode->setAttribute('id', $issue->getId());

return $customOrderNode;
}
}
5 changes: 0 additions & 5 deletions filter/import/NativeXmlExtendedIssueFilter.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ public function handleElement($node)
if ($issue->getCurrent()) {
$deployment->setCurrentIssue($issue);
}

if ($seq = $node->getAttribute('order')) {
$issueDao = DAORegistry::getDAO('IssueDAO');
$issueDao->moveCustomIssueOrder($journal->getId(), $issue->getId(), $seq);
}
}

return $issue;
Expand Down
20 changes: 18 additions & 2 deletions filter/import/NativeXmlJournalFilter.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,13 @@ public function parseIssues($node, $journal)

echo __('plugins.importexport.fullJournal.importingIssues') . "\n";
for ($n = $node->firstChild; $n !== null; $n = $n->nextSibling) {
if (is_a($n, 'DOMElement') && $n->tagName === 'extended_issue') {
$this->parseIssue($n, $journal);
if (is_a($n, 'DOMElement')) {
if ($n->tagName === 'extended_issue') {
$this->parseIssue($n, $journal);
}
if ($n->tagName === 'custom_order') {
$this->parseIssueOrder($n, $journal);
}
}
}

Expand All @@ -410,6 +415,17 @@ public function parseIssue($node, $journal)
return $importedObjects;
}

public function parseIssueOrder($node, $journal)
{
$deployment = $this->getDeployment();

$issueId = $deployment->getIssueDBId($node->getAttribute('id'));
$customOrder = $node->textContent;

$issueDAO = DAORegistry::getDAO('IssueDAO');
$issueDAO->moveCustomIssueOrder($journal->getId(), $issueId, $customOrder);
}

public function parseArticles($node, $journal)
{
$deployment = $this->getDeployment();
Expand Down
6 changes: 5 additions & 1 deletion fullJournal.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,17 @@
<attribute name="current" type="int" use="optional" />
<attribute name="access_status" type="int" use="optional" />
<attribute name="url_path" type="string" use="optional" />
<attribute name="order" type="int" use="optional" />
</complexType>

<element name="extended_issues">
<complexType>
<sequence>
<element ref="pkp:extended_issue" minOccurs="0" maxOccurs="unbounded" />
<element name="custom_order" minOccurs="0" maxOccurs="unbounded">
<complexType mixed="true">
<attribute name="id" type="int" />
</complexType>
</element>
</sequence>
</complexType>
</element>
Expand Down
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<version>
<application>fullJournalTransfer</application>
<type>plugins.importexport</type>
<release>2.0.11.3</release>
<date>2024-05-09</date>
<release>2.0.11.4</release>
<date>2024-05-10</date>
<class>FullJournalImportExportPlugin</class>
</version>

0 comments on commit 0036102

Please sign in to comment.