Search in sources :

Example 11 with Affiliation

use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.

the class PojoUtilTest method affiliationsCreateDateSortString_NullEndYearTest.

@Test
public void affiliationsCreateDateSortString_NullEndYearTest() {
    Affiliation aff = new Employment();
    FuzzyDate end = new FuzzyDate();
    end.setDay(new Day(1));
    end.setMonth(new Month(2));
    aff.setEndDate(end);
    String dateSortString = PojoUtil.createDateSortString(aff);
    assertEquals("X-NaN-02-01", dateSortString);
}
Also used : Month(org.orcid.jaxb.model.v3.dev1.common.Month) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Day(org.orcid.jaxb.model.v3.dev1.common.Day) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) Test(org.junit.Test)

Example 12 with Affiliation

use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.

the class PojoUtilTest method affiliationsCreateDateSortString_StartDateAndEndDate_NullMonthNullDayTest.

@Test
public void affiliationsCreateDateSortString_StartDateAndEndDate_NullMonthNullDayTest() {
    Affiliation aff = new Employment();
    FuzzyDate start = new FuzzyDate();
    FuzzyDate end = new FuzzyDate();
    start.setYear(new Year(1970));
    end.setYear(new Year(2017));
    aff.setStartDate(start);
    aff.setEndDate(end);
    String dateSortString = PojoUtil.createDateSortString(aff);
    assertEquals("X-2017-00-00-1970-00-00", dateSortString);
}
Also used : Year(org.orcid.jaxb.model.v3.dev1.common.Year) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) Test(org.junit.Test)

Example 13 with Affiliation

use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.

the class PojoUtilTest method affiliationsCreateDateSortString_NullStartYearTest.

@Test
public void affiliationsCreateDateSortString_NullStartYearTest() {
    Affiliation aff = new Employment();
    FuzzyDate start = new FuzzyDate();
    start.setDay(new Day(1));
    start.setMonth(new Month(2));
    aff.setStartDate(start);
    String dateSortString = PojoUtil.createDateSortString(aff);
    assertEquals("Y-NaN-02-01", dateSortString);
}
Also used : Month(org.orcid.jaxb.model.v3.dev1.common.Month) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Day(org.orcid.jaxb.model.v3.dev1.common.Day) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) Test(org.junit.Test)

Example 14 with Affiliation

use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.

the class PojoUtilTest method affiliationsCreateDateSortString_StartAndEndDateExistsTest.

@Test
public void affiliationsCreateDateSortString_StartAndEndDateExistsTest() {
    Affiliation aff = new Employment();
    FuzzyDate start = new FuzzyDate();
    FuzzyDate end = new FuzzyDate();
    start.setDay(new Day(1));
    start.setMonth(new Month(2));
    start.setYear(new Year(3));
    end.setDay(new Day(4));
    end.setMonth(new Month(5));
    end.setYear(new Year(6));
    aff.setStartDate(start);
    aff.setEndDate(end);
    String dateSortString = PojoUtil.createDateSortString(aff);
    assertNotNull(dateSortString);
    assertEquals("X-6-05-04-3-02-01", dateSortString);
}
Also used : Month(org.orcid.jaxb.model.v3.dev1.common.Month) Year(org.orcid.jaxb.model.v3.dev1.common.Year) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Day(org.orcid.jaxb.model.v3.dev1.common.Day) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) Test(org.junit.Test)

Example 15 with Affiliation

use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.

the class AffiliationsManagerImpl method createAffiliation.

private Affiliation createAffiliation(String orcid, Affiliation affiliation, boolean isApiRequest, AffiliationType type) {
    SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
    activityValidator.validateAffiliation(affiliation, sourceEntity, true, isApiRequest, null);
    if (isApiRequest) {
        checkAffiliationExternalIDsForDuplicates(orcid, affiliation, sourceEntity);
    }
    OrgAffiliationRelationEntity entity = null;
    switch(type) {
        case DISTINCTION:
            entity = jpaJaxbDistinctionAdapter.toOrgAffiliationRelationEntity((Distinction) affiliation);
            break;
        case EDUCATION:
            entity = jpaJaxbEducationAdapter.toOrgAffiliationRelationEntity((Education) affiliation);
            break;
        case EMPLOYMENT:
            entity = jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity((Employment) affiliation);
            break;
        case INVITED_POSITION:
            entity = jpaJaxbInvitedPositionAdapter.toOrgAffiliationRelationEntity((InvitedPosition) affiliation);
            break;
        case MEMBERSHIP:
            entity = jpaJaxbMembershipAdapter.toOrgAffiliationRelationEntity((Membership) affiliation);
            break;
        case QUALIFICATION:
            entity = jpaJaxbQualificationAdapter.toOrgAffiliationRelationEntity((Qualification) affiliation);
            break;
        case SERVICE:
            entity = jpaJaxbServiceAdapter.toOrgAffiliationRelationEntity((Service) affiliation);
            break;
    }
    // Updates the give organization with the latest organization from
    // database
    OrgEntity updatedOrganization = orgManager.getOrgEntity(affiliation);
    entity.setOrg(updatedOrganization);
    // Set source id
    if (sourceEntity.getSourceProfile() != null) {
        entity.setSourceId(sourceEntity.getSourceProfile().getId());
    }
    if (sourceEntity.getSourceClient() != null) {
        entity.setClientSourceId(sourceEntity.getSourceClient().getId());
    }
    ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
    entity.setProfile(profile);
    setIncomingWorkPrivacy(entity, profile);
    entity.setAffiliationType(type);
    orgAffiliationRelationDao.persist(entity);
    orgAffiliationRelationDao.flush();
    Affiliation result = null;
    switch(type) {
        case DISTINCTION:
            notificationManager.sendAmendEmail(orcid, AmendedSection.DISTINCTION, createItemList(entity));
            result = jpaJaxbDistinctionAdapter.toDistinction(entity);
            break;
        case EDUCATION:
            notificationManager.sendAmendEmail(orcid, AmendedSection.EDUCATION, createItemList(entity));
            result = jpaJaxbEducationAdapter.toEducation(entity);
            break;
        case EMPLOYMENT:
            notificationManager.sendAmendEmail(orcid, AmendedSection.EMPLOYMENT, createItemList(entity));
            result = jpaJaxbEmploymentAdapter.toEmployment(entity);
            break;
        case INVITED_POSITION:
            notificationManager.sendAmendEmail(orcid, AmendedSection.INVITED_POSITION, createItemList(entity));
            result = jpaJaxbInvitedPositionAdapter.toInvitedPosition(entity);
            break;
        case MEMBERSHIP:
            notificationManager.sendAmendEmail(orcid, AmendedSection.MEMBERSHIP, createItemList(entity));
            result = jpaJaxbMembershipAdapter.toMembership(entity);
            break;
        case QUALIFICATION:
            notificationManager.sendAmendEmail(orcid, AmendedSection.QUALIFICATION, createItemList(entity));
            result = jpaJaxbQualificationAdapter.toQualification(entity);
            break;
        case SERVICE:
            notificationManager.sendAmendEmail(orcid, AmendedSection.SERVICE, createItemList(entity));
            result = jpaJaxbServiceAdapter.toService(entity);
            break;
    }
    return result;
}
Also used : Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) Service(org.orcid.jaxb.model.v3.dev1.record.Service) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation)

Aggregations

Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)22 Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)17 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)11 Test (org.junit.Test)10 Day (org.orcid.jaxb.model.v3.dev1.common.Day)8 Month (org.orcid.jaxb.model.v3.dev1.common.Month)8 Year (org.orcid.jaxb.model.v3.dev1.common.Year)8 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)7 Education (org.orcid.jaxb.model.v3.dev1.record.Education)7 InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)7 Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)7 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)7 Service (org.orcid.jaxb.model.v3.dev1.record.Service)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)3 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)3 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)3 OrganizationAddress (org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress)3 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)3 LinkedHashMap (java.util.LinkedHashMap)2