Search in sources :

Example 26 with Name

use of org.orcid.jaxb.model.record_rc3.Name 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 27 with Name

use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.

the class OrcidSecurityManagerTestBase method createName.

protected Name createName(Visibility v) {
    Name name = new Name();
    name.setVisibility(v);
    name.setCreditName(new CreditName("Credit Name"));
    name.setFamilyName(new FamilyName("Family Name"));
    name.setGivenNames(new GivenNames("Given Names"));
    return name;
}
Also used : FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) CreditName(org.orcid.jaxb.model.common_v2.CreditName) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) CreditName(org.orcid.jaxb.model.common_v2.CreditName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name)

Example 28 with Name

use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.

the class RecordTest method testViewRecordFromMemberAPI.

@Test
public void testViewRecordFromMemberAPI() throws InterruptedException, JSONException {
    String accessToken = getAccessToken();
    assertNotNull(accessToken);
    ClientResponse response = memberV2ApiClient.viewRecord(getUser1OrcidId(), accessToken);
    assertNotNull(response);
    assertEquals("invalid " + response, 200, response.getStatus());
    Record record = response.getEntity(Record.class);
    assertNotNull(record);
    assertNotNull(record.getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
    //Check the visibility of every activity that exists
    if (record.getActivitiesSummary() != null) {
        //Educations
        if (record.getActivitiesSummary().getEducations() != null) {
            Educations e = record.getActivitiesSummary().getEducations();
            if (e.getSummaries() != null) {
                for (EducationSummary s : e.getSummaries()) {
                    assertNotNull(s.getSource());
                    assertNotNull(s.getVisibility());
                    Visibility v = s.getVisibility();
                    //If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Employments
        if (record.getActivitiesSummary().getEmployments() != null) {
            Employments e = record.getActivitiesSummary().getEmployments();
            if (e.getSummaries() != null) {
                for (EmploymentSummary s : e.getSummaries()) {
                    assertNotNull(s.getSource());
                    assertNotNull(s.getVisibility());
                    Visibility v = s.getVisibility();
                    //If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Fundings
        if (record.getActivitiesSummary().getFundings() != null) {
            Fundings f = record.getActivitiesSummary().getFundings();
            List<FundingGroup> groups = f.getFundingGroup();
            if (groups != null) {
                for (FundingGroup fGroup : groups) {
                    List<FundingSummary> summaries = fGroup.getFundingSummary();
                    if (summaries != null) {
                        for (FundingSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            //If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
        //PeerReviews
        if (record.getActivitiesSummary().getPeerReviews() != null) {
            PeerReviews p = record.getActivitiesSummary().getPeerReviews();
            List<PeerReviewGroup> groups = p.getPeerReviewGroup();
            if (groups != null) {
                for (PeerReviewGroup pGroup : groups) {
                    List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
                    if (summaries != null) {
                        for (PeerReviewSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            //If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
        //Works
        if (record.getActivitiesSummary().getWorks() != null) {
            Works w = record.getActivitiesSummary().getWorks();
            List<WorkGroup> groups = w.getWorkGroup();
            if (groups != null) {
                for (WorkGroup wGroup : groups) {
                    List<WorkSummary> summaries = wGroup.getWorkSummary();
                    if (summaries != null) {
                        for (WorkSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            //If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
    }
    //Check the visibility of every biography elements that exists
    if (record.getPerson() != null) {
        //Address
        if (record.getPerson().getAddresses() != null) {
            Addresses addresses = record.getPerson().getAddresses();
            List<Address> list = addresses.getAddress();
            if (list != null) {
                for (Address o : list) {
                    assertNotNull(o.getSource());
                    assertNotNull(o.getVisibility());
                    Visibility v = o.getVisibility();
                    //If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), o.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Biography
        if (record.getPerson().getBiography() != null) {
            Biography b = record.getPerson().getBiography();
            if (b != null) {
                assertNotNull(b.getVisibility());
                if (Visibility.PRIVATE.equals(b.getVisibility())) {
                    fail("Visibility is private");
                }
            }
        }
        //Emails
        if (record.getPerson().getEmails() != null) {
            Emails emails = record.getPerson().getEmails();
            List<Email> list = emails.getEmails();
            if (list != null) {
                for (Email e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        fail("Email " + e.getEmail() + " is private");
                    }
                }
            }
        }
        //External identifiers
        if (record.getPerson().getExternalIdentifiers() != null) {
            PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
            List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
            if (list != null) {
                for (PersonExternalIdentifier e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Keywords
        if (record.getPerson().getKeywords() != null) {
            Keywords keywords = record.getPerson().getKeywords();
            List<Keyword> list = keywords.getKeywords();
            if (list != null) {
                for (Keyword e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Name
        if (record.getPerson().getName() != null) {
            Name name = record.getPerson().getName();
            if (Visibility.PRIVATE.equals(name.getVisibility())) {
                fail("Name is private");
            }
        }
        //Other names
        if (record.getPerson().getOtherNames() != null) {
            OtherNames otherNames = record.getPerson().getOtherNames();
            List<OtherName> list = otherNames.getOtherNames();
            if (list != null) {
                for (OtherName e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        //Researcher urls
        if (record.getPerson().getResearcherUrls() != null) {
            ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
            List<ResearcherUrl> list = rUrls.getResearcherUrls();
            if (list != null) {
                for (ResearcherUrl e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.record_v2.Email) Keywords(org.orcid.jaxb.model.record_v2.Keywords) Address(org.orcid.jaxb.model.record_v2.Address) Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Addresses(org.orcid.jaxb.model.record_v2.Addresses) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Record(org.orcid.jaxb.model.record_v2.Record) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails) Works(org.orcid.jaxb.model.record.summary_v2.Works) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Test(org.junit.Test)

Example 29 with Name

use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method testUnmarshallRecord.

@Test
public void testUnmarshallRecord() throws SAXException, URISyntaxException {
    Record record = (Record) unmarshallFromPath("/record_2.0_rc2/samples/record-2.0_rc2.xml", Record.class, "/record_2.0_rc2/record-2.0_rc2.xsd");
    assertNotNull(record);
    //Check activities
    assertNotNull(record.getActivitiesSummary());
    ActivitiesSummary activities = record.getActivitiesSummary();
    assertNotNull(activities.getLastModifiedDate());
    assertNotNull(activities.getEducations());
    Educations educations = activities.getEducations();
    assertNotNull(educations.getLastModifiedDate());
    assertEquals(1, educations.getSummaries().size());
    EducationSummary education = educations.getSummaries().get(0);
    assertEquals(Long.valueOf(0), education.getPutCode());
    assertEquals(Visibility.PRIVATE, education.getVisibility());
    assertEquals("education:department-name", education.getDepartmentName());
    assertEquals("education:role-title", education.getRoleTitle());
    assertNotNull(education.getEndDate());
    assertEquals("02", education.getEndDate().getDay().getValue());
    assertEquals("02", education.getEndDate().getMonth().getValue());
    assertEquals("1848", education.getEndDate().getYear().getValue());
    assertNotNull(education.getStartDate());
    assertEquals("02", education.getStartDate().getDay().getValue());
    assertEquals("02", education.getStartDate().getMonth().getValue());
    assertEquals("1848", education.getStartDate().getYear().getValue());
    assertNotNull(education.getOrganization());
    assertEquals("common:name", education.getOrganization().getName());
    assertEquals("common:city", education.getOrganization().getAddress().getCity());
    assertEquals("common:region", education.getOrganization().getAddress().getRegion());
    assertEquals(Iso3166Country.AF, education.getOrganization().getAddress().getCountry());
    assertNotNull(activities.getEmployments());
    Employments employments = activities.getEmployments();
    assertNotNull(employments.getLastModifiedDate());
    assertEquals(1, employments.getSummaries().size());
    EmploymentSummary employment = employments.getSummaries().get(0);
    assertEquals(Long.valueOf(0), employment.getPutCode());
    assertEquals(Visibility.PRIVATE, employment.getVisibility());
    assertEquals("employment:department-name", employment.getDepartmentName());
    assertEquals("employment:role-title", employment.getRoleTitle());
    assertNotNull(employment.getEndDate());
    assertEquals("02", employment.getEndDate().getDay().getValue());
    assertEquals("02", employment.getEndDate().getMonth().getValue());
    assertEquals("1848", employment.getEndDate().getYear().getValue());
    assertNotNull(employment.getStartDate());
    assertEquals("02", employment.getStartDate().getDay().getValue());
    assertEquals("02", employment.getStartDate().getMonth().getValue());
    assertEquals("1848", employment.getStartDate().getYear().getValue());
    assertNotNull(employment.getOrganization());
    assertEquals("common:name", employment.getOrganization().getName());
    assertEquals("common:city", employment.getOrganization().getAddress().getCity());
    assertEquals("common:region", employment.getOrganization().getAddress().getRegion());
    assertEquals(Iso3166Country.AF, employment.getOrganization().getAddress().getCountry());
    assertNotNull(activities.getFundings());
    Fundings fundings = activities.getFundings();
    assertNotNull(fundings.getLastModifiedDate());
    assertEquals(1, fundings.getFundingGroup().size());
    assertNotNull(fundings.getFundingGroup().get(0).getLastModifiedDate());
    assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
    assertEquals(1, fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals("grant_number", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
    FundingSummary funding = fundings.getFundingGroup().get(0).getFundingSummary().get(0);
    assertEquals(Long.valueOf(0), funding.getPutCode());
    assertEquals(Visibility.PRIVATE, funding.getVisibility());
    assertNotNull(funding.getTitle());
    assertEquals("common:title", funding.getTitle().getTitle().getContent());
    assertEquals("common:translated-title", funding.getTitle().getTranslatedTitle().getContent());
    assertEquals("en", funding.getTitle().getTranslatedTitle().getLanguageCode());
    assertNotNull(funding.getExternalIdentifiers());
    assertEquals(1, funding.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(Relationship.SELF, funding.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("grant_number", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("http://tempuri.org", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
    assertEquals("external-id-value", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertNotNull(funding.getEndDate());
    assertEquals("02", funding.getEndDate().getDay().getValue());
    assertEquals("02", funding.getEndDate().getMonth().getValue());
    assertEquals("1848", funding.getEndDate().getYear().getValue());
    assertNotNull(funding.getStartDate());
    assertEquals("02", funding.getStartDate().getDay().getValue());
    assertEquals("02", funding.getStartDate().getMonth().getValue());
    assertEquals("1848", funding.getStartDate().getYear().getValue());
    assertNotNull(activities.getPeerReviews());
    assertNotNull(activities.getPeerReviews().getLastModifiedDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getUrl());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getDay());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getMonth());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getYear());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCreatedDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCreatedDate().getValue());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getDisplayIndex());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getUrl());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getGroupId());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getLastModifiedDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getCity());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getCountry());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getRegion());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getName());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getSource());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getSource().retrieveSourcePath());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
    assertNotNull(activities.getWorks());
    Works works = activities.getWorks();
    assertNotNull(works.getLastModifiedDate());
    assertEquals(1, works.getWorkGroup().size());
    assertNotNull(works.getWorkGroup().get(0).getIdentifiers());
    assertEquals(1, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals(Relationship.PART_OF, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("agr", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("http://orcid.org", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
    assertEquals("external-id-value", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(1, works.getWorkGroup().get(0).getWorkSummary().size());
    WorkSummary work = works.getWorkGroup().get(0).getWorkSummary().get(0);
    assertEquals(Long.valueOf(0), work.getPutCode());
    assertEquals(Visibility.PRIVATE, work.getVisibility());
    assertNotNull(work.getTitle());
    assertEquals("common:title", work.getTitle().getTitle().getContent());
    assertEquals("common:translated-title", work.getTitle().getTranslatedTitle().getContent());
    assertEquals("en", work.getTitle().getTranslatedTitle().getLanguageCode());
    assertNotNull(work.getExternalIdentifiers());
    assertEquals(1, work.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(Relationship.SELF, work.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("agr", work.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("http://tempuri.org", work.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
    assertEquals("external-id-value", work.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(WorkType.ARTISTIC_PERFORMANCE, work.getType());
    assertNotNull(work.getPublicationDate());
    assertEquals("02", work.getPublicationDate().getDay().getValue());
    assertEquals("02", work.getPublicationDate().getMonth().getValue());
    assertEquals("1848", work.getPublicationDate().getYear().getValue());
    //Check biography
    Person person = record.getPerson();
    assertNotNull(person);
    assertNotNull(person.getLastModifiedDate().getValue());
    assertNotNull(person.getAddresses());
    assertNotNull(person.getAddresses().getLastModifiedDate());
    assertEquals(1, person.getAddresses().getAddress().size());
    Address address = person.getAddresses().getAddress().get(0);
    assertEquals(Long.valueOf(1), address.getPutCode());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Long.valueOf(0), address.getDisplayIndex());
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(person.getBiography());
    assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
    assertEquals("biography", person.getBiography().getContent());
    assertNotNull(person.getEmails());
    assertTrue(StringUtils.isNotBlank(person.getEmails().getPath()));
    assertNotNull(person.getEmails().getLastModifiedDate());
    assertNotNull(person.getEmails().getEmails());
    assertEquals(1, person.getEmails().getEmails().size());
    Email email = person.getEmails().getEmails().get(0);
    assertNotNull(email.getCreatedDate().getValue());
    assertEquals("user1@email.com", email.getEmail());
    assertNotNull(email.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(0), email.getPutCode());
    assertNotNull(email.getSource());
    assertEquals(Visibility.PUBLIC, email.getVisibility());
    assertNotNull(person.getExternalIdentifiers());
    assertTrue(StringUtils.isNotBlank(person.getExternalIdentifiers().getPath()));
    assertNotNull(person.getExternalIdentifiers().getLastModifiedDate().getValue());
    assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
    assertNotNull(extId.getCreatedDate().getValue());
    assertNotNull(extId.getLastModifiedDate());
    assertEquals(Long.valueOf(0), extId.getDisplayIndex());
    assertEquals(Long.valueOf(1), extId.getPutCode());
    assertEquals(Relationship.PART_OF, extId.getRelationship());
    assertNotNull(extId.getSource());
    assertEquals("type-1", extId.getType());
    assertEquals("http://url.com/1", extId.getUrl().getValue());
    assertEquals("value-1", extId.getValue());
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
    assertNotNull(person.getKeywords());
    assertTrue(StringUtils.isNotBlank(person.getKeywords().getPath()));
    assertNotNull(person.getKeywords().getLastModifiedDate().getValue());
    assertNotNull(person.getKeywords().getKeywords());
    assertEquals(1, person.getKeywords().getKeywords().size());
    Keyword keyword = person.getKeywords().getKeywords().get(0);
    assertEquals("keyword1", keyword.getContent());
    assertNotNull(keyword.getCreatedDate().getValue());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(0), keyword.getDisplayIndex());
    assertEquals(Long.valueOf(1), keyword.getPutCode());
    assertNotNull(keyword.getSource());
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
    assertNotNull(person.getOtherNames());
    assertTrue(StringUtils.isNotBlank(person.getOtherNames().getPath()));
    assertNotNull(person.getOtherNames().getLastModifiedDate().getValue());
    assertNotNull(person.getOtherNames().getOtherNames());
    assertEquals(1, person.getOtherNames().getOtherNames().size());
    OtherName otherName = person.getOtherNames().getOtherNames().get(0);
    assertEquals("other-name-1", otherName.getContent());
    assertNotNull(otherName.getCreatedDate().getValue());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(0), otherName.getDisplayIndex());
    assertEquals(Long.valueOf(1), otherName.getPutCode());
    assertNotNull(otherName.getSource());
    assertEquals(Visibility.PUBLIC, otherName.getVisibility());
    assertNotNull(person.getResearcherUrls());
    assertTrue(StringUtils.isNotBlank(person.getResearcherUrls().getPath()));
    assertNotNull(person.getResearcherUrls().getLastModifiedDate().getValue());
    assertNotNull(person.getResearcherUrls().getResearcherUrls().size());
    ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
    assertNotNull(rUrl.getCreatedDate().getValue());
    assertEquals(Long.valueOf(0), rUrl.getDisplayIndex());
    assertNotNull(rUrl.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(1248), rUrl.getPutCode());
    assertNotNull(rUrl.getSource());
    assertEquals("http://url.com/", rUrl.getUrl().getValue());
    assertEquals("url-name-1", rUrl.getUrlName());
    assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
    assertNotNull(person.getName());
    Name name = person.getName();
    assertTrue(StringUtils.isNotBlank(name.getPath()));
    assertEquals("credit-name", name.getCreditName().getContent());
    assertEquals("family-name", name.getFamilyName().getContent());
    assertEquals("give-names", name.getGivenNames().getContent());
    assertNotNull(name.getLastModifiedDate().getValue());
    assertEquals(Visibility.PUBLIC, name.getVisibility());
}
Also used : Email(org.orcid.jaxb.model.record_rc2.Email) Address(org.orcid.jaxb.model.record_rc2.Address) Keyword(org.orcid.jaxb.model.record_rc2.Keyword) Fundings(org.orcid.jaxb.model.record.summary_rc2.Fundings) OtherName(org.orcid.jaxb.model.record_rc2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc2.ActivitiesSummary) OtherName(org.orcid.jaxb.model.record_rc2.OtherName) CreditName(org.orcid.jaxb.model.record_rc2.CreditName) Name(org.orcid.jaxb.model.record_rc2.Name) Employments(org.orcid.jaxb.model.record.summary_rc2.Employments) WorkSummary(org.orcid.jaxb.model.record.summary_rc2.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_rc2.EducationSummary) Educations(org.orcid.jaxb.model.record.summary_rc2.Educations) FundingSummary(org.orcid.jaxb.model.record.summary_rc2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_rc2.EmploymentSummary) Record(org.orcid.jaxb.model.record_rc2.Record) ResearcherUrl(org.orcid.jaxb.model.record_rc2.ResearcherUrl) Works(org.orcid.jaxb.model.record.summary_rc2.Works) Person(org.orcid.jaxb.model.record_rc2.Person) Test(org.junit.Test)

Example 30 with Name

use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method testMarshallName.

@Test
public void testMarshallName() throws JAXBException, SAXException, URISyntaxException {
    Name object = (Name) unmarshallFromPath("/record_2.0_rc2/samples/name-2.0_rc2.xml", Name.class);
    marshall(object, "/record_2.0_rc2/personal-details-2.0_rc2.xsd");
}
Also used : OtherName(org.orcid.jaxb.model.record_rc2.OtherName) CreditName(org.orcid.jaxb.model.record_rc2.CreditName) Name(org.orcid.jaxb.model.record_rc2.Name) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)92 Name (org.orcid.jaxb.model.record_v2.Name)75 OtherName (org.orcid.jaxb.model.record_v2.OtherName)61 Biography (org.orcid.jaxb.model.record_v2.Biography)45 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)40 Address (org.orcid.jaxb.model.record_v2.Address)30 Email (org.orcid.jaxb.model.record_v2.Email)30 Emails (org.orcid.jaxb.model.record_v2.Emails)29 Keyword (org.orcid.jaxb.model.record_v2.Keyword)29 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)29 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)29 Addresses (org.orcid.jaxb.model.record_v2.Addresses)28 Keywords (org.orcid.jaxb.model.record_v2.Keywords)28 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)28 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)28 Person (org.orcid.jaxb.model.record_v2.Person)26 ClientResponse (com.sun.jersey.api.client.ClientResponse)17 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)17 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)17 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)17