Search in sources :

Example 81 with PersonExternalIdentifier

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

the class BlackBoxBaseRC3 method createExternalIdentifier.

/**
     * EXTERNAL IDENTIFIERS
     * 
     * External identifiers can't be added through the UI
     * */
public Long createExternalIdentifier(String value, String userOrcid, String accessToken) {
    PersonExternalIdentifier e = new PersonExternalIdentifier();
    e.setValue(value);
    e.setType("test");
    e.setUrl(new Url("http://test.orcid.org"));
    e.setRelationship(Relationship.SELF);
    ClientResponse response = memberV2ApiClient.createExternalIdentifier(userOrcid, e, accessToken);
    assertNotNull(response);
    assertEquals(ClientResponse.Status.CREATED.getStatusCode(), response.getStatus());
    return getPutCodeFromResponse(response);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier) Url(org.orcid.jaxb.model.common_rc3.Url) ResearcherUrl(org.orcid.jaxb.model.record_rc3.ResearcherUrl)

Example 82 with PersonExternalIdentifier

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

the class BlackBoxBaseRC2 method createExternalIdentifier.

@SuppressWarnings({ "rawtypes", "deprecation" })
protected Long createExternalIdentifier(String name) throws InterruptedException, JSONException {
    //Get the access token
    String accessToken = getAccessToken(getScopes(ScopePathType.PERSON_UPDATE, ScopePathType.READ_LIMITED));
    assertNotNull(accessToken);
    //Create the external identifier
    PersonExternalIdentifier extId = getExternalIdentifier(name);
    ClientResponse response = memberV2ApiClient.createExternalIdentifier(getUser1OrcidId(), extId, accessToken);
    assertNotNull(response);
    assertEquals(ClientResponse.Status.CREATED.getStatusCode(), response.getStatus());
    Map map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List resultWithPutCode = (List) map.get("Location");
    String location = resultWithPutCode.get(0).toString();
    Long putCode = Long.valueOf(location.substring(location.lastIndexOf('/') + 1));
    return putCode;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) List(java.util.List) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) Map(java.util.Map)

Example 83 with PersonExternalIdentifier

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

the class ValidateV2IdentifiersTest 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/samples/read_samples/person-2.0.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_v2.PersonExternalIdentifier) Person(org.orcid.jaxb.model.record_v2.Person) Url(org.orcid.jaxb.model.common_v2.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 84 with PersonExternalIdentifier

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

the class ValidateV2RC2SamplesTest method testUnmarshallExternalIdentifiers.

@Test
public void testUnmarshallExternalIdentifiers() throws SAXException, URISyntaxException {
    PersonExternalIdentifiers externalIdentifiers = (PersonExternalIdentifiers) unmarshallFromPath("/record_2.0_rc2/samples/external-identifiers-2.0_rc2.xml", PersonExternalIdentifiers.class, "/record_2.0_rc2/person-external-identifier-2.0_rc2.xsd");
    assertNotNull(externalIdentifiers);
    assertNotNull(externalIdentifiers.getExternalIdentifiers());
    assertEquals(2, externalIdentifiers.getExternalIdentifiers().size());
    for (PersonExternalIdentifier extId : externalIdentifiers.getExternalIdentifiers()) {
        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.0_rc2/samples/external-identifier-2.0_rc2.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());
    assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifiers) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) Test(org.junit.Test)

Example 85 with PersonExternalIdentifier

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

the class ValidateV2_1SamplesTest method testUnmarshallPerson.

@Test
public void testUnmarshallPerson() throws SAXException, URISyntaxException {
    Person person = (Person) unmarshallFromPath("/record_2.1/samples/read_samples/person-2.1.xml", Person.class, "/record_2.1/person-2.1.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());
    validateSourceInHttps(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());
    validateSourceInHttps(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());
    validateSourceInHttps(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());
    validateSourceInHttps(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());
    validateSourceInHttps(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());
    validateSourceInHttps(extId.getSource());
    assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
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) Person(org.orcid.jaxb.model.record_v2.Person) Test(org.junit.Test)

Aggregations

PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)104 Test (org.junit.Test)93 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)49 Address (org.orcid.jaxb.model.record_v2.Address)44 Keyword (org.orcid.jaxb.model.record_v2.Keyword)44 OtherName (org.orcid.jaxb.model.record_v2.OtherName)42 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)42 Email (org.orcid.jaxb.model.record_v2.Email)41 Biography (org.orcid.jaxb.model.record_v2.Biography)33 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 Person (org.orcid.jaxb.model.record_v2.Person)32 Addresses (org.orcid.jaxb.model.record_v2.Addresses)31 Emails (org.orcid.jaxb.model.record_v2.Emails)31 Keywords (org.orcid.jaxb.model.record_v2.Keywords)31 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)31 Name (org.orcid.jaxb.model.record_v2.Name)29 DBUnitTest (org.orcid.test.DBUnitTest)21 Response (javax.ws.rs.core.Response)19 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)19 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)19