Skip to content

Commit

Permalink
Email domains fixes for summary endpoint (#7089)
Browse files Browse the repository at this point in the history
* Email domains fixes for summary endpoint

* Fixes for summary unit test for marshalling

---------

Co-authored-by: Angel Montenegro <a.montenegro@orcid.org>
  • Loading branch information
Camelia-Orcid and amontenegro authored Sep 23, 2024
1 parent 5c6fc01 commit 4912303
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@
import org.orcid.pojo.summary.ExternalIdentifiersSummary;
import org.orcid.pojo.summary.RecordSummaryPojo;
import org.orcid.utils.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;

public class SummaryManagerImpl implements SummaryManager {

@Resource(name = "recordNameManagerReadOnlyV3")
private RecordNameManagerReadOnly recordNameManagerReadOnly;

Expand Down Expand Up @@ -285,8 +286,7 @@ public RecordSummaryPojo getRecordSummaryPojo(String orcid) {
for (EmailDomain ed : recordSummary.getEmailDomains().getEmailDomains()) {
EmailDomainSummary eds = new EmailDomainSummary();
eds.setValue(ed.getValue());
eds.setCreatedDate(ed.getCreatedDate().toFuzzyDate().toString());
eds.setLastModified(ed.getLastModified().toFuzzyDate().toString());
emailDomains.add(eds);
}
}
pojo.setEmailDomains(emailDomains);
Expand Down Expand Up @@ -520,7 +520,6 @@ public void generateEmailDomainsSummary(RecordSummary recordSummary, String orci
emailDomains = profileEmailDomainManagerReadOnly.getPublicEmailDomains(orcid);
List<EmailDomain> edList = new ArrayList<EmailDomain>();
if (emailDomains != null && !emailDomains.isEmpty()) {

EmailDomain ed = null;
for (ProfileEmailDomainEntity ped : emailDomains) {
ed = new EmailDomain();
Expand All @@ -530,7 +529,6 @@ public void generateEmailDomainsSummary(RecordSummary recordSummary, String orci
edList.add(ed);
}
}

List<EmailDomain> emailDomainsTop3 = new ArrayList<EmailDomain>();
edList.stream().limit(3).forEach(t -> {
EmailDomain ed = new EmailDomain();
Expand All @@ -544,7 +542,9 @@ public void generateEmailDomainsSummary(RecordSummary recordSummary, String orci
eds.setCount(edList.size());
if (!emailDomainsTop3.isEmpty()) {
eds.setEmailDomains(emailDomainsTop3);

}

recordSummary.setEmailDomains(eds);
}
}
Expand Down
11 changes: 7 additions & 4 deletions orcid-core/src/main/java/org/orcid/core/model/EmailDomain.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import org.orcid.jaxb.model.v3.release.common.FuzzyDate;
Expand All @@ -14,9 +15,9 @@
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")
@XmlType(propOrder = { "value", "createdDate","lastModified"})
@XmlRootElement(name = "email-domain", namespace = "http://www.orcid.org/ns/summary")
@Schema(description = "Email Domain")
public class EmailDomain {
@XmlElement(name = "value", namespace = "http://www.orcid.org/ns/summary")
protected String value;
Expand All @@ -32,7 +33,8 @@ public String getValue() {
public void setValue(String value) {
this.value = value;
}


@XmlTransient
public Date getCreatedDate() {
return createdDate;
}
Expand All @@ -41,6 +43,7 @@ public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}

@XmlTransient
public Date getLastModified() {
return lastModified;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

public class EmailDomainSummary {
private String value;
private String createdDate;
private String lastModified;

public String getValue() {
return value;
Expand All @@ -16,22 +14,6 @@ public void setValue(String value) {
this.value = value;
}

public String getCreatedDate() {
return createdDate;
}

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

public String getLastModified() {
return lastModified;
}

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


public static EmailDomainSummary valueOf(ProfileEmailDomainEntity pem) {
EmailDomainSummary form = new EmailDomainSummary();
Expand All @@ -40,14 +22,6 @@ public static EmailDomainSummary valueOf(ProfileEmailDomainEntity pem) {
if(!PojoUtil.isEmpty(pem.getEmailDomain())) {
form.setValue(pem.getEmailDomain());
}

if (pem.getDateCreated() != null) {
form.setCreatedDate(org.orcid.pojo.ajaxForm.Date.valueOf(pem.getDateCreated()).toFuzzyDate().toString());
}

if (pem.getLastModified() !=null) {
form.setLastModified(org.orcid.pojo.ajaxForm.Date.valueOf(pem.getLastModified()).toFuzzyDate().toString());
}
}
return form;
}
Expand Down

0 comments on commit 4912303

Please sign in to comment.