Search in sources :

Example 81 with Keywords

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

the class ValidateV2RC4SamplesTest method testMarshallKeyword.

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

Example 82 with Keywords

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

the class ValidateV2RC3SamplesTest method testMarshallKeyword.

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

Example 83 with Keywords

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

the class PublicV2ApiServiceDelegatorTest method validatePerson.

private void validatePerson(Person person) {
    assertNotNull(person);
    assertNotNull(person.getLastModifiedDate());
    assertNotNull(person.getLastModifiedDate().getValue());
    assertNotNull(person.getAddresses());
    assertEquals("/0000-0000-0000-0003/address", person.getAddresses().getPath());
    assertNotNull(person.getAddresses().getLastModifiedDate());
    assertNotNull(person.getAddresses().getLastModifiedDate().getValue());
    assertEquals(1, person.getAddresses().getAddress().size());
    Address address = person.getAddresses().getAddress().get(0);
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC.value(), address.getVisibility().value());
    assertEquals(Long.valueOf(9), address.getPutCode());
    assertEquals("/0000-0000-0000-0003/address/9", address.getPath());
    assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
    assertNotNull(person.getBiography());
    assertEquals(Visibility.PUBLIC.value(), person.getBiography().getVisibility().value());
    assertEquals("Biography for 0000-0000-0000-0003", person.getBiography().getContent());
    assertNotNull(person.getBiography().getLastModifiedDate());
    assertNotNull(person.getBiography().getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/biography", person.getBiography().getPath());
    assertNotNull(person.getEmails());
    assertNotNull(person.getEmails().getLastModifiedDate());
    assertNotNull(person.getEmails().getLastModifiedDate().getValue());
    assertEquals(1, person.getEmails().getEmails().size());
    Email email = person.getEmails().getEmails().get(0);
    assertEquals("public_0000-0000-0000-0003@test.orcid.org", email.getEmail());
    assertNotNull(email.getLastModifiedDate());
    assertNotNull(email.getLastModifiedDate().getValue());
    assertEquals("APP-5555555555555555", email.getSource().retrieveSourcePath());
    assertEquals(Visibility.PUBLIC.value(), email.getVisibility().value());
    assertNotNull(person.getExternalIdentifiers());
    assertNotNull(person.getExternalIdentifiers().getLastModifiedDate());
    assertNotNull(person.getExternalIdentifiers().getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/external-identifiers", person.getExternalIdentifiers().getPath());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
    assertNotNull(extId);
    assertNotNull(extId.getLastModifiedDate());
    assertNotNull(extId.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(13), extId.getPutCode());
    assertEquals("public_type", extId.getType());
    assertNotNull(extId.getUrl());
    assertEquals("http://ext-id/public_ref", extId.getUrl().getValue());
    assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/external-identifiers/13", extId.getPath());
    assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
    assertNotNull(person.getKeywords());
    assertNotNull(person.getKeywords().getLastModifiedDate());
    assertNotNull(person.getKeywords().getLastModifiedDate().getValue());
    assertEquals(1, person.getKeywords().getKeywords().size());
    assertNotNull(person.getKeywords().getLastModifiedDate());
    assertEquals("/0000-0000-0000-0003/keywords", person.getKeywords().getPath());
    Keyword keyword = person.getKeywords().getKeywords().get(0);
    assertNotNull(keyword);
    assertNotNull(keyword.getLastModifiedDate());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(9), keyword.getPutCode());
    assertEquals("PUBLIC", keyword.getContent());
    assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/keywords/9", keyword.getPath());
    assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
    assertNotNull(person.getName());
    assertNotNull(person.getName().getLastModifiedDate());
    assertNotNull(person.getName().getLastModifiedDate().getValue());
    assertEquals("Credit Name", person.getName().getCreditName().getContent());
    assertEquals("Family Name", person.getName().getFamilyName().getContent());
    assertEquals("Given Names", person.getName().getGivenNames().getContent());
    assertEquals(Visibility.PUBLIC.value(), person.getName().getVisibility().value());
    assertNotNull(person.getOtherNames());
    assertEquals("/0000-0000-0000-0003/other-names", person.getOtherNames().getPath());
    assertNotNull(person.getOtherNames().getLastModifiedDate());
    assertNotNull(person.getOtherNames().getLastModifiedDate().getValue());
    assertEquals(1, person.getOtherNames().getOtherNames().size());
    OtherName otherName = person.getOtherNames().getOtherNames().get(0);
    assertEquals("Other Name PUBLIC", otherName.getContent());
    assertNotNull(otherName.getLastModifiedDate());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/other-names/13", otherName.getPath());
    assertEquals(Long.valueOf(13), otherName.getPutCode());
    assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
    assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
    assertNotNull(person.getResearcherUrls());
    assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
    assertNotNull(person.getResearcherUrls().getLastModifiedDate());
    assertNotNull(person.getResearcherUrls().getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/researcher-urls", person.getResearcherUrls().getPath());
    ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
    assertNotNull(rUrl);
    assertNotNull(rUrl.getLastModifiedDate());
    assertNotNull(rUrl.getLastModifiedDate().getValue());
    assertNotNull(rUrl.getUrl());
    assertEquals("http://www.researcherurl.com?id=13", rUrl.getUrl().getValue());
    assertEquals("public_rurl", rUrl.getUrlName());
    assertEquals(Visibility.PUBLIC.value(), rUrl.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/researcher-urls/13", rUrl.getPath());
    assertEquals("APP-5555555555555555", rUrl.getSource().retrieveSourcePath());
    assertEquals("/0000-0000-0000-0003/person", person.getPath());
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherName(org.orcid.jaxb.model.record_v2.OtherName) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)

Example 84 with Keywords

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

the class WorkspaceController method getKeywordsFormJson.

@RequestMapping(value = "/my-orcid/keywordsForms.json", method = RequestMethod.GET)
@ResponseBody
public KeywordsForm getKeywordsFormJson(HttpServletRequest request) throws NoSuchRequestHandlingMethodException {
    long lastModifiedTime = getLastModifiedTime(getCurrentUserOrcid());
    Keywords keywords = profileKeywordManager.getKeywords(getCurrentUserOrcid(), lastModifiedTime);
    KeywordsForm form = KeywordsForm.valueOf(keywords);
    //Set the default visibility
    ProfileEntity profile = profileEntityCacheManager.retrieve(getCurrentUserOrcid());
    if (profile != null && profile.getActivitiesVisibilityDefault() != null) {
        form.setVisibility(Visibility.valueOf(profile.getActivitiesVisibilityDefault()));
    }
    return form;
}
Also used : KeywordsForm(org.orcid.pojo.ajaxForm.KeywordsForm) Keywords(org.orcid.jaxb.model.record_v2.Keywords) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 85 with Keywords

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

the class WorkspaceController method setKeywordsFormJson.

@RequestMapping(value = "/my-orcid/keywordsForms.json", method = RequestMethod.POST)
@ResponseBody
public KeywordsForm setKeywordsFormJson(HttpServletRequest request, @RequestBody KeywordsForm kf) throws NoSuchRequestHandlingMethodException {
    kf.setErrors(new ArrayList<String>());
    ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
    Visibility defaultVisibility = Visibility.valueOf(profile.getActivitiesVisibilityDefault());
    if (kf != null) {
        Iterator<KeywordForm> it = kf.getKeywords().iterator();
        while (it.hasNext()) {
            KeywordForm k = it.next();
            if (!PojoUtil.isEmpty(k.getContent())) {
                if (k.getContent().length() > SiteConstants.KEYWORD_MAX_LENGTH) {
                    k.setContent(k.getContent().substring(0, SiteConstants.KEYWORD_MAX_LENGTH));
                }
            } else {
                it.remove();
            }
            //Set default visibility in case it is null
            if (k.getVisibility() == null || k.getVisibility().getVisibility() == null) {
                k.setVisibility(defaultVisibility);
            }
            copyErrors(k, kf);
        }
        if (kf.getErrors().size() > 0) {
            return kf;
        }
        Keywords updatedKeywords = kf.toKeywords();
        profileKeywordManager.updateKeywords(getCurrentUserOrcid(), updatedKeywords);
    }
    return kf;
}
Also used : KeywordForm(org.orcid.pojo.ajaxForm.KeywordForm) Keywords(org.orcid.jaxb.model.record_v2.Keywords) Visibility(org.orcid.pojo.ajaxForm.Visibility) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Test (org.junit.Test)62 Keywords (org.orcid.jaxb.model.record_v2.Keywords)54 Keyword (org.orcid.jaxb.model.record_v2.Keyword)53 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)37 Address (org.orcid.jaxb.model.record_v2.Address)36 Biography (org.orcid.jaxb.model.record_v2.Biography)36 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)36 Addresses (org.orcid.jaxb.model.record_v2.Addresses)35 Email (org.orcid.jaxb.model.record_v2.Email)35 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)35 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)35 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)35 OtherName (org.orcid.jaxb.model.record_v2.OtherName)34 Emails (org.orcid.jaxb.model.record_v2.Emails)33 Name (org.orcid.jaxb.model.record_v2.Name)30 Person (org.orcid.jaxb.model.record_v2.Person)28 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)17 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)17 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)17 Record (org.orcid.jaxb.model.record_v2.Record)17