From 177e0b451ab0ed0e09607a8f746d7f9edef59b45 Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:18:22 +0200 Subject: [PATCH 1/3] add verification date cutoff to summary responses --- .../manager/impl/SummaryManagerImpl.java | 15 ++++++++-- .../orcid/core/constants/EmailConstants.java | 29 ++++++++++++++++++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/orcid-core/src/main/java/org/orcid/core/common/manager/impl/SummaryManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/common/manager/impl/SummaryManagerImpl.java index c815b9e24bf..bf087814070 100644 --- a/orcid-core/src/main/java/org/orcid/core/common/manager/impl/SummaryManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/common/manager/impl/SummaryManagerImpl.java @@ -73,6 +73,8 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import static org.orcid.core.constants.EmailConstants.VERIFICATION_DATE_CUTOFF; + public class SummaryManagerImpl implements SummaryManager { @Resource(name = "recordNameManagerReadOnlyV3") private RecordNameManagerReadOnly recordNameManagerReadOnly; @@ -282,7 +284,9 @@ public RecordSummaryPojo getRecordSummaryPojo(String orcid) { for (EmailDomain ed : recordSummary.getEmailDomains().getEmailDomains()) { EmailDomainSummary eds = new EmailDomainSummary(); eds.setValue(ed.getValue()); - eds.setVerificationDate(ed.getVerificationDate().toString()); + if (ed.getVerificationDate() != null && ed.getVerificationDate().after(VERIFICATION_DATE_CUTOFF)) { + eds.setVerificationDate(ed.getVerificationDate().toString()); + } emailDomains.add(eds); } } @@ -521,7 +525,10 @@ public void generateEmailDomainsSummary(RecordSummary recordSummary, String orci for (ProfileEmailDomainEntity ped : emailDomains) { ed = new EmailDomain(); ed.setValue(ped.getEmailDomain()); - ed.setVerificationDate( new VerificationDate(DateUtils.convertToXMLGregorianCalendar(ped.getDateCreated()))); + VerificationDate verificationDate = new VerificationDate(DateUtils.convertToXMLGregorianCalendar(ped.getDateCreated())); + if (verificationDate.after(VERIFICATION_DATE_CUTOFF)) { + ed.setVerificationDate(verificationDate); + } edList.add(ed); } } @@ -529,7 +536,9 @@ public void generateEmailDomainsSummary(RecordSummary recordSummary, String orci edList.stream().limit(3).forEach(t -> { EmailDomain ed = new EmailDomain(); ed.setValue(t.getValue()); - ed.setVerificationDate(t.getVerificationDate()); + if (t.getVerificationDate() != null) { + ed.setVerificationDate(t.getVerificationDate()); + } emailDomainsTop3.add(ed); }); diff --git a/orcid-core/src/main/java/org/orcid/core/constants/EmailConstants.java b/orcid-core/src/main/java/org/orcid/core/constants/EmailConstants.java index b7e4f673930..269e7523d1c 100644 --- a/orcid-core/src/main/java/org/orcid/core/constants/EmailConstants.java +++ b/orcid-core/src/main/java/org/orcid/core/constants/EmailConstants.java @@ -1,12 +1,18 @@ package org.orcid.core.constants; +import org.orcid.jaxb.model.v3.release.common.VerificationDate; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; + public class EmailConstants { public static final String WILDCARD_VERIFICATION_URL = "${verification_url}"; /* * session attribute that is used to see if we should check and notify the - * user if their primary email ins't verified. + * user if their primary email isn't verified. */ public static String CHECK_EMAIL_VALIDATED = "CHECK_EMAIL_VALIDATED"; @@ -17,4 +23,25 @@ public class EmailConstants { public static final String DO_NOT_REPLY_NOTIFY_ORCID_ORG = "ORCID - Do not reply "; public static final String DO_NOT_REPLY_VERIFY_ORCID_ORG = "ORCID - Do not reply "; + + public static final VerificationDate VERIFICATION_DATE_CUTOFF; + + static { + XMLGregorianCalendar gregorianCutoffDate = null; + VerificationDate verificationDate = null; + + try { + gregorianCutoffDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(); + + gregorianCutoffDate.setYear(2024); + gregorianCutoffDate.setMonth(10); + gregorianCutoffDate.setDay(27); + + verificationDate = new VerificationDate(gregorianCutoffDate); + } catch (DatatypeConfigurationException e) { + throw new RuntimeException("Error initializing XMLGregorianCalendar", e); + } + + VERIFICATION_DATE_CUTOFF = verificationDate; + } } From 037e082ee8c282b4a40dfcf4564fc650632444a9 Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:32:13 +0200 Subject: [PATCH 2/3] update tests --- .../core/common/manager/SummaryManagerTest.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java b/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java index f6367c52d44..1c645a8b6ab 100644 --- a/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java @@ -562,7 +562,8 @@ public void getSummaryTest() { // Email domains assertEquals("2024-12-20", rs.getEmailDomains().getEmailDomains().get(0).getVerificationDate().toString()); - assertEquals(1, rs.getEmailDomains().getEmailDomains().size()); + assertEquals(null, rs.getEmailDomains().getEmailDomains().get(1).getVerificationDate()); + assertEquals(2, rs.getEmailDomains().getEmailDomains().size()); } /** @@ -595,11 +596,13 @@ public void getSummaryPojoTest() { assertEquals(4, rs.getPeerReviewPublicationGrants()); assertEquals(16, rs.getPeerReviewsTotal()); // Email domain - assertEquals(1, rs.getEmailDomains().size()); + assertEquals(2, rs.getEmailDomains().size()); assertEquals("2024-12-20", rs.getEmailDomains().get(0).getVerificationDate()); + assertEquals(null, rs.getEmailDomains().get(1).getVerificationDate()); + } - + private PersonExternalIdentifiers getPersonExternalIdentifiers() { PersonExternalIdentifiers peis = new PersonExternalIdentifiers(); PersonExternalIdentifier pei = new PersonExternalIdentifier(); @@ -623,6 +626,13 @@ private List getEmailDomains() { emailDomain.setOrcid(ORCID); emailDomain.setDateCreated(new Date(124, 11, 20)); emailDomains.add(emailDomain); + + ProfileEmailDomainEntity emailDomain2 = new ProfileEmailDomainEntity(); + emailDomain2.setEmailDomain(EMAIL_DOMAIN + "2"); + emailDomain2.setOrcid(ORCID); + emailDomain2.setDateCreated(new Date(124, 9, 20)); + emailDomains.add(emailDomain2); + return emailDomains; } From 268789fd850378bcf375348a451dd49205968dff Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Tue, 19 Nov 2024 23:45:32 +0200 Subject: [PATCH 3/3] test commit --- .../java/org/orcid/core/common/manager/SummaryManagerTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java b/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java index 1c645a8b6ab..2e477dcf308 100644 --- a/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java @@ -600,7 +600,6 @@ public void getSummaryPojoTest() { assertEquals("2024-12-20", rs.getEmailDomains().get(0).getVerificationDate()); assertEquals(null, rs.getEmailDomains().get(1).getVerificationDate()); - } private PersonExternalIdentifiers getPersonExternalIdentifiers() {