Search in sources :

Example 26 with ResearcherUrlEntity

use of org.orcid.persistence.jpa.entities.ResearcherUrlEntity 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)

Example 27 with ResearcherUrlEntity

use of org.orcid.persistence.jpa.entities.ResearcherUrlEntity in project ORCID-Source by ORCID.

the class Jpa2JaxbAdapterImpl method getResearcherUrls.

private ResearcherUrls getResearcherUrls(ProfileEntity profileEntity) {
    Set<ResearcherUrlEntity> researcherUrlEntities = profileEntity.getResearcherUrls();
    if (researcherUrlEntities != null) {
        ResearcherUrls researcherUrls = new ResearcherUrls();
        Visibility mostRestrictive = Visibility.PUBLIC;
        for (ResearcherUrlEntity researcherUrl : researcherUrlEntities) {
            // will only be null if there's an issue with the data or you're using this layer directly
            Visibility vis = (researcherUrl.getVisibility() != null) ? Visibility.fromValue(researcherUrl.getVisibility().value()) : Visibility.PRIVATE;
            if (vis.isMoreRestrictiveThan(mostRestrictive))
                mostRestrictive = vis;
            ResearcherUrl url = new ResearcherUrl(new Url(researcherUrl.getUrl()), vis);
            if (!StringUtils.isBlank(researcherUrl.getUrlName()))
                url.setUrlName(new UrlName(researcherUrl.getUrlName()));
            if (!PojoUtil.isEmpty(researcherUrl.getElementSourceId())) {
                Source source = getSource(researcherUrl);
                url.setSource(source);
            }
            researcherUrls.setVisibility(mostRestrictive);
            researcherUrls.getResearcherUrl().add(url);
        }
        return researcherUrls;
    }
    return null;
}
Also used : ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity)

Example 28 with ResearcherUrlEntity

use of org.orcid.persistence.jpa.entities.ResearcherUrlEntity in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getResearcherUrlMapperFacade.

public MapperFacade getResearcherUrlMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<ResearcherUrl, ResearcherUrlEntity> researcherUrlClassMap = mapperFactory.classMap(ResearcherUrl.class, ResearcherUrlEntity.class);
    addV3DateFields(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) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)

Aggregations

ResearcherUrlEntity (org.orcid.persistence.jpa.entities.ResearcherUrlEntity)28 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)12 Transactional (org.springframework.transaction.annotation.Transactional)12 Date (java.util.Date)10 Test (org.junit.Test)10 OrcidDuplicatedElementException (org.orcid.core.exception.OrcidDuplicatedElementException)8 ExternalIdentifierEntity (org.orcid.persistence.jpa.entities.ExternalIdentifierEntity)7 OtherNameEntity (org.orcid.persistence.jpa.entities.OtherNameEntity)7 ProfileKeywordEntity (org.orcid.persistence.jpa.entities.ProfileKeywordEntity)7 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)7 AddressEntity (org.orcid.persistence.jpa.entities.AddressEntity)6 DBUnitTest (org.orcid.test.DBUnitTest)6 ApplicationException (org.orcid.core.exception.ApplicationException)5 HashMap (java.util.HashMap)4 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)3 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)3 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)3 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)3 Rollback (org.springframework.test.annotation.Rollback)3 InvalidParameterException (java.security.InvalidParameterException)2