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.
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.
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.
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.
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.
Please use two spaces for indentation.
| legalEntityService = MCRConfiguration2.getInstanceOfOrThrow( | ||
| MCRLegalEntityService.class, MCRORCIDConstants.CONFIG_PREFIX + "LegalEntityService.Class"); |
There was a problem hiding this comment.
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.
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.
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; |
| import org.mycore.orcid2.exception.MCRORCIDException; | ||
| import org.mycore.orcid2.oauth.MCRORCIDOAuthClient; | ||
| import org.mycore.orcid2.util.MCRIdentifier; | ||
| import org.mycore.datamodel.legalentity.MCRIdentifier; |
| @BeforeEach | ||
| public void prepare() throws NoSuchFieldException, IllegalAccessException { | ||
| userMock = new MCRUser("junit"); | ||
| MCRLegalEntityServiceMock legalEntityServiceMock = new MCRLegalEntityServiceMock(); |
There was a problem hiding this comment.
I'm pretty sure I tried that and failed, but will look into it again..
There was a problem hiding this comment.
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; |
Link to jira.
This PR: #2733, but renamed branch and Jira Ticket