Search in sources :

Example 6 with Relationship

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

the class JpaJaxbWorkAdapterTest method testToWorkEntity.

@Test
public void testToWorkEntity() throws JAXBException {
    Work work = getWork(true);
    assertNotNull(work);
    WorkEntity workEntity = jpaJaxbWorkAdapter.toWorkEntity(work);
    assertNotNull(workEntity);
    assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, workEntity.getVisibility());
    assertNotNull(workEntity);
    assertEquals(123, workEntity.getId().longValue());
    assertEquals("common:title", workEntity.getTitle());
    assertTrue(PojoUtil.isEmpty(workEntity.getSubtitle()));
    assertEquals("common:translated-title", workEntity.getTranslatedTitle());
    assertEquals("en", workEntity.getTranslatedTitleLanguageCode());
    assertEquals("work:short-description", workEntity.getDescription());
    assertEquals(org.orcid.jaxb.model.record_v2.CitationType.FORMATTED_UNSPECIFIED, workEntity.getCitationType());
    assertEquals(org.orcid.jaxb.model.record_v2.WorkType.ARTISTIC_PERFORMANCE, workEntity.getWorkType());
    PublicationDateEntity publicationDateEntity = workEntity.getPublicationDate();
    assertNotNull(publicationDateEntity);
    assertEquals(1848, publicationDateEntity.getYear().intValue());
    assertEquals(02, publicationDateEntity.getMonth().intValue());
    assertEquals(02, publicationDateEntity.getDay().intValue());
    assertEquals("{\"workExternalIdentifier\":[{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"AGR\",\"workExternalIdentifierId\":{\"content\":\"work:external-identifier-id\"}}]}", workEntity.getExternalIdentifiersJson());
    assertEquals("http://tempuri.org", workEntity.getWorkUrl());
    assertEquals("{\"contributor\":[{\"contributorOrcid\":{\"uri\":\"http://orcid.org/8888-8888-8888-8880\",\"path\":\"8888-8888-8888-8880\",\"host\":\"orcid.org\"},\"creditName\":{\"content\":\"work:credit-name\"},\"contributorEmail\":{\"value\":\"work@contributor.email\"},\"contributorAttributes\":{\"contributorSequence\":\"FIRST\",\"contributorRole\":\"AUTHOR\"}}]}", workEntity.getContributorsJson());
    assertEquals("en", workEntity.getLanguageCode());
    assertEquals(org.orcid.jaxb.model.common_v2.Iso3166Country.AF, workEntity.getIso2Country());
    // Source
    assertNull(workEntity.getSourceId());
    assertNull(workEntity.getClientSourceId());
    assertNull(workEntity.getElementSourceId());
}
Also used : WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) PublicationDateEntity(org.orcid.persistence.jpa.entities.PublicationDateEntity) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Test(org.junit.Test)

Example 7 with Relationship

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

the class JpaJaxbFundingAdapterTest method toFundingEntityTest.

@Test
public void toFundingEntityTest() throws JAXBException {
    Funding f = getFunding(true);
    assertNotNull(f);
    ProfileFundingEntity pfe = jpaJaxbFundingAdapter.toProfileFundingEntity(f);
    assertNotNull(pfe);
    // Enums
    assertEquals(Visibility.PRIVATE.value(), pfe.getVisibility().value());
    assertEquals(FundingType.GRANT.value(), pfe.getType().value());
    // General info
    assertEquals(Long.valueOf(0), pfe.getId());
    assertEquals("common:title", pfe.getTitle());
    assertEquals("common:translated-title", pfe.getTranslatedTitle());
    assertEquals("en", pfe.getTranslatedTitleLanguageCode());
    assertEquals("funding:organization-defined-type", pfe.getOrganizationDefinedType());
    assertEquals("funding:short-description", pfe.getDescription());
    assertEquals("1234", pfe.getNumericAmount().toString());
    assertEquals("ADP", pfe.getCurrencyCode());
    assertEquals("http://tempuri.org", pfe.getUrl());
    // Dates
    assertEquals(Integer.valueOf(2), pfe.getStartDate().getDay());
    assertEquals(Integer.valueOf(2), pfe.getStartDate().getMonth());
    assertEquals(Integer.valueOf(1848), pfe.getStartDate().getYear());
    assertEquals(Integer.valueOf(2), pfe.getEndDate().getDay());
    assertEquals(Integer.valueOf(2), pfe.getEndDate().getMonth());
    assertEquals(Integer.valueOf(1848), pfe.getEndDate().getYear());
    // Contributors
    assertEquals("{\"contributor\":[{\"contributorOrcid\":{\"uri\":\"http://orcid.org/8888-8888-8888-8880\",\"path\":\"8888-8888-8888-8880\",\"host\":\"orcid.org\"},\"creditName\":{\"content\":\"funding:credit-name\"},\"contributorEmail\":{\"value\":\"funding@contributor.email\"},\"contributorAttributes\":{\"contributorRole\":\"LEAD\"}}]}", pfe.getContributorsJson());
    // External identifiers
    assertEquals("{\"fundingExternalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value\",\"url\":{\"value\":\"http://tempuri.org\"},\"relationship\":\"SELF\"},{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value2\",\"url\":{\"value\":\"http://tempuri.org/2\"},\"relationship\":\"SELF\"}]}", pfe.getExternalIdentifiersJson());
    // Check org is null
    assertNull(pfe.getOrg());
    // Source
    assertNull(pfe.getSourceId());
    assertNull(pfe.getClientSourceId());
    assertNull(pfe.getElementSourceId());
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test)

Example 8 with Relationship

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

the class JSONExternalIdentifiersConverterV3Test method testConvertFrom.

@Test
public void testConvertFrom() {
    ExternalIDs externalIDs = converter.convertFrom("{\"externalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"external-identifier-value\",\"url\":{\"value\":\"http://tempuri.org\"},\"relationship\":\"SELF\"},{\"type\":\"GRANT_NUMBER\",\"value\":\"external-identifier-value2\",\"url\":{\"value\":\"http://tempuri.org/2\"},\"relationship\":\"SELF\"}]}", null);
    assertNotNull(externalIDs);
    assertEquals(2, externalIDs.getExternalIdentifier().size());
    ExternalID externalID = externalIDs.getExternalIdentifier().get(0);
    assertEquals("grant_number", externalID.getType());
    assertEquals("external-identifier-value", externalID.getValue());
    assertEquals("http://tempuri.org", externalID.getUrl().getValue());
    externalID = externalIDs.getExternalIdentifier().get(1);
    assertEquals("grant_number", externalID.getType());
    assertEquals("external-identifier-value2", externalID.getValue());
    assertEquals("http://tempuri.org/2", externalID.getUrl().getValue());
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Test(org.junit.Test)

Example 9 with Relationship

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

the class JSONFundingExternalIdentifiersConverterV3Test method testConvertTo.

@Test
public void testConvertTo() throws JAXBException {
    Funding funding = getFunding();
    assertEquals("{\"fundingExternalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value\",\"url\":{\"value\":\"http://tempuri.org\"},\"relationship\":\"SELF\"},{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value2\",\"url\":{\"value\":\"http://tempuri.org/2\"},\"relationship\":\"SELF\"}]}", converter.convertTo(funding.getExternalIdentifiers(), null));
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) Test(org.junit.Test)

Example 10 with Relationship

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

the class ExternalIDValidator method validateFunding.

public void validateFunding(ExternalIDs ids) {
    if (// urgh
    ids == null)
        return;
    List<String> errors = Lists.newArrayList();
    for (ExternalID id : ids.getExternalIdentifier()) {
        if (id.getType() == null || !identifierTypeManager.fetchIdentifierTypesByAPITypeName(null).containsKey(id.getType())) {
            errors.add(id.getType());
        }
        if (PojoUtil.isEmpty(id.getValue())) {
            errors.add("value");
        }
        if (requireRelationshipOnExternalIdentifier) {
            if (id.getRelationship() == null) {
                errors.add("relationship");
            }
        }
    }
    checkAndThrow(errors);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID)

Aggregations

Test (org.junit.Test)10 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)6 Url (org.orcid.jaxb.model.v3.dev1.common.Url)2 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)2 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)2 Work (org.orcid.jaxb.model.v3.dev1.record.Work)2 MapperFactory (ma.glasnost.orika.MapperFactory)1 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)1 Item (org.orcid.jaxb.model.v3.dev1.notification.permission.Item)1 Education (org.orcid.jaxb.model.v3.dev1.record.Education)1 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)1 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)1 ExternalIdentifierEntity (org.orcid.persistence.jpa.entities.ExternalIdentifierEntity)1 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)1 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)1 PublicationDateEntity (org.orcid.persistence.jpa.entities.PublicationDateEntity)1 WorkEntity (org.orcid.persistence.jpa.entities.WorkEntity)1