Search in sources :

Example 6 with EndDateEntity

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

the class Jaxb2JpaAdapterImpl method getOrgAffiliationRelationEntity.

private OrgAffiliationRelationEntity getOrgAffiliationRelationEntity(Affiliation affiliation, OrgAffiliationRelationEntity exisitingOrgAffiliationEntity) {
    if (affiliation != null) {
        // Get the org
        OrgEntity orgEntity = getOrgEntity(affiliation);
        OrgAffiliationRelationEntity orgRelationEntity = null;
        if (exisitingOrgAffiliationEntity == null) {
            String putCode = affiliation.getPutCode();
            if (StringUtils.isNotBlank(putCode) && !"-1".equals(putCode)) {
                throw new IllegalArgumentException("Invalid put-code was supplied for an affiliation: " + putCode);
            }
            orgRelationEntity = new OrgAffiliationRelationEntity();
            setSource(sourceManager.retrieveSourceEntity(), orgRelationEntity);
        } else {
            orgRelationEntity = exisitingOrgAffiliationEntity;
            orgRelationEntity.clean();
        }
        FuzzyDate startDate = affiliation.getStartDate();
        FuzzyDate endDate = affiliation.getEndDate();
        if (affiliation.getType() != null) {
            orgRelationEntity.setAffiliationType(org.orcid.jaxb.model.v3.dev1.record.AffiliationType.fromValue(affiliation.getType().value()));
        }
        if (affiliation.getVisibility() != null) {
            orgRelationEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(affiliation.getVisibility().value()));
        } else {
            orgRelationEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
        }
        orgRelationEntity.setDepartment(affiliation.getDepartmentName());
        orgRelationEntity.setEndDate(endDate != null ? new EndDateEntity(endDate) : null);
        orgRelationEntity.setOrg(orgEntity);
        orgRelationEntity.setTitle(affiliation.getRoleTitle());
        orgRelationEntity.setStartDate(startDate != null ? new StartDateEntity(startDate) : null);
        if (affiliation.getCreatedDate() != null && affiliation.getCreatedDate().getValue() != null)
            orgRelationEntity.setDateCreated(affiliation.getCreatedDate().getValue().toGregorianCalendar().getTime());
        if (affiliation.getLastModifiedDate() != null && affiliation.getLastModifiedDate().getValue() != null)
            orgRelationEntity.setLastModified(affiliation.getLastModifiedDate().getValue().toGregorianCalendar().getTime());
        return orgRelationEntity;
    }
    return null;
}
Also used : EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 7 with EndDateEntity

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

the class JpaJaxbServiceAdapterTest method getEntity.

private OrgAffiliationRelationEntity getEntity() {
    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.SERVICE);
    result.setDepartment("service: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("service:title");
    result.setVisibility(org.orcid.jaxb.model.common_v2.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 8 with EndDateEntity

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

the class JpaJaxbInvitedPositionAdapterTest method getEntity.

private OrgAffiliationRelationEntity getEntity() {
    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.INVITED_POSITION);
    result.setDepartment("invited-position: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("invited-position:title");
    result.setVisibility(org.orcid.jaxb.model.common_v2.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 9 with EndDateEntity

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

the class JpaJaxbDistinctionAdapterTest method getEntity.

private OrgAffiliationRelationEntity getEntity() {
    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.DISTINCTION);
    result.setDepartment("distinction: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("distinction:title");
    result.setVisibility(org.orcid.jaxb.model.common_v2.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 10 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(org.orcid.jaxb.model.common_v2.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)

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