Search in sources :

Example 1 with JSONWorkExternalIdentifiersConverterV2

use of org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV2 in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getWorkMapperFacade.

public MapperFacade getWorkMapperFacade() {
    MapperFactory mapperFactory = getNewMapperFactory();
    ConverterFactory converterFactory = mapperFactory.getConverterFactory();
    converterFactory.registerConverter("workExternalIdentifiersConverterId", new JSONWorkExternalIdentifiersConverterV2());
    converterFactory.registerConverter("workContributorsConverterId", new JsonOrikaConverter<WorkContributors>());
    ClassMapBuilder<Work, WorkEntity> workClassMap = mapperFactory.classMap(Work.class, WorkEntity.class);
    workClassMap.byDefault();
    workClassMap.field("putCode", "id");
    addV2DateFields(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("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);
    addV2CommonFields(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.record_v2.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.record.summary_v2.WorkSummary) JSONWorkExternalIdentifiersConverterV2(org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV2) MinimizedWorkEntity(org.orcid.persistence.jpa.entities.MinimizedWorkEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) Work(org.orcid.jaxb.model.record_v2.Work)

Example 2 with JSONWorkExternalIdentifiersConverterV2

use of org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV2 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)

Aggregations

MapperFactory (ma.glasnost.orika.MapperFactory)2 ConverterFactory (ma.glasnost.orika.converter.ConverterFactory)2 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)2 JSONWorkExternalIdentifiersConverterV2 (org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV2)2 JSONPeerReviewWorkExternalIdentifierConverterV2 (org.orcid.core.adapter.jsonidentifier.converter.JSONPeerReviewWorkExternalIdentifierConverterV2)1 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)1 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)1 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)1 Work (org.orcid.jaxb.model.record_v2.Work)1 WorkContributors (org.orcid.jaxb.model.record_v2.WorkContributors)1 MinimizedWorkEntity (org.orcid.persistence.jpa.entities.MinimizedWorkEntity)1 NotificationWorkEntity (org.orcid.persistence.jpa.entities.NotificationWorkEntity)1 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)1 WorkEntity (org.orcid.persistence.jpa.entities.WorkEntity)1