Skip to content

Commit 9aaeae2

Browse files
aromanovvCamelia-Orcidamontenegro
authored
Add verification date to email endpoint (ORCID#7104)
* Added the date verified when verifying an email address * fix domain modification date value * formatting * test verification date logic * update orcid model version * set up verification date in the endpoint * fix verification date endpoint logic * configure mapper to process verification dates * add verification assertions --------- Co-authored-by: Camelia Dumitru <c.dumitru@orcid.org> Co-authored-by: Angel Montenegro <a.montenegro@orcid.org>
1 parent 14d1885 commit 9aaeae2

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

orcid-core/src/main/java/org/orcid/core/adapter/v3/impl/MapperFacadeFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ public MapperFacade getEmailMapperFacade() {
500500
emailClassMap.field("primary", "primary");
501501
emailClassMap.field("verified", "verified");
502502
emailClassMap.fieldMap("visibility", "visibility").converter("visibilityConverter").add();
503+
emailClassMap.field("verificationDate.value", "dateVerified");
503504
addV3DateFields(emailClassMap);
504505
registerSourceConverters(mapperFactory, emailClassMap);
505506
emailClassMap.register();

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class Email implements ErrorsInterface {
3232

3333
private Date lastModified;
3434

35+
private Date verificationDate;
36+
3537
private List<String> errors = new ArrayList<String>();
3638

3739
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) {
7678
lastModifiedDate.setDay(String.valueOf(e.getLastModifiedDate().getValue().getDay()));
7779
email.setLastModified(lastModifiedDate);
7880
}
81+
82+
if (e.getVerificationDate() != null) {
83+
Date verificationDate = new Date();
84+
verificationDate.setYear(String.valueOf(e.getVerificationDate().getValue().getYear()));
85+
verificationDate.setMonth(String.valueOf(e.getVerificationDate().getValue().getMonth()));
86+
verificationDate.setDay(String.valueOf(e.getVerificationDate().getValue().getDay()));
87+
email.setVerificationDate(verificationDate);
88+
}
7989
}
8090
return email;
8191
}
@@ -187,6 +197,14 @@ public void setLastModified(Date lastModified) {
187197
this.lastModified = lastModified;
188198
}
189199

200+
public Date getVerificationDate() {
201+
return verificationDate;
202+
}
203+
204+
public void setVerificationDate(Date verificationDate) {
205+
this.verificationDate = verificationDate;
206+
}
207+
190208
public List<String> getErrors() {
191209
return errors;
192210
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static Emails valueOf(org.orcid.jaxb.model.v3.release.record.Emails e, Li
3333

3434
public org.orcid.jaxb.model.v3.release.record.Emails toV3Emails() {
3535
org.orcid.jaxb.model.v3.release.record.Emails v3Emails = new org.orcid.jaxb.model.v3.release.record.Emails();
36-
if(emails != null && !emails.isEmpty()) {
36+
if (emails != null && !emails.isEmpty()) {
3737
for(Email email : emails) {
3838
v3Emails.getEmails().add(email.toV3Email());
3939
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static ProfileEmailDomain valueOf(ProfileEmailDomainEntity ed) {
2626
Date createdDate = new Date();
2727
LocalDate date = ed.getDateCreated().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
2828
createdDate.setYear(String.valueOf(date.getYear()));
29-
createdDate.setMonth(String.valueOf(date.getMonth()));
29+
createdDate.setMonth(String.valueOf(date.getMonthValue()));
3030
createdDate.setDay(String.valueOf(date.getDayOfMonth()));
3131
createdDate.setTimestamp(ed.getDateCreated().toInstant().toEpochMilli());
3232
emailDomain.setCreatedDate(createdDate);
@@ -36,10 +36,11 @@ public static ProfileEmailDomain valueOf(ProfileEmailDomainEntity ed) {
3636
Date lastModifiedDate = new Date();
3737
LocalDate date = ed.getLastModified().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
3838
lastModifiedDate.setYear(String.valueOf(date.getYear()));
39-
lastModifiedDate.setMonth(String.valueOf(date.getMonth()));
39+
lastModifiedDate.setMonth(String.valueOf(date.getMonthValue()));
4040
lastModifiedDate.setDay(String.valueOf(date.getDayOfMonth()));
4141
emailDomain.setLastModified(lastModifiedDate);
4242
}
43+
4344
}
4445
return emailDomain;
4546
}

orcid-core/src/test/java/org/orcid/core/adapter/v3/JpaJaxbEmailAdapterTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public void testEmailToEmailEntity() throws JAXBException {
101101
assertNotNull(entity);
102102
assertNull(entity.getDateCreated());
103103
assertNull(entity.getLastModified());
104+
assertNull(entity.getDateVerified());
104105
assertEquals("user1@email.com", entity.getEmail());
105106
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC.name(), entity.getVisibility());
106107

@@ -119,6 +120,8 @@ public void testEmailEntityToEmail() throws IllegalAccessException {
119120
assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(email.getCreatedDate().getValue()));
120121
assertNotNull(email.getLastModifiedDate());
121122
assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(email.getLastModifiedDate().getValue()));
123+
assertNotNull(email.getVerificationDate());
124+
assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(email.getVerificationDate().getValue()));
122125
assertEquals("email@test.orcid.org", email.getEmail());
123126
assertEquals(Visibility.PRIVATE, email.getVisibility());
124127

@@ -159,6 +162,7 @@ private EmailEntity getEmailEntity() throws IllegalAccessException {
159162
Date date = DateUtils.convertToDate("2015-06-05T10:15:20");
160163
EmailEntity result = new EmailEntity();
161164
DateFieldsOnBaseEntityUtils.setDateFields(result, date);
165+
result.setDateVerified(date);
162166
result.setEmail("email@test.orcid.org");
163167
result.setCurrent(true);
164168
result.setPrimary(true);

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ the software.
918918
<dependency>
919919
<groupId>org.orcid</groupId>
920920
<artifactId>orcid-model</artifactId>
921-
<version>3.3.1</version>
921+
<version>3.3.2</version>
922922
</dependency>
923923
<dependency>
924924
<groupId>org.orcid</groupId>

0 commit comments

Comments
 (0)