Search in sources :

Example 16 with Affiliations

use of org.orcid.jaxb.model.message.Affiliations in project ORCID-Source by ORCID.

the class T2OrcidApiServiceVersionedDelegatorTest method addAffiliationTest.

@Test
public void addAffiliationTest() {
    setUpSecurityContext();
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4441"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    Affiliation affiliation = new Affiliation();
    affiliation.setStartDate(new FuzzyDate(2010, 01, 01));
    affiliation.setEndDate(new FuzzyDate(2015, 01, 01));
    affiliation.setDepartmentName("Dep Name");
    affiliation.setRoleTitle("Role Title");
    affiliation.setType(AffiliationType.EDUCATION);
    Organization organization = new Organization();
    organization.setName("My Org");
    OrganizationAddress add = new OrganizationAddress();
    add.setCity("My City");
    add.setCountry(Iso3166Country.US);
    organization.setAddress(add);
    affiliation.setOrganization(organization);
    affiliations.getAffiliation().add(affiliation);
    orcidActivities.setAffiliations(affiliations);
    Response response = t2OrcidApiServiceDelegatorLatest.addAffiliations(mockedUriInfo, "4444-4444-4444-4441", orcidMessage);
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    assertEquals(1, orgAffiliationRelationDao.getByUserAndType("4444-4444-4444-4441", org.orcid.jaxb.model.record_v2.AffiliationType.EDUCATION).size());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Response(javax.ws.rs.core.Response) DisambiguatedOrganization(org.orcid.jaxb.model.message.DisambiguatedOrganization) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 17 with Affiliations

use of org.orcid.jaxb.model.message.Affiliations in project ORCID-Source by ORCID.

the class Jaxb2JpaAdapterImpl method setActivityDetails.

private void setActivityDetails(ProfileEntity profileEntity, OrcidActivities orcidActivities, UpdateOptions updateOptions) {
    Affiliations affiliations = null;
    FundingList orcidFundings = null;
    OrcidWorks orcidWorks = null;
    if (orcidActivities != null) {
        affiliations = orcidActivities.getAffiliations();
        orcidFundings = orcidActivities.getFundings();
        orcidWorks = orcidActivities.getOrcidWorks();
    }
    if (updateOptions.isUpdateAffiliations()) {
        setOrgAffiliationRelations(profileEntity, affiliations);
    }
    if (updateOptions.isUpdateFundings()) {
        setFundings(profileEntity, orcidFundings);
    }
    if (updateOptions.isUpdateWorks()) {
        setWorks(profileEntity, orcidWorks);
    }
}
Also used : FundingList(org.orcid.jaxb.model.message.FundingList) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Example 18 with Affiliations

use of org.orcid.jaxb.model.message.Affiliations in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testAddAffiliationToDeprecatedAccount.

@Test(expected = OrcidDeprecatedException.class)
public void testAddAffiliationToDeprecatedAccount() {
    SecurityContextTestUtils.setUpSecurityContext();
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-444X"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    OrganizationAddress address = new OrganizationAddress();
    address.setCity("City");
    address.setCountry(Iso3166Country.US);
    Organization org = new Organization();
    org.setAddress(address);
    org.setName("Testing org name");
    Affiliations affiliations = new Affiliations();
    Affiliation affiliation = new Affiliation();
    affiliation.setDepartmentName("Dept name");
    affiliation.setOrganization(org);
    affiliation.setType(AffiliationType.EMPLOYMENT);
    affiliations.getAffiliation().add(affiliation);
    orcidActivities.setAffiliations(affiliations);
    t2OrcidApiServiceDelegator.addAffiliations(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 19 with Affiliations

use of org.orcid.jaxb.model.message.Affiliations in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testUpdateExistingNonPrivateAffiliation.

@Test
@Transactional
public void testUpdateExistingNonPrivateAffiliation() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.AFFILIATIONS_UPDATE);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4443"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    Affiliation affiliation1 = new Affiliation();
    affiliations.getAffiliation().add(affiliation1);
    affiliation1.setPutCode("3");
    affiliation1.setType(AffiliationType.EDUCATION);
    Organization organization1 = new Organization();
    affiliation1.setOrganization(organization1);
    organization1.setName("Different org");
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization1.setAddress(organizationAddress);
    organizationAddress.setCity("Edinburgh");
    organizationAddress.setCountry(Iso3166Country.GB);
    Response response = t2OrcidApiServiceDelegator.updateAffiliations(mockedUriInfo, "4444-4444-4444-4443", orcidMessage);
    assertNotNull(response);
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4443");
    List<Affiliation> retreivedAffiliationsList = retrievedProfile.getOrcidActivities().getAffiliations().getAffiliation();
    assertEquals(3, retreivedAffiliationsList.size());
    Affiliation updatedAffiliation = retreivedAffiliationsList.get(0);
    assertEquals("Different org", updatedAffiliation.getOrganization().getName());
    assertEquals("APP-5555555555555555", updatedAffiliation.getSource().retrieveSourcePath());
    Affiliation existingAffiliation = retreivedAffiliationsList.get(1);
    assertEquals(Visibility.PRIVATE, existingAffiliation.getVisibility());
    assertEquals("Eine Institution", existingAffiliation.getOrganization().getName());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Response(javax.ws.rs.core.Response) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 20 with Affiliations

use of org.orcid.jaxb.model.message.Affiliations in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method dedupeAffiliations.

private Affiliations dedupeAffiliations(Affiliations affiliations) {
    Set<Affiliation> affiliationSet = new LinkedHashSet<Affiliation>();
    for (Affiliation affiliation : affiliations.getAffiliation()) {
        orcidProfileCleaner.clean(affiliation);
        affiliationSet.add(affiliation);
    }
    Affiliations dedupedAffiliations = new Affiliations();
    dedupedAffiliations.getAffiliation().addAll(affiliationSet);
    return dedupedAffiliations;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Affiliations(org.orcid.jaxb.model.message.Affiliations) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Aggregations

Affiliations (org.orcid.jaxb.model.message.Affiliations)24 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)19 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)18 Affiliation (org.orcid.jaxb.model.message.Affiliation)16 Test (org.junit.Test)11 Organization (org.orcid.jaxb.model.message.Organization)10 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)9 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)9 DBUnitTest (org.orcid.test.DBUnitTest)8 Transactional (org.springframework.transaction.annotation.Transactional)8 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)7 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)6 Response (javax.ws.rs.core.Response)5 FundingList (org.orcid.jaxb.model.message.FundingList)5 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)5 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)5 Email (org.orcid.jaxb.model.message.Email)4 FamilyName (org.orcid.jaxb.model.message.FamilyName)4 GivenNames (org.orcid.jaxb.model.message.GivenNames)4 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)4