Skip to content

Commit

Permalink
First draft education, qualification and research resources added to …
Browse files Browse the repository at this point in the history
…record summary
  • Loading branch information
Camelia-Orcid committed Sep 12, 2024
1 parent 76920bb commit 0b4177c
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import org.orcid.core.manager.v3.read_only.RecordManagerReadOnly;
import org.orcid.core.manager.v3.read_only.RecordNameManagerReadOnly;
import org.orcid.core.manager.v3.read_only.WorkManagerReadOnly;
import org.orcid.core.manager.v3.read_only.ResearchResourceManagerReadOnly;
import org.orcid.core.model.EducationQualification;
import org.orcid.core.model.EducationQualifications;
import org.orcid.core.model.Employment;
import org.orcid.core.model.Employments;
import org.orcid.core.model.ExternalIdentifier;
Expand All @@ -31,6 +34,7 @@
import org.orcid.core.model.ProfessionalActivities;
import org.orcid.core.model.ProfessionalActivity;
import org.orcid.core.model.RecordSummary;
import org.orcid.core.model.ResearchResources;
import org.orcid.core.model.Works;
import org.orcid.core.utils.JsonUtils;
import org.orcid.core.utils.cache.redis.RedisClient;
Expand All @@ -49,8 +53,10 @@
import org.orcid.jaxb.model.v3.release.record.SourceAware;
import org.orcid.jaxb.model.v3.release.record.summary.AffiliationGroup;
import org.orcid.jaxb.model.v3.release.record.summary.DistinctionSummary;
import org.orcid.jaxb.model.v3.release.record.summary.EducationSummary;
import org.orcid.jaxb.model.v3.release.record.summary.InvitedPositionSummary;
import org.orcid.jaxb.model.v3.release.record.summary.MembershipSummary;
import org.orcid.jaxb.model.v3.release.record.summary.QualificationSummary;
import org.orcid.jaxb.model.v3.release.record.summary.ServiceSummary;
import org.orcid.jaxb.model.v3.release.record.summary.WorkGroup;
import org.orcid.jaxb.model.v3.release.record.summary.WorkSummary;
Expand Down Expand Up @@ -84,6 +90,9 @@ public class SummaryManagerImpl implements SummaryManager {

@Resource(name = "recordManagerReadOnlyV3")
private RecordManagerReadOnly recordManagerReadOnly;

@Resource(name = "researchResourceManagerReadOnlyV3")
private ResearchResourceManagerReadOnly researchResourceManagerReadOnly;

@Resource
private ProfileEntityCacheManager profileEntityCacheManager;
Expand Down Expand Up @@ -137,7 +146,10 @@ public RecordSummary getRecordSummary(String orcid) {
generateFundingSummary(recordSummary, orcid);

// Generate the peer review summary
generatePeerReviewSummary(recordSummary, orcid);
generatePeerReviewSummary(recordSummary, orcid);

// Generate the research resources summary
generateResearchResourcesSummary(recordSummary, orcid);

// Set the summary in the cache
if(isSummaryCacheEnabled) {
Expand Down Expand Up @@ -231,6 +243,30 @@ public RecordSummaryPojo getRecordSummaryPojo(String orcid) {
pojo.setValidatedWorks(recordSummary.getWorks().getValidatedCount());
}

if(recordSummary.getEducationQualifications() != null && recordSummary.getEducationQualifications().getEducationQualifications() != null) {
List<AffiliationSummary> educationQualifications = new ArrayList<>();
for(EducationQualification eq : recordSummary.getEducationQualifications().getEducationQualifications()) {
AffiliationSummary as = new AffiliationSummary();
as.setEndDate(eq.getEndDate() == null ? null : eq.getEndDate().toString());
as.setStartDate(eq.getStartDate() == null ? null : eq.getStartDate().toString());
as.setOrganizationName(eq.getOrganizationName());
as.setPutCode(eq.getPutCode());
as.setRole(eq.getRole());
as.setType(eq.getType());
as.setUrl(eq.getUrl());
as.setValidated(eq.isValidated());
educationQualifications.add(as);
}

pojo.setEducationQualifications(educationQualifications);
pojo.setEducationQualificationsCount(recordSummary.getEducationQualifications().getCount());
}

if(recordSummary.getResearchResources() != null) {
pojo.setSelfAssertedResearchResources(recordSummary.getResearchResources().getSelfAssertedCount());
pojo.setValidatedResearchResources(recordSummary.getResearchResources().getValidatedCount());
}

return pojo;
}

Expand Down Expand Up @@ -284,6 +320,7 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci
if (affiliationsMap.containsKey(AffiliationType.SERVICE)) {
profesionalActivitesGroups.addAll(affiliationsMap.get(AffiliationType.SERVICE));
}

List<org.orcid.jaxb.model.v3.release.record.summary.AffiliationSummary> preferredProfesionalActivities = new ArrayList<>();
for (AffiliationGroup<org.orcid.jaxb.model.v3.release.record.summary.AffiliationSummary> group : profesionalActivitesGroups) {
preferredProfesionalActivities.add(getDefaultAffiliationFromGroup(group));
Expand Down Expand Up @@ -317,7 +354,48 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci
if(!professionalActivitiesTop3.isEmpty()) {
pa.setProfessionalActivities(professionalActivitiesTop3);
}

recordSummary.setProfessionalActivities(pa);

//EDUCATION Y QUALIFICATION
List<AffiliationGroup<org.orcid.jaxb.model.v3.release.record.summary.AffiliationSummary>> educationQualificationsGroups = new ArrayList<>();
if (affiliationsMap.containsKey(AffiliationType.EDUCATION)) {
educationQualificationsGroups.addAll(affiliationsMap.get(AffiliationType.EDUCATION));
}
if (affiliationsMap.containsKey(AffiliationType.QUALIFICATION)) {
educationQualificationsGroups.addAll(affiliationsMap.get(AffiliationType.QUALIFICATION));
}

List<org.orcid.jaxb.model.v3.release.record.summary.AffiliationSummary> preferredEducationQualifications = new ArrayList<>();
for (AffiliationGroup<org.orcid.jaxb.model.v3.release.record.summary.AffiliationSummary> group : educationQualificationsGroups) {
preferredEducationQualifications.add(getDefaultAffiliationFromGroup(group));
}
// Sort them by end date by default
sortAffiliationsByEndDate(preferredEducationQualifications);

List<EducationQualification> educationQualificationsTop3 = new ArrayList<EducationQualification>();
educationQualificationsTop3.stream().limit(3).forEach(t -> {
EducationQualification eq = new EducationQualification();
eq.setOrganizationName(t.getOrganizationName());
eq.setPutCode(t.getPutCode());
eq.setStartDate(t.getStartDate());
eq.setEndDate(t.getEndDate());
eq.setRole(t.getRole());
eq.setType(t.getType());

eq.setUrl(t.getUrl());
eq.setValidated(t.isValidated());
educationQualificationsTop3.add(eq);
});

EducationQualifications eqList = new EducationQualifications();
eqList.setCount(preferredEducationQualifications.size());
if(!educationQualificationsTop3.isEmpty()) {
eqList.setEducationQualifications(educationQualificationsTop3);
}


recordSummary.setEducationQualifications(eqList);
}

public void generateExternalIdentifiersSummary(RecordSummary recordSummary, String orcid) {
Expand Down Expand Up @@ -394,6 +472,16 @@ public void generatePeerReviewSummary(RecordSummary recordSummary, String orcid)
pr.setTotal(totalReviewsCount);
recordSummary.setPeerReviews(pr);
}

public void generateResearchResourcesSummary(RecordSummary recordSummary, String orcid) {
org.orcid.jaxb.model.v3.release.record.summary.ResearchResources researchResourcesGroups = researchResourceManagerReadOnly.groupResearchResources(researchResourceManagerReadOnly.getResearchResourceSummaryList(orcid),true);
Pair<Integer, Integer> validAndSelfAssertedStats = calculateSelfAssertedAndValidated(researchResourcesGroups, orcid);

ResearchResources researchResourceModel = new ResearchResources();
researchResourceModel.setSelfAssertedCount(validAndSelfAssertedStats.getRight());
researchResourceModel.setValidatedCount(validAndSelfAssertedStats.getLeft());
recordSummary.setResearchResources(researchResourceModel);
}

private Pair<Integer, Integer> calculateSelfAssertedAndValidated(GroupsContainer c, String orcid) {
Integer validated = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
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);
}

}
23 changes: 23 additions & 0 deletions orcid-core/src/main/java/org/orcid/core/model/RecordSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public class RecordSummary implements Serializable {
private Works works;
@XmlElement(name = "peer-reviews", namespace = "http://www.orcid.org/ns/summary")
private PeerReviews peerReviews;

@XmlElement(name = "education-qualifications", namespace = "http://www.orcid.org/ns/summary")
private EducationQualifications educationQualifications;
@XmlElement(name = "research-resources", namespace = "http://www.orcid.org/ns/summary")
private ResearchResources researchResources;


public OrcidIdentifier getOrcidIdentifier() {
return orcidIdentifier;
Expand Down Expand Up @@ -131,6 +137,23 @@ public PeerReviews getPeerReviews() {
public void setPeerReviews(PeerReviews peerReviews) {
this.peerReviews = peerReviews;
}

public EducationQualifications getEducationQualifications() {
return educationQualifications;
}

public void setEducationQualifications(EducationQualifications educationQualifications) {
this.educationQualifications = educationQualifications;
}


public ResearchResources getResearchResources() {
return researchResources;
}

public void setResearchResources(ResearchResources researchResources) {
this.researchResources = researchResources;
}

@Override
public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.orcid.core.model;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlRootElement;

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

@XmlRootElement(name = "research-resources", namespace = "http://www.orcid.org/ns/summary")
@Schema(description = "Research resources")
public class ResearchResources extends ItemsCount implements Serializable {

/**
*
*/
private static final long serialVersionUID = 1L;

}
Loading

0 comments on commit 0b4177c

Please sign in to comment.