-
Notifications
You must be signed in to change notification settings - Fork 13
MCR-3578 Changes modsperson attribute handling #2773
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
base: main
Are you sure you want to change the base?
MCR-3578 Changes modsperson attribute handling #2773
Conversation
| */ | ||
|
|
||
| package org.mycore.orcid2.util; | ||
| package org.mycore.datamodel.legalentity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether we’re "allowed" to just move this like that. I would first copy the class and then deprecate the class.
| Set<MCRIdentifier> getAllIdentifiers(MCRIdentifier identifier); | ||
|
|
||
| /** | ||
| * Gets a legal entity's identifiers of a given type. The legal entity is determined by a specific identifier. | ||
| * @param primaryIdentifier unique identifier of legal entity, not null | ||
| * @param identifierType the type of looked up identifiers as a string, not null | ||
| * @return a set of identifiers a legal entity owns | ||
| */ | ||
| Set<MCRIdentifier> getTypedIdentifiers(MCRIdentifier primaryIdentifier, String identifierType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: I would not call the methods "get" but rather findAllIdentifiers / findAllIdentifiersByType or lookupAllIdentifiers / lookupAllIdentifiersByType...
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public class MCRUser2MODSPersonIdentifierService implements MCRLegalEntityService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the name confusing. Maybe just MCRMODSPersonIdentifierService?
| @@ -0,0 +1,20 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <mycoreobject xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="datamodel-modsperson.xsd" ID="junit_modsperson_00000001"> | |||
| <metadata> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use two spaces for indentation.
| @@ -0,0 +1,17 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <mycoreobject xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="datamodel-modsperson.xsd" ID="junit_modsperson_00000002"> | |||
| <metadata> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use two spaces for indentation.
| legalEntityService = MCRConfiguration2.getInstanceOfOrThrow( | ||
| MCRLegalEntityService.class, MCRORCIDConstants.CONFIG_PREFIX + "LegalEntityService.Class"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it perhaps make more sense to have a centralized service? Something like a DefaultLegalEntityService where you can configure the default service? There are certainly other places where this service is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current implementation, each class makes its own decision which LegalEntityService to use through a configuration string. The MCROrcidUser uses the class configured in MCR.ORCID2.LegalEntityService.Class. Would you propose to have one centralized configuration for all classes that want to use a LegalEntityService? Or should all configurations be managed in that DefaultLegalEntityService? Or would that DefaultService be a fallback to a specific, configurable Service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, this would prevent the "wrong" service from being called. In addition, the service is independent of the MCRORCIDUser and does not need to be loaded in the constructor every time. I would expect something like a DefaultLegalEntityService that manages the corresponding implementation.
| import org.mycore.orcid2.client.MCRORCIDCredential; | ||
| import org.mycore.orcid2.exception.MCRORCIDException; | ||
| import org.mycore.orcid2.util.MCRIdentifier; | ||
| import org.mycore.datamodel.legalentity.MCRIdentifier; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix package ordner.
| import org.mycore.orcid2.exception.MCRORCIDException; | ||
| import org.mycore.orcid2.oauth.MCRORCIDOAuthClient; | ||
| import org.mycore.orcid2.util.MCRIdentifier; | ||
| import org.mycore.datamodel.legalentity.MCRIdentifier; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix package order
| @BeforeEach | ||
| public void prepare() throws NoSuchFieldException, IllegalAccessException { | ||
| userMock = new MCRUser("junit"); | ||
| MCRLegalEntityServiceMock legalEntityServiceMock = new MCRLegalEntityServiceMock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use mockito?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure I tried that and failed, but will look into it again..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I mocked the service using mockito.
| import org.mycore.orcid2.user.MCRORCIDUser; | ||
| import org.mycore.orcid2.user.MCRORCIDUserUtils; | ||
| import org.mycore.orcid2.util.MCRIdentifier; | ||
| import org.mycore.datamodel.legalentity.MCRIdentifier; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package order
Link to jira.
This PR: #2733, but renamed branch and Jira Ticket