Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add verification date cutoff to summary responses #7141

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -521,15 +525,20 @@ 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);
}
}
List<EmailDomain> emailDomainsTop3 = new ArrayList<EmailDomain>();
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);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -17,4 +23,25 @@ public class EmailConstants {
public static final String DO_NOT_REPLY_NOTIFY_ORCID_ORG = "ORCID - Do not reply <[email protected]>";

public static final String DO_NOT_REPLY_VERIFY_ORCID_ORG = "ORCID - Do not reply <[email protected]>";

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -595,11 +596,12 @@ 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();
Expand All @@ -623,6 +625,13 @@ private List<ProfileEmailDomainEntity> 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;
}

Expand Down