diff --git a/orcid-core/src/main/java/org/orcid/core/cli/anonymize/AnonymizeText.java b/orcid-core/src/main/java/org/orcid/core/cli/anonymize/AnonymizeText.java index 59816904dda..ea28eb8ed9f 100644 --- a/orcid-core/src/main/java/org/orcid/core/cli/anonymize/AnonymizeText.java +++ b/orcid-core/src/main/java/org/orcid/core/cli/anonymize/AnonymizeText.java @@ -107,7 +107,11 @@ public ExternalID anonymizeWorkExternalIdentifier(JSONObject original) throws Ma ExternalID wExtId = new ExternalID(); if (extIdKey != null) { if (extIdsAnonymized.get(extIdKey) != null) { - return extIdsAnonymized.get(extIdKey); + wExtId = extIdsAnonymized.get(extIdKey); + if (original.has(KEY_RELATIONSHIP)) { + wExtId.setRelationship(Relationship.valueOf(original.getString(KEY_RELATIONSHIP))); + } + return wExtId; } } if (workIdentifierType != null) { @@ -154,7 +158,11 @@ public ExternalID anonymizeWorkExternalIdentifier(ExternalID original) throws Ma ExternalID wExtId = new ExternalID(); if (extIdKey != null) { if (extIdsAnonymized.get(extIdKey) != null) { - return extIdsAnonymized.get(extIdKey); + wExtId = extIdsAnonymized.get(extIdKey); + if (original.getRelationship() != null) { + wExtId.setRelationship(original.getRelationship()); + } + return wExtId; } }