Search in sources :

Example 21 with RecordNameEntity

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

the class MapperFacadeFactory method getNameMapperFacade.

public MapperFacade getNameMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<Name, RecordNameEntity> nameClassMap = mapperFactory.classMap(Name.class, RecordNameEntity.class);
    addV2DateFields(nameClassMap);
    nameClassMap.field("creditName.content", "creditName");
    nameClassMap.field("givenNames.content", "givenNames");
    nameClassMap.field("familyName.content", "familyName");
    nameClassMap.field("path", "profile.id");
    nameClassMap.byDefault();
    nameClassMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) SourceName(org.orcid.jaxb.model.common_v2.SourceName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name)

Example 22 with RecordNameEntity

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

the class Jpa2JaxbAdapterImpl method getFamilyName.

private FamilyName getFamilyName(ProfileEntity profileEntity) {
    RecordNameEntity recordName = profileEntity.getRecordNameEntity();
    if (recordName != null) {
        if (StringUtils.isNotBlank(recordName.getFamilyName())) {
            FamilyName name = new FamilyName();
            name.setContent(recordName.getFamilyName());
            name.setVisibility(recordName.getVisibility() == null ? OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility() : Visibility.fromValue(recordName.getVisibility().value()));
            return name;
        }
    }
    return null;
}
Also used : RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity)

Example 23 with RecordNameEntity

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

the class Jpa2JaxbAdapterImpl method getGivenNames.

private GivenNames getGivenNames(ProfileEntity profileEntity) {
    RecordNameEntity recordName = profileEntity.getRecordNameEntity();
    if (recordName != null) {
        if (StringUtils.isNotBlank(recordName.getGivenNames())) {
            GivenNames names = new GivenNames();
            names.setContent(recordName.getGivenNames());
            names.setVisibility(recordName.getVisibility() == null ? OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility() : Visibility.fromValue(recordName.getVisibility().value()));
            return names;
        }
    }
    return null;
}
Also used : RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity)

Example 24 with RecordNameEntity

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

the class Jpa2JaxbAdapterImpl method getCreditName.

private CreditName getCreditName(ProfileEntity profileEntity) {
    RecordNameEntity recordName = profileEntity.getRecordNameEntity();
    if (recordName != null) {
        if (StringUtils.isNotBlank(recordName.getCreditName())) {
            CreditName name = new CreditName();
            name.setContent(recordName.getCreditName());
            name.setVisibility(recordName.getVisibility() == null ? OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility() : Visibility.fromValue(recordName.getVisibility().value()));
            return name;
        }
    }
    return null;
}
Also used : RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity)

Example 25 with RecordNameEntity

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

the class Jaxb2JpaAdapterImpl method setCreditNameDetails.

private void setCreditNameDetails(ProfileEntity profileEntity, CreditName creditName) {
    if (creditName != null) {
        if (profileEntity.getRecordNameEntity() == null) {
            profileEntity.setRecordNameEntity(new RecordNameEntity());
            profileEntity.getRecordNameEntity().setProfile(profileEntity);
        }
        RecordNameEntity recordName = profileEntity.getRecordNameEntity();
        //Save the record name entity
        if (creditName.getVisibility() != null) {
            recordName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(creditName.getVisibility().value()));
        } else {
            recordName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility().value()));
        }
        recordName.setCreditName(creditName.getContent());
    }
}
Also used : RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity)

Aggregations

RecordNameEntity (org.orcid.persistence.jpa.entities.RecordNameEntity)42 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)20 Test (org.junit.Test)15 DBUnitTest (org.orcid.test.DBUnitTest)8 Date (java.util.Date)7 EmailEntity (org.orcid.persistence.jpa.entities.EmailEntity)6 HashSet (java.util.HashSet)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 Visibility (org.orcid.jaxb.model.common_v2.Visibility)4 Email (org.orcid.jaxb.model.record_v2.Email)4 Before (org.junit.Before)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Name (org.orcid.jaxb.model.record_v2.Name)3 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)3 List (java.util.List)2 Query (javax.persistence.Query)2 TypedQuery (javax.persistence.TypedQuery)2 CreditName (org.orcid.jaxb.model.common_v2.CreditName)2 FamilyName (org.orcid.jaxb.model.record_v2.FamilyName)2 Transactional (org.springframework.transaction.annotation.Transactional)2