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 to email endpoint #7104

Merged
merged 12 commits into from
Oct 15, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ public MapperFacade getEmailMapperFacade() {
emailClassMap.field("primary", "primary");
emailClassMap.field("verified", "verified");
emailClassMap.fieldMap("visibility", "visibility").converter("visibilityConverter").add();
emailClassMap.field("verificationDate.value", "dateVerified");
addV3DateFields(emailClassMap);
registerSourceConverters(mapperFactory, emailClassMap);
emailClassMap.register();
Expand Down
18 changes: 18 additions & 0 deletions orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class Email implements ErrorsInterface {

private Date lastModified;

private Date verificationDate;

private List<String> errors = new ArrayList<String>();

public static Email valueOf(org.orcid.jaxb.model.v3.release.record.Email e) {
Expand Down Expand Up @@ -76,6 +78,14 @@ public static Email valueOf(org.orcid.jaxb.model.v3.release.record.Email e) {
lastModifiedDate.setDay(String.valueOf(e.getLastModifiedDate().getValue().getDay()));
email.setLastModified(lastModifiedDate);
}

if (e.getVerificationDate() != null) {
Date verificationDate = new Date();
verificationDate.setYear(String.valueOf(e.getVerificationDate().getValue().getYear()));
verificationDate.setMonth(String.valueOf(e.getVerificationDate().getValue().getMonth()));
verificationDate.setDay(String.valueOf(e.getVerificationDate().getValue().getDay()));
email.setVerificationDate(verificationDate);
}
}
return email;
}
Expand Down Expand Up @@ -187,6 +197,14 @@ public void setLastModified(Date lastModified) {
this.lastModified = lastModified;
}

public Date getVerificationDate() {
return verificationDate;
}

public void setVerificationDate(Date verificationDate) {
this.verificationDate = verificationDate;
}

public List<String> getErrors() {
return errors;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static Emails valueOf(org.orcid.jaxb.model.v3.release.record.Emails e, Li

public org.orcid.jaxb.model.v3.release.record.Emails toV3Emails() {
org.orcid.jaxb.model.v3.release.record.Emails v3Emails = new org.orcid.jaxb.model.v3.release.record.Emails();
if(emails != null && !emails.isEmpty()) {
if (emails != null && !emails.isEmpty()) {
for(Email email : emails) {
v3Emails.getEmails().add(email.toV3Email());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static ProfileEmailDomain valueOf(ProfileEmailDomainEntity ed) {
Date createdDate = new Date();
LocalDate date = ed.getDateCreated().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
createdDate.setYear(String.valueOf(date.getYear()));
createdDate.setMonth(String.valueOf(date.getMonth()));
createdDate.setMonth(String.valueOf(date.getMonthValue()));
createdDate.setDay(String.valueOf(date.getDayOfMonth()));
createdDate.setTimestamp(ed.getDateCreated().toInstant().toEpochMilli());
emailDomain.setCreatedDate(createdDate);
Expand All @@ -36,10 +36,11 @@ public static ProfileEmailDomain valueOf(ProfileEmailDomainEntity ed) {
Date lastModifiedDate = new Date();
LocalDate date = ed.getLastModified().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
lastModifiedDate.setYear(String.valueOf(date.getYear()));
lastModifiedDate.setMonth(String.valueOf(date.getMonth()));
lastModifiedDate.setMonth(String.valueOf(date.getMonthValue()));
lastModifiedDate.setDay(String.valueOf(date.getDayOfMonth()));
emailDomain.setLastModified(lastModifiedDate);
}

}
return emailDomain;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public void testEmailToEmailEntity() throws JAXBException {
assertNotNull(entity);
assertNull(entity.getDateCreated());
assertNull(entity.getLastModified());
assertNull(entity.getDateVerified());
assertEquals("[email protected]", entity.getEmail());
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC.name(), entity.getVisibility());

Expand All @@ -119,6 +120,8 @@ public void testEmailEntityToEmail() throws IllegalAccessException {
assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(email.getCreatedDate().getValue()));
assertNotNull(email.getLastModifiedDate());
assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(email.getLastModifiedDate().getValue()));
assertNotNull(email.getVerificationDate());
assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(email.getVerificationDate().getValue()));
assertEquals("[email protected]", email.getEmail());
assertEquals(Visibility.PRIVATE, email.getVisibility());

Expand Down Expand Up @@ -159,6 +162,7 @@ private EmailEntity getEmailEntity() throws IllegalAccessException {
Date date = DateUtils.convertToDate("2015-06-05T10:15:20");
EmailEntity result = new EmailEntity();
DateFieldsOnBaseEntityUtils.setDateFields(result, date);
result.setDateVerified(date);
result.setEmail("[email protected]");
result.setCurrent(true);
result.setPrimary(true);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ the software.
<dependency>
<groupId>org.orcid</groupId>
<artifactId>orcid-model</artifactId>
<version>3.3.1</version>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>org.orcid</groupId>
Expand Down
Loading