Search in sources :

Example 1 with EndDateEntity

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

the class JpaJaxbEducationAdapterTest method getEducationEntity.

private OrgAffiliationRelationEntity getEducationEntity() {
    OrgEntity orgEntity = new OrgEntity();
    orgEntity.setCity("org:city");
    orgEntity.setCountry(org.orcid.jaxb.model.message.Iso3166Country.US);
    orgEntity.setName("org:name");
    orgEntity.setRegion("org:region");
    orgEntity.setUrl("org:url");
    orgEntity.setSource(new SourceEntity("APP-000000001"));
    OrgAffiliationRelationEntity result = new OrgAffiliationRelationEntity();
    result.setAffiliationType(AffiliationType.EDUCATION);
    result.setDepartment("education:department");
    result.setEndDate(new EndDateEntity(2020, 2, 2));
    result.setId(123456L);
    result.setOrg(orgEntity);
    result.setProfile(new ProfileEntity("0000-0001-0002-0003"));
    result.setStartDate(new StartDateEntity(2000, 1, 1));
    result.setTitle("education:title");
    result.setVisibility(Visibility.PRIVATE);
    result.setClientSourceId("APP-000000001");
    return result;
}
Also used : EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 2 with EndDateEntity

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

the class JpaJaxbEmploymentAdapterTest method getEmploymentEntity.

private OrgAffiliationRelationEntity getEmploymentEntity() {
    OrgEntity orgEntity = new OrgEntity();
    orgEntity.setCity("org:city");
    orgEntity.setCountry(org.orcid.jaxb.model.message.Iso3166Country.US);
    orgEntity.setName("org:name");
    orgEntity.setRegion("org:region");
    orgEntity.setUrl("org:url");
    orgEntity.setSource(new SourceEntity("APP-000000001"));
    OrgAffiliationRelationEntity result = new OrgAffiliationRelationEntity();
    result.setAffiliationType(AffiliationType.EMPLOYMENT);
    result.setDepartment("employment:department");
    result.setEndDate(new EndDateEntity(2020, 2, 2));
    result.setId(123456L);
    result.setOrg(orgEntity);
    result.setProfile(new ProfileEntity("0000-0001-0002-0003"));
    result.setStartDate(new StartDateEntity(2000, 1, 1));
    result.setTitle("employment:title");
    result.setVisibility(Visibility.PRIVATE);
    result.setClientSourceId("APP-000000001");
    return result;
}
Also used : EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 3 with EndDateEntity

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

the class JSONFundingExternalIdentifiersConverterV2Test method getProfileFundingEntity.

private ProfileFundingEntity getProfileFundingEntity() {
    ProfileFundingEntity result = new ProfileFundingEntity();
    result.setContributorsJson("{\"contributor\":[{\"contributorOrcid\":{\"value\":null,\"valueAsString\":null,\"uri\":\"http://orcid.org/8888-8888-8888-8880\",\"path\":\"8888-8888-8888-8880\",\"host\":\"orcid.org\"},\"creditName\":{\"content\":\"funding:creditName\"},\"contributorEmail\":{\"value\":\"funding@contributorEmail.com\"},\"contributorAttributes\":{\"contributorRole\":\"LEAD\"}}]}");
    result.setDescription("funding:description");
    result.setEndDate(new EndDateEntity(2020, 1, 1));
    result.setStartDate(new StartDateEntity(2000, 1, 1));
    result.setExternalIdentifiersJson("{\"fundingExternalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"12345\",\"url\":{\"value\":\"http://tempuri.org\"}},{\"type\":\"GRANT_NUMBER\",\"value\":\"67890\",\"url\":{\"value\":\"http://tempuri.org/2\"}}]}");
    result.setId(12345L);
    result.setNumericAmount(new BigDecimal(123456));
    result.setCurrencyCode("CRC");
    result.setTitle("funding:title");
    result.setTranslatedTitle("funding:translatedTitle");
    result.setTranslatedTitleLanguageCode("ES");
    result.setType(FundingType.SALARY_AWARD);
    result.setVisibility(Visibility.PRIVATE);
    return result;
}
Also used : EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) BigDecimal(java.math.BigDecimal) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity)

Example 4 with EndDateEntity

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

the class MapperFacadeFactory method mapFuzzyDateToStartDateEntityAndEndDateEntity.

private void mapFuzzyDateToStartDateEntityAndEndDateEntity(MapperFactory mapperFactory) {
    mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).customize(new CustomMapper<FuzzyDate, StartDateEntity>() {

        @Override
        public void mapAtoB(FuzzyDate fuzzyDate, StartDateEntity entity, MappingContext context) {
            if (fuzzyDate.getYear() != null) {
                entity.setYear(Integer.valueOf(fuzzyDate.getYear().getValue()));
            } else {
                entity.setYear(null);
            }
            if (fuzzyDate.getMonth() != null) {
                entity.setMonth(Integer.valueOf(fuzzyDate.getMonth().getValue()));
            } else {
                entity.setMonth(null);
            }
            if (fuzzyDate.getDay() != null) {
                entity.setDay(Integer.valueOf(fuzzyDate.getDay().getValue()));
            } else {
                entity.setDay(null);
            }
        }

        @Override
        public void mapBtoA(StartDateEntity entity, FuzzyDate fuzzyDate, MappingContext context) {
            if (entity.getYear() != null) {
                fuzzyDate.setYear(new Year(entity.getYear()));
            } else {
                fuzzyDate.setYear(null);
            }
            if (entity.getMonth() != null) {
                fuzzyDate.setMonth(new Month(entity.getMonth()));
            } else {
                fuzzyDate.setMonth(null);
            }
            if (entity.getDay() != null) {
                fuzzyDate.setDay(new Day(entity.getDay()));
            } else {
                fuzzyDate.setDay(null);
            }
        }
    }).register();
    mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).customize(new CustomMapper<FuzzyDate, EndDateEntity>() {

        @Override
        public void mapAtoB(FuzzyDate fuzzyDate, EndDateEntity entity, MappingContext context) {
            if (fuzzyDate.getYear() != null) {
                entity.setYear(Integer.valueOf(fuzzyDate.getYear().getValue()));
            } else {
                entity.setYear(null);
            }
            if (fuzzyDate.getMonth() != null) {
                entity.setMonth(Integer.valueOf(fuzzyDate.getMonth().getValue()));
            } else {
                entity.setMonth(null);
            }
            if (fuzzyDate.getDay() != null) {
                entity.setDay(Integer.valueOf(fuzzyDate.getDay().getValue()));
            } else {
                entity.setDay(null);
            }
        }

        @Override
        public void mapBtoA(EndDateEntity entity, FuzzyDate fuzzyDate, MappingContext context) {
            if (entity.getYear() != null) {
                fuzzyDate.setYear(new Year(entity.getYear()));
            } else {
                fuzzyDate.setYear(null);
            }
            if (entity.getMonth() != null) {
                fuzzyDate.setMonth(new Month(entity.getMonth()));
            } else {
                fuzzyDate.setMonth(null);
            }
            if (entity.getDay() != null) {
                fuzzyDate.setDay(new Day(entity.getDay()));
            } else {
                fuzzyDate.setDay(null);
            }
        }
    }).register();
}
Also used : MappingContext(ma.glasnost.orika.MappingContext) EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) Month(org.orcid.jaxb.model.v3.dev1.common.Month) Year(org.orcid.jaxb.model.v3.dev1.common.Year) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) CustomMapper(ma.glasnost.orika.CustomMapper) Day(org.orcid.jaxb.model.v3.dev1.common.Day)

Example 5 with EndDateEntity

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

the class MapperFacadeFactory method mapFuzzyDateToStartDateEntityAndEndDateEntity.

private void mapFuzzyDateToStartDateEntityAndEndDateEntity(MapperFactory mapperFactory) {
    mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).customize(new CustomMapper<FuzzyDate, StartDateEntity>() {

        @Override
        public void mapAtoB(FuzzyDate fuzzyDate, StartDateEntity entity, MappingContext context) {
            if (fuzzyDate.getYear() != null) {
                entity.setYear(Integer.valueOf(fuzzyDate.getYear().getValue()));
            } else {
                entity.setYear(null);
            }
            if (fuzzyDate.getMonth() != null) {
                entity.setMonth(Integer.valueOf(fuzzyDate.getMonth().getValue()));
            } else {
                entity.setMonth(null);
            }
            if (fuzzyDate.getDay() != null) {
                entity.setDay(Integer.valueOf(fuzzyDate.getDay().getValue()));
            } else {
                entity.setDay(null);
            }
        }

        @Override
        public void mapBtoA(StartDateEntity entity, FuzzyDate fuzzyDate, MappingContext context) {
            if (entity.getYear() != null) {
                fuzzyDate.setYear(new Year(entity.getYear()));
            } else {
                fuzzyDate.setYear(null);
            }
            if (entity.getMonth() != null) {
                fuzzyDate.setMonth(new Month(entity.getMonth()));
            } else {
                fuzzyDate.setMonth(null);
            }
            if (entity.getDay() != null) {
                fuzzyDate.setDay(new Day(entity.getDay()));
            } else {
                fuzzyDate.setDay(null);
            }
        }
    }).register();
    mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).customize(new CustomMapper<FuzzyDate, EndDateEntity>() {

        @Override
        public void mapAtoB(FuzzyDate fuzzyDate, EndDateEntity entity, MappingContext context) {
            if (fuzzyDate.getYear() != null) {
                entity.setYear(Integer.valueOf(fuzzyDate.getYear().getValue()));
            } else {
                entity.setYear(null);
            }
            if (fuzzyDate.getMonth() != null) {
                entity.setMonth(Integer.valueOf(fuzzyDate.getMonth().getValue()));
            } else {
                entity.setMonth(null);
            }
            if (fuzzyDate.getDay() != null) {
                entity.setDay(Integer.valueOf(fuzzyDate.getDay().getValue()));
            } else {
                entity.setDay(null);
            }
        }

        @Override
        public void mapBtoA(EndDateEntity entity, FuzzyDate fuzzyDate, MappingContext context) {
            if (entity.getYear() != null) {
                fuzzyDate.setYear(new Year(entity.getYear()));
            } else {
                fuzzyDate.setYear(null);
            }
            if (entity.getMonth() != null) {
                fuzzyDate.setMonth(new Month(entity.getMonth()));
            } else {
                fuzzyDate.setMonth(null);
            }
            if (entity.getDay() != null) {
                fuzzyDate.setDay(new Day(entity.getDay()));
            } else {
                fuzzyDate.setDay(null);
            }
        }
    }).register();
}
Also used : MappingContext(ma.glasnost.orika.MappingContext) EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) Month(org.orcid.jaxb.model.common_v2.Month) Year(org.orcid.jaxb.model.common_v2.Year) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) CustomMapper(ma.glasnost.orika.CustomMapper) Day(org.orcid.jaxb.model.common_v2.Day)

Aggregations

EndDateEntity (org.orcid.persistence.jpa.entities.EndDateEntity)17 StartDateEntity (org.orcid.persistence.jpa.entities.StartDateEntity)17 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)11 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)10 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)9 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)9 BigDecimal (java.math.BigDecimal)5 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)5 CustomMapper (ma.glasnost.orika.CustomMapper)2 MappingContext (ma.glasnost.orika.MappingContext)2 FuzzyDate (org.orcid.jaxb.model.message.FuzzyDate)2 JSONFundingExternalIdentifiersConverterV1 (org.orcid.core.adapter.jsonidentifier.converter.JSONFundingExternalIdentifiersConverterV1)1 ApplicationException (org.orcid.core.exception.ApplicationException)1 Day (org.orcid.jaxb.model.common_v2.Day)1 FuzzyDate (org.orcid.jaxb.model.common_v2.FuzzyDate)1 Month (org.orcid.jaxb.model.common_v2.Month)1 Year (org.orcid.jaxb.model.common_v2.Year)1 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)1 Day (org.orcid.jaxb.model.v3.dev1.common.Day)1 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)1