Search in sources :

Example 21 with Keywords

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

the class KeywordsTest method testGetKeywordWithPublicAPI.

/**
     * --------- -- -- -- All -- -- -- ---------
     * 
     */
/**
     * PRECONDITIONS: The user should have two public keywords keyword1 and
     * keyword2
     * 
     * @throws JSONException
     * @throws InterruptedException
     */
@Test
public void testGetKeywordWithPublicAPI() throws InterruptedException, JSONException {
    changeCurrentKeywordsVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
    // RC2
    ClientResponse response = publicV2ApiClient_rc2.viewKeywordsXML(getUser1OrcidId());
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    org.orcid.jaxb.model.record_rc2.Keywords keywordsRc2 = response.getEntity(org.orcid.jaxb.model.record_rc2.Keywords.class);
    assertNotNull(keywordsRc2);
    assertNotNull(keywordsRc2.getKeywords());
    // There should be at least two, one public and one limited
    boolean found1 = false;
    boolean found2 = false;
    for (org.orcid.jaxb.model.record_rc2.Keyword keyword : keywordsRc2.getKeywords()) {
        assertEquals(org.orcid.jaxb.model.common_rc2.Visibility.PUBLIC, keyword.getVisibility());
        if (keyword.getContent().equals(keyword1)) {
            found1 = true;
        } else if (keyword.getContent().equals(keyword2)) {
            found2 = true;
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    // RC3
    response = publicV2ApiClient_rc3.viewKeywordsXML(getUser1OrcidId());
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    org.orcid.jaxb.model.record_rc3.Keywords keywordsRc3 = response.getEntity(org.orcid.jaxb.model.record_rc3.Keywords.class);
    assertNotNull(keywordsRc3);
    assertNotNull(keywordsRc3.getKeywords());
    // There should be at least two, one public and one limited
    found1 = false;
    found2 = false;
    for (org.orcid.jaxb.model.record_rc3.Keyword keyword : keywordsRc3.getKeywords()) {
        assertEquals(org.orcid.jaxb.model.common_rc3.Visibility.PUBLIC, keyword.getVisibility());
        if (keyword.getContent().equals(keyword1)) {
            found1 = true;
        } else if (keyword.getContent().equals(keyword2)) {
            found2 = true;
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    // RC4
    response = publicV2ApiClient_rc4.viewKeywordsXML(getUser1OrcidId());
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    org.orcid.jaxb.model.record_rc4.Keywords keywordsRc4 = response.getEntity(org.orcid.jaxb.model.record_rc4.Keywords.class);
    assertNotNull(keywordsRc4);
    assertNotNull(keywordsRc4.getKeywords());
    // There should be at least two, one public and one limited
    found1 = false;
    found2 = false;
    for (org.orcid.jaxb.model.record_rc4.Keyword keyword : keywordsRc4.getKeywords()) {
        assertEquals(org.orcid.jaxb.model.common_rc4.Visibility.PUBLIC, keyword.getVisibility());
        if (keyword.getContent().equals(keyword1)) {
            found1 = true;
        } else if (keyword.getContent().equals(keyword2)) {
            found2 = true;
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    // Release
    response = publicV2ApiClient_release.viewKeywordsXML(getUser1OrcidId());
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    org.orcid.jaxb.model.record_v2.Keywords keywordsV2 = response.getEntity(org.orcid.jaxb.model.record_v2.Keywords.class);
    assertNotNull(keywordsV2);
    assertNotNull(keywordsV2.getKeywords());
    // There should be at least two, one public and one limited
    found1 = false;
    found2 = false;
    for (org.orcid.jaxb.model.record_v2.Keyword keyword : keywordsV2.getKeywords()) {
        assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC, keyword.getVisibility());
        if (keyword.getContent().equals(keyword1)) {
            found1 = true;
        } else if (keyword.getContent().equals(keyword2)) {
            found2 = true;
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    // V2.1
    response = publicV2_1ApiClient_release.viewKeywordsXML(getUser1OrcidId());
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    org.orcid.jaxb.model.record_v2.Keywords keywordsV2_1 = response.getEntity(org.orcid.jaxb.model.record_v2.Keywords.class);
    assertNotNull(keywordsV2_1);
    assertNotNull(keywordsV2_1.getKeywords());
    // There should be at least two, one public and one limited
    found1 = false;
    found2 = false;
    for (org.orcid.jaxb.model.record_v2.Keyword keyword : keywordsV2_1.getKeywords()) {
        assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC, keyword.getVisibility());
        if (keyword.getContent().equals(keyword1)) {
            found1 = true;
        } else if (keyword.getContent().equals(keyword2)) {
            found2 = true;
        }
    }
    assertTrue(found1);
    assertTrue(found2);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Keywords(org.orcid.jaxb.model.record_rc3.Keywords) Keyword(org.orcid.jaxb.model.record_rc3.Keyword) Test(org.junit.Test)

Example 22 with Keywords

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

the class ValidateV2SamplesTest method testMarshallKeyword.

@Test
public void testMarshallKeyword() throws JAXBException, SAXException, URISyntaxException {
    Keywords object = (Keywords) unmarshallFromPath("/record_2.0/samples/read_samples/keywords-2.0.xml", Keywords.class);
    marshall(object, "/record_2.0/keyword-2.0.xsd");
}
Also used : Keywords(org.orcid.jaxb.model.record_v2.Keywords) Test(org.junit.Test)

Example 23 with Keywords

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

the class PublicV2ApiServiceDelegatorImpl method viewKeywords.

@Override
public Response viewKeywords(String orcid) {
    long lastModifiedTime = getLastModifiedTime(orcid);
    Keywords keywords = profileKeywordManagerReadOnly.getPublicKeywords(orcid, lastModifiedTime);
    publicAPISecurityManagerV2.filter(keywords);
    ElementUtils.setPathToKeywords(keywords, orcid);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(keywords);
    sourceUtilsReadOnly.setSourceName(keywords);
    return Response.ok(keywords).build();
}
Also used : Keywords(org.orcid.jaxb.model.record_v2.Keywords)

Example 24 with Keywords

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

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

the class MemberV2ApiServiceDelegator_ReadPersonTest method testViewPerson.

@Test
public void testViewPerson() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewPerson(ORCID);
    assertNotNull(response);
    assertEquals(Person.class.getName(), response.getEntity().getClass().getName());
    Person p = (Person) response.getEntity();
    assertNotNull(p);
    assertEquals("/0000-0000-0000-0003/person", p.getPath());
    Utils.verifyLastModified(p.getLastModifiedDate());
    // Address
    assertNotNull(p.getAddresses());
    Addresses a = p.getAddresses();
    assertNotNull(a);
    Utils.verifyLastModified(a.getLastModifiedDate());
    assertEquals(4, a.getAddress().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (Address element : a.getAddress()) {
        Utils.verifyLastModified(element.getLastModifiedDate());
        if (element.getPutCode() == 9) {
            found1 = true;
        } else if (element.getPutCode() == 10) {
            found2 = true;
        } else if (element.getPutCode() == 11) {
            found3 = true;
        } else if (element.getPutCode() == 12) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    // Biography
    assertNotNull(p.getBiography());
    Biography b = p.getBiography();
    assertNotNull(b);
    Utils.verifyLastModified(b.getLastModifiedDate());
    assertEquals("Biography for 0000-0000-0000-0003", b.getContent());
    // Email
    assertNotNull(p.getEmails());
    Emails email = p.getEmails();
    assertNotNull(email);
    Utils.verifyLastModified(email.getLastModifiedDate());
    assertEquals(4, email.getEmails().size());
    found1 = false;
    found2 = false;
    found3 = false;
    found4 = false;
    for (Email element : email.getEmails()) {
        if (element.getEmail().equals("public_0000-0000-0000-0003@test.orcid.org")) {
            found1 = true;
        } else if (element.getEmail().equals("limited_0000-0000-0000-0003@test.orcid.org")) {
            found2 = true;
        } else if (element.getEmail().equals("private_0000-0000-0000-0003@test.orcid.org")) {
            found3 = true;
        } else if (element.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) {
            found4 = true;
        } else {
            fail("Invalid email " + element.getEmail());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    // External identifiers
    assertNotNull(p.getExternalIdentifiers());
    PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
    assertNotNull(extIds);
    Utils.verifyLastModified(extIds.getLastModifiedDate());
    assertEquals(4, extIds.getExternalIdentifiers().size());
    found1 = false;
    found2 = false;
    found3 = false;
    found4 = false;
    for (PersonExternalIdentifier element : extIds.getExternalIdentifiers()) {
        Utils.verifyLastModified(element.getLastModifiedDate());
        if (element.getPutCode() == 13) {
            found1 = true;
        } else if (element.getPutCode() == 14) {
            found2 = true;
        } else if (element.getPutCode() == 15) {
            found3 = true;
        } else if (element.getPutCode() == 16) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    // Keywords
    assertNotNull(p.getKeywords());
    Keywords k = p.getKeywords();
    assertNotNull(k);
    Utils.verifyLastModified(k.getLastModifiedDate());
    assertEquals(4, k.getKeywords().size());
    found1 = false;
    found2 = false;
    found3 = false;
    found4 = false;
    for (Keyword element : k.getKeywords()) {
        Utils.verifyLastModified(element.getLastModifiedDate());
        if (element.getPutCode() == 9) {
            found1 = true;
        } else if (element.getPutCode() == 10) {
            found2 = true;
        } else if (element.getPutCode() == 11) {
            found3 = true;
        } else if (element.getPutCode() == 12) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    // Name
    assertNotNull(p.getName());
    assertEquals("Credit Name", p.getName().getCreditName().getContent());
    assertEquals("Given Names", p.getName().getGivenNames().getContent());
    assertEquals("Family Name", p.getName().getFamilyName().getContent());
    // Other names
    assertNotNull(p.getOtherNames());
    OtherNames o = p.getOtherNames();
    assertNotNull(o);
    Utils.verifyLastModified(o.getLastModifiedDate());
    assertEquals(4, o.getOtherNames().size());
    found1 = false;
    found2 = false;
    found3 = false;
    found4 = false;
    for (OtherName element : o.getOtherNames()) {
        Utils.verifyLastModified(element.getLastModifiedDate());
        if (element.getPutCode() == 13) {
            found1 = true;
        } else if (element.getPutCode() == 14) {
            found2 = true;
        } else if (element.getPutCode() == 15) {
            found3 = true;
        } else if (element.getPutCode() == 16) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    // Researcher urls
    assertNotNull(p.getResearcherUrls());
    ResearcherUrls ru = p.getResearcherUrls();
    assertNotNull(ru);
    Utils.verifyLastModified(ru.getLastModifiedDate());
    assertEquals(4, ru.getResearcherUrls().size());
    found1 = false;
    found2 = false;
    found3 = false;
    found4 = false;
    for (ResearcherUrl element : ru.getResearcherUrls()) {
        Utils.verifyLastModified(element.getLastModifiedDate());
        if (element.getPutCode() == 13) {
            found1 = true;
        } else if (element.getPutCode() == 14) {
            found2 = true;
        } else if (element.getPutCode() == 15) {
            found3 = true;
        } else if (element.getPutCode() == 16) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    assertNotNull(p.getPath());
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Keywords(org.orcid.jaxb.model.record_v2.Keywords) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Response(javax.ws.rs.core.Response) Addresses(org.orcid.jaxb.model.record_v2.Addresses) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails) Person(org.orcid.jaxb.model.record_v2.Person) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)58 Keywords (org.orcid.jaxb.model.record_v2.Keywords)54 Keyword (org.orcid.jaxb.model.record_v2.Keyword)41 Addresses (org.orcid.jaxb.model.record_v2.Addresses)35 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)35 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)35 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)35 Biography (org.orcid.jaxb.model.record_v2.Biography)33 Emails (org.orcid.jaxb.model.record_v2.Emails)33 Address (org.orcid.jaxb.model.record_v2.Address)32 OtherName (org.orcid.jaxb.model.record_v2.OtherName)32 Email (org.orcid.jaxb.model.record_v2.Email)31 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)31 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)31 Name (org.orcid.jaxb.model.record_v2.Name)28 Person (org.orcid.jaxb.model.record_v2.Person)25 ClientResponse (com.sun.jersey.api.client.ClientResponse)17 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)15 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)15 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)15