Search in sources :

Example 1 with MapperFactory

use of ma.glasnost.orika.MapperFactory in project Saturn by vipshop.

the class MapperFactoryBean method getObject.

@Override
public MapperFactory getObject() throws Exception {
    MapperFactory factory = new DefaultMapperFactory.Builder().build();
    factory.classMap(JobSettings.class, CurrentJobConfig.class).mapNulls(false).byDefault().register();
    factory.classMap(JobConfig.class, CurrentJobConfig.class).mapNulls(false).byDefault().register();
    factory.classMap(CurrentJobConfig.class, HistoryJobConfig.class).mapNulls(false).byDefault().register();
    return factory;
}
Also used : HistoryJobConfig(com.vip.saturn.job.console.mybatis.entity.HistoryJobConfig) JobSettings(com.vip.saturn.job.console.domain.JobSettings) CurrentJobConfig(com.vip.saturn.job.console.mybatis.entity.CurrentJobConfig) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) JobConfig(com.vip.saturn.job.console.domain.JobConfig) HistoryJobConfig(com.vip.saturn.job.console.mybatis.entity.HistoryJobConfig) CurrentJobConfig(com.vip.saturn.job.console.mybatis.entity.CurrentJobConfig)

Example 2 with MapperFactory

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

the class SalesForceMapperFacadeFactory method getMemberMapperFacade.

public MapperFacade getMemberMapperFacade() throws Exception {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().propertyResolverStrategy(new JSONPropertyResolver()).build();
    ConverterFactory converterFactory = mapperFactory.getConverterFactory();
    converterFactory.registerConverter(new StringConverter());
    converterFactory.registerConverter(new URLConverter());
    converterFactory.registerConverter(new ReverseURLConverter());
    registerMemberMap(mapperFactory);
    registerOpportunityMap(mapperFactory);
    registerContactMap(mapperFactory);
    registerContactRoleMap(mapperFactory);
    registerOpportunityContactRoleMap(mapperFactory);
    registerOrgIdMap(mapperFactory);
    return mapperFactory.getMapperFacade();
}
Also used : ClassMapBuilder(ma.glasnost.orika.metadata.ClassMapBuilder) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) ConverterFactory(ma.glasnost.orika.converter.ConverterFactory)

Example 3 with MapperFactory

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

the class MapperFacadeFactory method getWorkMapperFacade.

public MapperFacade getWorkMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ConverterFactory converterFactory = mapperFactory.getConverterFactory();
    converterFactory.registerConverter("workExternalIdentifiersConverterId", new JSONWorkExternalIdentifiersConverterV3(norm, localeManager));
    converterFactory.registerConverter("workContributorsConverterId", new JsonOrikaConverter<WorkContributors>());
    ClassMapBuilder<Work, WorkEntity> workClassMap = mapperFactory.classMap(Work.class, WorkEntity.class);
    workClassMap.byDefault();
    workClassMap.field("putCode", "id");
    addV3DateFields(workClassMap);
    registerSourceConverters(mapperFactory, workClassMap);
    workClassMap.field("journalTitle.content", "journalTitle");
    workClassMap.field("workTitle.title.content", "title");
    workClassMap.field("workTitle.translatedTitle.content", "translatedTitle");
    workClassMap.field("workTitle.translatedTitle.languageCode", "translatedTitleLanguageCode");
    workClassMap.field("workTitle.subtitle.content", "subtitle");
    workClassMap.field("shortDescription", "description");
    workClassMap.field("workCitation.workCitationType", "citationType");
    workClassMap.field("workCitation.citation", "citation");
    workClassMap.field("workType", "workType");
    workClassMap.field("publicationDate", "publicationDate");
    workClassMap.fieldMap("workExternalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    workClassMap.field("url.value", "workUrl");
    workClassMap.fieldMap("workContributors", "contributorsJson").converter("workContributorsConverterId").add();
    workClassMap.field("languageCode", "languageCode");
    workClassMap.field("country.value", "iso2Country");
    workClassMap.register();
    ClassMapBuilder<WorkSummary, WorkEntity> workSummaryClassMap = mapperFactory.classMap(WorkSummary.class, WorkEntity.class);
    registerSourceConverters(mapperFactory, workSummaryClassMap);
    workSummaryClassMap.field("putCode", "id");
    workSummaryClassMap.field("title.title.content", "title");
    workSummaryClassMap.field("title.translatedTitle.content", "translatedTitle");
    workSummaryClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
    workSummaryClassMap.field("journalTitle.content", "journalTitle");
    workSummaryClassMap.field("type", "workType");
    workSummaryClassMap.field("publicationDate", "publicationDate");
    workSummaryClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    workSummaryClassMap.byDefault();
    workSummaryClassMap.register();
    ClassMapBuilder<WorkSummary, MinimizedWorkEntity> workSummaryMinimizedClassMap = mapperFactory.classMap(WorkSummary.class, MinimizedWorkEntity.class);
    addV3CommonFields(workSummaryMinimizedClassMap);
    registerSourceConverters(mapperFactory, workSummaryMinimizedClassMap);
    workSummaryMinimizedClassMap.field("title.title.content", "title");
    workSummaryMinimizedClassMap.field("title.translatedTitle.content", "translatedTitle");
    workSummaryMinimizedClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
    workSummaryMinimizedClassMap.field("type", "workType");
    workSummaryMinimizedClassMap.field("publicationDate.year.value", "publicationYear");
    workSummaryMinimizedClassMap.field("publicationDate.month.value", "publicationMonth");
    workSummaryMinimizedClassMap.field("publicationDate.day.value", "publicationDay");
    workSummaryMinimizedClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    workSummaryMinimizedClassMap.byDefault();
    workSummaryMinimizedClassMap.register();
    ClassMapBuilder<Work, MinimizedWorkEntity> minimizedWorkClassMap = mapperFactory.classMap(Work.class, MinimizedWorkEntity.class);
    minimizedWorkClassMap.byDefault();
    registerSourceConverters(mapperFactory, minimizedWorkClassMap);
    minimizedWorkClassMap.field("putCode", "id");
    minimizedWorkClassMap.field("journalTitle.content", "journalTitle");
    minimizedWorkClassMap.field("workTitle.title.content", "title");
    minimizedWorkClassMap.field("workTitle.translatedTitle.content", "translatedTitle");
    minimizedWorkClassMap.field("workTitle.translatedTitle.languageCode", "translatedTitleLanguageCode");
    minimizedWorkClassMap.field("workTitle.subtitle.content", "subtitle");
    minimizedWorkClassMap.field("shortDescription", "description");
    minimizedWorkClassMap.field("workType", "workType");
    minimizedWorkClassMap.field("publicationDate.year.value", "publicationYear");
    minimizedWorkClassMap.field("publicationDate.month.value", "publicationMonth");
    minimizedWorkClassMap.field("publicationDate.day.value", "publicationDay");
    minimizedWorkClassMap.fieldMap("workExternalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    minimizedWorkClassMap.field("url.value", "workUrl");
    minimizedWorkClassMap.register();
    mapperFactory.classMap(PublicationDate.class, PublicationDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
    return mapperFactory.getMapperFacade();
}
Also used : WorkContributors(org.orcid.jaxb.model.v3.dev1.record.WorkContributors) ConverterFactory(ma.glasnost.orika.converter.ConverterFactory) WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) MinimizedWorkEntity(org.orcid.persistence.jpa.entities.MinimizedWorkEntity) NotificationWorkEntity(org.orcid.persistence.jpa.entities.NotificationWorkEntity) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) JSONWorkExternalIdentifiersConverterV3(org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV3) MinimizedWorkEntity(org.orcid.persistence.jpa.entities.MinimizedWorkEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) Work(org.orcid.jaxb.model.v3.dev1.record.Work)

Example 4 with MapperFactory

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

the class MapperFacadeFactory method getQualificationMapperFacade.

public MapperFacade getQualificationMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<Qualification, OrgAffiliationRelationEntity> classMap = mapperFactory.classMap(Qualification.class, OrgAffiliationRelationEntity.class);
    ClassMapBuilder<QualificationSummary, OrgAffiliationRelationEntity> summaryClassMap = mapperFactory.classMap(QualificationSummary.class, OrgAffiliationRelationEntity.class);
    return generateMapperFacadeForAffiliation(mapperFactory, classMap, summaryClassMap);
}
Also used : Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) QualificationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Example 5 with MapperFactory

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

the class MapperFacadeFactory method getGroupIdRecordMapperFacade.

public MapperFacade getGroupIdRecordMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<GroupIdRecord, GroupIdRecordEntity> classMap = mapperFactory.classMap(GroupIdRecord.class, GroupIdRecordEntity.class);
    addV3CommonFields(classMap);
    registerSourceConverters(mapperFactory, classMap);
    classMap.field("name", "groupName");
    classMap.field("groupId", "groupId");
    classMap.field("description", "groupDescription");
    classMap.field("type", "groupType");
    classMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : GroupIdRecord(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity)

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