Skip to content

Commit

Permalink
import Native xml, restrict review stages
Browse files Browse the repository at this point in the history
  • Loading branch information
withanage committed Jan 31, 2025
1 parent 80ca552 commit 4e0bfbe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Data suite tests', function() {
});
});
});
it.skip('Imports submissions from XML', function() {
it('Imports submissions from XML', function() {
var username = 'admin';
cy.login(username, 'admin');

Expand Down
32 changes: 27 additions & 5 deletions plugins/importexport/native/filter/NativeXmlSubmissionFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
use APP\facades\Repo;
use APP\submission\Submission;
use PKP\core\Core;
use PKP\db\DAORegistry;
use PKP\filter\Filter;
use PKP\filter\FilterGroup;
use PKP\observers\events\BatchMetadataChanged;
use PKP\submission\reviewRound\ReviewRound;
use PKP\workflow\WorkflowStageDAO;

class NativeXmlSubmissionFilter extends NativeImportFilter
Expand Down Expand Up @@ -82,8 +84,8 @@ public function handleElement($node)
$submission->stampModified();
$submission->setData('status', $node->getAttribute('status'));
$submission->setData('submissionProgress', '');

$submission->setData('stageId', WorkflowStageDAO::getIdFromPath($node->getAttribute('stage')));
$stageName = $node->getAttribute('stage');
$submission->setData('stageId', WorkflowStageDAO::getIdFromPath($stageName));

// Handle any additional attributes etc.
$submission = $this->populateObject($submission, $node);
Expand All @@ -105,6 +107,9 @@ public function handleElement($node)

$deployment->addImportedRootEntity(Application::ASSOC_TYPE_SUBMISSION, $submission);

if ($stageName === "externalReview" or $stageName === "internalReview") {
$this->createReviewRound($submission);
}
return $submission;
}

Expand Down Expand Up @@ -173,15 +178,15 @@ public function parseIdentifier($element, $submission)
}

/**
* @see Filter::process()
*
* @param \DOMDocument|string $document
*
* @return array Array of imported documents
* @see Filter::process()
*
*/
public function &process(&$document)
{
$importedObjects = & parent::process($document);
$importedObjects = &parent::process($document);

$deployment = $this->getDeployment();

Expand Down Expand Up @@ -238,4 +243,21 @@ public function getImportFilter($elementName)
{
assert(false); // Subclasses should override
}

/**
* Create review round
* @param Submission $submission
* @return void
*/
public function createReviewRound(Submission $submission): void
{
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
$reviewRound = $reviewRoundDao->build(
$submission->getId(),
$submission->getData('stageId'),
1,
ReviewRound::REVIEW_ROUND_STATUS_PENDING_REVIEWERS,
);
}

}

0 comments on commit 4e0bfbe

Please sign in to comment.