Search in sources :

Example 6 with Affiliation

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

the class ActivityManagerImpl method affiliationMap.

public LinkedHashMap<Long, Affiliation> affiliationMap(String orcid) {
    LinkedHashMap<Long, Affiliation> affiliationMap = new LinkedHashMap<>();
    List<Affiliation> affiliations = affiliationsManager.getAffiliations(orcid);
    for (Affiliation affiliation : affiliations) {
        if (Visibility.PUBLIC.equals(affiliation.getVisibility())) {
            affiliationMap.put(affiliation.getPutCode(), affiliation);
        }
    }
    return affiliationMap;
}
Also used : Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with Affiliation

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

the class AffiliationsManagerImpl method updateAffiliation.

public Affiliation updateAffiliation(String orcid, Affiliation affiliation, boolean isApiRequest, AffiliationType type) {
    OrgAffiliationRelationEntity entity = orgAffiliationRelationDao.getOrgAffiliationRelation(orcid, affiliation.getPutCode());
    SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
    // Save the original source
    String existingSourceId = entity.getSourceId();
    String existingClientSourceId = entity.getClientSourceId();
    org.orcid.jaxb.model.common_v2.Visibility originalVisibility = entity.getVisibility();
    orcidSecurityManager.checkSource(entity);
    activityValidator.validateAffiliation(affiliation, sourceEntity, false, isApiRequest, org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(originalVisibility.value()));
    if (isApiRequest) {
        checkAffiliationExternalIDsForDuplicates(orcid, affiliation, sourceEntity);
    }
    switch(type) {
        case DISTINCTION:
            jpaJaxbDistinctionAdapter.toOrgAffiliationRelationEntity((Distinction) affiliation, entity);
            break;
        case EDUCATION:
            jpaJaxbEducationAdapter.toOrgAffiliationRelationEntity((Education) affiliation, entity);
            break;
        case EMPLOYMENT:
            jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity((Employment) affiliation, entity);
            break;
        case INVITED_POSITION:
            jpaJaxbInvitedPositionAdapter.toOrgAffiliationRelationEntity((InvitedPosition) affiliation, entity);
            break;
        case MEMBERSHIP:
            jpaJaxbMembershipAdapter.toOrgAffiliationRelationEntity((Membership) affiliation, entity);
            break;
        case QUALIFICATION:
            jpaJaxbQualificationAdapter.toOrgAffiliationRelationEntity((Qualification) affiliation, entity);
            break;
        case SERVICE:
            jpaJaxbServiceAdapter.toOrgAffiliationRelationEntity((Service) affiliation, entity);
            break;
    }
    entity.setVisibility(originalVisibility);
    // Be sure it doesn't overwrite the source
    entity.setSourceId(existingSourceId);
    entity.setClientSourceId(existingClientSourceId);
    // Updates the give organization with the latest organization from
    // database, or, create a new one
    OrgEntity updatedOrganization = orgManager.getOrgEntity(affiliation);
    entity.setOrg(updatedOrganization);
    entity.setAffiliationType(type);
    entity = orgAffiliationRelationDao.merge(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 : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation)

Example 8 with Affiliation

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

the class AffiliationsManagerReadOnlyImpl method getAffiliations.

@Override
public List<Affiliation> getAffiliations(String orcid) {
    List<OrgAffiliationRelationEntity> affiliations = orgAffiliationRelationDao.getByUser(orcid);
    List<Affiliation> result = new ArrayList<Affiliation>();
    if (affiliations != null) {
        for (OrgAffiliationRelationEntity affiliation : affiliations) {
            switch(affiliation.getAffiliationType()) {
                case DISTINCTION:
                    result.add(jpaJaxbDistinctionAdapter.toDistinction(affiliation));
                    break;
                case EDUCATION:
                    result.add(jpaJaxbEducationAdapter.toEducation(affiliation));
                    break;
                case EMPLOYMENT:
                    result.add(jpaJaxbEmploymentAdapter.toEmployment(affiliation));
                    break;
                case INVITED_POSITION:
                    result.add(jpaJaxbInvitedPositionAdapter.toInvitedPosition(affiliation));
                    break;
                case MEMBERSHIP:
                    result.add(jpaJaxbMembershipAdapter.toMembership(affiliation));
                    break;
                case QUALIFICATION:
                    result.add(jpaJaxbQualificationAdapter.toQualification(affiliation));
                    break;
                case SERVICE:
                    result.add(jpaJaxbServiceAdapter.toService(affiliation));
                    break;
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation)

Example 9 with Affiliation

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

the class PojoUtilTest method affiliationsCreateDateSortString_StartAndEndDateNullTest.

@Test
public void affiliationsCreateDateSortString_StartAndEndDateNullTest() {
    Affiliation aff = new Employment();
    aff.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(0)));
    String dateSortString = PojoUtil.createDateSortString(aff);
    assertNotNull(dateSortString);
    assertThat(dateSortString, anyOf(is("Z-1969-12-31"), is("Z-1970-1-1")));
}
Also used : Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) Test(org.junit.Test)

Example 10 with Affiliation

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

the class PojoUtilTest method affiliationsCreateDateSortString_NullStartYearNullEndYearTest.

@Test
public void affiliationsCreateDateSortString_NullStartYearNullEndYearTest() {
    Affiliation aff = new Employment();
    FuzzyDate start = new FuzzyDate();
    FuzzyDate end = new FuzzyDate();
    start.setDay(new Day(1));
    start.setMonth(new Month(2));
    end.setDay(new Day(3));
    end.setMonth(new Month(4));
    aff.setStartDate(start);
    aff.setEndDate(end);
    String dateSortString = PojoUtil.createDateSortString(aff);
    assertEquals("X-NaN-04-03-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)

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