Search in sources :

Example 26 with OrgAffiliationRelationEntity

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

the class Jaxb2JpaAdapterImpl method getUpdatedAffiliationRelationEntity.

@Override
public OrgAffiliationRelationEntity getUpdatedAffiliationRelationEntity(Affiliation updatedAffiliation) {
    if (PojoUtil.isEmpty(updatedAffiliation.getPutCode()))
        throw new IllegalArgumentException("Affiliation must contain a put code to be edited");
    long affiliationId = Long.valueOf(updatedAffiliation.getPutCode());
    OrgAffiliationRelationEntity exisitingOrgAffiliationEntity = orgAffiliationRelationDao.find(affiliationId);
    OrgAffiliationRelationEntity orgAffiliationRelationEntity = getOrgAffiliationRelationEntity(updatedAffiliation, exisitingOrgAffiliationEntity);
    return orgAffiliationRelationEntity;
}
Also used : OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Example 27 with OrgAffiliationRelationEntity

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

the class Jpa2JaxbAdapterImpl method getAffiliations.

private Affiliations getAffiliations(ProfileEntity profileEntity) {
    LOGGER.debug("About to convert affiliations from entity: " + profileEntity.getId());
    Set<OrgAffiliationRelationEntity> orgRelationEntities = profileEntity.getOrgAffiliationRelations();
    if (orgRelationEntities != null && !orgRelationEntities.isEmpty()) {
        Affiliations affiliations = new Affiliations();
        List<Affiliation> affiliationList = affiliations.getAffiliation();
        for (OrgAffiliationRelationEntity orgRelationEntity : orgRelationEntities) {
            affiliationList.add(getAffiliation(orgRelationEntity));
        }
        return affiliations;
    }
    return null;
}
Also used : OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Example 28 with OrgAffiliationRelationEntity

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

the class MapperFacadeFactory method getEducationMapperFacade.

public MapperFacade getEducationMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<Education, OrgAffiliationRelationEntity> educationClassMap = mapperFactory.classMap(Education.class, OrgAffiliationRelationEntity.class);
    addV2CommonFields(educationClassMap);
    registerSourceConverters(mapperFactory, educationClassMap);
    educationClassMap.fieldBToA("org.name", "organization.name");
    educationClassMap.fieldBToA("org.city", "organization.address.city");
    educationClassMap.fieldBToA("org.region", "organization.address.region");
    educationClassMap.fieldBToA("org.country", "organization.address.country");
    educationClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
    educationClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
    educationClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
    educationClassMap.field("departmentName", "department");
    educationClassMap.field("roleTitle", "title");
    educationClassMap.register();
    ClassMapBuilder<EducationSummary, OrgAffiliationRelationEntity> educationSummaryClassMap = mapperFactory.classMap(EducationSummary.class, OrgAffiliationRelationEntity.class);
    addV2CommonFields(educationSummaryClassMap);
    registerSourceConverters(mapperFactory, educationSummaryClassMap);
    educationSummaryClassMap.fieldBToA("org.name", "organization.name");
    educationSummaryClassMap.fieldBToA("org.city", "organization.address.city");
    educationSummaryClassMap.fieldBToA("org.region", "organization.address.region");
    educationSummaryClassMap.fieldBToA("org.country", "organization.address.country");
    educationSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
    educationSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
    educationSummaryClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
    educationSummaryClassMap.field("departmentName", "department");
    educationSummaryClassMap.field("roleTitle", "title");
    educationSummaryClassMap.register();
    mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
    mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
    return mapperFactory.getMapperFacade();
}
Also used : Education(org.orcid.jaxb.model.record_v2.Education) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Aggregations

OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)28 Test (org.junit.Test)8 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)8 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)7 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)6 Education (org.orcid.jaxb.model.record_v2.Education)3 Employment (org.orcid.jaxb.model.record_v2.Employment)3 EndDateEntity (org.orcid.persistence.jpa.entities.EndDateEntity)3 ExternalIdentifierEntity (org.orcid.persistence.jpa.entities.ExternalIdentifierEntity)3 OtherNameEntity (org.orcid.persistence.jpa.entities.OtherNameEntity)3 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)3 ProfileKeywordEntity (org.orcid.persistence.jpa.entities.ProfileKeywordEntity)3 ResearcherUrlEntity (org.orcid.persistence.jpa.entities.ResearcherUrlEntity)3 StartDateEntity (org.orcid.persistence.jpa.entities.StartDateEntity)3 TreeSet (java.util.TreeSet)2 MapperFactory (ma.glasnost.orika.MapperFactory)2 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)2 Visibility (org.orcid.jaxb.model.common_v2.Visibility)2 Affiliation (org.orcid.jaxb.model.message.Affiliation)2 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)2