Search in sources :

Example 21 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testViewExternalIdentifiersReadPublic.

@Test
public void testViewExternalIdentifiersReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewExternalIdentifiers(ORCID);
    PersonExternalIdentifiers element = (PersonExternalIdentifiers) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/external-identifiers", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 22 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class SourceUtils method setSourceName.

public void setSourceName(Person person) {
    if (person == null) {
        return;
    }
    if (person.getAddresses() != null) {
        Addresses addresses = person.getAddresses();
        setSourceName(addresses);
    }
    if (person.getEmails() != null) {
        Emails emails = person.getEmails();
        setSourceName(emails);
    }
    if (person.getExternalIdentifiers() != null) {
        PersonExternalIdentifiers extIds = person.getExternalIdentifiers();
        setSourceName(extIds);
    }
    if (person.getKeywords() != null) {
        Keywords keywords = person.getKeywords();
        setSourceName(keywords);
    }
    if (person.getOtherNames() != null) {
        OtherNames otherNames = person.getOtherNames();
        setSourceName(otherNames);
    }
    if (person.getResearcherUrls() != null) {
        ResearcherUrls researcherUrls = person.getResearcherUrls();
        setSourceName(researcherUrls);
    }
}
Also used : Addresses(org.orcid.jaxb.model.record_v2.Addresses) Keywords(org.orcid.jaxb.model.record_v2.Keywords) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Emails(org.orcid.jaxb.model.record_v2.Emails)

Example 23 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method testMarshallExternalIdentifiers.

@Test
public void testMarshallExternalIdentifiers() throws JAXBException, SAXException, URISyntaxException {
    PersonExternalIdentifiers object = (PersonExternalIdentifiers) unmarshallFromPath("/record_2.1/samples/read_samples/external-identifiers-2.1.xml", PersonExternalIdentifiers.class);
    marshall(object, "/record_2.1/person-external-identifier-2.1.xsd");
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) Test(org.junit.Test)

Example 24 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method testUnmarshallExternalIdentifiers.

@Test
public void testUnmarshallExternalIdentifiers() throws SAXException, URISyntaxException {
    PersonExternalIdentifiers externalIdentifiers = (PersonExternalIdentifiers) unmarshallFromPath("/record_2.1/samples/read_samples/external-identifiers-2.1.xml", PersonExternalIdentifiers.class, "/record_2.1/person-external-identifier-2.1.xsd");
    assertNotNull(externalIdentifiers);
    assertNotNull(externalIdentifiers.getExternalIdentifiers());
    assertEquals(2, externalIdentifiers.getExternalIdentifiers().size());
    for (PersonExternalIdentifier extId : externalIdentifiers.getExternalIdentifiers()) {
        validateSourceInHttps(extId.getSource());
        assertThat(extId.getPutCode(), anyOf(is(1L), is(2L)));
        assertThat(extId.getType(), anyOf(is("common-name-1"), is("common-name-2")));
        assertThat(extId.getValue(), anyOf(is("id-reference-1"), is("id-reference-2")));
        assertNotNull(extId.getUrl());
        assertThat(extId.getUrl().getValue(), anyOf(is("http://url/1"), is("http://url/2")));
        assertNotNull(extId.getCreatedDate());
        assertNotNull(extId.getLastModifiedDate());
        assertNotNull(extId.getSource());
        assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
    }
    PersonExternalIdentifier extId = (PersonExternalIdentifier) unmarshallFromPath("/record_2.1/samples/read_samples/external-identifier-2.1.xml", PersonExternalIdentifier.class);
    assertNotNull(extId);
    assertEquals("A-0003", extId.getType());
    assertEquals(Long.valueOf(1), extId.getPutCode());
    assertEquals("A-0003", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://ext-id/A-0003", extId.getUrl().getValue());
    assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
    assertNotNull(extId.getCreatedDate());
    assertNotNull(extId.getLastModifiedDate());
    assertNotNull(extId.getSource());
    validateSourceInHttps(extId.getSource());
    assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Test(org.junit.Test)

Example 25 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifiers 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)52 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)52 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)41 Addresses (org.orcid.jaxb.model.record_v2.Addresses)35 Keywords (org.orcid.jaxb.model.record_v2.Keywords)35 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)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 Keyword (org.orcid.jaxb.model.record_v2.Keyword)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 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 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)15