Search in sources :

Example 16 with MapperFactory

use of ma.glasnost.orika.MapperFactory in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getPeerReviewMapperFacade.

public MapperFacade getPeerReviewMapperFacade() {
    MapperFactory mapperFactory = getNewMapperFactory();
    ConverterFactory converterFactory = mapperFactory.getConverterFactory();
    converterFactory.registerConverter("workExternalIdentifiersConverterId", new JSONWorkExternalIdentifiersConverterV2());
    converterFactory.registerConverter("workExternalIdentifierConverterId", new JSONPeerReviewWorkExternalIdentifierConverterV2());
    // 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 : JSONWorkExternalIdentifiersConverterV2(org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV2) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) ConverterFactory(ma.glasnost.orika.converter.ConverterFactory) JSONPeerReviewWorkExternalIdentifierConverterV2(org.orcid.core.adapter.jsonidentifier.converter.JSONPeerReviewWorkExternalIdentifierConverterV2) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview)

Example 17 with MapperFactory

use of ma.glasnost.orika.MapperFactory in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getKeywordMapperFacade.

public MapperFacade getKeywordMapperFacade() {
    MapperFactory mapperFactory = getNewMapperFactory();
    ClassMapBuilder<Keyword, ProfileKeywordEntity> keywordClassMap = mapperFactory.classMap(Keyword.class, ProfileKeywordEntity.class);
    addV2DateFields(keywordClassMap);
    registerSourceConverters(mapperFactory, keywordClassMap);
    keywordClassMap.field("putCode", "id");
    keywordClassMap.field("content", "keywordName");
    keywordClassMap.fieldBToA("displayIndex", "displayIndex");
    keywordClassMap.byDefault();
    keywordClassMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : ProfileKeywordEntity(org.orcid.persistence.jpa.entities.ProfileKeywordEntity) Keyword(org.orcid.jaxb.model.record_v2.Keyword) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory)

Example 18 with MapperFactory

use of ma.glasnost.orika.MapperFactory in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getAddressMapperFacade.

public MapperFacade getAddressMapperFacade() {
    MapperFactory mapperFactory = getNewMapperFactory();
    ClassMapBuilder<Address, AddressEntity> addressClassMap = mapperFactory.classMap(Address.class, AddressEntity.class);
    addV2DateFields(addressClassMap);
    registerSourceConverters(mapperFactory, addressClassMap);
    addressClassMap.field("putCode", "id");
    addressClassMap.field("country.value", "iso2Country");
    addressClassMap.field("visibility", "visibility");
    addressClassMap.fieldBToA("displayIndex", "displayIndex");
    addressClassMap.byDefault();
    addressClassMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : Address(org.orcid.jaxb.model.record_v2.Address) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) AddressEntity(org.orcid.persistence.jpa.entities.AddressEntity)

Example 19 with MapperFactory

use of ma.glasnost.orika.MapperFactory in project orika-spring-boot-starter by akihyro.

the class OrikaAutoConfiguration method orikaMapperFactory.

/**
     * Creates a {@link MapperFactory}.
     *
     * @param orikaMapperFactoryBuilder the {@link MapperFactoryBuilder}.
     * @return a {@link MapperFactory}.
     */
@ConditionalOnMissingBean
@Bean
public MapperFactory orikaMapperFactory(MapperFactoryBuilder<?, ?> orikaMapperFactoryBuilder) {
    MapperFactory orikaMapperFactory = orikaMapperFactoryBuilder.build();
    orikaMapperFactoryConfigurers.orElseGet(Collections::emptyList).forEach(configurer -> configurer.configure(orikaMapperFactory));
    log.debug("Created a MapperFactory: [{}]", orikaMapperFactory);
    return orikaMapperFactory;
}
Also used : DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 20 with MapperFactory

use of ma.glasnost.orika.MapperFactory in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getResearcherUrlMapperFacade.

public MapperFacade getResearcherUrlMapperFacade() {
    MapperFactory mapperFactory = getNewMapperFactory();
    ClassMapBuilder<ResearcherUrl, ResearcherUrlEntity> researcherUrlClassMap = mapperFactory.classMap(ResearcherUrl.class, ResearcherUrlEntity.class);
    addV2DateFields(researcherUrlClassMap);
    registerSourceConverters(mapperFactory, researcherUrlClassMap);
    researcherUrlClassMap.field("putCode", "id");
    researcherUrlClassMap.field("url.value", "url");
    researcherUrlClassMap.field("urlName", "urlName");
    researcherUrlClassMap.fieldBToA("displayIndex", "displayIndex");
    researcherUrlClassMap.byDefault();
    researcherUrlClassMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Aggregations

MapperFactory (ma.glasnost.orika.MapperFactory)42 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)42 ConverterFactory (ma.glasnost.orika.converter.ConverterFactory)9 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)9 MappingContext (ma.glasnost.orika.MappingContext)4 NotificationWorkEntity (org.orcid.persistence.jpa.entities.NotificationWorkEntity)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 TreeSet (java.util.TreeSet)2 MapperFacade (ma.glasnost.orika.MapperFacade)2 ExternalIdentifierTypeConverter (org.orcid.core.adapter.jsonidentifier.converter.ExternalIdentifierTypeConverter)2 JSONWorkExternalIdentifiersConverterV2 (org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV2)2 JSONWorkExternalIdentifiersConverterV3 (org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV3)2 OtherName (org.orcid.jaxb.model.record_v2.OtherName)2 RecordCorrection (org.orcid.model.record_correction.RecordCorrection)2 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)2 ClientRedirectUriEntity (org.orcid.persistence.jpa.entities.ClientRedirectUriEntity)2 ClientSecretEntity (org.orcid.persistence.jpa.entities.ClientSecretEntity)2