Skip to content

Commit bb4e101

Browse files
Added the date verified when verifying an email address (ORCID#7101)
Co-authored-by: Angel Montenegro <a.montenegro@orcid.org>
1 parent 3b7017c commit bb4e101

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

orcid-persistence/src/main/java/org/orcid/persistence/dao/impl/EmailDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void addSourceToEmail(String sourceId, String email) {
123123
@Transactional
124124
@UpdateProfileLastModified
125125
public boolean verifyEmail(String email) {
126-
Query query = entityManager.createNativeQuery("update email set is_verified = true, is_current=true, last_modified=now() where trim(lower(email)) = trim(lower(:email))");
126+
Query query = entityManager.createNativeQuery("update email set is_verified = true, is_current=true, last_modified=now(), date_verified=now() where trim(lower(email)) = trim(lower(:email))");
127127
query.setParameter("email", email);
128128
return query.executeUpdate() > 0;
129129
}

orcid-persistence/src/main/java/org/orcid/persistence/jpa/entities/EmailEntity.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.Collection;
44
import java.util.HashMap;
55
import java.util.Map;
6+
import java.util.Date;
67

78
import javax.persistence.Column;
89
import javax.persistence.Entity;
@@ -24,7 +25,8 @@ public class EmailEntity extends SourceAwareEntity<String> implements OrcidAware
2425
private Boolean primary;
2526
private Boolean current;
2627
private Boolean verified;
27-
private String visibility;
28+
private String visibility;
29+
private Date dateVerified;
2830

2931
@Override
3032
@Id
@@ -90,6 +92,15 @@ public String getVisibility() {
9092
public void setVisibility(String visibility) {
9193
this.visibility = visibility;
9294
}
95+
96+
@Column(name = "date_verified")
97+
public Date getDateVerified() {
98+
return dateVerified;
99+
}
100+
101+
public void setDateVerified(Date dateVerified) {
102+
this.dateVerified = dateVerified;
103+
}
93104

94105
public static Map<String, EmailEntity> mapByLowerCaseEmail(Collection<EmailEntity> emailEntities) {
95106
Map<String, EmailEntity> map = new HashMap<>();
@@ -109,5 +120,6 @@ public void clean() {
109120
visibility= null;
110121
verified = null;
111122
visibility = null;
123+
dateVerified = null;
112124
}
113125
}

orcid-persistence/src/main/resources/db-master.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,4 +404,5 @@
404404
<include file="/db/updates/create_dw_notification.xml" />
405405
<include file="/db/updates/create_dw_profile_email_domain.xml" />
406406
<include file="/db/updates/add_unique_constraint_external_id_disambiguated_org.xml" />
407+
<include file="/db/updates/add_date_verified_to_email.xml" />
407408
</databaseChangeLog>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<databaseChangeLog
2+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
5+
6+
<changeSet author="Camelia Dumitru"
7+
id="ADD-DATE-VERIFIED-COLUMN-TO-EMAIL-TABLE">
8+
<addColumn tableName="email">
9+
<column name="date_verified" type="Timestamp">
10+
<constraints nullable="true" />
11+
</column>
12+
</addColumn>
13+
</changeSet>
14+
</databaseChangeLog>

0 commit comments

Comments
 (0)