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 e843c93a566..478e29617c3 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 @@ -18,6 +18,7 @@ import org.orcid.core.manager.v3.read_only.AffiliationsManagerReadOnly; import org.orcid.core.manager.v3.read_only.ExternalIdentifierManagerReadOnly; import org.orcid.core.manager.v3.read_only.PeerReviewManagerReadOnly; +import org.orcid.core.manager.v3.read_only.ProfileEmailDomainManagerReadOnly; import org.orcid.core.manager.v3.read_only.ProfileFundingManagerReadOnly; import org.orcid.core.manager.v3.read_only.RecordManagerReadOnly; import org.orcid.core.manager.v3.read_only.RecordNameManagerReadOnly; @@ -25,6 +26,8 @@ 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.EmailDomain; +import org.orcid.core.model.EmailDomains; import org.orcid.core.model.Employment; import org.orcid.core.model.Employments; import org.orcid.core.model.ExternalIdentifier; @@ -36,6 +39,7 @@ import org.orcid.core.model.RecordSummary; import org.orcid.core.model.ResearchResources; import org.orcid.core.model.Works; +import org.orcid.core.togglz.Features; import org.orcid.core.utils.JsonUtils; import org.orcid.core.utils.cache.redis.RedisClient; import org.orcid.core.utils.v3.SourceUtils; @@ -60,8 +64,10 @@ 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; +import org.orcid.persistence.jpa.entities.ProfileEmailDomainEntity; import org.orcid.persistence.jpa.entities.ProfileEntity; import org.orcid.pojo.PeerReviewMinimizedSummary; +import org.orcid.pojo.ajaxForm.Date; import org.orcid.pojo.summary.AffiliationSummary; import org.orcid.pojo.summary.ExternalIdentifiersSummary; import org.orcid.pojo.summary.RecordSummaryPojo; @@ -90,37 +96,40 @@ public class SummaryManagerImpl implements SummaryManager { @Resource(name = "recordManagerReadOnlyV3") private RecordManagerReadOnly recordManagerReadOnly; - + @Resource(name = "researchResourceManagerReadOnlyV3") private ResearchResourceManagerReadOnly researchResourceManagerReadOnly; + @Resource(name = "profileEmailDomainManagerReadOnly") + private ProfileEmailDomainManagerReadOnly profileEmailDomainManagerReadOnly; + @Resource private ProfileEntityCacheManager profileEntityCacheManager; @Resource private WorksCacheManager worksCacheManager; - + @Resource - private RedisClient redisClient; - - @Value("${org.orcid.core.utils.cache.redis.summary.enabled:false}") + private RedisClient redisClient; + + @Value("${org.orcid.core.utils.cache.redis.summary.enabled:false}") private boolean isSummaryCacheEnabled; - + // Set the cache TTL for the summary, 1 day by default - @Value("${org.orcid.core.utils.cache.redis.summary.ttl:3600}") + @Value("${org.orcid.core.utils.cache.redis.summary.ttl:3600}") private int summaryCacheTTL; @Override public RecordSummary getRecordSummary(String orcid) { String cacheKey = getCacheKey(orcid); // Check the cache - if(isSummaryCacheEnabled) { + if (isSummaryCacheEnabled) { String summaryString = redisClient.get(cacheKey); - if(StringUtils.isNotBlank(summaryString)) { - return JsonUtils.readObjectFromJsonString(summaryString, RecordSummary.class); + if (StringUtils.isNotBlank(summaryString)) { + return JsonUtils.readObjectFromJsonString(summaryString, RecordSummary.class); } } - + RecordSummary recordSummary = new RecordSummary(); // Set ORCID identifier @@ -146,15 +155,18 @@ 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); - + generateResearchResourcesSummary(recordSummary, orcid); + + // generate email domains summary + generateEmailDomainsSummary(recordSummary, orcid); + // Set the summary in the cache - if(isSummaryCacheEnabled) { + if (isSummaryCacheEnabled) { redisClient.set(cacheKey, JsonUtils.convertToJsonString(recordSummary), summaryCacheTTL); - } + } return recordSummary; } @@ -163,21 +175,21 @@ public RecordSummaryPojo getRecordSummaryPojo(String orcid) { RecordSummary recordSummary = getRecordSummary(orcid); RecordSummaryPojo pojo = new RecordSummaryPojo(); pojo.setStatus("active"); - + pojo.setOrcid(recordSummary.getOrcidIdentifier().getUri()); - pojo.setName(recordSummary.getCreditName()); - - if(recordSummary.getCreatedDate() != null && recordSummary.getCreatedDate().getValue() != null) { - pojo.setCreation(DateUtils.formatDateISO8601(recordSummary.getCreatedDate().getValue().toGregorianCalendar().getTime())); + pojo.setName(recordSummary.getCreditName()); + + if (recordSummary.getCreatedDate() != null && recordSummary.getCreatedDate().getValue() != null) { + pojo.setCreation(DateUtils.formatDateISO8601(recordSummary.getCreatedDate().getValue().toGregorianCalendar().getTime())); } - - if(recordSummary.getLastModifiedDate() != null && recordSummary.getLastModifiedDate().getValue() != null) { + + if (recordSummary.getLastModifiedDate() != null && recordSummary.getLastModifiedDate().getValue() != null) { pojo.setLastModified(DateUtils.formatDateISO8601(recordSummary.getLastModifiedDate().getValue().toGregorianCalendar().getTime())); } - - if(recordSummary.getExternalIdentifiers() != null && recordSummary.getExternalIdentifiers().getExternalIdentifiers() != null) { + + if (recordSummary.getExternalIdentifiers() != null && recordSummary.getExternalIdentifiers().getExternalIdentifiers() != null) { List externalIdentifiers = new ArrayList<>(); - for(ExternalIdentifier ei : recordSummary.getExternalIdentifiers().getExternalIdentifiers()) { + for (ExternalIdentifier ei : recordSummary.getExternalIdentifiers().getExternalIdentifiers()) { ExternalIdentifiersSummary eis = new ExternalIdentifiersSummary(); eis.setCommonName(ei.getExternalIdType()); eis.setId(String.valueOf(ei.getPutCode())); @@ -188,10 +200,10 @@ public RecordSummaryPojo getRecordSummaryPojo(String orcid) { } pojo.setExternalIdentifiers(externalIdentifiers); } - - if(recordSummary.getEmployments() != null && recordSummary.getEmployments().getEmployments() != null) { + + if (recordSummary.getEmployments() != null && recordSummary.getEmployments().getEmployments() != null) { List affiliations = new ArrayList<>(); - for(Employment e : recordSummary.getEmployments().getEmployments()) { + for (Employment e : recordSummary.getEmployments().getEmployments()) { AffiliationSummary as = new AffiliationSummary(); as.setStartDate(e.getStartDate() == null ? null : e.getStartDate().toString()); as.setEndDate(e.getEndDate() == null ? null : e.getEndDate().toString()); @@ -204,75 +216,74 @@ public RecordSummaryPojo getRecordSummaryPojo(String orcid) { affiliations.add(as); } pojo.setEmploymentAffiliations(affiliations); - pojo.setEmploymentAffiliationsCount(recordSummary.getEmployments().getCount()); + pojo.setEmploymentAffiliationsCount(recordSummary.getEmployments().getCount()); } - - if(recordSummary.getProfessionalActivities() != null && recordSummary.getProfessionalActivities().getProfessionalActivities() != null) { + + if (recordSummary.getProfessionalActivities() != null && recordSummary.getProfessionalActivities().getProfessionalActivities() != null) { List professionalActivities = new ArrayList<>(); - for(ProfessionalActivity pa : recordSummary.getProfessionalActivities().getProfessionalActivities()) { + for (ProfessionalActivity pa : recordSummary.getProfessionalActivities().getProfessionalActivities()) { AffiliationSummary as = new AffiliationSummary(); 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.setRole(pa.getRole()); as.setType(pa.getType()); as.setUrl(pa.getUrl()); as.setValidated(pa.isValidated()); professionalActivities.add(as); } - + pojo.setProfessionalActivities(professionalActivities); - pojo.setProfessionalActivitiesCount(recordSummary.getProfessionalActivities().getCount()); + pojo.setProfessionalActivitiesCount(recordSummary.getProfessionalActivities().getCount()); } - - - if(recordSummary.getFundings() != null) { + + if (recordSummary.getFundings() != null) { pojo.setSelfAssertedFunds(recordSummary.getFundings().getSelfAssertedCount()); pojo.setValidatedFunds(recordSummary.getFundings().getValidatedCount()); } - - if(recordSummary.getPeerReviews() != null) { + + if (recordSummary.getPeerReviews() != null) { pojo.setPeerReviewsTotal(recordSummary.getPeerReviews().getTotal()); pojo.setPeerReviewPublicationGrants(recordSummary.getPeerReviews().getPeerReviewPublicationGrants()); pojo.setSelfAssertedPeerReviews(recordSummary.getPeerReviews().getSelfAssertedCount()); } - - if(recordSummary.getWorks() != null) { + + if (recordSummary.getWorks() != null) { pojo.setSelfAssertedWorks(recordSummary.getWorks().getSelfAssertedCount()); pojo.setValidatedWorks(recordSummary.getWorks().getValidatedCount()); } - - if(recordSummary.getEducationQualifications() != null && recordSummary.getEducationQualifications().getEducationQualifications() != null) { + + if (recordSummary.getEducationQualifications() != null && recordSummary.getEducationQualifications().getEducationQualifications() != null) { List educationQualifications = new ArrayList<>(); - for(EducationQualification eq : recordSummary.getEducationQualifications().getEducationQualifications()) { + 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.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()); + pojo.setEducationQualificationsCount(recordSummary.getEducationQualifications().getCount()); } - - if(recordSummary.getResearchResources() != null) { + + if (recordSummary.getResearchResources() != null) { pojo.setSelfAssertedResearchResources(recordSummary.getResearchResources().getSelfAssertedCount()); pojo.setValidatedResearchResources(recordSummary.getResearchResources().getValidatedCount()); } - + return pojo; - } - + } + public void generateAffiliationsSummary(RecordSummary recordSummary, String orcid) { - Map>> affiliationsMap = affiliationsManagerReadOnly.getGroupedAffiliations(orcid, - true); + Map>> affiliationsMap = affiliationsManagerReadOnly + .getGroupedAffiliations(orcid, true); // EMPLOYMENT List> employmentGroups = affiliationsMap.get(AffiliationType.EMPLOYMENT); @@ -297,15 +308,15 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci e.setValidated(!SourceUtils.isSelfAsserted(t.getSource(), orcid)); employmentsTop3.add(e); }); - + Employments e = new Employments(); e.setCount(preferredEmployments.size()); recordSummary.setEmployments(e); - if(!employmentsTop3.isEmpty()) { + if (!employmentsTop3.isEmpty()) { e.setEmployments(employmentsTop3); - } + } recordSummary.setEmployments(e); - + // PROFESIONAL ACTIVITIES List> profesionalActivitesGroups = new ArrayList<>(); if (affiliationsMap.containsKey(AffiliationType.DISTINCTION)) { @@ -320,7 +331,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)); @@ -336,7 +347,7 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci p.setStartDate(t.getStartDate()); p.setEndDate(t.getEndDate()); p.setRole(t.getRoleTitle()); - if(t instanceof DistinctionSummary) { + if (t instanceof DistinctionSummary) { p.setType(AffiliationType.DISTINCTION.value()); } else if (t instanceof InvitedPositionSummary) { p.setType(AffiliationType.INVITED_POSITION.value()); @@ -351,13 +362,13 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci }); ProfessionalActivities pa = new ProfessionalActivities(); pa.setCount(preferredProfesionalActivities.size()); - if(!professionalActivitiesTop3.isEmpty()) { + if (!professionalActivitiesTop3.isEmpty()) { pa.setProfessionalActivities(professionalActivitiesTop3); } - + recordSummary.setProfessionalActivities(pa); - - //EDUCATION Y QUALIFICATION + + // EDUCATION Y QUALIFICATION List> educationQualificationsGroups = new ArrayList<>(); if (affiliationsMap.containsKey(AffiliationType.EDUCATION)) { educationQualificationsGroups.addAll(affiliationsMap.get(AffiliationType.EDUCATION)); @@ -365,47 +376,49 @@ public void generateAffiliationsSummary(RecordSummary recordSummary, String orci 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 -> { + preferredEducationQualifications.stream().limit(3).forEach(t -> { EducationQualification eq = new EducationQualification(); - eq.setOrganizationName(t.getOrganizationName()); + eq.setOrganizationName((t.getOrganization() == null || StringUtils.isBlank(t.getOrganization().getName())) ? null : t.getOrganization().getName()); 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()); + eq.setRole(t.getRoleTitle()); + if (t instanceof EducationSummary) { + eq.setType(AffiliationType.EDUCATION.value()); + } else if (t instanceof QualificationSummary) { + eq.setType(AffiliationType.QUALIFICATION.value()); + } + eq.setUrl((t.getUrl() == null || StringUtils.isBlank(t.getUrl().getValue())) ? null : t.getUrl().getValue()); + eq.setValidated(!SourceUtils.isSelfAsserted(t.getSource(), orcid)); educationQualificationsTop3.add(eq); }); - + EducationQualifications eqList = new EducationQualifications(); eqList.setCount(preferredEducationQualifications.size()); - if(!educationQualificationsTop3.isEmpty()) { + if (!educationQualificationsTop3.isEmpty()) { eqList.setEducationQualifications(educationQualificationsTop3); } - - + recordSummary.setEducationQualifications(eqList); } - + public void generateExternalIdentifiersSummary(RecordSummary recordSummary, String orcid) { PersonExternalIdentifiers personExternalIdentifiers = externalIdentifierManagerReadOnly.getPublicExternalIdentifiers(orcid); - if(personExternalIdentifiers == null || personExternalIdentifiers.getExternalIdentifiers().isEmpty()) { + if (personExternalIdentifiers == null || personExternalIdentifiers.getExternalIdentifiers().isEmpty()) { return; } ExternalIdentifiers eis = new ExternalIdentifiers(); eis.setExternalIdentifiers(new ArrayList<>()); - for(PersonExternalIdentifier pei : personExternalIdentifiers.getExternalIdentifiers()) { + 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()); @@ -415,21 +428,21 @@ public void generateExternalIdentifiersSummary(RecordSummary recordSummary, Stri eis.getExternalIdentifiers().add(ei); } recordSummary.setExternalIdentifiers(eis); - } - + } + public void generateWorksSummary(RecordSummary recordSummary, String orcid) { org.orcid.jaxb.model.v3.release.record.summary.Works works = worksCacheManager.getGroupedWorks(orcid); Iterator workGroupIt = works.getWorkGroup().iterator(); while (workGroupIt.hasNext()) { WorkGroup workGroup = workGroupIt.next(); Iterator summariesIt = workGroup.getWorkSummary().iterator(); - while(summariesIt.hasNext()) { + while (summariesIt.hasNext()) { WorkSummary w = summariesIt.next(); - if(!Visibility.PUBLIC.equals(w.getVisibility())) { + if (!Visibility.PUBLIC.equals(w.getVisibility())) { summariesIt.remove(); } } - if(workGroup.getActivities() == null || workGroup.getActivities().isEmpty()) { + if (workGroup.getActivities() == null || workGroup.getActivities().isEmpty()) { workGroupIt.remove(); } } @@ -440,9 +453,10 @@ public void generateWorksSummary(RecordSummary recordSummary, String orcid) { worksModel.setValidatedCount(validAndSelfAssertedStats.getLeft()); recordSummary.setWorks(worksModel); } - + public void generateFundingSummary(RecordSummary recordSummary, String orcid) { - org.orcid.jaxb.model.v3.release.record.summary.Fundings fundingGroups = profileFundingManagerReadOnly.groupFundings(profileFundingManagerReadOnly.getFundingSummaryList(orcid), true); + org.orcid.jaxb.model.v3.release.record.summary.Fundings fundingGroups = profileFundingManagerReadOnly + .groupFundings(profileFundingManagerReadOnly.getFundingSummaryList(orcid), true); Pair validAndSelfAssertedStats = calculateSelfAssertedAndValidated(fundingGroups, orcid); Fundings fundingsModel = new Fundings(); @@ -469,12 +483,13 @@ public void generatePeerReviewSummary(RecordSummary recordSummary, String orcid) PeerReviews pr = new PeerReviews(); pr.setPeerReviewPublicationGrants(peerReviewMinimizedSummaryList.size()); pr.setSelfAssertedCount(selfAssertedPeerReviews); - pr.setTotal(totalReviewsCount); + 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); + 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(); @@ -483,6 +498,42 @@ public void generateResearchResourcesSummary(RecordSummary recordSummary, String recordSummary.setResearchResources(researchResourceModel); } + public void generateEmailDomainsSummary(RecordSummary recordSummary, String orcid) { + // Fill email domains + List emailDomains = null; + if (Features.EMAIL_DOMAINS.isActive()) { + emailDomains = profileEmailDomainManagerReadOnly.getPublicEmailDomains(orcid); + List edList = new ArrayList(); + if (emailDomains != null && !emailDomains.isEmpty()) { + + EmailDomain ed = null; + for (ProfileEmailDomainEntity ped : emailDomains) { + ed = new EmailDomain(); + ed.setValue(ped.getEmailDomain()); + ed.setCreatedDate(Date.valueOf(ped.getDateCreated())); + ed.setLastModified(Date.valueOf(ped.getLastModified())); + edList.add(ed); + } + } + + List emailDomainsTop3 = new ArrayList(); + edList.stream().limit(3).forEach(t -> { + EmailDomain ed = new EmailDomain(); + ed.setValue(t.getValue()); + ed.setCreatedDate(t.getCreatedDate()); + ed.setLastModified(t.getLastModified()); + emailDomainsTop3.add(ed); + }); + + EmailDomains eds = new EmailDomains(); + eds.setCount(edList.size()); + if (!emailDomainsTop3.isEmpty()) { + eds.setEmailDomains(emailDomainsTop3); + } + recordSummary.setEmailDomains(eds); + } + } + private Pair calculateSelfAssertedAndValidated(GroupsContainer c, String orcid) { Integer validated = 0; Integer selfAsserted = 0; @@ -507,7 +558,8 @@ private Pair calculateSelfAssertedAndValidated(GroupsContainer return Pair.of(validated, selfAsserted); } - private org.orcid.jaxb.model.v3.release.record.summary.AffiliationSummary getDefaultAffiliationFromGroup(AffiliationGroup group) { + private org.orcid.jaxb.model.v3.release.record.summary.AffiliationSummary getDefaultAffiliationFromGroup( + AffiliationGroup group) { org.orcid.jaxb.model.v3.release.record.summary.AffiliationSummary defaultAffiliation = null; Long maxDisplayIndex = null; for (org.orcid.jaxb.model.v3.release.record.summary.AffiliationSummary as : group.getActivities()) { @@ -544,7 +596,7 @@ private void sortAffiliationsByEndDate(List s.setEndDate(null)); } - + private String getCacheKey(String orcid) { return orcid + "-summary"; } 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 index 1dd1dce890c..bdd2de9f6e8 100644 --- a/orcid-core/src/main/java/org/orcid/core/model/EducationQualification.java +++ b/orcid-core/src/main/java/org/orcid/core/model/EducationQualification.java @@ -116,5 +116,4 @@ public boolean equals(Object obj) { && 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/EmailDomain.java b/orcid-core/src/main/java/org/orcid/core/model/EmailDomain.java new file mode 100644 index 00000000000..f4d28c6d869 --- /dev/null +++ b/orcid-core/src/main/java/org/orcid/core/model/EmailDomain.java @@ -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 = { "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 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", 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); + } +} diff --git a/orcid-core/src/main/java/org/orcid/core/model/EmailDomains.java b/orcid-core/src/main/java/org/orcid/core/model/EmailDomains.java new file mode 100644 index 00000000000..138c28add94 --- /dev/null +++ b/orcid-core/src/main/java/org/orcid/core/model/EmailDomains.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", "emailDomains" }) +@XmlRootElement(name = "email-domains", namespace = "http://www.orcid.org/ns/summary") +@Schema(description = "Email domains list") +public class EmailDomains implements Serializable { + /** + * + */ + private static final long serialVersionUID = 1L; + @XmlElement(name = "count", namespace = "http://www.orcid.org/ns/summary") + private Integer count; + @XmlElement(name = "email-domain", namespace = "http://www.orcid.org/ns/summary") + private List emailDomains; + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public List getEmailDomains() { + return emailDomains; + } + + public void setEmailDomains(List emailDomains ) { + this.emailDomains = emailDomains ; + } + + @Override + public int hashCode() { + return Objects.hash(count, emailDomains); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + EmailDomains other = (EmailDomains) obj; + return Objects.equals(count, other.count) && Objects.equals(emailDomains, other.emailDomains); + } + +} 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 666831f0ac1..37920db5786 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,12 +51,13 @@ 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; - + @XmlElement(name = "email-domains", namespace = "http://www.orcid.org/ns/summary") + private EmailDomains emailDomains; public OrcidIdentifier getOrcidIdentifier() { return orcidIdentifier; @@ -137,7 +138,7 @@ public PeerReviews getPeerReviews() { public void setPeerReviews(PeerReviews peerReviews) { this.peerReviews = peerReviews; } - + public EducationQualifications getEducationQualifications() { return educationQualifications; } @@ -146,7 +147,6 @@ public void setEducationQualifications(EducationQualifications educationQualific this.educationQualifications = educationQualifications; } - public ResearchResources getResearchResources() { return researchResources; } @@ -155,10 +155,18 @@ public void setResearchResources(ResearchResources researchResources) { this.researchResources = researchResources; } + public EmailDomains getEmailDomains() { + return emailDomains; + } + + public void setEmailDomains(EmailDomains emailDomains) { + this.emailDomains = emailDomains; + } + @Override public int hashCode() { return Objects.hash(createdDate, creditName, employments, externalIdentifiers, fundings, lastModifiedDate, orcidIdentifier, orcidUrlManager, peerReviews, - professionalActivities, works); + professionalActivities, works, educationQualifications, researchResources, emailDomains); } @Override @@ -174,6 +182,8 @@ public boolean equals(Object obj) { && Objects.equals(externalIdentifiers, other.externalIdentifiers) && Objects.equals(fundings, other.fundings) && Objects.equals(lastModifiedDate, other.lastModifiedDate) && Objects.equals(orcidIdentifier, other.orcidIdentifier) && Objects.equals(orcidUrlManager, other.orcidUrlManager) && Objects.equals(peerReviews, other.peerReviews) - && Objects.equals(professionalActivities, other.professionalActivities) && Objects.equals(works, other.works); - } + && Objects.equals(professionalActivities, other.professionalActivities) && Objects.equals(works, other.works) + && Objects.equals(educationQualifications, other.educationQualifications) && Objects.equals(researchResources, other.researchResources) + && Objects.equals(emailDomains, other.emailDomains) ; + } } diff --git a/orcid-core/src/main/java/org/orcid/pojo/summary/EmailDomainSummary.java b/orcid-core/src/main/java/org/orcid/pojo/summary/EmailDomainSummary.java new file mode 100644 index 00000000000..df7f67b8487 --- /dev/null +++ b/orcid-core/src/main/java/org/orcid/pojo/summary/EmailDomainSummary.java @@ -0,0 +1,58 @@ +package org.orcid.pojo.summary; + +import java.util.Date; + +import org.orcid.persistence.jpa.entities.ProfileEmailDomainEntity; +import org.orcid.pojo.ajaxForm.PojoUtil; + +public class EmailDomainSummary { + private String value; + private Date createdDate; + private 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; + } + + + public static EmailDomainSummary valueOf(ProfileEmailDomainEntity pem) { + EmailDomainSummary form = new EmailDomainSummary(); + + if (pem != null) { + if(!PojoUtil.isEmpty(pem.getEmailDomain())) { + form.setValue(pem.getEmailDomain()); + } + + if (pem.getDateCreated() != null) { + form.setCreatedDate(pem.getDateCreated()); + } + + if (pem.getLastModified() !=null) { + form.setLastModified(pem.getLastModified()); + } + } + return form; + } + + +} 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 d5a3501fae1..b889c1547b1 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 @@ -31,6 +31,9 @@ public class RecordSummaryPojo { private int educationQualificationsCount; private int validatedResearchResources; private int selfAssertedResearchResources; + + private List emailDomains; + private int emailDomainsCount; public String getName() { return name; @@ -199,5 +202,21 @@ public int getSelfAssertedResearchResources() { public void setSelfAssertedResearchResources(int selfAssertedResearchResources) { this.selfAssertedResearchResources = selfAssertedResearchResources; } + + public List getEmailDomains() { + return emailDomains; + } + + public void setEmailDomains(List emailDomains) { + this.emailDomains = emailDomains; + } + + public int getEmailDomainsCount() { + return emailDomainsCount; + } + + public void setEmailDomainsCount(int emailDomainsCount) { + this.emailDomainsCount = emailDomainsCount; + } } diff --git a/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java b/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java index 509625b5407..be535f48a5d 100644 --- a/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java +++ b/orcid-core/src/test/java/org/orcid/core/common/manager/SummaryManagerTest.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.Map; +import javax.annotation.Resource; import javax.xml.datatype.XMLGregorianCalendar; import org.junit.Before; @@ -28,6 +29,7 @@ import org.orcid.core.manager.v3.read_only.ProfileFundingManagerReadOnly; 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.ResearchResourceManagerReadOnly; import org.orcid.core.model.ProfessionalActivity; import org.orcid.core.model.RecordSummary; import org.orcid.jaxb.model.v3.release.common.CreatedDate; @@ -103,6 +105,9 @@ public class SummaryManagerTest { @Mock private WorksCacheManager worksCacheManagerMock; + + @Mock + private ResearchResourceManagerReadOnly researchResourceManagerReadOnly; @Before public void setUp() {