diff --git a/dbscripts/xml/upgrade.xml b/dbscripts/xml/upgrade.xml
index e40caa7daac..ee282793ee0 100644
--- a/dbscripts/xml/upgrade.xml
+++ b/dbscripts/xml/upgrade.xml
@@ -140,6 +140,7 @@
+
diff --git a/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php b/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php
index 8e953bf64e2..a117c3216f9 100755
--- a/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php
+++ b/plugins/metadata/dc11/filter/Dc11SchemaPublicationFormatAdapter.php
@@ -28,6 +28,7 @@
use APP\publicationFormat\PublicationFormat;
use APP\section\Section;
use APP\submission\Submission;
+use PKP\controlledVocab\ControlledVocab;
use PKP\db\DAORegistry;
use PKP\facades\Locale;
use PKP\i18n\LocaleConversion;
@@ -35,8 +36,6 @@
use PKP\metadata\MetadataDescription;
use PKP\plugins\Hook;
use PKP\plugins\PluginRegistry;
-use PKP\submission\SubmissionKeywordDAO;
-use PKP\submission\SubmissionSubjectDAO;
class Dc11SchemaPublicationFormatAdapter extends MetadataDataObjectAdapter
{
@@ -99,12 +98,20 @@ public function extractMetadataFromDataObject(&$publicationFormat)
}
// Subject
- $submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO'); /** @var SubmissionKeywordDAO $submissionKeywordDao */
- $submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO'); /** @var SubmissionSubjectDAO $submissionSubjectDao */
$supportedLocales = array_keys(Locale::getSupportedFormLocales());
$subjects = array_merge_recursive(
- (array) $submissionKeywordDao->getKeywords($publication->getId(), $supportedLocales),
- (array) $submissionSubjectDao->getSubjects($publication->getId(), $supportedLocales)
+ Repo::controlledVocab()->getBySymbolic(
+ ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
+ Application::ASSOC_TYPE_PUBLICATION,
+ $publication->getId(),
+ $supportedLocales
+ ),
+ Repo::controlledVocab()->getBySymbolic(
+ ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_SUBJECT,
+ Application::ASSOC_TYPE_PUBLICATION,
+ $publication->getId(),
+ $supportedLocales
+ )
);
$this->_addLocalizedElements($dc11Description, 'dc:subject', $subjects);
diff --git a/plugins/reports/monographReport/Report.php b/plugins/reports/monographReport/Report.php
index 070472cdc5e..3c228af335e 100644
--- a/plugins/reports/monographReport/Report.php
+++ b/plugins/reports/monographReport/Report.php
@@ -32,14 +32,10 @@
use Illuminate\Support\LazyCollection;
use IteratorAggregate;
use PKP\category\Category;
-use PKP\db\DAORegistry;
+use PKP\controlledVocab\ControlledVocab;
use PKP\facades\Locale;
use PKP\security\Role;
use PKP\stageAssignment\StageAssignment;
-use PKP\submission\SubmissionAgencyDAO;
-use PKP\submission\SubmissionDisciplineDAO;
-use PKP\submission\SubmissionKeywordDAO;
-use PKP\submission\SubmissionSubjectDAO;
use PKP\user\User;
use PKP\userGroup\UserGroup;
use Traversable;
@@ -366,9 +362,13 @@ private function getStatus(): string
*/
private function getKeywords(): string
{
- /** @var SubmissionKeywordDAO */
- $submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO');
- return $this->flattenKeywords($submissionKeywordDao->getKeywords($this->publication->getId()));
+ return $this->flattenKeywords(
+ Repo::controlledVocab()->getBySymbolic(
+ ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
+ Application::ASSOC_TYPE_PUBLICATION,
+ $this->publication->getId()
+ )
+ );
}
/**
@@ -376,9 +376,13 @@ private function getKeywords(): string
*/
private function getSubjects(): string
{
- /** @var SubmissionSubjectDAO */
- $submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO');
- return $this->flattenKeywords($submissionSubjectDao->getSubjects($this->publication->getId()));
+ return $this->flattenKeywords(
+ Repo::controlledVocab()->getBySymbolic(
+ ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_SUBJECT,
+ Application::ASSOC_TYPE_PUBLICATION,
+ $this->publication->getId()
+ )
+ );
}
/**
@@ -386,9 +390,13 @@ private function getSubjects(): string
*/
private function getDisciplines(): string
{
- /** @var SubmissionDisciplineDAO */
- $submissionDisciplineDao = DAORegistry::getDAO('SubmissionDisciplineDAO');
- return $this->flattenKeywords($submissionDisciplineDao->getDisciplines($this->publication->getId()));
+ return $this->flattenKeywords(
+ Repo::controlledVocab()->getBySymbolic(
+ ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE,
+ Application::ASSOC_TYPE_PUBLICATION,
+ $this->publication->getId()
+ )
+ );
}
/**
@@ -396,9 +404,13 @@ private function getDisciplines(): string
*/
private function getAgencies(): string
{
- /** @var SubmissionAgencyDAO */
- $submissionAgencyDao = DAORegistry::getDAO('SubmissionAgencyDAO');
- return $this->flattenKeywords($submissionAgencyDao->getAgencies($this->publication->getId()));
+ return $this->flattenKeywords(
+ Repo::controlledVocab()->getBySymbolic(
+ ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_AGENCY,
+ Application::ASSOC_TYPE_PUBLICATION,
+ $this->publication->getId()
+ )
+ );
}
/**
diff --git a/tools/cleanReviewerInterests.php b/tools/cleanReviewerInterests.php
index fbfc7a5c527..ebeb2a2e781 100755
--- a/tools/cleanReviewerInterests.php
+++ b/tools/cleanReviewerInterests.php
@@ -14,11 +14,11 @@
* @brief CLI tool to remove user interests that are not referenced by any user accounts.
*/
+use APP\facades\Repo;
+use Illuminate\Support\Collection;
use PKP\cliTool\CommandLineTool;
-use PKP\controlledVocab\ControlledVocabDAO;
-use PKP\controlledVocab\ControlledVocabEntryDAO;
-use PKP\db\DAORegistry;
-use PKP\user\InterestDAO;
+use PKP\controlledVocab\ControlledVocabEntry;
+use PKP\user\interest\UserInterest;
require(dirname(__FILE__) . '/bootstrap.php');
@@ -60,7 +60,7 @@ public function usage()
public function execute()
{
$orphans = $this->_getOrphanVocabInterests();
- if (!count($orphans)) {
+ if ($orphans->count() === 0) {
echo "No user interests to remove.\n";
exit(0);
}
@@ -68,20 +68,13 @@ public function execute()
$command = $this->parameters[0];
switch ($command) {
case '--show':
- $interests = array_map(function ($entry) {
- return $entry->getData(InterestDAO::CONTROLLED_VOCAB_INTEREST);
- }, $orphans);
+ $interests = $orphans->pluck(UserInterest::CONTROLLED_VOCAB_INTEREST)->toArray();
echo "Below are the user interests that are not referenced by any user account.\n";
echo "\t" . join("\n\t", $interests) . "\n";
break;
case '--remove':
- /** @var ControlledVocabEntryDAO */
- $vocabEntryDao = DAORegistry::getDAO('ControlledVocabEntryDAO');
- foreach ($orphans as $orphanVocab) {
- $vocabEntryDao->deleteObject($orphanVocab);
- }
- echo count($orphans) . " entries deleted\n";
+ echo $orphans->toQuery()->delete() . " entries deleted\n";
break;
default:
@@ -93,50 +86,17 @@ public function execute()
/**
* Returns user interests that are not referenced
- *
- * @return array array of ControlledVocabEntry object
*/
- protected function _getOrphanVocabInterests()
+ protected function _getOrphanVocabInterests(): Collection
{
- /** @var InterestDAO */
- $interestDao = DAORegistry::getDAO('InterestDAO');
- /** @var ControlledVocabDAO */
- $vocabDao = DAORegistry::getDAO('ControlledVocabDAO');
- /** @var ControlledVocabEntryDAO */
- $vocabEntryDao = DAORegistry::getDAO('ControlledVocabEntryDAO');
-
- $interestVocab = $vocabDao->getBySymbolic(InterestDAO::CONTROLLED_VOCAB_INTEREST);
- $vocabEntryIterator = $vocabEntryDao->getByControlledVocabId($interestVocab->getId());
- $vocabEntryList = $vocabEntryIterator->toArray();
-
- // list of vocab interests in db
- $allInterestVocabIds = array_map(
- function ($entry) {
- return $entry->getId();
- },
- $vocabEntryList
- );
-
- // list of vocabs associated to users
- $interests = $interestDao->getAllInterests();
- $userInterestVocabIds = array_map(
- function ($interest) {
- return $interest->getId();
- },
- $interests->toArray()
- );
-
- // get the difference
- $diff = array_diff($allInterestVocabIds, $userInterestVocabIds);
-
- $orphans = array_filter(
- $vocabEntryList,
- function ($entry) use ($diff) {
- return in_array($entry->getId(), $diff);
- }
+ $controlledVocab = Repo::controlledVocab()->build(
+ UserInterest::CONTROLLED_VOCAB_INTEREST
);
- return $orphans;
+ return ControlledVocabEntry::query()
+ ->withControlledVocabId($controlledVocab->id)
+ ->whereDoesntHave('userInterest')
+ ->get();
}
}