Search in sources :

Example 76 with PersonExternalIdentifier

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

the class ValidateV2RC4Identifiers 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_rc4/samples/person-2.0_rc4.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_rc4.PersonExternalIdentifier) Person(org.orcid.jaxb.model.record_rc4.Person) Url(org.orcid.jaxb.model.common_rc4.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 77 with PersonExternalIdentifier

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

the class ExternalIdentifierManagerTest method testAddEqualsExternalIdentifiersFromSameSource.

@Test(expected = OrcidDuplicatedElementException.class)
public void testAddEqualsExternalIdentifiersFromSameSource() {
    PersonExternalIdentifier extId = getExternalIdentifier();
    extId.setType(extId.getType() + System.currentTimeMillis());
    // Create from client # 1
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    PersonExternalIdentifier extId1 = externalIdentifierManager.createExternalIdentifier(claimedOrcid, extId, true);
    assertNotNull(extId1);
    assertNotNull(extId1.getPutCode());
    // Remove the put code and the source
    extId1.setPutCode(null);
    extId1.setSource(null);
    externalIdentifierManager.createExternalIdentifier(claimedOrcid, extId, true);
    fail();
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 78 with PersonExternalIdentifier

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

the class Api2_0_rc3_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(PersonExternalIdentifiers extIds) {
    if (extIds != null && extIds.getExternalIdentifiers() != null && !extIds.getExternalIdentifiers().isEmpty()) {
        LastModifiedDate latest = null;
        for (PersonExternalIdentifier extId : extIds.getExternalIdentifiers()) {
            if (extId.getLastModifiedDate() != null && extId.getLastModifiedDate().after(latest)) {
                latest = extId.getLastModifiedDate();
            }
        }
        extIds.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc3.LastModifiedDate) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier)

Example 79 with PersonExternalIdentifier

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

the class JpaJaxbExternalIdentifierAdapterTest method fromExternalIdentifierEntityToExternalIdentifier.

@Test
public void fromExternalIdentifierEntityToExternalIdentifier() {
    ExternalIdentifierEntity entity = getExternalIdentifierEntity();
    PersonExternalIdentifier extId = jpaJaxbExternalIdentifierAdapter.toExternalIdentifier(entity);
    assertNotNull(extId);
    assertNotNull(extId.getCreatedDate());
    assertNotNull(extId.getCreatedDate().getValue());
    assertNotNull(extId.getLastModifiedDate());
    assertNotNull(extId.getLastModifiedDate().getValue());
    assertEquals("common-name", extId.getType());
    assertEquals("id-reference", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://myurl.com", extId.getUrl().getValue());
    assertEquals(Long.valueOf(123), extId.getPutCode());
    assertNotNull(extId.getSource());
    assertEquals("APP-0000000000000000", extId.getSource().retrieveSourcePath());
    assertEquals(Visibility.LIMITED.value(), extId.getVisibility().value());
    assertNotNull(extId.getCreatedDate());
    assertNotNull(extId.getLastModifiedDate());
}
Also used : ExternalIdentifierEntity(org.orcid.persistence.jpa.entities.ExternalIdentifierEntity) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Test(org.junit.Test)

Example 80 with PersonExternalIdentifier

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

the class JpaJaxbExternalIdentifierAdapterImpl method toExternalIdentifierList.

@Override
public PersonExternalIdentifiers toExternalIdentifierList(Collection<ExternalIdentifierEntity> entities) {
    if (entities == null) {
        return null;
    }
    List<PersonExternalIdentifier> externalIdentifier = mapperFacade.mapAsList(entities, PersonExternalIdentifier.class);
    for (PersonExternalIdentifier e : externalIdentifier) {
        e.setRelationship(Relationship.SELF);
    }
    PersonExternalIdentifiers externalIdentifiers = new PersonExternalIdentifiers();
    externalIdentifiers.setExternalIdentifiers(externalIdentifier);
    return externalIdentifiers;
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)

Aggregations

PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)99 Test (org.junit.Test)91 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)50 OtherName (org.orcid.jaxb.model.record_v2.OtherName)44 Address (org.orcid.jaxb.model.record_v2.Address)43 Keyword (org.orcid.jaxb.model.record_v2.Keyword)42 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)42 Email (org.orcid.jaxb.model.record_v2.Email)39 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)34 Biography (org.orcid.jaxb.model.record_v2.Biography)33 Addresses (org.orcid.jaxb.model.record_v2.Addresses)32 Emails (org.orcid.jaxb.model.record_v2.Emails)32 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 Person (org.orcid.jaxb.model.record_v2.Person)32 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)32 Name (org.orcid.jaxb.model.record_v2.Name)30 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 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)19