Search in sources :

Example 81 with Person

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

the class ValidateV2RC3SamplesTest method testMarshallPerson.

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

Example 82 with Person

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

the class ValidateV2RC4SamplesTest method testUnmarshallPerson.

@Test
public void testUnmarshallPerson() throws SAXException, URISyntaxException {
    Person person = (Person) unmarshallFromPath("/record_2.0_rc4/samples/person-2.0_rc4.xml", Person.class, "/record_2.0_rc4/person-2.0_rc4.xsd");
    assertNotNull(person);
    assertNotNull(person.getName());
    assertEquals("give-names", person.getName().getGivenNames().getContent());
    assertEquals("family-name", person.getName().getFamilyName().getContent());
    assertEquals("credit-name", person.getName().getCreditName().getContent());
    assertEquals(Visibility.PUBLIC, person.getName().getVisibility());
    assertNotNull(person.getOtherNames());
    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());
    assertNotNull(otherName.getCreatedDate().getValue());
    assertEquals(2001, otherName.getCreatedDate().getValue().getYear());
    assertEquals(12, otherName.getCreatedDate().getValue().getMonth());
    assertEquals(31, otherName.getCreatedDate().getValue().getDay());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals(2001, otherName.getLastModifiedDate().getValue().getYear());
    assertEquals(12, otherName.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, otherName.getLastModifiedDate().getValue().getDay());
    assertNotNull(otherName.getSource());
    assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
    assertNotNull(person.getBiography());
    assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
    assertEquals("biography", person.getBiography().getContent());
    assertNotNull(person.getResearcherUrls());
    assertNotNull(person.getResearcherUrls().getResearcherUrls());
    assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
    ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
    assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
    assertEquals(Long.valueOf(1248), rUrl.getPutCode());
    assertEquals("url-name-1", rUrl.getUrlName());
    assertNotNull(rUrl.getUrl());
    assertEquals("http://url.com/", rUrl.getUrl().getValue());
    assertNotNull(rUrl.getCreatedDate());
    assertEquals(2001, rUrl.getCreatedDate().getValue().getYear());
    assertEquals(12, rUrl.getCreatedDate().getValue().getMonth());
    assertEquals(31, rUrl.getCreatedDate().getValue().getDay());
    assertNotNull(rUrl.getLastModifiedDate());
    assertEquals(2001, rUrl.getLastModifiedDate().getValue().getYear());
    assertEquals(12, rUrl.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, rUrl.getLastModifiedDate().getValue().getDay());
    assertNotNull(rUrl.getSource());
    assertEquals("8888-8888-8888-8880", rUrl.getSource().retrieveSourcePath());
    assertNotNull(person.getEmails());
    assertNotNull(person.getEmails().getEmails());
    assertEquals(1, person.getEmails().getEmails().size());
    Email email = person.getEmails().getEmails().get(0);
    assertEquals(Visibility.PUBLIC, email.getVisibility());
    assertEquals("user1@email.com", email.getEmail());
    assertNotNull(email.getCreatedDate());
    assertNotNull(email.getCreatedDate().getValue());
    assertEquals(2001, email.getCreatedDate().getValue().getYear());
    assertEquals(12, email.getCreatedDate().getValue().getMonth());
    assertEquals(31, email.getCreatedDate().getValue().getDay());
    assertNotNull(email.getLastModifiedDate());
    assertNotNull(email.getLastModifiedDate().getValue());
    assertEquals(2001, email.getLastModifiedDate().getValue().getYear());
    assertEquals(12, email.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, email.getLastModifiedDate().getValue().getDay());
    assertNotNull(email.getSource());
    assertEquals("8888-8888-8888-8880", email.retrieveSourcePath());
    assertNotNull(person.getAddresses());
    assertNotNull(person.getAddresses().getAddress());
    assertEquals(1, person.getAddresses().getAddress().size());
    Address address = person.getAddresses().getAddress().get(0);
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    assertEquals(Long.valueOf(1), address.getPutCode());
    assertNotNull(address.getCountry());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertNotNull(address.getCreatedDate());
    assertNotNull(address.getCreatedDate().getValue());
    assertEquals(2001, address.getCreatedDate().getValue().getYear());
    assertEquals(12, address.getCreatedDate().getValue().getMonth());
    assertEquals(31, address.getCreatedDate().getValue().getDay());
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(address.getLastModifiedDate().getValue());
    assertEquals(2001, address.getLastModifiedDate().getValue().getYear());
    assertEquals(12, address.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, address.getLastModifiedDate().getValue().getDay());
    assertNotNull(address.getSource());
    assertEquals("8888-8888-8888-8880", address.getSource().retrieveSourcePath());
    assertNotNull(person.getKeywords());
    assertNotNull(person.getKeywords().getKeywords());
    assertEquals(1, person.getKeywords().getKeywords().size());
    Keyword keyword = person.getKeywords().getKeywords().get(0);
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
    assertEquals(Long.valueOf(1), keyword.getPutCode());
    assertEquals("keyword1", keyword.getContent());
    assertNotNull(keyword.getCreatedDate());
    assertNotNull(keyword.getCreatedDate().getValue());
    assertEquals(2001, keyword.getCreatedDate().getValue().getYear());
    assertEquals(12, keyword.getCreatedDate().getValue().getMonth());
    assertEquals(31, keyword.getCreatedDate().getValue().getDay());
    assertNotNull(keyword.getLastModifiedDate());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(2001, keyword.getLastModifiedDate().getValue().getYear());
    assertEquals(12, keyword.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, keyword.getLastModifiedDate().getValue().getDay());
    assertNotNull(keyword.getSource());
    assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
    assertNotNull(person.getExternalIdentifiers());
    assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
    assertEquals(Long.valueOf(1), extId.getPutCode());
    assertEquals("type-1", extId.getType());
    assertEquals("value-1", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://url.com/1", extId.getUrl().getValue());
    assertNotNull(extId.getCreatedDate());
    assertNotNull(extId.getCreatedDate().getValue());
    assertEquals(2001, extId.getCreatedDate().getValue().getYear());
    assertEquals(12, extId.getCreatedDate().getValue().getMonth());
    assertEquals(31, extId.getCreatedDate().getValue().getDay());
    assertNotNull(extId.getLastModifiedDate());
    assertNotNull(extId.getLastModifiedDate().getValue());
    assertEquals(2001, extId.getLastModifiedDate().getValue().getYear());
    assertEquals(12, extId.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, extId.getLastModifiedDate().getValue().getDay());
    assertNotNull(extId.getSource());
    assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
Also used : Email(org.orcid.jaxb.model.record_rc4.Email) Address(org.orcid.jaxb.model.record_rc4.Address) Keyword(org.orcid.jaxb.model.record_rc4.Keyword) OtherName(org.orcid.jaxb.model.record_rc4.OtherName) ResearcherUrl(org.orcid.jaxb.model.record_rc4.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier) Person(org.orcid.jaxb.model.record_rc4.Person) Test(org.junit.Test)

Example 83 with Person

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

the class ValidateV2RC3Identifiers method testPerson.

/**
     * <external-identifier:external-identifiers>
                <external-identifier:external-identifier visibility="public" put-code="1">
                        <common:external-id-type>type-1</common:external-id-type>
                        <common:external-id-value>value-1</common:external-id-value>
                        <common:external-id-url>http://url.com/1</common:external-id-url>
                        <common:created-date>2001-12-31T12:00:00</common:created-date>
                        <common:last-modified-date>2001-12-31T12:00:00</common:last-modified-date>
                        <common:source>
                                <common:source-orcid>
                                        <common:uri>http://orcid.org/8888-8888-8888-8880</common:uri>
                                        <common:path>8888-8888-8888-8880</common:path>
                                        <common:host>orcid.org</common:host>
                                </common:source-orcid>
                                <common:source-name />
                        </common:source>
                </external-identifier:external-identifier>
        </external-identifier:external-identifiers>
        
     * @throws SAXException
     * @throws IOException
     * @throws JAXBException
     * @throws ParserConfigurationException
     */
@Test
public void testPerson() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    Person person = unmarshallFromPath("/record_2.0_rc3/samples/person-2.0_rc3.xml", Person.class);
    assertEquals("credit-name", person.getName().getCreditName().getContent());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    PersonExternalIdentifier id = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
    assertEquals("type-1", id.getType());
    assertEquals("value-1", id.getValue());
    assertEquals(new Url("http://url.com/1"), id.getUrl());
    assertNull(id.getRelationship());
    assertNotNull(id.getCreatedDate().getValue());
    assertNotNull(id.getLastModifiedDate().getValue());
    assertEquals(new Long(1), id.getPutCode());
    assertEquals(Visibility.PUBLIC, id.getVisibility());
    Validator validator = getValidator("person");
    validator.validate(marshall(Person.class, person));
    validator.validate(marshallToDOM(Person.class, person));
}
Also used : PersonExternalIdentifier(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier) Person(org.orcid.jaxb.model.record_rc3.Person) Url(org.orcid.jaxb.model.common_rc3.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 84 with Person

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

the class PublicAPISecurityManagerV2Impl method filter.

@Override
public void filter(Person person) {
    if (person == null) {
        return;
    }
    if (person.getAddresses() != null) {
        filter(person.getAddresses());
    }
    if (person.getEmails() != null) {
        filter(person.getEmails());
    }
    if (person.getExternalIdentifiers() != null) {
        filter(person.getExternalIdentifiers());
    }
    if (person.getKeywords() != null) {
        filter(person.getKeywords());
    }
    if (person.getOtherNames() != null) {
        filter(person.getOtherNames());
    }
    if (person.getResearcherUrls() != null) {
        filter(person.getResearcherUrls());
    }
    Name name = person.getName();
    if (name != null) {
        try {
            checkIsPublic(name);
        } catch (OrcidNonPublicElementException ex) {
            person.setName(null);
        }
    }
    Biography bio = person.getBiography();
    if (bio != null) {
        try {
            checkIsPublic(bio);
        } catch (OrcidNonPublicElementException ex) {
            person.setBiography(null);
        }
    }
}
Also used : OrcidNonPublicElementException(org.orcid.core.exception.OrcidNonPublicElementException) Biography(org.orcid.jaxb.model.record_v2.Biography) Name(org.orcid.jaxb.model.record_v2.Name)

Example 85 with Person

use of org.orcid.jaxb.model.record_v2.Person 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)

Aggregations

Test (org.junit.Test)69 Person (org.orcid.jaxb.model.record_v2.Person)58 Email (org.orcid.jaxb.model.record_v2.Email)40 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)40 Address (org.orcid.jaxb.model.record_v2.Address)35 Keyword (org.orcid.jaxb.model.record_v2.Keyword)35 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)35 OtherName (org.orcid.jaxb.model.record_v2.OtherName)34 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)34 Emails (org.orcid.jaxb.model.record_v2.Emails)33 Biography (org.orcid.jaxb.model.record_v2.Biography)32 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)32 Addresses (org.orcid.jaxb.model.record_v2.Addresses)30 Keywords (org.orcid.jaxb.model.record_v2.Keywords)30 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)30 Name (org.orcid.jaxb.model.record_v2.Name)27 Record (org.orcid.jaxb.model.record_v2.Record)22 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)21 DBUnitTest (org.orcid.test.DBUnitTest)16 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)14