diff --git a/orcid-core/src/main/java/org/orcid/core/adapter/v3/impl/MapperFacadeFactory.java b/orcid-core/src/main/java/org/orcid/core/adapter/v3/impl/MapperFacadeFactory.java index f0c2c2f28b9..0e0cb01658b 100644 --- a/orcid-core/src/main/java/org/orcid/core/adapter/v3/impl/MapperFacadeFactory.java +++ b/orcid-core/src/main/java/org/orcid/core/adapter/v3/impl/MapperFacadeFactory.java @@ -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(); diff --git a/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Email.java b/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Email.java index 7b65d9f3190..930174b27bf 100644 --- a/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Email.java +++ b/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Email.java @@ -32,6 +32,8 @@ public class Email implements ErrorsInterface { private Date lastModified; + private Date verificationDate; + private List errors = new ArrayList(); public static Email valueOf(org.orcid.jaxb.model.v3.release.record.Email e) { @@ -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; } @@ -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 getErrors() { return errors; } diff --git a/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Emails.java b/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Emails.java index 1ea3ad73889..3d808766fc9 100644 --- a/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Emails.java +++ b/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Emails.java @@ -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()); } diff --git a/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/ProfileEmailDomain.java b/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/ProfileEmailDomain.java index 3ac0d064246..422442a130e 100644 --- a/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/ProfileEmailDomain.java +++ b/orcid-core/src/main/java/org/orcid/pojo/ajaxForm/ProfileEmailDomain.java @@ -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); @@ -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; } diff --git a/orcid-core/src/test/java/org/orcid/core/adapter/v3/JpaJaxbEmailAdapterTest.java b/orcid-core/src/test/java/org/orcid/core/adapter/v3/JpaJaxbEmailAdapterTest.java index 6fb86a0a529..65a70e2e6ac 100644 --- a/orcid-core/src/test/java/org/orcid/core/adapter/v3/JpaJaxbEmailAdapterTest.java +++ b/orcid-core/src/test/java/org/orcid/core/adapter/v3/JpaJaxbEmailAdapterTest.java @@ -101,6 +101,7 @@ public void testEmailToEmailEntity() throws JAXBException { assertNotNull(entity); assertNull(entity.getDateCreated()); assertNull(entity.getLastModified()); + assertNull(entity.getDateVerified()); assertEquals("user1@email.com", entity.getEmail()); assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC.name(), entity.getVisibility()); @@ -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@test.orcid.org", email.getEmail()); assertEquals(Visibility.PRIVATE, email.getVisibility()); @@ -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@test.orcid.org"); result.setCurrent(true); result.setPrimary(true); diff --git a/pom.xml b/pom.xml index 102707e2b93..c6024f0e181 100644 --- a/pom.xml +++ b/pom.xml @@ -918,7 +918,7 @@ the software. org.orcid orcid-model - 3.3.1 + 3.3.2 org.orcid