Search in sources :

Example 1 with Relationship

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

the class ExternalIDValidator method validateWorkOrPeerReview.

public void validateWorkOrPeerReview(ExternalIDs ids) {
    if (// yeuch
    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.record_v2.ExternalID)

Example 2 with Relationship

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

the class MapperFacadeFactory method getExternalIdentifierMapperFacade.

public MapperFacade getExternalIdentifierMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<PersonExternalIdentifier, ExternalIdentifierEntity> externalIdentifierClassMap = mapperFactory.classMap(PersonExternalIdentifier.class, ExternalIdentifierEntity.class);
    addV2DateFields(externalIdentifierClassMap);
    externalIdentifierClassMap.field("putCode", "id");
    externalIdentifierClassMap.field("type", "externalIdCommonName");
    externalIdentifierClassMap.field("value", "externalIdReference");
    externalIdentifierClassMap.field("url.value", "externalIdUrl");
    externalIdentifierClassMap.fieldBToA("displayIndex", "displayIndex");
    externalIdentifierClassMap.byDefault();
    registerSourceConverters(mapperFactory, externalIdentifierClassMap);
    //TODO: add relationship to database schema for people.
    externalIdentifierClassMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) ExternalIdentifierEntity(org.orcid.persistence.jpa.entities.ExternalIdentifierEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)

Example 3 with Relationship

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

the class JpaJaxbPeerReviewAdapterTest method testToOrgAffiliationRelationEntity.

@Test
public void testToOrgAffiliationRelationEntity() throws JAXBException {
    PeerReview e = getPeerReview(true);
    assertNotNull(e);
    PeerReviewEntity pe = jpaJaxbPeerReviewAdapter.toPeerReviewEntity(e);
    assertNotNull(pe);
    //General info
    assertEquals(Long.valueOf(12345), pe.getId());
    assertEquals(Visibility.PRIVATE.value(), pe.getVisibility().value());
    assertEquals("{\"workExternalIdentifier\":[{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"SOURCE_WORK_ID\",\"workExternalIdentifierId\":{\"content\":\"work:external-identifier-id\"}}]}", pe.getExternalIdentifiersJson());
    assertEquals("reviewer", pe.getRole().value());
    assertEquals("review", pe.getType().value());
    assertEquals("peer-review:url", pe.getUrl());
    //Dates
    assertEquals(Integer.valueOf(2), pe.getCompletionDate().getDay());
    assertEquals(Integer.valueOf(2), pe.getCompletionDate().getMonth());
    assertEquals(Integer.valueOf(1848), pe.getCompletionDate().getYear());
    // Source
    assertNull(pe.getSourceId());
    assertNull(pe.getClientSourceId());
    assertNull(pe.getElementSourceId());
    //Check org values
    assertEquals("common:name", pe.getOrg().getName());
    assertEquals("common:city", pe.getOrg().getCity());
    assertEquals("common:region", pe.getOrg().getRegion());
    assertEquals(Iso3166Country.AF.value(), pe.getOrg().getCountry().value());
    assertEquals("common:disambiguated-organization-identifier", pe.getOrg().getOrgDisambiguated().getSourceId());
    assertEquals("common:disambiguation-source", pe.getOrg().getOrgDisambiguated().getSourceType());
    //Check subject        
    assertEquals("{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"DOI\",\"workExternalIdentifierId\":{\"content\":\"peer-review:subject-external-identifier-id\"}}", pe.getSubjectExternalIdentifiersJson());
    assertEquals("peer-review:subject-container-name", pe.getSubjectContainerName());
    assertEquals("peer-review:subject-name", pe.getSubjectName());
    assertEquals("peer-review:subject-translated-name", pe.getSubjectTranslatedName());
    assertEquals("en", pe.getSubjectTranslatedNameLanguageCode());
    assertEquals("peer-review:subject-url", pe.getSubjectUrl());
    assertEquals(WorkType.JOURNAL_ARTICLE, pe.getSubjectType());
    //Check group id
    assertEquals("orcid-generated:12345", pe.getGroupId());
}
Also used : PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 4 with Relationship

use of org.orcid.jaxb.model.record_v2.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(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(CitationType.FORMATTED_UNSPECIFIED, workEntity.getCitationType());
    assertEquals(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(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.record_v2.Work) Test(org.junit.Test)

Example 5 with Relationship

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

the class ValidateV2IdentifiersTest method testWork.

/**
     * <common:external-ids>
                <common:external-id>
                        <common:external-id-type>agr</common:external-id-type>
                        <common:external-id-value>work:external-identifier-id</common:external-id-value>                        
                        <common:external-id-url>http://orcid.org</common:external-id-url>
                        <common:external-id-relationship>self</common:external-id-relationship>
                </common:external-id>
        </common:external-ids>
        
     * @throws SAXException
     * @throws IOException
     * @throws JAXBException
     * @throws ParserConfigurationException
     */
@Test
public void testWork() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    Work work = unmarshallFromPath("/record_2.0/samples/read_samples/work-2.0.xml", Work.class);
    ExternalID id = work.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("agr", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    Validator validator = getValidator("work");
    validator.validate(marshall(Work.class, work));
    validator.validate(marshallToDOM(Work.class, work));
    work = unmarshallFromPath("/record_2.0/samples/read_samples/work-full-2.0.xml", Work.class);
    id = work.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("agr", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    validator.validate(marshall(Work.class, work));
    validator.validate(marshallToDOM(Work.class, work));
}
Also used : ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) 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)

Aggregations

Test (org.junit.Test)7 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 Url (org.orcid.jaxb.model.common_v2.Url)4 Work (org.orcid.jaxb.model.record_v2.Work)3 Validator (javax.xml.validation.Validator)2 MarshallingTest (org.orcid.jaxb.model.notification.custom.MarshallingTest)2 MapperFactory (ma.glasnost.orika.MapperFactory)1 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)1 Item (org.orcid.jaxb.model.notification.permission_v2.Item)1 Funding (org.orcid.jaxb.model.record_v2.Funding)1 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)1 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.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