Search in sources :

Example 1 with Affiliation

use of org.orcid.jaxb.model.record_v2.Affiliation in project ORCID-Source by ORCID.

the class OrcidInfo method publicPreview.

@RequestMapping(value = { "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}", "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/print" })
public ModelAndView publicPreview(HttpServletRequest request, @RequestParam(value = "page", defaultValue = "1") int pageNo, @RequestParam(value = "v", defaultValue = "0") int v, @RequestParam(value = "maxResults", defaultValue = "15") int maxResults, @PathVariable("orcid") String orcid) {
    ProfileEntity profile = null;
    try {
        profile = profileEntityCacheManager.retrieve(orcid);
    } catch (Exception e) {
        return new ModelAndView("error-404");
    }
    try {
        // Check if the profile is deprecated, non claimed or locked
        orcidSecurityManager.checkProfile(orcid);
    } catch (OrcidDeprecatedException | OrcidNotClaimedException | LockedException e) {
        ModelAndView mav = new ModelAndView("public_profile_unavailable");
        mav.addObject("effectiveUserOrcid", orcid);
        String displayName = "";
        if (e instanceof OrcidDeprecatedException) {
            PersonalDetails publicPersonalDetails = personalDetailsManager.getPublicPersonalDetails(orcid);
            if (publicPersonalDetails.getName() != null) {
                Name name = publicPersonalDetails.getName();
                if (name.getVisibility().equals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC)) {
                    if (name.getCreditName() != null && !PojoUtil.isEmpty(name.getCreditName().getContent())) {
                        displayName = name.getCreditName().getContent();
                    } else {
                        if (name.getGivenNames() != null && !PojoUtil.isEmpty(name.getGivenNames().getContent())) {
                            displayName = name.getGivenNames().getContent() + " ";
                        }
                        if (name.getFamilyName() != null && !PojoUtil.isEmpty(name.getFamilyName().getContent())) {
                            displayName += name.getFamilyName().getContent();
                        }
                    }
                }
            }
            mav.addObject("deprecated", true);
            mav.addObject("primaryRecord", profile.getPrimaryRecord().getId());
        } else if (e instanceof OrcidNotClaimedException) {
            displayName = localeManager.resolveMessage("orcid.reserved_for_claim");
        } else {
            mav.addObject("locked", true);
            mav.addObject("isPublicProfile", true);
            displayName = localeManager.resolveMessage("public_profile.deactivated.given_names") + " " + localeManager.resolveMessage("public_profile.deactivated.family_name");
        }
        if (!PojoUtil.isEmpty(displayName)) {
            mav.addObject("title", getMessage("layout.public-layout.title", displayName, orcid));
            mav.addObject("displayName", displayName);
        }
        return mav;
    }
    long lastModifiedTime = getLastModifiedTime(orcid);
    ModelAndView mav = null;
    if (request.getRequestURI().contains("/print")) {
        mav = new ModelAndView("print_public_record");
        mav.addObject("hideUserVoiceScript", true);
    } else {
        mav = new ModelAndView("public_profile_v3");
    }
    mav.addObject("isPublicProfile", true);
    mav.addObject("effectiveUserOrcid", orcid);
    mav.addObject("lastModifiedTime", lastModifiedTime);
    boolean isProfileEmtpy = true;
    HttpSession session = request.getSession(false);
    if (session != null) {
        session.removeAttribute(PUBLIC_WORKS_RESULTS_ATTRIBUTE);
    }
    PersonalDetails publicPersonalDetails = personalDetailsManager.getPublicPersonalDetails(orcid);
    // Fill personal details
    if (publicPersonalDetails != null) {
        // Get display name
        String displayName = "";
        if (publicPersonalDetails.getName() != null) {
            Name name = publicPersonalDetails.getName();
            if (name.getVisibility().equals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC)) {
                if (name.getCreditName() != null && !PojoUtil.isEmpty(name.getCreditName().getContent())) {
                    displayName = name.getCreditName().getContent();
                } else {
                    if (name.getGivenNames() != null && !PojoUtil.isEmpty(name.getGivenNames().getContent())) {
                        displayName = name.getGivenNames().getContent() + " ";
                    }
                    if (name.getFamilyName() != null && !PojoUtil.isEmpty(name.getFamilyName().getContent())) {
                        displayName += name.getFamilyName().getContent();
                    }
                }
            }
        }
        if (!PojoUtil.isEmpty(displayName)) {
            // <Published Name> (<ORCID iD>) - ORCID | Connecting Research
            // and Researchers
            mav.addObject("title", getMessage("layout.public-layout.title", displayName.trim(), orcid));
            mav.addObject("displayName", displayName);
        }
        // Get biography
        if (publicPersonalDetails.getBiography() != null) {
            Biography bio = publicPersonalDetails.getBiography();
            if (org.orcid.jaxb.model.common_v2.Visibility.PUBLIC.equals(bio.getVisibility()) && !PojoUtil.isEmpty(bio.getContent())) {
                isProfileEmtpy = false;
                mav.addObject("biography", bio);
            }
        }
        // Fill other names
        OtherNames publicOtherNames = publicPersonalDetails.getOtherNames();
        if (publicOtherNames != null && publicOtherNames.getOtherNames() != null) {
            Iterator<OtherName> it = publicOtherNames.getOtherNames().iterator();
            while (it.hasNext()) {
                OtherName otherName = it.next();
                if (!org.orcid.jaxb.model.common_v2.Visibility.PUBLIC.equals(otherName.getVisibility())) {
                    it.remove();
                }
            }
        }
        Map<String, List<OtherName>> groupedOtherNames = groupOtherNames(publicOtherNames);
        mav.addObject("publicGroupedOtherNames", groupedOtherNames);
    }
    // Fill biography elements
    // Fill country
    Addresses publicAddresses = addressManager.getPublicAddresses(orcid, lastModifiedTime);
    Map<String, String> countryNames = new HashMap<String, String>();
    if (publicAddresses != null && publicAddresses.getAddress() != null) {
        Address publicAddress = null;
        // The primary address will be the one with the lowest display index
        for (Address address : publicAddresses.getAddress()) {
            countryNames.put(address.getCountry().getValue().value(), getcountryName(address.getCountry().getValue().value()));
            if (publicAddress == null) {
                publicAddress = address;
            }
        }
        if (publicAddress != null) {
            mav.addObject("publicAddress", publicAddress);
            mav.addObject("countryNames", countryNames);
            Map<String, List<Address>> groupedAddresses = groupAddresses(publicAddresses);
            mav.addObject("publicGroupedAddresses", groupedAddresses);
        }
    }
    // Fill keywords
    Keywords publicKeywords = keywordManager.getPublicKeywords(orcid, lastModifiedTime);
    Map<String, List<Keyword>> groupedKeywords = groupKeywords(publicKeywords);
    mav.addObject("publicGroupedKeywords", groupedKeywords);
    // Fill researcher urls
    ResearcherUrls publicResearcherUrls = researcherUrlManager.getPublicResearcherUrls(orcid, lastModifiedTime);
    Map<String, List<ResearcherUrl>> groupedResearcherUrls = groupResearcherUrls(publicResearcherUrls);
    mav.addObject("publicGroupedResearcherUrls", groupedResearcherUrls);
    // Fill emails
    Emails publicEmails = emailManager.getPublicEmails(orcid, lastModifiedTime);
    Map<String, List<Email>> groupedEmails = groupEmails(publicEmails);
    mav.addObject("publicGroupedEmails", groupedEmails);
    // Fill external identifiers
    PersonExternalIdentifiers publicPersonExternalIdentifiers = externalIdentifierManager.getPublicExternalIdentifiers(orcid, lastModifiedTime);
    Map<String, List<PersonExternalIdentifier>> groupedExternalIdentifiers = groupExternalIdentifiers(publicPersonExternalIdentifiers);
    mav.addObject("publicGroupedPersonExternalIdentifiers", groupedExternalIdentifiers);
    LinkedHashMap<Long, WorkForm> minimizedWorksMap = new LinkedHashMap<>();
    LinkedHashMap<Long, Affiliation> affiliationMap = new LinkedHashMap<>();
    LinkedHashMap<Long, Funding> fundingMap = new LinkedHashMap<>();
    LinkedHashMap<Long, PeerReview> peerReviewMap = new LinkedHashMap<>();
    minimizedWorksMap = activityCacheManager.pubMinWorksMap(orcid, lastModifiedTime);
    if (minimizedWorksMap.size() > 0) {
        isProfileEmtpy = false;
    } else {
        mav.addObject("worksEmpty", true);
    }
    affiliationMap = affiliationMap(orcid, lastModifiedTime);
    if (affiliationMap.size() > 0) {
        isProfileEmtpy = false;
    } else {
        mav.addObject("affiliationsEmpty", true);
    }
    fundingMap = fundingMap(orcid, lastModifiedTime);
    if (fundingMap.size() > 0)
        isProfileEmtpy = false;
    else {
        mav.addObject("fundingEmpty", true);
    }
    peerReviewMap = peerReviewMap(orcid, lastModifiedTime);
    if (peerReviewMap.size() > 0) {
        isProfileEmtpy = false;
    } else {
        mav.addObject("peerReviewsEmpty", true);
    }
    ObjectMapper mapper = new ObjectMapper();
    try {
        String worksIdsJson = mapper.writeValueAsString(minimizedWorksMap.keySet());
        String affiliationIdsJson = mapper.writeValueAsString(affiliationMap.keySet());
        String fundingIdsJson = mapper.writeValueAsString(fundingMap.keySet());
        String peerReviewIdsJson = mapper.writeValueAsString(peerReviewMap.keySet());
        mav.addObject("workIdsJson", StringEscapeUtils.escapeEcmaScript(worksIdsJson));
        mav.addObject("affiliationIdsJson", StringEscapeUtils.escapeEcmaScript(affiliationIdsJson));
        mav.addObject("fundingIdsJson", StringEscapeUtils.escapeEcmaScript(fundingIdsJson));
        mav.addObject("peerReviewIdsJson", StringEscapeUtils.escapeEcmaScript(peerReviewIdsJson));
        mav.addObject("isProfileEmpty", isProfileEmtpy);
    } catch (JsonGenerationException e) {
        e.printStackTrace();
    } catch (JsonMappingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (!profile.isReviewed()) {
        if (isProfileValidForIndex(profile)) {
            int countTokens = orcidOauth2TokenService.findCountByUserName(orcid, lastModifiedTime);
            if (!profile.isAccountNonLocked() || countTokens == 0 || (!CreationMethod.WEBSITE.value().equals(profile.getCreationMethod()) && !CreationMethod.DIRECT.value().equals(profile.getCreationMethod()))) {
                mav.addObject("noIndex", true);
            }
        } else {
            mav.addObject("noIndex", true);
        }
    }
    return mav;
}
Also used : Keywords(org.orcid.jaxb.model.record_v2.Keywords) Address(org.orcid.jaxb.model.record_v2.Address) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Funding(org.orcid.jaxb.model.record_v2.Funding) ModelAndView(org.springframework.web.servlet.ModelAndView) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) LinkedHashMap(java.util.LinkedHashMap) Addresses(org.orcid.jaxb.model.record_v2.Addresses) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) List(java.util.List) ArrayList(java.util.ArrayList) Emails(org.orcid.jaxb.model.record_v2.Emails) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Affiliation(org.orcid.jaxb.model.record_v2.Affiliation) LockedException(org.orcid.core.security.aop.LockedException) HttpSession(javax.servlet.http.HttpSession) OtherName(org.orcid.jaxb.model.record_v2.OtherName) IOException(java.io.IOException) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrcidNotClaimedException(org.orcid.core.exception.OrcidNotClaimedException) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) LockedException(org.orcid.core.security.aop.LockedException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) IOException(java.io.IOException) WorkForm(org.orcid.pojo.ajaxForm.WorkForm) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) OrcidNotClaimedException(org.orcid.core.exception.OrcidNotClaimedException) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Affiliation

use of org.orcid.jaxb.model.record_v2.Affiliation in project ORCID-Source by ORCID.

the class ProfileEntityManagerImpl method deprecateProfile.

/**
     * Deprecates a profile
     * 
     * @param deprecatedProfile
     *            The profile that want to be deprecated
     * @param primaryProfile
     *            The primary profile for the deprecated profile
     * @return true if the account was successfully deprecated, false otherwise
     */
@Override
@Transactional
public boolean deprecateProfile(String deprecatedOrcid, String primaryOrcid) {
    boolean wasDeprecated = profileDao.deprecateProfile(deprecatedOrcid, primaryOrcid);
    // If it was successfully deprecated
    if (wasDeprecated) {
        LOGGER.info("Account {} was deprecated to primary account: {}", deprecatedOrcid, primaryOrcid);
        ProfileEntity deprecated = profileDao.find(deprecatedOrcid);
        // Remove works
        workManager.removeAllWorks(deprecatedOrcid);
        // Remove funding
        if (deprecated.getProfileFunding() != null) {
            for (ProfileFundingEntity funding : deprecated.getProfileFunding()) {
                fundingManager.removeProfileFunding(funding.getProfile().getId(), funding.getId());
            }
        }
        // Remove affiliations
        if (deprecated.getOrgAffiliationRelations() != null) {
            for (OrgAffiliationRelationEntity affiliation : deprecated.getOrgAffiliationRelations()) {
                orgAffiliationRelationDao.removeOrgAffiliationRelation(affiliation.getProfile().getId(), affiliation.getId());
            }
        }
        // Remove external identifiers
        if (deprecated.getExternalIdentifiers() != null) {
            for (ExternalIdentifierEntity externalIdentifier : deprecated.getExternalIdentifiers()) {
                externalIdentifierManager.deleteExternalIdentifier(deprecated.getId(), externalIdentifier.getId(), false);
            }
        }
        // Remove researcher urls
        if (deprecated.getResearcherUrls() != null) {
            for (ResearcherUrlEntity rUrl : deprecated.getResearcherUrls()) {
                researcherUrlManager.deleteResearcherUrl(deprecatedOrcid, rUrl.getId(), false);
            }
        }
        // Remove other names
        if (deprecated.getOtherNames() != null) {
            for (OtherNameEntity otherName : deprecated.getOtherNames()) {
                otherNamesManager.deleteOtherName(deprecatedOrcid, otherName.getId(), false);
            }
        }
        // Remove keywords
        if (deprecated.getKeywords() != null) {
            for (ProfileKeywordEntity keyword : deprecated.getKeywords()) {
                profileKeywordManager.deleteKeyword(deprecatedOrcid, keyword.getId(), false);
            }
        }
        //Remove biography                        
        if (biographyManager.exists(deprecatedOrcid)) {
            Biography deprecatedBio = new Biography();
            deprecatedBio.setContent(null);
            deprecatedBio.setVisibility(Visibility.PRIVATE);
            biographyManager.updateBiography(deprecatedOrcid, deprecatedBio);
        }
        //Set the deactivated names
        if (recordNameManager.exists(deprecatedOrcid)) {
            Name name = new Name();
            name.setCreditName(new CreditName());
            name.setGivenNames(new GivenNames("Given Names Deactivated"));
            name.setFamilyName(new FamilyName("Family Name Deactivated"));
            name.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
            name.setPath(deprecatedOrcid);
            recordNameManager.updateRecordName(deprecatedOrcid, name);
        }
        userConnectionDao.deleteByOrcid(deprecatedOrcid);
        // Move all emails to the primary email
        Set<EmailEntity> deprecatedAccountEmails = deprecated.getEmails();
        if (deprecatedAccountEmails != null) {
            // For each email in the deprecated profile                            
            for (EmailEntity email : deprecatedAccountEmails) {
                // Delete each email from the deprecated
                // profile
                LOGGER.info("About to move email {} from profile {} to profile {}", new Object[] { email.getId(), deprecatedOrcid, primaryOrcid });
                emailManager.moveEmailToOtherAccount(email.getId(), deprecatedOrcid, primaryOrcid);
            }
        }
        return true;
    }
    return false;
}
Also used : ProfileKeywordEntity(org.orcid.persistence.jpa.entities.ProfileKeywordEntity) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity) ExternalIdentifierEntity(org.orcid.persistence.jpa.entities.ExternalIdentifierEntity) CreditName(org.orcid.jaxb.model.record_v2.CreditName) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) CreditName(org.orcid.jaxb.model.record_v2.CreditName) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) Name(org.orcid.jaxb.model.record_v2.Name) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherNameEntity(org.orcid.persistence.jpa.entities.OtherNameEntity) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Affiliation

use of org.orcid.jaxb.model.record_v2.Affiliation in project ORCID-Source by ORCID.

the class AffiliationsManagerReadOnlyImpl method getAffiliations.

@Override
public List<Affiliation> getAffiliations(String orcid) {
    List<OrgAffiliationRelationEntity> affiliations = orgAffiliationRelationDao.getByUser(orcid);
    List<Affiliation> result = new ArrayList<Affiliation>();
    if (affiliations != null) {
        for (OrgAffiliationRelationEntity affiliation : affiliations) {
            if (AffiliationType.EDUCATION.equals(affiliation.getAffiliationType())) {
                result.add(jpaJaxbEducationAdapter.toEducation(affiliation));
            } else {
                result.add(jpaJaxbEmploymentAdapter.toEmployment(affiliation));
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Affiliation(org.orcid.jaxb.model.record_v2.Affiliation)

Example 4 with Affiliation

use of org.orcid.jaxb.model.record_v2.Affiliation in project ORCID-Source by ORCID.

the class OrcidRecordToSolrDocumentTest method testOrgIDAndGrantNumber.

@Test
public void testOrgIDAndGrantNumber() throws JAXBException {
    Record record = getRecord("/v20record.xml");
    OrcidRecordToSolrDocument v20 = new OrcidRecordToSolrDocument(false);
    OrcidSolrDocument v20Doc = v20.convert(record, new ArrayList<Funding>());
    Assert.assertTrue(v20Doc.getOrganisationIds().containsKey("ringgold-org-id"));
    Assert.assertTrue(v20Doc.getOrganisationIds().get("ringgold-org-id").contains("5488"));
    Assert.assertTrue(v20Doc.getOrganisationIds().get("ringgold-org-id").contains("4925"));
    Assert.assertTrue(v20Doc.getOrganisationNames().get("affiliation-org-name").contains("Open University"));
    Assert.assertTrue(v20Doc.getOrganisationNames().get("affiliation-org-name").contains("British Library"));
/*
        Assert.assertTrue(v20Doc.getOrganisationNames().get("funding-org-name").contains("THOR - Technical and Human Infrastructure for Open Research"));
        Assert.assertTrue(v20Doc.getGrantNumbers().contains("H2020-EU.1.4.1.3."));
        */
}
Also used : OrcidRecordToSolrDocument(org.orcid.listener.solr.OrcidRecordToSolrDocument) Funding(org.orcid.jaxb.model.record_v2.Funding) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) Record(org.orcid.jaxb.model.record_v2.Record) Test(org.junit.Test)

Example 5 with Affiliation

use of org.orcid.jaxb.model.record_v2.Affiliation in project ORCID-Source by ORCID.

the class ActivityCacheManagerImpl method affiliationMap.

@Cacheable(value = "pub-affiliation-maps", key = "#orcid.concat('-').concat(#lastModified)")
public LinkedHashMap<Long, Affiliation> affiliationMap(String orcid, long lastModified) {
    LinkedHashMap<Long, Affiliation> affiliationMap = new LinkedHashMap<>();
    List<Affiliation> affiliations = affiliationsManager.getAffiliations(orcid);
    for (Affiliation affiliation : affiliations) {
        if (Visibility.PUBLIC.equals(affiliation.getVisibility())) {
            affiliationMap.put(affiliation.getPutCode(), affiliation);
        }
    }
    return affiliationMap;
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Affiliation(org.orcid.jaxb.model.record_v2.Affiliation) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

Affiliation (org.orcid.jaxb.model.record_v2.Affiliation)4 LinkedHashMap (java.util.LinkedHashMap)3 Name (org.orcid.jaxb.model.record_v2.Name)3 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)3 ArrayList (java.util.ArrayList)2 Biography (org.orcid.jaxb.model.record_v2.Biography)2 FamilyName (org.orcid.jaxb.model.record_v2.FamilyName)2 Funding (org.orcid.jaxb.model.record_v2.Funding)2 GivenNames (org.orcid.jaxb.model.record_v2.GivenNames)2 EmailEntity (org.orcid.persistence.jpa.entities.EmailEntity)2 ExternalIdentifierEntity (org.orcid.persistence.jpa.entities.ExternalIdentifierEntity)2 OtherNameEntity (org.orcid.persistence.jpa.entities.OtherNameEntity)2 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)2 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)2 ProfileKeywordEntity (org.orcid.persistence.jpa.entities.ProfileKeywordEntity)2 ResearcherUrlEntity (org.orcid.persistence.jpa.entities.ResearcherUrlEntity)2 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1