Skip to content

Add qualified Dublin Core record driver.#5053

Draft
EreMaijala wants to merge 7 commits intovufind-org:devfrom
EreMaijala:dev-qdc
Draft

Add qualified Dublin Core record driver.#5053
EreMaijala wants to merge 7 commits intovufind-org:devfrom
EreMaijala:dev-qdc

Conversation

@EreMaijala
Copy link
Contributor

This pull request adds support for "qdc" record format with the SolrQdc driver. As it is it doesn't do a whole lot, just allows one to see an abstract on the Description tab. But it introduces a couple of new things I'd like feedback on before any further progress:

  1. Dependency on finna-xml that we also use locally to make reading XML with namespaces less painful.
  2. Adds support for retrieving locale-specific information from records.

@EreMaijala EreMaijala changed the title Add initial support for qualified Dublin Core records. Add initial qualified Dublin Core record driver. Feb 4, 2026
@EreMaijala EreMaijala changed the title Add initial qualified Dublin Core record driver. Add qualified Dublin Core record driver. Feb 4, 2026
Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @EreMaijala! See below for a few suggestions.

Comment on lines 131 to 142
$userLocale = $this->localeSettings->getUserLocale();
[$userLanguage] = explode('-', $userLocale);
if (null !== ($results = $localeResults[$userLocale] ?? $localeResults[$userLanguage] ?? null)) {
return $results;
}
// Check for matching language in locale-specific results:
foreach ($localeResults as $locale => $results) {
[$lang] = explode('-', $locale);
if ($lang === $userLanguage) {
return $results;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to extract this logic to a support function (like getBestLocaleMatch($locale, $localeResults) so that you can reuse it inside the foreach loop on lines 145-150? Otherwise, the default/fallback logic is less flexible than the other logic, since it doesn't have the fuzzy language matching piece.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. done. Also decided to move them to a trait for reusability.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @EreMaijala, just one more thing!

Comment on lines 62 to 67
foreach ($localeResults as $locale => $results) {
[$lang] = explode('-', $locale);
if ($lang === $userLanguage) {
return $results;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my earlier comment, I was suggesting including this logic as part of the getBestLocaleMatch method, so it could be used in both scenarios. Is there a reason not to do that? Even if we only want to do it some of the time, maybe moving it there and adding a $fuzzyLanguageFallback switch would make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be done, If I now understood properly. :)

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @EreMaijala, see below for a couple more minor things...

}

// Check for matching language in locale-specific results:
[$language] = explode('-', $locale);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to calculate this twice.

Suggested change
[$language] = explode('-', $locale);

*/
protected function getLocaleSpecificResults(array $localeResults, array|string $allResults): array|string
{
if (null === $this->localeSettings) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this property is not defined by this trait, should we at least include a note in the header comment indicating that the trait expects the property (and recommending using it in combination with LocaleSettingsAwareTrait)?

If we're not expecting this scenario to ever happen, might it even be better to throw an exception if the dependency is missing? Otherwise, it may be hard to troubleshoot why things aren't working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants