Search in sources :

Example 26 with Keywords

use of org.orcid.jaxb.model.v3.dev1.record.Keywords in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testUnmarshallKeyword.

@Test
public void testUnmarshallKeyword() throws SAXException, URISyntaxException {
    Keywords keywords = (Keywords) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/keywords-3.0_dev1.xml", Keywords.class, "/record_3.0_dev1/keyword-3.0_dev1.xsd");
    assertNotNull(keywords);
    assertNotNull(keywords.getKeywords());
    assertEquals(2, keywords.getKeywords().size());
    for (Keyword keyword : keywords.getKeywords()) {
        assertThat(keyword.getContent(), anyOf(is("keyword1"), is("keyword2")));
        assertThat(keyword.getPutCode(), anyOf(is(Long.valueOf(1)), is(Long.valueOf(2))));
        assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
        assertNotNull(keyword.getCreatedDate());
        assertNotNull(keyword.getLastModifiedDate());
        assertNotNull(keyword.getSource());
        assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
    }
    Keyword keyword = (Keyword) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/keyword-3.0_dev1.xml", Keyword.class);
    assertNotNull(keyword);
    assertEquals("keyword1", keyword.getContent());
    assertEquals(Long.valueOf(1), keyword.getPutCode());
    assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
    assertNotNull(keyword.getCreatedDate());
    assertNotNull(keyword.getLastModifiedDate());
    assertNotNull(keyword.getSource());
    assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
}
Also used : Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) Test(org.junit.Test)

Example 27 with Keywords

use of org.orcid.jaxb.model.v3.dev1.record.Keywords in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testMarshallKeyword.

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

Example 28 with Keywords

use of org.orcid.jaxb.model.v3.dev1.record.Keywords in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorImpl method viewKeywords.

@Override
public Response viewKeywords(String orcid) {
    Keywords keywords = profileKeywordManagerReadOnly.getPublicKeywords(orcid);
    publicAPISecurityManagerV3.filter(keywords);
    ElementUtils.setPathToKeywords(keywords, orcid);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(keywords);
    sourceUtilsReadOnly.setSourceName(keywords);
    return Response.ok(keywords).build();
}
Also used : Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords)

Example 29 with Keywords

use of org.orcid.jaxb.model.v3.dev1.record.Keywords 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.v3.dev1.record.Addresses) Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails)

Example 30 with Keywords

use of org.orcid.jaxb.model.v3.dev1.record.Keywords in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_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.v3.dev1.record.Email) Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) Address(org.orcid.jaxb.model.v3.dev1.record.Address) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) Response(javax.ws.rs.core.Response) Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) Person(org.orcid.jaxb.model.v3.dev1.record.Person) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)50 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)49 Test (org.junit.Test)44 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)34 Address (org.orcid.jaxb.model.v3.dev1.record.Address)33 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)33 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)33 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)33 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)33 Email (org.orcid.jaxb.model.v3.dev1.record.Email)32 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)32 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)32 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)32 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)31 Person (org.orcid.jaxb.model.v3.dev1.record.Person)28 Name (org.orcid.jaxb.model.v3.dev1.record.Name)27 Record (org.orcid.jaxb.model.v3.dev1.record.Record)15 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)14 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)14 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)14