From 2bdc44993ae6382e996da99ae90d847071327490 Mon Sep 17 00:00:00 2001 From: Camelia Dumitru <62257307+Camelia-Orcid@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:14:36 +0100 Subject: [PATCH 1/4] First draft education, qualifications, research resources, email domains added to record summary (#7084) * First draft education, qualification and research resources added to record summary * Added the implementation for emailDomains * Email domain fixes + fix for failing tests * Fixed the failing test by specifying the right xml order * Added the new summaries to the record marshalling test * Added the updated orcid-model version and fixed the last modified element --- .../manager/impl/SummaryManagerImpl.java | 285 ++++++++++++++---- .../core/model/EducationQualification.java | 119 ++++++++ .../core/model/EducationQualifications.java | 62 ++++ .../org/orcid/core/model/EmailDomain.java | 68 +++++ .../org/orcid/core/model/EmailDomains.java | 62 ++++ .../org/orcid/core/model/RecordSummary.java | 41 ++- .../orcid/core/model/ResearchResources.java | 18 ++ .../pojo/summary/EmailDomainSummary.java | 56 ++++ .../orcid/pojo/summary/RecordSummaryPojo.java | 56 ++++ .../common/manager/SummaryManagerTest.java | 40 +++ .../model/RecordSummaryMarshallingTest.java | 53 +++- .../org/orcid/core/model/summary-3.0.xml | 2 +- pom.xml | 2 +- 13 files changed, 792 insertions(+), 72 deletions(-) create mode 100644 orcid-core/src/main/java/org/orcid/core/model/EducationQualification.java create mode 100644 orcid-core/src/main/java/org/orcid/core/model/EducationQualifications.java create mode 100644 orcid-core/src/main/java/org/orcid/core/model/EmailDomain.java create mode 100644 orcid-core/src/main/java/org/orcid/core/model/EmailDomains.java create mode 100644 orcid-core/src/main/java/org/orcid/core/model/ResearchResources.java create mode 100644 orcid-core/src/main/java/org/orcid/pojo/summary/EmailDomainSummary.java 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..766f3f4f65a 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,10 +18,16 @@ 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; 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.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; @@ -31,7 +37,9 @@ 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.togglz.Features; import org.orcid.core.utils.JsonUtils; import org.orcid.core.utils.cache.redis.RedisClient; import org.orcid.core.utils.v3.SourceUtils; @@ -49,14 +57,19 @@ 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; +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.EmailDomainSummary; import org.orcid.pojo.summary.ExternalIdentifiersSummary; import org.orcid.pojo.summary.RecordSummaryPojo; import org.orcid.utils.DateUtils; @@ -85,33 +98,39 @@ 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 @@ -137,12 +156,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); + + // 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; } @@ -151,21 +176,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())); @@ -176,10 +201,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()); @@ -192,51 +217,88 @@ 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) { + 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()); + } + + if (recordSummary.getEmailDomains() != null) { + List emailDomains = new ArrayList(); + if (recordSummary.getEmailDomains() != null && recordSummary.getEmailDomains().getEmailDomains() != null) { + 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()); + } + } + pojo.setEmailDomains(emailDomains); + pojo.setEmailDomainsCount(recordSummary.getEmailDomains().getCount()); + } + 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); @@ -261,15 +323,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)) { @@ -284,6 +346,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)); @@ -299,7 +362,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()); @@ -314,20 +377,63 @@ 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 + 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(); + preferredEducationQualifications.stream().limit(3).forEach(t -> { + EducationQualification eq = new EducationQualification(); + 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.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()) { + 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()); @@ -337,21 +443,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(); } } @@ -362,9 +468,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(); @@ -391,10 +498,57 @@ 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); + Pair validAndSelfAssertedStats = calculateSelfAssertedAndValidated(researchResourcesGroups, orcid); + + ResearchResources researchResourceModel = new ResearchResources(); + researchResourceModel.setSelfAssertedCount(validAndSelfAssertedStats.getRight()); + researchResourceModel.setValidatedCount(validAndSelfAssertedStats.getLeft()); + 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; @@ -419,7 +573,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()) { @@ -456,7 +611,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 new file mode 100644 index 00000000000..bdd2de9f6e8 --- /dev/null +++ b/orcid-core/src/main/java/org/orcid/core/model/EducationQualification.java @@ -0,0 +1,119 @@ +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/EmailDomain.java b/orcid-core/src/main/java/org/orcid/core/model/EmailDomain.java new file mode 100644 index 00000000000..a31928c6841 --- /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 = { "value","createdDate", "lastModified"}) +@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-date", 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 0dba0f03e5c..cc8189048da 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 @@ -20,7 +20,7 @@ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(propOrder = { "createdDate", "lastModifiedDate", "creditName", "orcidIdentifier", "externalIdentifiers", "employments", "professionalActivities", "fundings", - "works", "peerReviews" }) + "works", "peerReviews", "emailDomains", "educationQualifications", "researchResources" }) @XmlRootElement(name = "record-summary", namespace = "http://www.orcid.org/ns/summary") @Schema(description = "Record summary") public class RecordSummary implements Serializable { @@ -52,6 +52,13 @@ public class RecordSummary implements Serializable { @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; } @@ -132,10 +139,34 @@ 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; + } + + 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, emailDomains, educationQualifications, researchResources ); } @Override @@ -151,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/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/EmailDomainSummary.java b/orcid-core/src/main/java/org/orcid/pojo/summary/EmailDomainSummary.java new file mode 100644 index 00000000000..4513d3db408 --- /dev/null +++ b/orcid-core/src/main/java/org/orcid/pojo/summary/EmailDomainSummary.java @@ -0,0 +1,56 @@ +package org.orcid.pojo.summary; + +import org.orcid.persistence.jpa.entities.ProfileEmailDomainEntity; +import org.orcid.pojo.ajaxForm.PojoUtil; + +public class EmailDomainSummary { + private String value; + private String createdDate; + private String lastModified; + + public String getValue() { + return value; + } + + 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(); + + if (pem != null) { + 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; + } + + +} 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..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 @@ -27,6 +27,13 @@ public class RecordSummaryPojo { private int professionalActivitiesCount; private List externalIdentifiers; private String status; + private List educationQualifications; + private int educationQualificationsCount; + private int validatedResearchResources; + private int selfAssertedResearchResources; + + private List emailDomains; + private int emailDomainsCount; public String getName() { return name; @@ -163,4 +170,53 @@ 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; + } + + 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..61e4ac2e8f1 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; @@ -25,9 +26,12 @@ 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; +import org.orcid.core.manager.v3.read_only.ResearchResourceManagerReadOnly; +import org.orcid.core.model.EmailDomains; import org.orcid.core.model.ProfessionalActivity; import org.orcid.core.model.RecordSummary; import org.orcid.jaxb.model.v3.release.common.CreatedDate; @@ -61,10 +65,13 @@ 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.ResearchResourceSummary; 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.jaxb.model.v3.release.record.summary.Works; +import org.orcid.jaxb.model.v3.release.record.summary.ResearchResources; +import org.orcid.persistence.jpa.entities.ProfileEmailDomainEntity; import org.orcid.persistence.jpa.entities.ProfileEntity; import org.orcid.pojo.PeerReviewMinimizedSummary; import org.orcid.pojo.summary.RecordSummaryPojo; @@ -103,6 +110,12 @@ public class SummaryManagerTest { @Mock private WorksCacheManager worksCacheManagerMock; + + @Mock + private ResearchResourceManagerReadOnly researchResourceManagerReadOnlyMock; + + @Mock + private ProfileEmailDomainManagerReadOnly profileEmailDomainManagerReadOnlyMock; @Before public void setUp() { @@ -143,7 +156,20 @@ public void setUp() { // Set peer reviews Mockito.when(peerReviewManagerReadOnlyMock.getPeerReviewMinimizedSummaryList(Mockito.eq(ORCID), Mockito.eq(true))).thenReturn(getPeerReviewSummaryList()); ReflectionTestUtils.setField(manager, "peerReviewManagerReadOnly", peerReviewManagerReadOnlyMock); + + + // Set ResearchResources + ResearchResources researchResources = getResearchResources(); + Mockito.when(researchResourceManagerReadOnlyMock.getResearchResourceSummaryList(Mockito.eq(ORCID))).thenReturn(new ArrayList()); + Mockito.when(researchResourceManagerReadOnlyMock.groupResearchResources(Mockito.anyList(), Mockito.eq(true))).thenReturn(researchResources); + ReflectionTestUtils.setField(manager, "researchResourceManagerReadOnly", researchResourceManagerReadOnlyMock); + // Set EmailDomains + EmailDomains emailDomains = getEmailDomains(); + Mockito.when(profileEmailDomainManagerReadOnlyMock.getPublicEmailDomains(Mockito.eq(ORCID))).thenReturn(new ArrayList()); + ReflectionTestUtils.setField(manager, "profileEmailDomainManagerReadOnly", profileEmailDomainManagerReadOnlyMock); + + // Set metadata OrcidIdentifier oi = new OrcidIdentifier(); oi.setUri("https://test.orcid.org/0000-0000-0000-0000"); @@ -574,6 +600,20 @@ private PersonExternalIdentifiers getPersonExternalIdentifiers() { peis.getExternalIdentifiers().add(pei); return peis; } + + private ResearchResources getResearchResources() { + ResearchResources researchResources = new ResearchResources(); + + return researchResources; + } + + private EmailDomains getEmailDomains() { + EmailDomains emailDomains = new EmailDomains(); + + return emailDomains; + } + + private List> getAffiliations(AffiliationType affiliationType) { List> affiliationGroups = new ArrayList<>(); diff --git a/orcid-core/src/test/java/org/orcid/core/model/RecordSummaryMarshallingTest.java b/orcid-core/src/test/java/org/orcid/core/model/RecordSummaryMarshallingTest.java index a2de2996071..72c5a541aae 100644 --- a/orcid-core/src/test/java/org/orcid/core/model/RecordSummaryMarshallingTest.java +++ b/orcid-core/src/test/java/org/orcid/core/model/RecordSummaryMarshallingTest.java @@ -20,6 +20,7 @@ import org.orcid.jaxb.model.v3.release.common.Month; import org.orcid.jaxb.model.v3.release.common.OrcidIdentifier; import org.orcid.jaxb.model.v3.release.common.Year; +import org.orcid.pojo.ajaxForm.Date; import org.orcid.utils.DateUtils; public class RecordSummaryMarshallingTest { @@ -29,7 +30,6 @@ public void marshallingTest() throws JAXBException, IOException { JAXBContext context = JAXBContext.newInstance(new Class[] { RecordSummary.class }); Marshaller marshaller = context.createMarshaller(); String expectedText = IOUtils.toString(getClass().getResourceAsStream("summary-3.0.xml"), StandardCharsets.UTF_8); - RecordSummary recordSummary = getRecordSummary(); StringWriter stringWriter = new StringWriter(); marshaller.marshal(recordSummary, stringWriter); @@ -80,6 +80,8 @@ private RecordSummary getRecordSummary() { fundings.setValidatedCount(1); record.setFundings(fundings); + + Works works = new Works(); works.setSelfAssertedCount(0); works.setValidatedCount(1); @@ -91,6 +93,25 @@ private RecordSummary getRecordSummary() { peerReviews.setTotal(6); record.setPeerReviews(peerReviews); + //Set email domains + EmailDomains emailDomains = new EmailDomains(); + emailDomains.setCount(4); + emailDomains.setEmailDomains(new ArrayList()); + emailDomains.getEmailDomains().add(getEmailDomain("sometrusted.org", getEmailDomainCreatedDate(), getEmailDomainLastModified())); + record.setEmailDomains(emailDomains); + + //Set education/qualifications + EducationQualifications educationQualifications = new EducationQualifications(); + educationQualifications.setCount(6); + educationQualifications.setEducationQualifications(new ArrayList()); + educationQualifications.getEducationQualifications().add(getEducationQualification(1, "Org # 1", "Fake role title", "https://test.orcid.org/", "education", false)); + record.setEducationQualifications(educationQualifications); + //Set research resources + ResearchResources researchResources = new ResearchResources(); + researchResources.setSelfAssertedCount(0); + researchResources.setValidatedCount(1); + record.setResearchResources(researchResources); + return record; } @@ -129,6 +150,27 @@ private ProfessionalActivity getProfessionalActivity(int putCode, String role, S return pa; } + private EducationQualification getEducationQualification(int putCode, String role, String org, String url, String type, boolean validated) { + EducationQualification eq = new EducationQualification(); + eq.setPutCode(Long.valueOf(putCode)); + eq.setEndDate(getEndDate()); + eq.setStartDate(getStartDate()); + eq.setOrganizationName(org); + eq.setRole(role); + eq.setUrl(url); + eq.setValidated(validated); + eq.setType(type); + return eq; + } + + private EmailDomain getEmailDomain(String domainValue, Date created, Date modified) { + EmailDomain emailDomain = new EmailDomain(); + emailDomain.setValue(domainValue); + //emailDomain.setCreatedDate(created); + //emailDomain.setLastModified(modified); + return emailDomain; + } + private FuzzyDate getEndDate() { return new FuzzyDate(new Year(2024), new Month(12), new Day(31)); } @@ -136,4 +178,13 @@ private FuzzyDate getEndDate() { private FuzzyDate getStartDate() { return new FuzzyDate(new Year(2020), new Month(1), new Day(1)); } + + + private Date getEmailDomainCreatedDate() { + return Date.valueOf(new FuzzyDate(new Year(2020), new Month(1), new Day(1))); + } + + private Date getEmailDomainLastModified() { + return Date.valueOf(new FuzzyDate(new Year(2020), new Month(1), new Day(1))); + } } diff --git a/orcid-core/src/test/resources/org/orcid/core/model/summary-3.0.xml b/orcid-core/src/test/resources/org/orcid/core/model/summary-3.0.xml index ee782257c6d..d1b1400022d 100644 --- a/orcid-core/src/test/resources/org/orcid/core/model/summary-3.0.xml +++ b/orcid-core/src/test/resources/org/orcid/core/model/summary-3.0.xml @@ -1 +1 @@ -2024-01-01T12:00:002024-01-01T12:00:00User credited namehttps://orcid.org/8888-8888-8888-88808888-8888-8888-8880orcid.org1Scopus1https://test.orcid.org/1true2ResearcherID2https://test.orcid.org/2true3Other3https://test.orcid.org/3true51employmentFake role title 1Org # 1https://test.orcid.org/12020010120241231false2employmentFake role title 2Org # 2https://test.orcid.org/22020010120241231false3employmentFake role title 3Org # 3https://test.orcid.org/32020010120241231true51distinctionFake role titleOrg # 1https://test.orcid.org/2020010120241231false0101606 \ No newline at end of file +2024-01-01T12:00:002024-01-01T12:00:00User credited namehttps://orcid.org/8888-8888-8888-88808888-8888-8888-8880orcid.org1Scopus1https://test.orcid.org/1true2ResearcherID2https://test.orcid.org/2true3Other3https://test.orcid.org/3true51employmentFake role title 1Org # 1https://test.orcid.org/12020010120241231false2employmentFake role title 2Org # 2https://test.orcid.org/22020010120241231false3employmentFake role title 3Org # 3https://test.orcid.org/32020010120241231true51distinctionFake role titleOrg # 1https://test.orcid.org/2020010120241231false01016064sometrusted.org61educationFake role titleOrg # 1https://test.orcid.org/2020010120241231false01 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8db2798b0da..102707e2b93 100644 --- a/pom.xml +++ b/pom.xml @@ -918,7 +918,7 @@ the software. org.orcid orcid-model - 3.3.0 + 3.3.1 org.orcid From 436368cea5ddc644a2406a55f5ee1d9aced9c3fe Mon Sep 17 00:00:00 2001 From: github actions Date: Tue, 17 Sep 2024 15:36:53 +0000 Subject: [PATCH 2/4] v2.65.1 changelog update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 676a7bc6c21..6a8aee8d89e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v2.65.1 - 2024-09-17 + +[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.65.0...v2.65.1) + ## v2.65.0 - 2024-09-13 [Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.64.6...v2.65.0) From a321ebf539a795140421ee79987a541f087fd26f Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Tue, 17 Sep 2024 20:14:45 +0300 Subject: [PATCH 3/4] new email domains should have a default profile visibility (#7088) * new email domains should have a default profile visibility * use cache instead of database call --- .../impl/ProfileEmailDomainManagerImpl.java | 41 ++++--------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/ProfileEmailDomainManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/ProfileEmailDomainManagerImpl.java index c2eb6ae2eb9..ecbf129bd04 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/ProfileEmailDomainManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/v3/impl/ProfileEmailDomainManagerImpl.java @@ -1,15 +1,18 @@ package org.orcid.core.manager.v3.impl; +import org.orcid.core.manager.ProfileEntityCacheManager; import org.orcid.core.manager.v3.ProfileEmailDomainManager; import org.orcid.core.manager.v3.read_only.impl.ProfileEmailDomainManagerReadOnlyImpl; import org.orcid.jaxb.model.v3.release.common.Visibility; import org.orcid.persistence.dao.EmailDao; import org.orcid.persistence.dao.EmailDomainDao; +import org.orcid.persistence.dao.ProfileDao; import org.orcid.persistence.dao.ProfileEmailDomainDao; import org.orcid.persistence.jpa.entities.EmailDomainEntity; import org.orcid.persistence.jpa.entities.EmailEntity; import org.orcid.persistence.jpa.entities.ProfileEmailDomainEntity; +import org.orcid.persistence.jpa.entities.ProfileEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.transaction.annotation.Transactional; @@ -34,7 +37,8 @@ public class ProfileEmailDomainManagerImpl extends ProfileEmailDomainManagerRead @Resource(name = "emailDaoReadOnly") protected EmailDao emailDaoReadOnly; - private static final String DEFAULT_DOMAIN_VISIBILITY = Visibility.PRIVATE.toString().toUpperCase(); + @Resource + private ProfileEntityCacheManager profileEntityCacheManager; @Transactional public void updateEmailDomains(String orcid, org.orcid.pojo.ajaxForm.Emails newEmails) { @@ -71,47 +75,16 @@ public void updateEmailDomains(String orcid, org.orcid.pojo.ajaxForm.Emails newE public void processDomain(String orcid, String email) { String domain = email.split("@")[1]; EmailDomainEntity domainInfo = emailDomainDao.findByEmailDomain(domain); - String domainVisibility = DEFAULT_DOMAIN_VISIBILITY; // Check if email is professional if (domainInfo != null && domainInfo.getCategory().equals(EmailDomainEntity.DomainCategory.PROFESSIONAL)) { ProfileEmailDomainEntity existingDomain = profileEmailDomainDao.findByEmailDomain(orcid, domain); // ADD NEW DOMAIN IF ONE DOESN'T EXIST if (existingDomain == null) { // Verify the user doesn't have more emails with that domain - List existingEmails = emailDaoReadOnly.findByOrcid(orcid, System.currentTimeMillis()); - if(existingEmails != null && existingEmails.size() > 1) { - for(EmailEntity emailEntity : existingEmails) { - //If it is not the same emails that is being verified and it is verified - if(!email.equals(emailEntity.getEmail()) && emailEntity.getVerified()) { - try { - String emailEntityDomain = (emailEntity.getEmail() == null) ? null : (email.split("@")[1]); - // If one of the existing emails have the same domain as the email being verified check the visibility and select the less restrictive - if(domain.equals(emailEntityDomain)){ - String entityVisibility = emailEntity.getVisibility(); - domainVisibility = getLessRestrictiveVisibility(domainVisibility, entityVisibility); - } - } catch (Exception e) { - LOGGER.warn("Could not get email domain from email entity " + emailEntity.getEmail(), e); - } - } - } - } + ProfileEntity profile = profileEntityCacheManager.retrieve(orcid); + String domainVisibility = profile.getActivitiesVisibilityDefault(); profileEmailDomainDao.addEmailDomain(orcid, domain, domainVisibility); } } } - - private String getLessRestrictiveVisibility(String a, String b) { - String visibility = DEFAULT_DOMAIN_VISIBILITY; - if(Visibility.PUBLIC.name().equals(a) || Visibility.PUBLIC.name().equals(b)) { - visibility = Visibility.PUBLIC.name(); - } else if(a.equals(b)) { - visibility = a; - } else if(Visibility.PRIVATE.name().equals(a)) { - visibility = b; - } else if(Visibility.PRIVATE.name().equals(b)) { - visibility = a; - } - return visibility; - } } From 85443c56e84d5d9470ef4bf4df2799a375e42dc2 Mon Sep 17 00:00:00 2001 From: github actions Date: Tue, 17 Sep 2024 17:28:47 +0000 Subject: [PATCH 4/4] v2.65.2 changelog update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a8aee8d89e..e1b92466bce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v2.65.2 - 2024-09-17 + +[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.65.1...v2.65.2) + ## v2.65.1 - 2024-09-17 [Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.65.0...v2.65.1)