Search in sources :

Example 1 with PeerReviewWorkExternalIDConverter

use of org.orcid.core.adapter.impl.jsonidentifiers.PeerReviewWorkExternalIDConverter in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getPeerReviewMapperFacade.

public MapperFacade getPeerReviewMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ConverterFactory converterFactory = mapperFactory.getConverterFactory();
    converterFactory.registerConverter("workExternalIdentifiersConverterId", new WorkExternalIDsConverter());
    converterFactory.registerConverter("workExternalIdentifierConverterId", new PeerReviewWorkExternalIDConverter());
    //do same as work
    ClassMapBuilder<PeerReview, PeerReviewEntity> classMap = mapperFactory.classMap(PeerReview.class, PeerReviewEntity.class);
    addV2CommonFields(classMap);
    registerSourceConverters(mapperFactory, classMap);
    classMap.field("url.value", "url");
    classMap.field("organization.name", "org.name");
    classMap.field("organization.address.city", "org.city");
    classMap.field("organization.address.region", "org.region");
    classMap.field("organization.address.country", "org.country");
    classMap.field("organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier", "org.orgDisambiguated.sourceId");
    classMap.field("organization.disambiguatedOrganization.disambiguationSource", "org.orgDisambiguated.sourceType");
    classMap.field("groupId", "groupId");
    classMap.field("subjectType", "subjectType");
    classMap.field("subjectUrl.value", "subjectUrl");
    classMap.field("subjectName.title.content", "subjectName");
    classMap.field("subjectName.translatedTitle.content", "subjectTranslatedName");
    classMap.field("subjectName.translatedTitle.languageCode", "subjectTranslatedNameLanguageCode");
    classMap.field("subjectContainerName.content", "subjectContainerName");
    classMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    classMap.fieldMap("subjectExternalIdentifier", "subjectExternalIdentifiersJson").converter("workExternalIdentifierConverterId").add();
    classMap.register();
    ClassMapBuilder<PeerReviewSummary, PeerReviewEntity> peerReviewSummaryClassMap = mapperFactory.classMap(PeerReviewSummary.class, PeerReviewEntity.class);
    addV2CommonFields(peerReviewSummaryClassMap);
    registerSourceConverters(mapperFactory, peerReviewSummaryClassMap);
    peerReviewSummaryClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    peerReviewSummaryClassMap.field("organization.name", "org.name");
    peerReviewSummaryClassMap.field("organization.address.city", "org.city");
    peerReviewSummaryClassMap.field("organization.address.region", "org.region");
    peerReviewSummaryClassMap.field("organization.address.country", "org.country");
    peerReviewSummaryClassMap.field("organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier", "org.orgDisambiguated.sourceId");
    peerReviewSummaryClassMap.field("organization.disambiguatedOrganization.disambiguationSource", "org.orgDisambiguated.sourceType");
    peerReviewSummaryClassMap.register();
    mapperFactory.classMap(FuzzyDate.class, CompletionDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
    return mapperFactory.getMapperFacade();
}
Also used : PeerReviewWorkExternalIDConverter(org.orcid.core.adapter.impl.jsonidentifiers.PeerReviewWorkExternalIDConverter) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) WorkExternalIDsConverter(org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter) ConverterFactory(ma.glasnost.orika.converter.ConverterFactory) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview)

Example 2 with PeerReviewWorkExternalIDConverter

use of org.orcid.core.adapter.impl.jsonidentifiers.PeerReviewWorkExternalIDConverter in project ORCID-Source by ORCID.

the class WorkExternalIdentifiersConversionsTest method testConvertToExternalID.

@Test
public void testConvertToExternalID() {
    PeerReviewWorkExternalIDConverter conv = new PeerReviewWorkExternalIDConverter();
    ExternalID id = new ExternalID();
    id.setRelationship(Relationship.SELF);
    id.setType("doi");
    id.setUrl(new Url("http://what.com"));
    id.setValue("value");
    String externalIdentifiersAsString = conv.convertTo(id, null);
    assertEquals(expected, externalIdentifiersAsString);
}
Also used : PeerReviewWorkExternalIDConverter(org.orcid.core.adapter.impl.jsonidentifiers.PeerReviewWorkExternalIDConverter) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 3 with PeerReviewWorkExternalIDConverter

use of org.orcid.core.adapter.impl.jsonidentifiers.PeerReviewWorkExternalIDConverter in project ORCID-Source by ORCID.

the class WorkExternalIdentifiersConversionsTest method testConvertFromExternalID.

@Test
public void testConvertFromExternalID() {
    PeerReviewWorkExternalIDConverter conv = new PeerReviewWorkExternalIDConverter();
    String externalIdentifiersAsString = expected;
    ExternalID id = conv.convertFrom(externalIdentifiersAsString, null);
    assertEquals(Relationship.SELF, id.getRelationship());
    assertEquals(new Url("http://what.com"), id.getUrl());
    assertEquals("doi", id.getType());
    assertEquals("value", id.getValue());
}
Also used : PeerReviewWorkExternalIDConverter(org.orcid.core.adapter.impl.jsonidentifiers.PeerReviewWorkExternalIDConverter) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Aggregations

PeerReviewWorkExternalIDConverter (org.orcid.core.adapter.impl.jsonidentifiers.PeerReviewWorkExternalIDConverter)3 Test (org.junit.Test)2 Url (org.orcid.jaxb.model.common_v2.Url)2 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)2 MapperFactory (ma.glasnost.orika.MapperFactory)1 ConverterFactory (ma.glasnost.orika.converter.ConverterFactory)1 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)1 WorkExternalIDsConverter (org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter)1 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)1 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)1 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)1