Search in sources :

Example 1 with Affiliations

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

the class T2OrcidApiServiceDelegatorTest method testUpdateAffiliationWhenNotSource.

@Test(expected = WrongSourceException.class)
@Transactional
public void testUpdateAffiliationWhenNotSource() {
    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("2");
    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);
    t2OrcidApiServiceDelegator.updateAffiliations(mockedUriInfo, "4444-4444-4444-4443", 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Affiliations

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

the class T2OrcidApiServiceDelegatorTest method testAddAffilliations.

@Test
public void testAddAffilliations() {
    SecurityContextTestUtils.setUpSecurityContext(ScopePathType.AFFILIATIONS_CREATE);
    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();
    orcidActivities.setAffiliations(affiliations);
    Affiliation affiliation1 = new Affiliation();
    affiliations.getAffiliation().add(affiliation1);
    affiliation1.setType(AffiliationType.EDUCATION);
    Organization organization1 = new Organization();
    affiliation1.setOrganization(organization1);
    organization1.setName("A new affiliation");
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization1.setAddress(organizationAddress);
    organizationAddress.setCity("Edinburgh");
    organizationAddress.setCountry(Iso3166Country.GB);
    Response response = t2OrcidApiServiceDelegator.addAffiliations(mockedUriInfo, "4444-4444-4444-4441", orcidMessage);
    assertNotNull(response);
    assertEquals(HttpStatus.SC_CREATED, response.getStatus());
    String location = ((URI) response.getMetadata().getFirst("Location")).getPath();
    assertNotNull(location);
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4441");
    List<Affiliation> affiliationsList = retrievedProfile.getOrcidActivities().getAffiliations().getAffiliation();
    assertEquals(1, affiliationsList.size());
    Affiliation affiliation = affiliationsList.get(0);
    assertEquals("A new affiliation", affiliation.getOrganization().getName());
    assertEquals("APP-5555555555555555", affiliation.getSource().retrieveSourcePath());
}
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) URI(java.net.URI) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with Affiliations

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

the class T2OrcidApiServiceDelegatorTest method testUpdateWithNewAffiliation.

@Test
@Transactional
public void testUpdateWithNewAffiliation() {
    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.setType(AffiliationType.EDUCATION);
    Organization organization1 = new Organization();
    affiliation1.setOrganization(organization1);
    organization1.setName("A new affiliation");
    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 newAffiliation = retreivedAffiliationsList.get(0);
    assertEquals("A new affiliation", newAffiliation.getOrganization().getName());
    assertEquals("APP-5555555555555555", newAffiliation.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 4 with Affiliations

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

the class T2OrcidApiServiceVersionedDelegatorTest method buildMessageWithAffiliation.

private OrcidMessage buildMessageWithAffiliation(AffiliationType type, String dept, String role, String orcid) {
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier(orcid));
    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(dept);
    affiliation.setRoleTitle(role);
    affiliation.setType(type);
    Organization organization = new Organization();
    organization.setName("My Org");
    OrganizationAddress add = new OrganizationAddress();
    add.setCity("My City");
    add.setCountry(Iso3166Country.US);
    organization.setAddress(add);
    DisambiguatedOrganization dorg = new DisambiguatedOrganization();
    dorg.setDisambiguatedOrganizationIdentifier("disambiguated org ID");
    dorg.setDisambiguationSource("THESOURCE");
    organization.setDisambiguatedOrganization(dorg);
    affiliation.setOrganization(organization);
    affiliations.getAffiliation().add(affiliation);
    orcidActivities.setAffiliations(affiliations);
    return orcidMessage;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) DisambiguatedOrganization(org.orcid.jaxb.model.message.DisambiguatedOrganization) Organization(org.orcid.jaxb.model.message.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.message.DisambiguatedOrganization) 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)

Example 5 with Affiliations

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

the class T2OrcidApiServiceVersionedDelegatorTest method testCreateWithAffiliations.

@Test
public void testCreateWithAffiliations() throws JAXBException {
    setUpSecurityContextForClientOnly();
    OrcidMessage orcidMessage = getOrcidMessage("/orcid-message-for-create-latest.xml");
    Response createResponse = t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    assertNotNull(createResponse);
    assertEquals(HttpStatus.SC_CREATED, createResponse.getStatus());
    String location = ((URI) createResponse.getMetadata().getFirst("Location")).getPath();
    assertNotNull(location);
    String orcid = location.substring(1, 20);
    Response readResponse = t2OrcidApiServiceDelegatorLatest.findFullDetails(orcid);
    assertNotNull(readResponse);
    assertEquals(HttpStatus.SC_OK, readResponse.getStatus());
    OrcidMessage retrievedMessage = (OrcidMessage) readResponse.getEntity();
    OrcidProfile orcidProfile = retrievedMessage.getOrcidProfile();
    assertEquals(orcid, orcidProfile.getOrcidIdentifier().getPath());
    Affiliations affiliations = orcidProfile.retrieveAffiliations();
    assertNotNull(affiliations);
    assertEquals(1, affiliations.getAffiliation().size());
    Affiliation affiliation = affiliations.getAffiliation().get(0);
    assertEquals(Visibility.PRIVATE, affiliation.getVisibility());
    Source source = affiliation.getSource();
    assertNotNull(source);
    String sourceOrcid = source.retrieveSourcePath();
    assertNotNull(sourceOrcid);
    assertEquals("4444-4444-4444-4445", sourceOrcid);
}
Also used : Response(javax.ws.rs.core.Response) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) URI(java.net.URI) Source(org.orcid.jaxb.model.message.Source) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

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