Search in sources :

Example 16 with Affiliation

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

the class Utils method getAffiliation.

public static Affiliation getAffiliation(AffiliationType type) {
    Affiliation a = null;
    switch(type) {
        case DISTINCTION:
            a = new Distinction();
            break;
        case EDUCATION:
            a = new Education();
            break;
        case EMPLOYMENT:
            a = new Employment();
            break;
        case INVITED_POSITION:
            a = new InvitedPosition();
            break;
        case MEMBERSHIP:
            a = new Membership();
            break;
        case QUALIFICATION:
            a = new Qualification();
            break;
        case SERVICE:
            a = new Service();
            break;
    }
    a.setDepartmentName("My department name");
    a.setRoleTitle("My Role");
    a.setOrganization(getOrganization());
    a.setStartDate(FuzzyDate.valueOf(2017, 1, 1));
    return a;
}
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) 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) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation)

Example 17 with Affiliation

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

the class AffiliationsController method createAffiliationsIdList.

/**
 * Create an affiliation id list and sorts a map associated with the list in
 * in the session
 */
private List<String> createAffiliationsIdList(HttpServletRequest request) {
    List<Affiliation> affiliationsList = affiliationsManager.getAffiliations(getCurrentUserOrcid());
    HashMap<String, AffiliationForm> affiliationsMap = new HashMap<>();
    List<String> affiliationIds = new ArrayList<String>();
    if (affiliationsList != null) {
        for (Affiliation affiliation : affiliationsList) {
            AffiliationForm form = AffiliationForm.valueOf(affiliation);
            form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, form.getCountry().getValue())));
            if (form.getOrgDisambiguatedId() != null) {
                OrgDisambiguated orgDisambiguated = orgDisambiguatedManager.findInDB(Long.parseLong(form.getOrgDisambiguatedId().getValue()));
                form.setOrgDisambiguatedName(orgDisambiguated.getValue());
                form.setOrgDisambiguatedUrl(orgDisambiguated.getUrl());
                form.setOrgDisambiguatedCity(orgDisambiguated.getCity());
                form.setOrgDisambiguatedRegion(orgDisambiguated.getRegion());
                form.setOrgDisambiguatedCountry(orgDisambiguated.getCountry());
                if (orgDisambiguated.getOrgDisambiguatedExternalIdentifiers() != null) {
                    form.setOrgDisambiguatedExternalIdentifiers(orgDisambiguated.getOrgDisambiguatedExternalIdentifiers());
                }
            }
            affiliationsMap.put(form.getPutCode().getValue(), form);
            affiliationIds.add(form.getPutCode().getValue());
        }
        request.getSession().setAttribute(AFFILIATIONS_MAP, affiliationsMap);
    }
    return affiliationIds;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AffiliationForm(org.orcid.pojo.ajaxForm.AffiliationForm) OrgDisambiguated(org.orcid.pojo.OrgDisambiguated) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation)

Example 18 with Affiliation

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

the class ActivityValidator method validateAffiliation.

public void validateAffiliation(Affiliation affiliation, SourceEntity sourceEntity, boolean createFlag, boolean isApiRequest, Visibility originalVisibility) {
    if (affiliation.getPutCode() != null && createFlag) {
        Map<String, String> params = new HashMap<String, String>();
        if (sourceEntity != null) {
            params.put("clientName", sourceEntity.getSourceName());
        }
        throw new InvalidPutCodeException(params);
    }
    // Check that we are not changing the visibility
    if (isApiRequest && !createFlag) {
        Visibility updatedVisibility = affiliation.getVisibility();
        validateVisibilityDoesntChange(updatedVisibility, originalVisibility);
    }
    if (affiliation.getStartDate() == null) {
        throw new OrcidValidationException("Education start date is required");
    }
    if (isApiRequest) {
        validateDisambiguatedOrg(affiliation);
    }
}
Also used : HashMap(java.util.HashMap) InvalidPutCodeException(org.orcid.core.exception.InvalidPutCodeException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)

Example 19 with Affiliation

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

the class PojoUtilTest method affiliationsCreateDateSortString_StartDateOnlyTest.

@Test
public void affiliationsCreateDateSortString_StartDateOnlyTest() {
    Affiliation aff = new Employment();
    FuzzyDate start = new FuzzyDate();
    start.setDay(new Day(1));
    start.setMonth(new Month(2));
    start.setYear(new Year(3));
    aff.setStartDate(start);
    String dateSortString = PojoUtil.createDateSortString(aff);
    assertEquals("Y-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 20 with Affiliation

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

the class PojoUtilTest method affiliationsCreateDateSortString_EndDateOnlyTest.

@Test
public void affiliationsCreateDateSortString_EndDateOnlyTest() {
    Affiliation aff = new Employment();
    FuzzyDate end = new FuzzyDate();
    end.setDay(new Day(1));
    end.setMonth(new Month(2));
    end.setYear(new Year(3));
    aff.setEndDate(end);
    String dateSortString = PojoUtil.createDateSortString(aff);
    assertEquals("X-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)

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