diff --git a/orcid-core/src/main/java/org/orcid/core/common/manager/impl/SummaryManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/common/manager/impl/SummaryManagerImpl.java index 190e19d01e5..e843c93a566 100644 --- a/orcid-core/src/main/java/org/orcid/core/common/manager/impl/SummaryManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/common/manager/impl/SummaryManagerImpl.java @@ -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; @@ -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; @@ -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; @@ -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; @@ -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) { @@ -231,6 +243,30 @@ public RecordSummaryPojo getRecordSummaryPojo(String orcid) { pojo.setValidatedWorks(recordSummary.getWorks().getValidatedCount()); } + if(recordSummary.getEducationQualifications() != null && recordSummary.getEducationQualifications().getEducationQualifications() != null) { + List 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; } @@ -284,6 +320,7 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci if (affiliationsMap.containsKey(AffiliationType.SERVICE)) { profesionalActivitesGroups.addAll(affiliationsMap.get(AffiliationType.SERVICE)); } + List preferredProfesionalActivities = new ArrayList<>(); for (AffiliationGroup group : profesionalActivitesGroups) { preferredProfesionalActivities.add(getDefaultAffiliationFromGroup(group)); @@ -317,7 +354,48 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci if(!professionalActivitiesTop3.isEmpty()) { pa.setProfessionalActivities(professionalActivitiesTop3); } + recordSummary.setProfessionalActivities(pa); + + //EDUCATION Y QUALIFICATION + List> 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 preferredEducationQualifications = new ArrayList<>(); + for (AffiliationGroup group : educationQualificationsGroups) { + preferredEducationQualifications.add(getDefaultAffiliationFromGroup(group)); + } + // Sort them by end date by default + sortAffiliationsByEndDate(preferredEducationQualifications); + + List educationQualificationsTop3 = new ArrayList(); + 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) { @@ -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 validAndSelfAssertedStats = calculateSelfAssertedAndValidated(researchResourcesGroups, orcid); + + ResearchResources researchResourceModel = new ResearchResources(); + researchResourceModel.setSelfAssertedCount(validAndSelfAssertedStats.getRight()); + researchResourceModel.setValidatedCount(validAndSelfAssertedStats.getLeft()); + recordSummary.setResearchResources(researchResourceModel); + } private Pair calculateSelfAssertedAndValidated(GroupsContainer c, String orcid) { Integer validated = 0; diff --git a/orcid-core/src/main/java/org/orcid/core/model/EducationQualification.java b/orcid-core/src/main/java/org/orcid/core/model/EducationQualification.java new file mode 100644 index 00000000000..1dd1dce890c --- /dev/null +++ b/orcid-core/src/main/java/org/orcid/core/model/EducationQualification.java @@ -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; + } + +} diff --git a/orcid-core/src/main/java/org/orcid/core/model/EducationQualifications.java b/orcid-core/src/main/java/org/orcid/core/model/EducationQualifications.java new file mode 100644 index 00000000000..f20f1a9e3dd --- /dev/null +++ b/orcid-core/src/main/java/org/orcid/core/model/EducationQualifications.java @@ -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 educationQualifications; + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public List getEducationQualifications() { + return educationQualifications; + } + + public void setEducationQualifications(List 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); + } + +} diff --git a/orcid-core/src/main/java/org/orcid/core/model/RecordSummary.java b/orcid-core/src/main/java/org/orcid/core/model/RecordSummary.java index 0dba0f03e5c..666831f0ac1 100644 --- a/orcid-core/src/main/java/org/orcid/core/model/RecordSummary.java +++ b/orcid-core/src/main/java/org/orcid/core/model/RecordSummary.java @@ -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; @@ -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() { diff --git a/orcid-core/src/main/java/org/orcid/core/model/ResearchResources.java b/orcid-core/src/main/java/org/orcid/core/model/ResearchResources.java new file mode 100644 index 00000000000..3748e41b223 --- /dev/null +++ b/orcid-core/src/main/java/org/orcid/core/model/ResearchResources.java @@ -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; + +} diff --git a/orcid-core/src/main/java/org/orcid/pojo/summary/RecordSummaryPojo.java b/orcid-core/src/main/java/org/orcid/pojo/summary/RecordSummaryPojo.java index 1628c45bbed..d5a3501fae1 100644 --- a/orcid-core/src/main/java/org/orcid/pojo/summary/RecordSummaryPojo.java +++ b/orcid-core/src/main/java/org/orcid/pojo/summary/RecordSummaryPojo.java @@ -27,6 +27,10 @@ public class RecordSummaryPojo { private int professionalActivitiesCount; private List externalIdentifiers; private String status; + private List educationQualifications; + private int educationQualificationsCount; + private int validatedResearchResources; + private int selfAssertedResearchResources; public String getName() { return name; @@ -163,4 +167,37 @@ public String getStatus() { public void setStatus(String status) { this.status = status; } + + public List getEducationQualifications() { + return educationQualifications; + } + + public void setEducationQualifications(List educationQualifications) { + this.educationQualifications = educationQualifications; + } + + public int getEducationQualificationsCount() { + return educationQualificationsCount; + } + + public void setEducationQualificationsCount(int educationQualificationsCount) { + this.educationQualificationsCount = educationQualificationsCount; + } + + public int getValidatedResearchResources() { + return validatedResearchResources; + } + + public void setValidatedResearchResources(int validatedResearchResources) { + this.validatedResearchResources = validatedResearchResources; + } + + public int getSelfAssertedResearchResources() { + return selfAssertedResearchResources; + } + + public void setSelfAssertedResearchResources(int selfAssertedResearchResources) { + this.selfAssertedResearchResources = selfAssertedResearchResources; + } + }