Skip to content

Conversation

@erodde
Copy link
Contributor

@erodde erodde commented Dec 12, 2025

Link to jira.
This PR: #2733, but renamed branch and Jira Ticket

*/

package org.mycore.orcid2.util;
package org.mycore.datamodel.legalentity;
Copy link
Member

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.

Comment on lines 36 to 44
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);
Copy link
Member

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 {
Copy link
Member

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>
Copy link
Member

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>
Copy link
Member

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.

Comment on lines +85 to +86
legalEntityService = MCRConfiguration2.getInstanceOfOrThrow(
MCRLegalEntityService.class, MCRORCIDConstants.CONFIG_PREFIX + "LegalEntityService.Class");
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 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.

Copy link
Contributor Author

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?

Copy link
Member

@golsch golsch Dec 22, 2025

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;
Copy link
Member

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;
Copy link
Member

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();
Copy link
Member

Choose a reason for hiding this comment

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

Why not use mockito?

Copy link
Contributor Author

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..

Copy link
Contributor Author

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;
Copy link
Member

Choose a reason for hiding this comment

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

Package order

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.

3 participants