Search in sources :

Example 1 with Deprecated

use of org.orcid.jaxb.model.v3.dev1.record.Deprecated 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, HttpServletResponse response, @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) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
        return new ModelAndView("error-404");
    }
    try {
        // Check if the profile is deprecated, non claimed or locked
        orcidSecurityManager.checkProfile(orcid);
    } catch (OrcidDeprecatedException | OrcidNotClaimedException | LockedException | DeactivatedException 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(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 if (e instanceof LockedException) {
            mav.addObject("locked", true);
            mav.addObject("isPublicProfile", true);
            displayName = localeManager.resolveMessage("public_profile.deactivated.given_names") + " " + localeManager.resolveMessage("public_profile.deactivated.family_name");
        } else {
            mav.addObject("deactivated", 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;
    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(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 (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 (!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);
    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);
    Map<String, List<Keyword>> groupedKeywords = groupKeywords(publicKeywords);
    mav.addObject("publicGroupedKeywords", groupedKeywords);
    // Fill researcher urls
    ResearcherUrls publicResearcherUrls = researcherUrlManager.getPublicResearcherUrls(orcid);
    Map<String, List<ResearcherUrl>> groupedResearcherUrls = groupResearcherUrls(publicResearcherUrls);
    mav.addObject("publicGroupedResearcherUrls", groupedResearcherUrls);
    // Fill emails
    Emails publicEmails = emailManager.getPublicEmails(orcid);
    Map<String, List<Email>> groupedEmails = groupEmails(publicEmails);
    mav.addObject("publicGroupedEmails", groupedEmails);
    // Fill external identifiers
    PersonExternalIdentifiers publicPersonExternalIdentifiers = externalIdentifierManager.getPublicExternalIdentifiers(orcid);
    Map<String, List<PersonExternalIdentifier>> groupedExternalIdentifiers = groupExternalIdentifiers(publicPersonExternalIdentifiers);
    mav.addObject("publicGroupedPersonExternalIdentifiers", groupedExternalIdentifiers);
    LinkedHashMap<Long, Affiliation> affiliationMap = new LinkedHashMap<>();
    LinkedHashMap<Long, Funding> fundingMap = new LinkedHashMap<>();
    LinkedHashMap<Long, PeerReview> peerReviewMap = new LinkedHashMap<>();
    if (worksPaginator.getPublicWorksCount(orcid) > 0) {
        isProfileEmtpy = false;
    }
    affiliationMap = activityManager.affiliationMap(orcid);
    if (affiliationMap.size() > 0) {
        isProfileEmtpy = false;
    } else {
        mav.addObject("affiliationsEmpty", true);
    }
    fundingMap = activityManager.fundingMap(orcid);
    if (fundingMap.size() > 0)
        isProfileEmtpy = false;
    else {
        mav.addObject("fundingEmpty", true);
    }
    peerReviewMap = activityManager.pubPeerReviewsMap(orcid);
    if (peerReviewMap.size() > 0) {
        isProfileEmtpy = false;
    } else {
        mav.addObject("peerReviewsEmpty", true);
    }
    ObjectMapper mapper = new ObjectMapper();
    try {
        String affiliationIdsJson = mapper.writeValueAsString(affiliationMap.keySet());
        String fundingIdsJson = mapper.writeValueAsString(fundingMap.keySet());
        String peerReviewIdsJson = mapper.writeValueAsString(peerReviewMap.keySet());
        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.v3.dev1.record.Keywords) Address(org.orcid.jaxb.model.v3.dev1.record.Address) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) ModelAndView(org.springframework.web.servlet.ModelAndView) DeactivatedException(org.orcid.core.exception.DeactivatedException) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) LinkedHashMap(java.util.LinkedHashMap) Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) List(java.util.List) ArrayList(java.util.ArrayList) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) LockedException(org.orcid.core.security.aop.LockedException) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) IOException(java.io.IOException) PersonalDetails(org.orcid.jaxb.model.v3.dev1.record.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) DeactivatedException(org.orcid.core.exception.DeactivatedException) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) OrcidNotClaimedException(org.orcid.core.exception.OrcidNotClaimedException) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Deprecated

use of org.orcid.jaxb.model.v3.dev1.record.Deprecated in project ORCID-Source by ORCID.

the class RedirectUri method toRedirectUri.

@Deprecated
public static RedirectUri toRedirectUri(org.orcid.jaxb.model.clientgroup.RedirectUri orcidRedirectUri) {
    RedirectUri redirectUri = new RedirectUri();
    redirectUri.setType(Text.valueOf(orcidRedirectUri.getType().value()));
    redirectUri.setValue(Text.valueOf(orcidRedirectUri.getValue()));
    if (orcidRedirectUri.getScope() != null) {
        List<String> scopes = redirectUri.getScopes();
        for (ScopePathType scope : orcidRedirectUri.getScope()) {
            scopes.add(scope.value());
        }
    }
    redirectUri.setActType(Text.valueOf(orcidRedirectUri.getActType()));
    redirectUri.setGeoArea(Text.valueOf(orcidRedirectUri.getGeoArea()));
    return redirectUri;
}
Also used : ScopePathType(org.orcid.jaxb.model.message.ScopePathType) ClientRedirectUri(org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri)

Example 3 with Deprecated

use of org.orcid.jaxb.model.v3.dev1.record.Deprecated in project ORCID-Source by ORCID.

the class TransientNonEmptyStringTest method testMarshal.

/**
 *    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 *    <common:external-ids xmlns:internal="http://www.orcid.org/ns/internal" xmlns:address="http://www.orcid.org/ns/address" xmlns:email="http://www.orcid.org/ns/email" xmlns:history="http://www.orcid.org/ns/history" xmlns:employment="http://www.orcid.org/ns/employment" xmlns:person="http://www.orcid.org/ns/person" xmlns:education="http://www.orcid.org/ns/education" xmlns:other-name="http://www.orcid.org/ns/other-name" xmlns:personal-details="http://www.orcid.org/ns/personal-details" xmlns:bulk="http://www.orcid.org/ns/bulk" xmlns:common="http://www.orcid.org/ns/common" xmlns:record="http://www.orcid.org/ns/record" xmlns:keyword="http://www.orcid.org/ns/keyword" xmlns:activities="http://www.orcid.org/ns/activities" xmlns:deprecated="http://www.orcid.org/ns/deprecated" xmlns:external-identifier="http://www.orcid.org/ns/external-identifier" xmlns:funding="http://www.orcid.org/ns/funding" xmlns:error="http://www.orcid.org/ns/error" xmlns:preferences="http://www.orcid.org/ns/preferences" xmlns:work="http://www.orcid.org/ns/work" xmlns:researcher-url="http://www.orcid.org/ns/researcher-url" xmlns:peer-review="http://www.orcid.org/ns/peer-review">
 *        <common:external-id>
 *            <common:external-id-type>doi</common:external-id-type>
 *            <common:external-id-value>value</common:external-id-value>
 *            <common:external-id-normalized transient="true">normalized-value</common:external-id-normalized>
 *        </common:external-id>
 *    </common:external-ids>
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Test
public void testMarshal() throws JAXBException, SAXException, IOException {
    ExternalIDs ids = new ExternalIDs();
    ExternalID id = new ExternalID();
    id.setType("doi");
    id.setValue("value");
    id.setNormalized(new TransientNonEmptyString("normalized-value"));
    ids.getExternalIdentifier().add(id);
    JAXBContext context = JAXBContext.newInstance(ExternalIDs.class);
    Marshaller marshaller = context.createMarshaller();
    StringWriter sw = new StringWriter();
    marshaller.marshal(ids, sw);
    assertTrue(sw.toString().contains("<common:external-id-normalized transient=\"true\">normalized-value</common:external-id-normalized>"));
    SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
    Schema schema = factory.newSchema(getClass().getResource("/common_3.0_dev1/common-3.0_dev1.xsd"));
    Validator validator = schema.newValidator();
    validator.validate(new JAXBSource(context, ids));
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) Marshaller(javax.xml.bind.Marshaller) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) StringWriter(java.io.StringWriter) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Schema(javax.xml.validation.Schema) JAXBContext(javax.xml.bind.JAXBContext) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Validator(javax.xml.validation.Validator) JAXBSource(javax.xml.bind.util.JAXBSource) Test(org.junit.Test)

Example 4 with Deprecated

use of org.orcid.jaxb.model.v3.dev1.record.Deprecated in project ORCID-Source by ORCID.

the class ActivitiesGroup method belongsToGroup.

@Deprecated
public /**
 * This method is only used by tests to confirm accuracy of ActivitiesGroupGenerator and should not be used in production
 *
 * @param activity
 * @return
 */
boolean belongsToGroup(GroupableActivity activity) {
    boolean isPeerReview = PeerReviewSummary.class.isAssignableFrom(activity.getClass());
    // If there are no grouping keys
    if (groupKeys == null || groupKeys.isEmpty()) {
        if (isPeerReview) {
            return false;
        } else {
            if (activity.getExternalIdentifiers() == null || activity.getExternalIdentifiers().getExternalIdentifier() == null || activity.getExternalIdentifiers().getExternalIdentifier().isEmpty()) {
                // If the activity doesn't have any external identifier, check if the activity is in the group
                if (activities.contains(activity))
                    return true;
                else
                    return false;
            } else {
                // If any of the activities pass the grouping validation, the activity must belong to other group
                for (GroupAble extId : activity.getExternalIdentifiers().getExternalIdentifier()) {
                    if (extId.isGroupAble())
                        return false;
                }
                // If none of the activities pass the groupings validation, so, lets check if the group actually contains the activity
                if (activities.contains(activity))
                    return true;
                else
                    return false;
            }
        }
    }
    if (isPeerReview) {
        PeerReviewSummary peerReviewSummary = (PeerReviewSummary) activity;
        PeerReviewGroupKey prgk = new PeerReviewGroupKey();
        prgk.setGroupId(peerReviewSummary.getGroupId());
        if (prgk.isGroupAble()) {
            if (groupKeys.contains(prgk)) {
                return true;
            }
        }
    } else {
        // Check existing keys
        ExternalIdentifiersContainer container = activity.getExternalIdentifiers();
        if (container != null) {
            List<? extends GroupAble> extIds = (List<? extends GroupAble>) container.getExternalIdentifier();
            for (GroupAble extId : extIds) {
                // First check keys restrictions
                if (extId.isGroupAble()) {
                    // If any of the keys already exists on this group, return true
                    if (containsKey(extId))
                        return true;
                }
            }
        }
    }
    return false;
}
Also used : PeerReviewGroupKey(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroupKey) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) ExternalIdentifiersContainer(org.orcid.jaxb.model.v3.dev1.record.ExternalIdentifiersContainer) List(java.util.List) GroupAble(org.orcid.jaxb.model.v3.dev1.record.GroupAble)

Example 5 with Deprecated

use of org.orcid.jaxb.model.v3.dev1.record.Deprecated in project ORCID-Source by ORCID.

the class Contributor method valueOf.

@Deprecated
public static Contributor valueOf(org.orcid.jaxb.model.message.FundingContributor contributor) {
    Contributor c = new Contributor();
    if (contributor != null) {
        if (contributor.getContributorAttributes() != null) {
            contributor.getContributorAttributes();
            if (contributor.getContributorAttributes().getContributorRole() != null)
                c.setContributorRole(Text.valueOf(contributor.getContributorAttributes().getContributorRole().value()));
        }
        if (contributor.getContributorEmail() != null)
            c.setEmail(Text.valueOf(contributor.getContributorEmail().getValue()));
        if (contributor.getContributorOrcid() != null) {
            c.setOrcid(Text.valueOf(contributor.getContributorOrcid().getPath()));
            c.setUri(Text.valueOf(contributor.getContributorOrcid().getUri()));
        }
        if (contributor.getCreditName() != null) {
            c.setCreditName(Text.valueOf(contributor.getCreditName().getContent()));
        }
    }
    return c;
}
Also used : FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor)

Aggregations

IOException (java.io.IOException)2 List (java.util.List)2 ClientRedirectUri (org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri)2 Address (org.orcid.jaxb.model.v3.dev1.record.Address)2 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)2 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)2 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringWriter (java.io.StringWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 JAXBSource (javax.xml.bind.util.JAXBSource)1 Schema (javax.xml.validation.Schema)1