Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#10292 Controlled Vocab DAO to Eloquent Model #10324

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5a726eb
pkp/pkp-lib#10292 Controlled Vocab DAO to Eloquent Model
touhidurabir Aug 16, 2024
017ace3
pkp/pkp-lib#10292 WIP: Controlled Vocab DAO to Eloquent Model
touhidurabir Aug 19, 2024
2900809
pkp/pkp-lib#10292 typo fixed
touhidurabir Aug 19, 2024
780f3a2
pkp/pkp-lib#10292 proper model import for native xml
touhidurabir Aug 20, 2024
8db7988
pkp/pkp-lib#10292 fixing unit tests
touhidurabir Aug 20, 2024
e54f0b0
pkp/pkp-lib#10292 Refactored user interest to model and repository
touhidurabir Aug 26, 2024
f54ff87
pkp/pkp-lib#10292 removed extended vocab classes
touhidurabir Aug 26, 2024
52c26cc
pkp/pkp-lib#10292 fixing issue with vocab storing and some doc blocks…
touhidurabir Aug 27, 2024
efbda26
pkp/pkp-lib#10292 added TODO to investigate the impact of merged issu…
touhidurabir Oct 3, 2024
e609b39
pkp/pkp-lib#10292 refactored entry dao to model class
touhidurabir Oct 7, 2024
a97e1bf
pkp/pkp-lib#10292 removed setting_type column
touhidurabir Oct 7, 2024
bbeedae
pkp/pkp-lib#10292 fixed vocab setting issue
touhidurabir Oct 8, 2024
5b4bbbd
pkp/pkp-lib#10292 refactored interest manager to repo and removed it
touhidurabir Oct 8, 2024
4dd5837
pkp/pkp-lib#10292 resolved all but one TODO
touhidurabir Oct 8, 2024
6724d7e
pkp/pkp-lib#10292 fixed issue the settings builder to retrieve specif…
touhidurabir Oct 18, 2024
29e0695
pkp/pkp-lib#10292 fixed issue when guarded attribute defined
touhidurabir Oct 21, 2024
acd9d45
pkp/pkp-lib#10292 updated implementation of updating with multilingua…
touhidurabir Oct 22, 2024
190cfdc
pkp/pkp-lib#10292 added multilingual casting as part of #10476
touhidurabir Oct 22, 2024
edcb7bd
pkp/pkp-lib#10292 fixed issue the data building with settings attrs
touhidurabir Oct 23, 2024
87e8807
pkp/pkp-lib#10292 updated setting builder to work with non schema bas…
touhidurabir Nov 16, 2024
4ba0abe
pkp/pkp-lib#10292 allow nullable locales to be passed to repo method …
touhidurabir Nov 16, 2024
31e9afc
pkp/pkp-lib#10292 updated to handle context based query
touhidurabir Nov 24, 2024
96b6fba
pkp/pkp-lib#10292 make context id required on controlled vocabs opera…
touhidurabir Nov 24, 2024
aeeb424
pkp/pkp-lib#10292 update mistaken test modification
touhidurabir Nov 24, 2024
10b6b06
pkp/pkp-lib#10292 sub query update for locale and setting value search
touhidurabir Nov 24, 2024
5649196
pkp/pkp-lib#10292 revert back context id direct addition to vocabs
touhidurabir Nov 29, 2024
0c9f069
pkp/pkp-lib#10292 fixing symbolics and settings name mixing confusion
touhidurabir Dec 17, 2024
8a8ad77
pkp/pkp-lib#10292 fixed issue with user interest and multilingual dat…
touhidurabir Dec 18, 2024
fb469a3
pkp/pkp-lib#10292 controlled vocabs assoc id nullable
touhidurabir Dec 20, 2024
9414859
pkp/pkp-lib#10292 migrated controlled vocabs setting name from symbol…
touhidurabir Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 25 additions & 27 deletions api/v1/vocabs/PKPVocabController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Route;
use PKP\controlledVocab\ControlledVocab;
use PKP\controlledVocab\ControlledVocabEntry;
use PKP\controlledVocab\ControlledVocabEntryMatch;
use PKP\core\PKPBaseController;
use PKP\core\PKPRequest;
use PKP\db\DAORegistry;
use PKP\facades\Locale;
use PKP\plugins\Hook;
use PKP\security\authorization\ContextAccessPolicy;
use PKP\security\authorization\UserRolesRequiredPolicy;
use PKP\security\Role;
use PKP\submission\SubmissionAgencyDAO;
use PKP\submission\SubmissionDisciplineDAO;
use PKP\submission\SubmissionKeywordDAO;
use PKP\submission\SubmissionSubjectDAO;

class PKPVocabController extends PKPBaseController
{
Expand Down Expand Up @@ -105,39 +103,39 @@ public function getMany(Request $illuminateRequest): JsonResponse
$vocab = $requestParams['vocab'] ?? '';
$locale = $requestParams['locale'] ?? Locale::getLocale();
$term = $requestParams['term'] ?? null;
$locales = array_merge($context->getSupportedSubmissionMetadataLocales(), isset($requestParams['submissionId']) ? Repo::submission()->get((int) $requestParams['submissionId'])?->getPublicationLanguages() ?? [] : []);
$locales = array_merge(
$context->getSupportedSubmissionMetadataLocales(),
isset($requestParams['submissionId'])
? (Repo::submission()->get((int) $requestParams['submissionId'])?->getPublicationLanguages() ?? [])
: []
);

if (!in_array($locale, $locales)) {
return response()->json([
'error' => __('api.vocabs.400.localeNotSupported', ['locale' => $locale]),
], Response::HTTP_BAD_REQUEST);
}

switch ($vocab) {
case SubmissionKeywordDAO::CONTROLLED_VOCAB_SUBMISSION_KEYWORD:
$submissionKeywordEntryDao = DAORegistry::getDAO('SubmissionKeywordEntryDAO'); /** @var \PKP\submission\SubmissionKeywordEntryDAO $submissionKeywordEntryDao */
$entries = $submissionKeywordEntryDao->getByContextId($vocab, $context->getId(), $locale, $term)->toArray();
break;
case SubmissionSubjectDAO::CONTROLLED_VOCAB_SUBMISSION_SUBJECT:
$submissionSubjectEntryDao = DAORegistry::getDAO('SubmissionSubjectEntryDAO'); /** @var \PKP\submission\SubmissionSubjectEntryDAO $submissionSubjectEntryDao */
$entries = $submissionSubjectEntryDao->getByContextId($vocab, $context->getId(), $locale, $term)->toArray();
break;
case SubmissionDisciplineDAO::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE:
$submissionDisciplineEntryDao = DAORegistry::getDAO('SubmissionDisciplineEntryDAO'); /** @var \PKP\submission\SubmissionDisciplineEntryDAO $submissionDisciplineEntryDao */
$entries = $submissionDisciplineEntryDao->getByContextId($vocab, $context->getId(), $locale, $term)->toArray();
break;
case SubmissionAgencyDAO::CONTROLLED_VOCAB_SUBMISSION_AGENCY:
$submissionAgencyEntryDao = DAORegistry::getDAO('SubmissionAgencyEntryDAO'); /** @var \PKP\submission\SubmissionAgencyEntryDAO $submissionAgencyEntryDao */
$entries = $submissionAgencyEntryDao->getByContextId($vocab, $context->getId(), $locale, $term)->toArray();
break;
default:
$entries = [];
Hook::call('API::vocabs::getMany', [$vocab, &$entries, $illuminateRequest, response(), $request]);
if (in_array($vocab, ControlledVocab::getDefinedVocabSymbolic())) {
$entries = ControlledVocabEntry::query()
->whereHas(
'controlledVocab',
fn ($query) => $query->withSymbolics([$vocab])->withContextId($context->getId())
)
->withLocales([$locale])
->when(
$term,
fn ($query) => $query->withSetting($vocab, $term, ControlledVocabEntryMatch::PARTIAL)
)
->get();
} else {
$entries = [];
Hook::call('API::vocabs::getMany', [$vocab, &$entries, $illuminateRequest, response(), $request]);
}

$data = [];
foreach ($entries as $entry) {
$data[] = $entry->getData($vocab, $locale);
$data[] = $entry->getLocalizedData('name', $locale);
}

$data = array_values(array_unique($data));
Expand Down
4 changes: 2 additions & 2 deletions classes/components/forms/publication/Details.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use APP\publication\Publication;
use PKP\components\forms\FieldControlledVocab;
use PKP\context\Context;
use PKP\submission\SubmissionKeywordDAO;
use PKP\controlledVocab\ControlledVocab;

class Details extends TitleAbstractForm
{
Expand Down Expand Up @@ -46,7 +46,7 @@ public function __construct(
'label' => __('common.keywords'),
'description' => __('manager.setup.metadata.keywords.description'),
'isMultilingual' => true,
'apiUrl' => str_replace('__vocab__', SubmissionKeywordDAO::CONTROLLED_VOCAB_SUBMISSION_KEYWORD, $suggestionUrlBase),
'apiUrl' => str_replace('__vocab__', ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD, $suggestionUrlBase),
'locales' => $this->locales,
'value' => (array) $publication->getData('keywords'),
'isRequired' => $context->getData('keywords') === Context::METADATA_REQUIRE ? true : false,
Expand Down
13 changes: 5 additions & 8 deletions classes/components/forms/publication/PKPMetadataForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@
namespace PKP\components\forms\publication;

use APP\publication\Publication;
use PKP\controlledVocab\ControlledVocab;
use PKP\components\forms\FieldControlledVocab;
use PKP\components\forms\FieldRichTextarea;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
use PKP\context\Context;
use PKP\submission\SubmissionAgencyDAO;
use PKP\submission\SubmissionDisciplineDAO;
use PKP\submission\SubmissionKeywordDAO;
use PKP\submission\SubmissionSubjectDAO;

class PKPMetadataForm extends FormComponent
{
Expand Down Expand Up @@ -55,7 +52,7 @@ public function __construct(string $action, array $locales, Publication $publica
'label' => __('common.keywords'),
'tooltip' => __('manager.setup.metadata.keywords.description'),
'isMultilingual' => true,
'apiUrl' => str_replace('__vocab__', SubmissionKeywordDAO::CONTROLLED_VOCAB_SUBMISSION_KEYWORD, $suggestionUrlBase),
'apiUrl' => str_replace('__vocab__', ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_KEYWORD, $suggestionUrlBase),
'locales' => $this->locales,
'value' => (array) $publication->getData('keywords'),
]));
Expand All @@ -66,7 +63,7 @@ public function __construct(string $action, array $locales, Publication $publica
'label' => __('common.subjects'),
'tooltip' => __('manager.setup.metadata.subjects.description'),
'isMultilingual' => true,
'apiUrl' => str_replace('__vocab__', SubmissionSubjectDAO::CONTROLLED_VOCAB_SUBMISSION_SUBJECT, $suggestionUrlBase),
'apiUrl' => str_replace('__vocab__', ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_SUBJECT, $suggestionUrlBase),
'locales' => $this->locales,
'value' => (array) $publication->getData('subjects'),
]));
Expand All @@ -77,7 +74,7 @@ public function __construct(string $action, array $locales, Publication $publica
'label' => __('search.discipline'),
'tooltip' => __('manager.setup.metadata.disciplines.description'),
'isMultilingual' => true,
'apiUrl' => str_replace('__vocab__', SubmissionDisciplineDAO::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE, $suggestionUrlBase),
'apiUrl' => str_replace('__vocab__', ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_DISCIPLINE, $suggestionUrlBase),
'locales' => $this->locales,
'value' => (array) $publication->getData('disciplines'),
]));
Expand All @@ -88,7 +85,7 @@ public function __construct(string $action, array $locales, Publication $publica
'label' => __('submission.supportingAgencies'),
'tooltip' => __('manager.setup.metadata.agencies.description'),
'isMultilingual' => true,
'apiUrl' => str_replace('__vocab__', SubmissionAgencyDAO::CONTROLLED_VOCAB_SUBMISSION_AGENCY, $suggestionUrlBase),
'apiUrl' => str_replace('__vocab__', ControlledVocab::CONTROLLED_VOCAB_SUBMISSION_AGENCY, $suggestionUrlBase),
'locales' => $this->locales,
'value' => (array) $publication->getData('supportingAgencies'),
]));
Expand Down
Loading