Skip to content

Commit

Permalink
pkp/pkp-lib#10292 removed extended vocab classes
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Dec 21, 2024
1 parent 8d5d78b commit 30e1914
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 34 deletions.
10 changes: 9 additions & 1 deletion classes/search/ArticleSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use APP\core\Request;
use APP\facades\Repo;
use APP\issue\IssueAction;
use PKP\controlledVocab\ControlledVocab;
use PKP\db\DAORegistry;
use PKP\facades\Locale;
use PKP\plugins\Hook;
Expand Down Expand Up @@ -334,7 +335,14 @@ public function getSimilarityTerms($submissionId)
$article = Repo::submission()->get($submissionId);
if ($article->getData('status') === PKPSubmission::STATUS_PUBLISHED) {
// Retrieve keywords (if any).
$allSearchTerms = array_filter(SubmissionKeywordVocab::getKeywords($article->getCurrentPublication()->getId(), [Locale::getLocale(), $article->getData('locale'), Locale::getPrimaryLocale()]));
$allSearchTerms = array_filter(
Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
Application::ASSOC_TYPE_PUBLICATION,
$article->getCurrentPublication()->getId(),
[Locale::getLocale(), $article->getData('locale'), Locale::getPrimaryLocale()]
)
);
foreach ($allSearchTerms as $locale => $localeSearchTerms) {
$searchTerms += $localeSearchTerms;
}
Expand Down
10 changes: 8 additions & 2 deletions plugins/importexport/doaj/filter/DOAJJsonFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
use APP\facades\Repo;
use APP\plugins\importexport\doaj\DOAJExportDeployment;
use APP\plugins\importexport\doaj\DOAJExportPlugin;
use PKP\controlledVocab\ControlledVocab;
use PKP\core\PKPString;
use PKP\plugins\importexport\PKPImportExportFilter;
use PKP\submission\SubmissionKeywordVocab;

class DOAJJsonFilter extends PKPImportExportFilter
{
Expand Down Expand Up @@ -175,7 +175,13 @@ public function &process(&$pubObject)
$article['bibjson']['abstract'] = PKPString::html2text($abstract);
}
// Keywords
$keywords = SubmissionKeywordVocab::getKeywords($publication->getId(), [$publicationLocale]);
$keywords = Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
Application::ASSOC_TYPE_PUBLICATION,
$publication->getId(),
[$publicationLocale]
);

$allowedNoOfKeywords = array_slice($keywords[$publicationLocale] ?? [], 0, 6);
if (!empty($keywords[$publicationLocale])) {
$article['bibjson']['keywords'] = $allowedNoOfKeywords;
Expand Down
9 changes: 7 additions & 2 deletions plugins/importexport/doaj/filter/DOAJXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
use APP\plugins\importexport\doaj\DOAJExportPlugin;
use APP\publication\Publication;
use APP\submission\Submission;
use PKP\controlledVocab\ControlledVocab;
use PKP\core\PKPString;
use PKP\i18n\LocaleConversion;
use PKP\submission\SubmissionKeywordVocab;

class DOAJXmlFilter extends \PKP\plugins\importexport\native\filter\NativeExportFilter
{
Expand Down Expand Up @@ -191,7 +191,12 @@ public function &process(&$pubObjects)

// Keywords
$supportedLocales = $context->getSupportedFormLocales();
$articleKeywords = SubmissionKeywordVocab::getKeywords($publication->getId(), $supportedLocales);
$articleKeywords = Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
Application::ASSOC_TYPE_PUBLICATION,
$publication->getId(),
$supportedLocales
);

if (array_key_exists($publication->getData('locale'), $articleKeywords)) {
$keywordsInArticleLocale = $articleKeywords[$publication->getData('locale')];
Expand Down
17 changes: 13 additions & 4 deletions plugins/metadata/dc11/filter/Dc11SchemaArticleAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
use APP\oai\ojs\OAIDAO;
use APP\plugins\PubIdPlugin;
use APP\submission\Submission;
use PKP\controlledVocab\ControlledVocab;
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\facades\Locale;
use PKP\metadata\MetadataDataObjectAdapter;
use PKP\metadata\MetadataDescription;
use PKP\plugins\Hook;
use PKP\plugins\PluginRegistry;
use PKP\submission\SubmissionKeywordVocab;
use PKP\submission\SubmissionSubjectVocab;

class Dc11SchemaArticleAdapter extends MetadataDataObjectAdapter
{
Expand Down Expand Up @@ -92,8 +91,18 @@ public function &extractMetadataFromDataObject(&$article)
// Subject
$supportedLocales = $journal->getSupportedFormLocales();
$subjects = array_merge_recursive(
SubmissionKeywordVocab::getKeywords($publication->getId(), $supportedLocales),
SubmissionSubjectVocab::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);

Expand Down
28 changes: 15 additions & 13 deletions plugins/oaiMetadataFormats/rfc1807/OAIMetadataFormat_RFC1807.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@

use APP\core\Application;
use APP\issue\Issue;
use APP\issue\IssueAction;
use APP\journal\Journal;
use APP\publication\Publication;
use APP\section\Section;
use APP\submission\Submission;
use PKP\db\DAORegistry;
use APP\facades\Repo;
use APP\issue\IssueAction;
use PKP\controlledVocab\ControlledVocab;
use PKP\oai\OAIMetadataFormat;
use PKP\oai\OAIUtils;
use PKP\submission\SubmissionKeywordVocab;
use PKP\submission\SubmissionSubjectVocab;

class OAIMetadataFormat_RFC1807 extends OAIMetadataFormat
{
Expand Down Expand Up @@ -79,15 +77,19 @@ public function toXml($record, $format = null)

$supportedLocales = $journal->getSupportedFormLocales();

/** @var SubmissionKeywordDAO $submissionKeywordDao */
$submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO');

/** @var SubmissionSubjectDAO $submissionSubjectDao */
$submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO');

$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,
$article->getCurrentPublication()->getId(),
$supportedLocales
)
);
$subject = $subjects[$journal->getPrimaryLocale()] ?? '';

Expand Down
37 changes: 25 additions & 12 deletions plugins/reports/articles/ArticleReportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@

namespace APP\plugins\reports\articles;

use APP\core\Application;
use APP\decision\Decision;
use APP\facades\Repo;
use PKP\controlledVocab\ControlledVocab;
use PKP\facades\Locale;
use PKP\plugins\ReportPlugin;
use PKP\security\Role;
use PKP\stageAssignment\StageAssignment;
use PKP\submission\PKPSubmission;
use PKP\submission\SubmissionAgencyVocab;
use PKP\submission\SubmissionDisciplineDAO;
use PKP\submission\SubmissionKeywordDAO;
use PKP\submission\SubmissionSubjectDAO;
use PKP\userGroup\UserGroup;

class ArticleReportPlugin extends ReportPlugin
Expand Down Expand Up @@ -85,10 +83,6 @@ public function display($args, $request)
// Add BOM (byte order mark) to fix UTF-8 in Excel
fprintf($fp, chr(0xEF) . chr(0xBB) . chr(0xBF));

$submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO'); /** @var SubmissionKeywordDAO $submissionKeywordDao */
$submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO'); /** @var SubmissionSubjectDAO $submissionSubjectDao */
$submissionDisciplineDao = DAORegistry::getDAO('SubmissionDisciplineDAO'); /** @var SubmissionDisciplineDAO $submissionDisciplineDao */

$userGroups = UserGroup::withContextIds([$context->getId()])
->get()
->all();
Expand Down Expand Up @@ -157,10 +151,29 @@ public function display($args, $request)
$sectionTitles[$sectionId] = $section->getLocalizedTitle();
}

$subjects = SubmissionSubjectVocab::getSubjects($submission->getCurrentPublication()->getId());
$disciplines = SubmissionDisciplineVocab::getDisciplines($submission->getCurrentPublication()->getId());
$keywords = SubmissionKeywordVocab::getKeywords($submission->getCurrentPublication()->getId());
$agencies = SubmissionAgencyVocab::getAgencies($submission->getCurrentPublication()->getId());
$subjects = Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_SUBJECT,
Application::ASSOC_TYPE_PUBLICATION,
$submission->getCurrentPublication()->getId()
);

$disciplines = Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE,
Application::ASSOC_TYPE_PUBLICATION,
$submission->getCurrentPublication()->getId()
);

$keywords = Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD,
Application::ASSOC_TYPE_PUBLICATION,
$submission->getCurrentPublication()->getId()
);

$agencies = Repo::controlledVocab()->getBySymbolic(
ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_AGENCY,
Application::ASSOC_TYPE_PUBLICATION,
$submission->getCurrentPublication()->getId()
);

// Store the submission results
$results[] = [
Expand Down

0 comments on commit 30e1914

Please sign in to comment.