Ejemplo n.º 1
0
 public function testNativeDoiImport()
 {
     $testfile = 'tests/functional/plugins/importexport/native/testissue.xml';
     $args = array('import', $testfile, 'test', 'admin');
     $result = $this->executeCli('NativeImportExportPlugin', $args);
     self::assertRegExp('/##plugins.importexport.native.import.success.description##/', $result);
     $daos = array('Issue' => 'IssueDAO', 'PublishedArticle' => 'PublishedArticleDAO', 'Galley' => 'ArticleGalleyDAO');
     $articleId = null;
     foreach ($daos as $objectType => $daoName) {
         $dao = DAORegistry::getDAO($daoName);
         $pubObject = call_user_func(array($dao, "get{$objectType}ByPubId"), 'doi', $this->expectedDois[$objectType]);
         self::assertNotNull($pubObject, "Error while testing {$objectType}: object or DOI has not been imported.");
         $pubObjectByURN = call_user_func(array($dao, "get{$objectType}ByPubId"), 'other::urn', $this->expectedURNs[$objectType]);
         self::assertNotNull($pubObjectByURN, "Error while testing {$objectType}: object or URN has not been imported.");
         if ($objectType == 'PublishedArticle') {
             $articleId = $pubObject->getId();
         }
     }
     // Trying to import the same file again should lead to an error.
     $args = array('import', $testfile, 'test', 'admin');
     $result = $this->executeCli('NativeImportExportPlugin', $args);
     self::assertRegExp('/##plugins.importexport.native.import.error.duplicatePubId##/', $result);
     // Delete inserted article files from the filesystem.
     $request = $application->getRequest();
     $context = $request->getContext();
     import('lib.pkp.classes.file.SubmissionFileManager');
     $submissionFileManager = new SubmissionFileManager($context->getId(), $articleId);
     $submissionFileManager->rmtree($submissionFileManager->getBasePath());
 }
Ejemplo n.º 2
0
 /**
  * Delete a submission by ID.
  * @param $submissionId int
  */
 function deleteById($submissionId)
 {
     // Delete submission files.
     $submission = $this->getById($submissionId);
     assert(is_a($submission, 'Submission'));
     import('lib.pkp.classes.file.SubmissionFileManager');
     $submissionFileManager = new SubmissionFileManager($submission->getContextId(), $submission->getId());
     $submissionFileManager->rmtree($submissionFileManager->getBasePath());
     $this->authorDao->deleteBySubmissionId($submissionId);
     $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
     $reviewRoundDao->deleteBySubmissionId($submissionId);
     $editDecisionDao = DAORegistry::getDAO('EditDecisionDAO');
     $editDecisionDao->deleteDecisionsBySubmissionId($submissionId);
     $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignmentDao->deleteBySubmissionId($submissionId);
     // Signoff DAOs
     $signoffDao = DAORegistry::getDAO('SignoffDAO');
     $submissionFileSignoffDao = DAORegistry::getDAO('SubmissionFileSignoffDAO');
     // Delete Signoffs associated with a submission file of this submission.
     $submissionFileSignoffs = $submissionFileSignoffDao->getAllBySubmission($submissionId);
     while ($signoff = $submissionFileSignoffs->next()) {
         $signoffDao->deleteObject($signoff);
     }
     // Delete the Signoffs associated with the submission itself.
     $submissionSignoffs = $signoffDao->getAllByAssocType(ASSOC_TYPE_SUBMISSION, $submissionId);
     while ($signoff = $submissionSignoffs->next()) {
         $signoffDao->deleteObject($signoff);
     }
     // Delete the stage assignments.
     $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
     $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submissionId);
     while ($stageAssignment = $stageAssignments->next()) {
         $stageAssignmentDao->deleteObject($stageAssignment);
     }
     // N.B. Files must be deleted after signoffs to identify submission file signoffs.
     // Delete submission files.
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     /* @var $submissionFileDao SubmissionFileDAO */
     $submissionFileDao->deleteAllRevisionsBySubmissionId($submissionId);
     $noteDao = DAORegistry::getDAO('NoteDAO');
     $noteDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
     $submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO');
     $submissionCommentDao->deleteBySubmissionId($submissionId);
     // Delete any outstanding notifications for this submission
     $notificationDao = DAORegistry::getDAO('NotificationDAO');
     $notificationDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
     $submissionEventLogDao = DAORegistry::getDAO('SubmissionEventLogDAO');
     $submissionEventLogDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
     $submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
     $submissionEmailLogDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
     // Delete controlled vocab lists assigned to this submission
     $submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO');
     $submissionKeywordVocab = $submissionKeywordDao->getBySymbolic(CONTROLLED_VOCAB_SUBMISSION_KEYWORD, ASSOC_TYPE_SUBMISSION, $submissionId);
     if (isset($submissionKeywordVocab)) {
         $submissionKeywordDao->deleteObject($submissionKeywordVocab);
     }
     $submissionDisciplineDao = DAORegistry::getDAO('SubmissionDisciplineDAO');
     $submissionDisciplineVocab = $submissionDisciplineDao->getBySymbolic(CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE, ASSOC_TYPE_SUBMISSION, $submissionId);
     if (isset($submissionDisciplineVocab)) {
         $submissionDisciplineDao->deleteObject($submissionDisciplineVocab);
     }
     $submissionAgencyDao = DAORegistry::getDAO('SubmissionAgencyDAO');
     $submissionAgencyVocab = $submissionAgencyDao->getBySymbolic(CONTROLLED_VOCAB_SUBMISSION_AGENCY, ASSOC_TYPE_SUBMISSION, $submissionId);
     if (isset($submissionAgencyVocab)) {
         $submissionAgencyDao->deleteObject($submissionAgencyVocab);
     }
     $submissionLanguageDao = DAORegistry::getDAO('SubmissionLanguageDAO');
     $submissionLanguageVocab = $submissionLanguageDao->getBySymbolic(CONTROLLED_VOCAB_SUBMISSION_LANGUAGE, ASSOC_TYPE_SUBMISSION, $submissionId);
     if (isset($submissionLanguageVocab)) {
         $submissionLanguageDao->deleteObject($submissionLanguageVocab);
     }
     $submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO');
     $submissionSubjectVocab = $submissionSubjectDao->getBySymbolic(CONTROLLED_VOCAB_SUBMISSION_SUBJECT, ASSOC_TYPE_SUBMISSION, $submissionId);
     if (isset($submissionSubjectVocab)) {
         $submissionSubjectDao->deleteObject($submissionSubjectVocab);
     }
     $this->update('DELETE FROM submission_settings WHERE submission_id = ?', (int) $submissionId);
     $this->update('DELETE FROM submissions WHERE submission_id = ?', (int) $submissionId);
 }
Ejemplo n.º 3
0
 /**
  * Delete a submission by ID.
  * @param $submissionId int
  */
 function deleteById($submissionId)
 {
     // Delete submission files.
     $submission = $this->getById($submissionId);
     assert(is_a($submission, 'Submission'));
     // 'deleteAllRevisionsBySubmissionId' has to be called before 'rmtree'
     // because SubmissionFileDaoDelegate::deleteObjects checks the file
     // and returns false if the file is not there, which makes the foreach loop in
     // PKPSubmissionFileDAO::_deleteInternally not run till the end.
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     /* @var $submissionFileDao SubmissionFileDAO */
     $submissionFileDao->deleteAllRevisionsBySubmissionId($submissionId);
     import('lib.pkp.classes.file.SubmissionFileManager');
     $submissionFileManager = new SubmissionFileManager($submission->getContextId(), $submission->getId());
     $submissionFileManager->rmtree($submissionFileManager->getBasePath());
     $this->authorDao->deleteBySubmissionId($submissionId);
     $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
     $reviewRoundDao->deleteBySubmissionId($submissionId);
     $editDecisionDao = DAORegistry::getDAO('EditDecisionDAO');
     $editDecisionDao->deleteDecisionsBySubmissionId($submissionId);
     $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignmentDao->deleteBySubmissionId($submissionId);
     // Delete the queries associated with a submission
     $queryDao = DAORegistry::getDAO('QueryDAO');
     $queryDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
     // Delete the stage assignments.
     $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
     $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submissionId);
     while ($stageAssignment = $stageAssignments->next()) {
         $stageAssignmentDao->deleteObject($stageAssignment);
     }
     $noteDao = DAORegistry::getDAO('NoteDAO');
     $noteDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
     $submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO');
     $submissionCommentDao->deleteBySubmissionId($submissionId);
     // Delete any outstanding notifications for this submission
     $notificationDao = DAORegistry::getDAO('NotificationDAO');
     $notificationDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
     $submissionEventLogDao = DAORegistry::getDAO('SubmissionEventLogDAO');
     $submissionEventLogDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
     $submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
     $submissionEmailLogDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
     // Delete controlled vocab lists assigned to this submission
     $submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO');
     $submissionKeywordVocab = $submissionKeywordDao->getBySymbolic(CONTROLLED_VOCAB_SUBMISSION_KEYWORD, ASSOC_TYPE_SUBMISSION, $submissionId);
     if (isset($submissionKeywordVocab)) {
         $submissionKeywordDao->deleteObject($submissionKeywordVocab);
     }
     $submissionDisciplineDao = DAORegistry::getDAO('SubmissionDisciplineDAO');
     $submissionDisciplineVocab = $submissionDisciplineDao->getBySymbolic(CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE, ASSOC_TYPE_SUBMISSION, $submissionId);
     if (isset($submissionDisciplineVocab)) {
         $submissionDisciplineDao->deleteObject($submissionDisciplineVocab);
     }
     $submissionAgencyDao = DAORegistry::getDAO('SubmissionAgencyDAO');
     $submissionAgencyVocab = $submissionAgencyDao->getBySymbolic(CONTROLLED_VOCAB_SUBMISSION_AGENCY, ASSOC_TYPE_SUBMISSION, $submissionId);
     if (isset($submissionAgencyVocab)) {
         $submissionAgencyDao->deleteObject($submissionAgencyVocab);
     }
     $submissionLanguageDao = DAORegistry::getDAO('SubmissionLanguageDAO');
     $submissionLanguageVocab = $submissionLanguageDao->getBySymbolic(CONTROLLED_VOCAB_SUBMISSION_LANGUAGE, ASSOC_TYPE_SUBMISSION, $submissionId);
     if (isset($submissionLanguageVocab)) {
         $submissionLanguageDao->deleteObject($submissionLanguageVocab);
     }
     $submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO');
     $submissionSubjectVocab = $submissionSubjectDao->getBySymbolic(CONTROLLED_VOCAB_SUBMISSION_SUBJECT, ASSOC_TYPE_SUBMISSION, $submissionId);
     if (isset($submissionSubjectVocab)) {
         $submissionSubjectDao->deleteObject($submissionSubjectVocab);
     }
     $this->update('DELETE FROM submission_settings WHERE submission_id = ?', (int) $submissionId);
     $this->update('DELETE FROM submissions WHERE submission_id = ?', (int) $submissionId);
 }