Skip to content

Commit

Permalink
Merge branch 'main' into 9357-unexpected-name-data-in-the-org-typeahead
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro authored Sep 17, 2024
2 parents 3daaf6d + 85443c5 commit 8da4df0
Show file tree
Hide file tree
Showing 15 changed files with 807 additions and 106 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v2.65.2 - 2024-09-17

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.65.1...v2.65.2)

## v2.65.1 - 2024-09-17

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.65.0...v2.65.1)

## v2.65.0 - 2024-09-13

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.64.6...v2.65.0)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package org.orcid.core.manager.v3.impl;


import org.orcid.core.manager.ProfileEntityCacheManager;
import org.orcid.core.manager.v3.ProfileEmailDomainManager;
import org.orcid.core.manager.v3.read_only.impl.ProfileEmailDomainManagerReadOnlyImpl;
import org.orcid.jaxb.model.v3.release.common.Visibility;
import org.orcid.persistence.dao.EmailDao;
import org.orcid.persistence.dao.EmailDomainDao;
import org.orcid.persistence.dao.ProfileDao;
import org.orcid.persistence.dao.ProfileEmailDomainDao;
import org.orcid.persistence.jpa.entities.EmailDomainEntity;
import org.orcid.persistence.jpa.entities.EmailEntity;
import org.orcid.persistence.jpa.entities.ProfileEmailDomainEntity;
import org.orcid.persistence.jpa.entities.ProfileEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -34,7 +37,8 @@ public class ProfileEmailDomainManagerImpl extends ProfileEmailDomainManagerRead
@Resource(name = "emailDaoReadOnly")
protected EmailDao emailDaoReadOnly;

private static final String DEFAULT_DOMAIN_VISIBILITY = Visibility.PRIVATE.toString().toUpperCase();
@Resource
private ProfileEntityCacheManager profileEntityCacheManager;

@Transactional
public void updateEmailDomains(String orcid, org.orcid.pojo.ajaxForm.Emails newEmails) {
Expand Down Expand Up @@ -71,47 +75,16 @@ public void updateEmailDomains(String orcid, org.orcid.pojo.ajaxForm.Emails newE
public void processDomain(String orcid, String email) {
String domain = email.split("@")[1];
EmailDomainEntity domainInfo = emailDomainDao.findByEmailDomain(domain);
String domainVisibility = DEFAULT_DOMAIN_VISIBILITY;
// Check if email is professional
if (domainInfo != null && domainInfo.getCategory().equals(EmailDomainEntity.DomainCategory.PROFESSIONAL)) {
ProfileEmailDomainEntity existingDomain = profileEmailDomainDao.findByEmailDomain(orcid, domain);
// ADD NEW DOMAIN IF ONE DOESN'T EXIST
if (existingDomain == null) {
// Verify the user doesn't have more emails with that domain
List<EmailEntity> existingEmails = emailDaoReadOnly.findByOrcid(orcid, System.currentTimeMillis());
if(existingEmails != null && existingEmails.size() > 1) {
for(EmailEntity emailEntity : existingEmails) {
//If it is not the same emails that is being verified and it is verified
if(!email.equals(emailEntity.getEmail()) && emailEntity.getVerified()) {
try {
String emailEntityDomain = (emailEntity.getEmail() == null) ? null : (email.split("@")[1]);
// If one of the existing emails have the same domain as the email being verified check the visibility and select the less restrictive
if(domain.equals(emailEntityDomain)){
String entityVisibility = emailEntity.getVisibility();
domainVisibility = getLessRestrictiveVisibility(domainVisibility, entityVisibility);
}
} catch (Exception e) {
LOGGER.warn("Could not get email domain from email entity " + emailEntity.getEmail(), e);
}
}
}
}
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
String domainVisibility = profile.getActivitiesVisibilityDefault();
profileEmailDomainDao.addEmailDomain(orcid, domain, domainVisibility);
}
}
}

private String getLessRestrictiveVisibility(String a, String b) {
String visibility = DEFAULT_DOMAIN_VISIBILITY;
if(Visibility.PUBLIC.name().equals(a) || Visibility.PUBLIC.name().equals(b)) {
visibility = Visibility.PUBLIC.name();
} else if(a.equals(b)) {
visibility = a;
} else if(Visibility.PRIVATE.name().equals(a)) {
visibility = b;
} else if(Visibility.PRIVATE.name().equals(b)) {
visibility = a;
}
return visibility;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package org.orcid.core.model;

import java.util.Objects;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.orcid.jaxb.model.v3.release.common.FuzzyDate;

import io.swagger.v3.oas.annotations.media.Schema;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "putCode", "type", "organizationName", "role", "url", "startDate", "endDate", "validated" })
@XmlRootElement(name = "education-qualification", namespace = "http://www.orcid.org/ns/summary")
@Schema(description = "Education Qualification")
public class EducationQualification {
@XmlElement(name = "put-code", namespace = "http://www.orcid.org/ns/summary")
protected Long putCode;
@XmlElement(name = "start-date", namespace = "http://www.orcid.org/ns/common")
protected FuzzyDate startDate;
@XmlElement(name = "end-date", namespace = "http://www.orcid.org/ns/common")
protected FuzzyDate endDate;
@XmlElement(name = "type", namespace = "http://www.orcid.org/ns/summary")
protected String type;
@XmlElement(name = "organization-name", namespace = "http://www.orcid.org/ns/summary")
protected String organizationName;
@XmlElement(name = "role", namespace = "http://www.orcid.org/ns/summary")
protected String role;
@XmlElement(name = "url", namespace = "http://www.orcid.org/ns/summary")
protected String url;
@XmlElement(name = "validated", namespace = "http://www.orcid.org/ns/summary")
protected boolean validated;

public Long getPutCode() {
return putCode;
}

public void setPutCode(Long putCode) {
this.putCode = putCode;
}

public FuzzyDate getStartDate() {
return startDate;
}

public void setStartDate(FuzzyDate startDate) {
this.startDate = startDate;
}

public FuzzyDate getEndDate() {
return endDate;
}

public void setEndDate(FuzzyDate endDate) {
this.endDate = endDate;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getOrganizationName() {
return organizationName;
}

public void setOrganizationName(String organizationName) {
this.organizationName = organizationName;
}

public String getRole() {
return role;
}

public void setRole(String role) {
this.role = role;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public boolean isValidated() {
return validated;
}

public void setValidated(boolean validated) {
this.validated = validated;
}

@Override
public int hashCode() {
return Objects.hash(endDate, organizationName, putCode, role, startDate, type, url, validated);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EducationQualification other = (EducationQualification) obj;
return Objects.equals(endDate, other.endDate) && Objects.equals(organizationName, other.organizationName) && Objects.equals(putCode, other.putCode)
&& Objects.equals(role, other.role) && Objects.equals(startDate, other.startDate) && Objects.equals(type, other.type) && Objects.equals(url, other.url)
&& validated == other.validated;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.orcid.core.model;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import io.swagger.v3.oas.annotations.media.Schema;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "count", "educationQualifications" })
@XmlRootElement(name = "education-qualifications", namespace = "http://www.orcid.org/ns/summary")
@Schema(description = "Education qualifications list")
public class EducationQualifications implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlElement(name = "count", namespace = "http://www.orcid.org/ns/summary")
private Integer count;
@XmlElement(name = "education-qualification", namespace = "http://www.orcid.org/ns/summary")
private List<EducationQualification> educationQualifications;

public Integer getCount() {
return count;
}

public void setCount(Integer count) {
this.count = count;
}

public List<EducationQualification> getEducationQualifications() {
return educationQualifications;
}

public void setEducationQualifications(List<EducationQualification> educationQualifications ) {
this.educationQualifications = educationQualifications ;
}

@Override
public int hashCode() {
return Objects.hash(count, educationQualifications);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EducationQualifications other = (EducationQualifications) obj;
return Objects.equals(count, other.count) && Objects.equals(educationQualifications, other.educationQualifications);
}

}
68 changes: 68 additions & 0 deletions orcid-core/src/main/java/org/orcid/core/model/EmailDomain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.orcid.core.model;

import java.util.Objects;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.orcid.jaxb.model.v3.release.common.FuzzyDate;
import org.orcid.pojo.ajaxForm.Date;

import io.swagger.v3.oas.annotations.media.Schema;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "value","createdDate", "lastModified"})
@XmlRootElement(name = "education-qualification", namespace = "http://www.orcid.org/ns/summary")
@Schema(description = "Education Qualification")
public class EmailDomain {
@XmlElement(name = "value", namespace = "http://www.orcid.org/ns/summary")
protected String value;
@XmlElement(name = "created-date", namespace = "http://www.orcid.org/ns/common")
protected Date createdDate;
@XmlElement(name = "last-modified-date", namespace = "http://www.orcid.org/ns/common")
protected Date lastModified;

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public Date getCreatedDate() {
return createdDate;
}

public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}

public Date getLastModified() {
return lastModified;
}

public void setLastModified(Date lastModified) {
this.lastModified = lastModified;
}

@Override
public int hashCode() {
return Objects.hash(value, createdDate, lastModified);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EmailDomain other = (EmailDomain) obj;
return Objects.equals(createdDate, other.createdDate) && Objects.equals(lastModified, other.lastModified) && Objects.equals(value, other.value);
}
}
Loading

0 comments on commit 8da4df0

Please sign in to comment.