Skip to content

Commit

Permalink
Working on unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Apr 25, 2024
1 parent ac0c523 commit 423cb84
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.Map;

import javax.annotation.Resource;
import javax.xml.datatype.XMLGregorianCalendar;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
Expand Down Expand Up @@ -196,13 +195,13 @@ public RecordSummaryPojo getRecordSummaryPojo(String orcid) {
List<AffiliationSummary> professionalActivities = new ArrayList<>();
for(ProfessionalActivity pa : recordSummary.getProfessionalActivities().getProfessionalActivities()) {
AffiliationSummary as = new AffiliationSummary();
as.setEndDate();
as.setOrganizationName();
as.setPutCode();
as.setRole();
as.setStartDate();
as.setType();
as.setUrl();
as.setEndDate(pa.getEndDate() == null ? null : pa.getEndDate().toString());
as.setStartDate(pa.getStartDate() == null ? null : pa.getStartDate().toString());
as.setOrganizationName(pa.getOrganizationName());
as.setPutCode(pa.getPutCode());
as.setRole(pa.getRole());
as.setType(pa.getType());
as.setUrl(pa.getUrl());
as.setValidated(pa.isValidated());
professionalActivities.add(as);
}
Expand All @@ -212,15 +211,23 @@ public RecordSummaryPojo getRecordSummaryPojo(String orcid) {
}


pojo.setSelfAssertedFunds();
pojo.setValidatedFunds();
if(recordSummary.getFundings() != null) {
pojo.setSelfAssertedFunds(recordSummary.getFundings().getSelfAssertedCount());
pojo.setValidatedFunds(recordSummary.getFundings().getValidatdeCount());
}

pojo.setPeerReviewsTotal();
pojo.setPeerReviewPublicationGrants();
pojo.setSelfAssertedPeerReviews();
if(recordSummary.getPeerReviews() != null) {
pojo.setPeerReviewsTotal(recordSummary.getPeerReviews().getTotal());
pojo.setPeerReviewPublicationGrants(recordSummary.getPeerReviews().getPeerReviewPublicationGrants());
pojo.setSelfAssertedPeerReviews(recordSummary.getPeerReviews().getSelfAssertedCount());
}

pojo.setSelfAssertedWorks();
pojo.setValidatedWorks();
if(recordSummary.getWorks() != null) {
pojo.setSelfAssertedWorks(recordSummary.getWorks().getSelfAssertedCount());
pojo.setValidatedWorks(recordSummary.getWorks().getValidatdeCount());
}

return pojo;
}

public void generateAffiliationsSummary(RecordSummary recordSummary, String orcid) {
Expand All @@ -245,14 +252,19 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci
e.setStartDate(t.getStartDate());
e.setOrganizationName((t.getOrganization() == null || StringUtils.isBlank(t.getOrganization().getName())) ? null : t.getOrganization().getName());
e.setPutCode(t.getPutCode());
e.setRole(t.getRoleTitle());
e.setUrl((t.getUrl() == null || StringUtils.isBlank(t.getUrl().getValue())) ? null : t.getUrl().getValue());
e.setValidated(!SourceUtils.isSelfAsserted(t.getSource(), orcid));
employmentsTop3.add(e);
});
});

Employments e = new Employments();
e.setCount(preferredEmployments.size());
e.setEmployments(employmentsTop3);
recordSummary.setEmployments(e);

if(!employmentsTop3.isEmpty()) {
e.setEmployments(employmentsTop3);
}

// PROFESIONAL ACTIVITIES
List<AffiliationGroup<org.orcid.jaxb.model.v3.release.record.summary.AffiliationSummary>> profesionalActivitesGroups = new ArrayList<>();
if (affiliationsMap.containsKey(AffiliationType.DISTINCTION)) {
Expand Down Expand Up @@ -281,7 +293,7 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci
p.setPutCode(t.getPutCode());
p.setStartDate(t.getStartDate());
p.setEndDate(t.getEndDate());
p.setRole(p.getRole());
p.setRole(t.getRoleTitle());
if(t instanceof DistinctionSummary) {
p.setType(AffiliationType.DISTINCTION.name());
} else if (t instanceof InvitedPositionSummary) {
Expand All @@ -297,7 +309,9 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci
});
ProfessionalActivities pa = new ProfessionalActivities();
pa.setCount(preferredProfesionalActivities.size());
pa.setProfessionalActivities(professionalActivitiesTop3);
if(!professionalActivitiesTop3.isEmpty()) {
pa.setProfessionalActivities(professionalActivitiesTop3);
}
}

public void generateExternalIdentifiersSummary(RecordSummary recordSummary, String orcid) {
Expand All @@ -306,13 +320,15 @@ public void generateExternalIdentifiersSummary(RecordSummary recordSummary, Stri
return;
}
ExternalIdentifiers eis = new ExternalIdentifiers();
eis.setExternalIdentifiers(new ArrayList<>());
for(PersonExternalIdentifier pei : personExternalIdentifiers.getExternalIdentifiers()) {
ExternalIdentifier ei = new ExternalIdentifier();
ei.setExternalIdType(pei.getType());
ei.setExternalIdUrl((pei.getUrl() == null || StringUtils.isEmpty(pei.getUrl().getValue())) ? null : pei.getUrl().getValue());
ei.setExternalIdValue(pei.getValue());
ei.setPutCode(pei.getPutCode());
ei.setValidated(!SourceUtils.isSelfAsserted(pei.getSource(), orcid));
eis.getExternalIdentifiers().add(ei);
}
recordSummary.setExternalIdentifiers(eis);
}
Expand Down
67 changes: 6 additions & 61 deletions orcid-core/src/main/java/org/orcid/core/model/Employment.java
Original file line number Diff line number Diff line change
@@ -1,77 +1,22 @@
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.XmlTransient;
import javax.xml.bind.annotation.XmlType;

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

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

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "putCode", "endDate", "organizationName", "validated" })
@XmlRootElement(name = "employment", namespace = "http://www.orcid.org/ns/summary")
@Schema(description = "Employment")
public class Employment {
@XmlElement(name = "put-code", namespace = "http://www.orcid.org/ns/summary")
private Long putCode;
@XmlElement(name = "start-date", namespace = "http://www.orcid.org/ns/common")
private FuzzyDate startDate;
@XmlElement(name = "end-date", namespace = "http://www.orcid.org/ns/common")
private FuzzyDate endDate;
@XmlElement(name = "organization-name", namespace = "http://www.orcid.org/ns/summary")
private String organizationName;
@XmlElement(name = "validated", namespace = "http://www.orcid.org/ns/summary")
private 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 getOrganizationName() {
return organizationName;
}
public void setOrganizationName(String organizationName) {
this.organizationName = organizationName;
}
public boolean isValidated() {
return validated;
}
public void setValidated(boolean validated) {
this.validated = validated;
}
@Override
public int hashCode() {
return Objects.hash(endDate, organizationName, putCode, startDate, validated);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Employment other = (Employment) obj;
return Objects.equals(endDate, other.endDate) && Objects.equals(organizationName, other.organizationName) && Objects.equals(putCode, other.putCode)
&& Objects.equals(startDate, other.startDate) && validated == other.validated;
}
public class Employment extends ProfessionalActivity {
@XmlTransient
private String type = AffiliationType.EMPLOYMENT.name();


}
Loading

0 comments on commit 423cb84

Please sign in to comment.