Skip to content

Commit 0f1106b

Browse files
authored
Merge pull request #6736 from ORCID/fix/8494-qa-put-requests-that-change-publication-year-month-or-day-not-working
fix: Add missing language code and citation type comparison
2 parents 614aad7 + f0b7c3c commit 0f1106b

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

orcid-core/src/main/java/org/orcid/pojo/ajaxForm/WorkForm.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,24 +1259,30 @@ public boolean compare(Object obj) {
12591259
if (citation == null && other.citation.getCitation() != null && StringUtils.isNotBlank(other.citation.getCitation().getValue())) {
12601260
return false;
12611261
}
1262-
} else if (citation.getCitation() != null && other.citation.getCitation() != null && !compareTexts(citation.getCitation(), other.citation.getCitation(), false))
1262+
} else if (
1263+
citation.getCitation() != null && other.citation.getCitation() != null && !compareTexts(citation.getCitation(), other.citation.getCitation(), false) ||
1264+
citation.getCitationType() != null && other.citation.getCitationType() != null && !compareTexts(citation.getCitationType(), other.citation.getCitationType(), false)
1265+
)
12631266
return false;
12641267
}
12651268
if (!isEachObjectNull(translatedTitle, other.translatedTitle)) {
12661269
if (isAnyObjectNotNull(translatedTitle, other.translatedTitle)) {
12671270
if (translatedTitle == null && StringUtils.isNotBlank(other.translatedTitle.getContent())) {
12681271
return false;
12691272
}
1270-
} else if (other.translatedTitle.getContent() != null && !translatedTitle.getContent().equals(other.translatedTitle.getContent()))
1273+
} else if (
1274+
other.translatedTitle.getContent() != null && !translatedTitle.getContent().equals(other.translatedTitle.getContent()) ||
1275+
other.translatedTitle.getLanguageCode() != null && !translatedTitle.getLanguageCode().equals(other.translatedTitle.getLanguageCode())
1276+
)
12711277
return false;
12721278
}
12731279
if (!isEachObjectNull(publicationDate, other.publicationDate)) {
12741280
if (isAnyObjectNotNull(publicationDate, other.publicationDate)) {
12751281
if (publicationDate == null && StringUtils.isNotBlank(other.publicationDate.getYear()))
12761282
return false;
12771283
} else if (
1278-
!compareStrings(publicationDate.getYear(), other.publicationDate.getYear()) &&
1279-
!compareStrings(publicationDate.getMonth(), other.publicationDate.getMonth()) &&
1284+
!compareStrings(publicationDate.getYear(), other.publicationDate.getYear()) ||
1285+
!compareStrings(publicationDate.getMonth(), other.publicationDate.getMonth()) ||
12801286
!compareStrings(publicationDate.getDay(), other.publicationDate.getDay())
12811287
)
12821288
return false;

orcid-core/src/test/java/org/orcid/core/manager/v3/WorkManagerTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,13 @@ public void testCompareWorksPublicationDate() {
18161816
Work workToUpdate = new Work();
18171817
fillWork(workToUpdate);
18181818
workToUpdate.setPutCode(work.getPutCode());
1819-
workToUpdate.setPublicationDate(new PublicationDate(new FuzzyDate(new Year(2023), new Month(3), new Day(3))));
1819+
workToUpdate.setPublicationDate(new PublicationDate(new FuzzyDate(new Year(2017), new Month(1), new Day(2))));
1820+
WorkTitle title = new WorkTitle();
1821+
title.setTitle(new Title("title"));
1822+
title.setSubtitle(new Subtitle("subtitle"));
1823+
title.setTranslatedTitle(new TranslatedTitle("titulo traducido", "es"));
1824+
workToUpdate.setWorkTitle(title);
1825+
workToUpdate.setWorkCitation(new Citation("citation", CitationType.FORMATTED_IEEE));
18201826
WorkForm workFormToUpdate = WorkForm.valueOf(workToUpdate, 50);
18211827

18221828
assertFalse(workSaved.compare(workFormToUpdate));

0 commit comments

Comments
 (0)