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

Multiple author affiliations #10460

Open
wants to merge 110 commits into
base: main
Choose a base branch
from

Conversation

GaziYucel
Copy link
Contributor

@GaziYucel GaziYucel commented Sep 20, 2024

GaziYucel and others added 30 commits September 20, 2024 14:33
@GaziYucel
Copy link
Contributor Author

GaziYucel commented Oct 29, 2024

Hi,

Some notes.

  • I have made some assumptions regarding business logic in several places. The ones I am uncertain about are the import/export classes:

    • plugins/importexport/native/filter/NativeXmlPKPAuthorFilter.php
    • plugins/importexport/native/filter/PKPAuthorNativeXmlFilter.php
  • During an upgrade from an earlier version, the ROR cache is filled during the upgrade. After this a migration is done for all affiliations currently saved for the authors. First a match is searched for all ROR on an exact match for the names. After this all remaining is migrated as a non-ROR affiliation.

  • There is an issue regarding the ROR data. Most affiliations have a name in one language, sometimes 2 -3 languages. Not all have a name in English. This is an issue regarding searching for a name in the backend.
    For now I look for an alternate name and show this if an English name is not there, with at the end the language. For example: "Technische Universiteit Delft [Dutch]".

  • The class in "classes/task/UpdateRorRegistryDataset.php" is responsible for updating the ROR cache. There are a lot of records without a language code. These are marked with "no_lang_code". I replace these with the locale code 'en'.

  • And a question regarding the class PKP\API\v1\submissions\PKPSubmissionController.
    If you look at the method getContributor, you see this at the end of this method.

    return response()->json(
    Repo::author()->getSchemaMap()->map($author),
    Response::HTTP_OK
    );
    

    I expected that the method "getSchemaMap()->map($author), also transforms "affiliations" to it's schema. But this is not happening, only author is mapped. Affiliations stays as in PHP, with "_data" and other keys still in it.

    I defined in the schema of author (schema/author.json) the following:

    "affiliations": {
    "type": "array",
    "description": "The scholarly institution this contributor is employed by or affiliated with.",
    "apiSummary": true,
    "readOnly": true,
    "items": {
        "type": "object",
        "$ref": "#/definitions/Affiliation"
    }
    },
    

    This is what I came up with, but this feels as a hack.

    $mappedAffiliations = [];
    foreach ($author->getAffiliations() as $key => $affiliation) {
    $mappedAffiliations[] = Repo::affiliations()->getSchemaMap()->map($affiliation);
    }
    
    $author->setAffiliations(new LazyCollection($mappedAffiliations));
    

    How should I do this to make affiliations also transform/map to it's schema?

@GaziYucel GaziYucel marked this pull request as ready for review October 29, 2024 09:21
@GaziYucel
Copy link
Contributor Author

Hi @bozana. This PR is ready for review. Thanks.

@bozana
Copy link
Collaborator

bozana commented Oct 31, 2024

Hi @GaziYucel, I am still reviewing the code and would also like to test it locally (also to understand some things better) but I wanted to already suggest something regarding the native import/export:
I think we could introduce the additional element rorAffiliation for the author, that could occur several times and that would contain the element ror and localized element name.
The existing localized element affiliation could be used for the authors affiliations without ROR.
The examples how multiple affiliations and an affiliated institution with its identifier are represented in JATS can be found here: https://jats.nlm.nih.gov/archiving/tag-library/1.3/element/aff.html

@bozana
Copy link
Collaborator

bozana commented Oct 31, 2024

Hi @GaziYucel,
and maybe regarding your last question above -- "And a question regarding the class PKP\API\v1\submissions\PKPSubmissionController" -- regarding the mapping of affiliations to the author: I think you could take a look how this is solved for issues and articles, e.g. here https://github.com/pkp/ojs/blob/main/classes/issue/maps/Schema.php#L111. I think something like this could work for this case as well.

@bozana
Copy link
Collaborator

bozana commented Nov 1, 2024

Hi @GaziYucel,
And regarding the replacing no_lang_code with en: I think we cannot do it -- this way the original en entry can be overridden. We just cannot map no_lang_code to anything correctly. We would need to leave it as is.

Copy link
Collaborator

@bozana bozana left a comment

Choose a reason for hiding this comment

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

Hi @GaziYucel, I left some comments.
Because we decided not to copy ROR names to author_affiliation_settings table some things will change here, so I can take a look once that is done...
About a few things I would maybe also need to think a little bit more, but I left a comment -- maybe you would immediately have an idea...
And because I have not taken a look at the OJS PR yet i.e. I would need some time to see how such affiliations need to be exported into different formats, I will probably first then know what Affiliation::getLocalized... function are needed...
So I am already submitting this comments so that you can eventually already integrate some of them when working on the new version without copying...
I am wondering if we should keep this code version in case Alec has good arguments that we should proceed with copying -- because he has not said anything yet... although I do not think it will be the case...
Thanks a lot for this great work!

api/v1/rors/PKPRorController.php Outdated Show resolved Hide resolved
classes/ror/DAO.php Outdated Show resolved Hide resolved
classes/ror/DAO.php Outdated Show resolved Hide resolved
api/v1/rors/PKPRorController.php Show resolved Hide resolved
classes/affiliation/Affiliation.php Outdated Show resolved Hide resolved
classes/author/DAO.php Outdated Show resolved Hide resolved
classes/author/Author.php Show resolved Hide resolved
*
* @return void
*/
public function setAffiliationsFromString(string $affiliationName, string $locale): void
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function will maybe not be needed when we implement the native import/export with separate elements for each author affiliation

classes/ror/Repository.php Outdated Show resolved Hide resolved
classes/ror/Ror.php Outdated Show resolved Hide resolved
classes/author/Author.php Outdated Show resolved Hide resolved
@GaziYucel
Copy link
Contributor Author

GaziYucel commented Nov 12, 2024

Hi @bozana
I implemented validation for affiliations in this commit:

I had to remove Repo::affiliation()->saveAffiliations(..) from Repo::author()->dao->insert(..) and Repo::author()->dao->update(...) for this. I added Repo::affiliation()->saveAffiliations(..) to classes where the insert and update are called. Otherwise I can't check if an author exists.

To wrap up, I have done all your notes of your review. What's left now is the no-copy of ror names.

I will make a copy of this branch in my fork, to have a backup. After the copy, I will implement the no-copy in the current branch/PR.

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.

4 participants