Search in sources :

Example 21 with Affiliation

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

the class OrcidSearchManagerImplTest method getOrcidProfile5678MandatoryOnly.

private OrcidProfile getOrcidProfile5678MandatoryOnly() {
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier("5678");
    OrcidBio orcidBio = new OrcidBio();
    PersonalDetails personalDetails = new PersonalDetails();
    personalDetails.setFamilyName(new FamilyName("Logan"));
    personalDetails.setGivenNames(new GivenNames("Donald Edward"));
    new Affiliation();
    orcidBio.setPersonalDetails(personalDetails);
    orcidProfile.setOrcidBio(orcidBio);
    return orcidProfile;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) GivenNames(org.orcid.jaxb.model.message.GivenNames) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Example 22 with Affiliation

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

the class OrcidJaxbCopyManagerTest method testUpdatedAffilationsToExistingPreservingVisibility.

@Test
public void testUpdatedAffilationsToExistingPreservingVisibility() throws Exception {
    OrcidProfile existingOrcidProfile = protectedOrcidMessage.getOrcidProfile();
    // create a copy of the profile data for doing a merge
    OrcidProfile updatedOrcidProfile = getOrcidMessage("/orcid-public-full-message-latest.xml").getOrcidProfile();
    Affiliations existingAffiliations = existingOrcidProfile.getOrcidActivities().getAffiliations();
    List<Affiliation> existingAffilationsList = existingAffiliations.getAffiliation();
    Affiliations updatedAffiliations = updatedOrcidProfile.getOrcidActivities().getAffiliations();
    List<Affiliation> updatedAffilationsList = updatedAffiliations.getAffiliation();
    assertEquals("New College", existingAffilationsList.get(0).getOrganization().getName());
    assertEquals("Brown University", existingAffilationsList.get(1).getOrganization().getName());
    assertEquals(Visibility.PUBLIC, existingAffilationsList.get(0).getVisibility());
    assertEquals(Visibility.PUBLIC, existingAffilationsList.get(1).getVisibility());
    assertEquals(4, existingAffilationsList.size());
    assertEquals(4, updatedAffilationsList.size());
    // to test:
    // updating affiliations retains visibility when null - changes content
    updatedAffilationsList.get(0).getOrganization().setName("new affiliation name");
    updatedAffilationsList.get(0).setVisibility(null);
    orcidJaxbCopyManager.copyAffiliationsToExistingPreservingVisibility(existingAffiliations, updatedAffiliations);
    assertEquals("new affiliation name", existingAffilationsList.get(0).getOrganization().getName());
    assertEquals(Visibility.PUBLIC, existingAffilationsList.get(0).getVisibility());
    // updating affiliations changes visibility when populated - changes
    // content
    updatedAffilationsList.get(0).getOrganization().setName("a seperate affiliation name");
    updatedAffilationsList.get(0).setVisibility(Visibility.PRIVATE);
    orcidJaxbCopyManager.copyAffiliationsToExistingPreservingVisibility(existingAffiliations, updatedAffiliations);
    assertEquals("a seperate affiliation name", existingAffilationsList.get(0).getOrganization().getName());
    assertEquals(Visibility.PRIVATE, existingAffilationsList.get(0).getVisibility());
    // adding new affiliations with a null visibility adds an extra element
    // with the def
    Affiliation extraAffiliation = new Affiliation();
    Organization organization = new Organization();
    extraAffiliation.setOrganization(organization);
    organization.setName("extra affiliation");
    updatedAffilationsList.add(extraAffiliation);
    orcidJaxbCopyManager.copyAffiliationsToExistingPreservingVisibility(existingAffiliations, updatedAffiliations);
    assertEquals(5, existingAffilationsList.size());
    assertEquals("a seperate affiliation name", existingAffilationsList.get(0).getOrganization().getName());
    assertEquals("Brown University", existingAffilationsList.get(1).getOrganization().getName());
    assertEquals("extra affiliation", existingAffilationsList.get(4).getOrganization().getName());
    assertEquals(Visibility.PRIVATE, existingAffilationsList.get(0).getVisibility());
    assertEquals(Visibility.PUBLIC, existingAffilationsList.get(1).getVisibility());
    assertEquals(Visibility.PUBLIC, existingAffilationsList.get(4).getVisibility());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) Affiliation(org.orcid.jaxb.model.message.Affiliation) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 23 with Affiliation

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

the class OrcidProfileManagerImplTest method testAffiliations.

@Test
@Transactional
@Rollback(true)
public void testAffiliations() throws DatatypeConfigurationException {
    OrcidProfile profile1 = createBasicProfile();
    orcidProfileManager.createOrcidProfile(profile1, false, false);
    OrcidProfile profile2 = new OrcidProfile();
    profile2.setOrcidIdentifier(TEST_ORCID);
    OrcidBio orcidBio = new OrcidBio();
    orcidBio.setPersonalDetails(new PersonalDetails());
    OrcidActivities orcidActivities = new OrcidActivities();
    profile2.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    Affiliation affiliation1 = getAffiliation();
    Affiliation affiliation2 = getAffiliation();
    affiliation2.setType(AffiliationType.EDUCATION);
    affiliation2.getOrganization().setName("Past Institution 2");
    affiliations.getAffiliation().add(affiliation1);
    affiliations.getAffiliation().add(affiliation2);
    profile2.setOrcidBio(orcidBio);
    orcidProfileManager.addAffiliations(profile2);
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    assertNotNull(retrievedProfile);
    assertEquals(2, retrievedProfile.getOrcidActivities().getAffiliations().getAffiliation().size());
    for (Affiliation affiliation : retrievedProfile.getOrcidActivities().getAffiliations().getAffiliation()) {
        assertNotNull(affiliation.getPutCode());
    }
    // Remove an affiliation
    profile2 = createFullOrcidProfile();
    affiliations.getAffiliation().clear();
    affiliations.getAffiliation().add(affiliation1);
    profile2.setOrcidActivities(orcidActivities);
    orcidProfileManager.updateOrcidProfile(profile2);
    OrcidProfile profile3 = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    assertEquals(1, profile3.getOrcidActivities().getAffiliations().getAffiliation().size());
    assertEquals(IndexingStatus.PENDING, profileDao.find(TEST_ORCID).getIndexingStatus());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Affiliations(org.orcid.jaxb.model.message.Affiliations) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with Affiliation

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

the class OrcidProfileManagerBaseTest method getAffiliation.

public Affiliation getAffiliation() throws DatatypeConfigurationException {
    GregorianCalendar cal = new GregorianCalendar();
    XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
    Affiliation affiliation = new Affiliation();
    affiliation.setStartDate(new FuzzyDate(calendar.getYear(), calendar.getMonth(), calendar.getDay()));
    affiliation.setEndDate(new FuzzyDate(calendar.getYear(), calendar.getMonth(), calendar.getDay()));
    affiliation.setType(AffiliationType.EDUCATION);
    affiliation.setRoleTitle("A Role");
    affiliation.setDepartmentName("A Department");
    Organization organization = new Organization();
    affiliation.setOrganization(organization);
    organization.setName("Past Institution");
    OrganizationAddress address = new OrganizationAddress();
    address.setCountry(Iso3166Country.GB);
    organization.setAddress(address);
    return affiliation;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Organization(org.orcid.jaxb.model.message.Organization) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Example 25 with Affiliation

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

the class OrcidJaxbCopyManagerTest method getOrcidMessage.

private OrcidMessage getOrcidMessage(String s) throws JAXBException {
    InputStream inputStream = OrcidJaxbCopyManagerTest.class.getResourceAsStream(s);
    OrcidMessage orcidMessage = (OrcidMessage) unmarshaller.unmarshal(inputStream);
    // Put codes are needed for these tests
    int putCode = 1;
    for (Affiliation affiliation : orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation()) {
        affiliation.setPutCode(String.valueOf(putCode));
        putCode++;
    }
    return orcidMessage;
}
Also used : InputStream(java.io.InputStream) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Aggregations

Affiliation (org.orcid.jaxb.model.message.Affiliation)29 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)18 Affiliations (org.orcid.jaxb.model.message.Affiliations)16 Test (org.junit.Test)14 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)13 Organization (org.orcid.jaxb.model.message.Organization)12 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)11 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)10 DBUnitTest (org.orcid.test.DBUnitTest)8 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)7 Transactional (org.springframework.transaction.annotation.Transactional)7 Response (javax.ws.rs.core.Response)5 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 Funding (org.orcid.jaxb.model.message.Funding)4 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)4 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)4 DisambiguatedOrganization (org.orcid.jaxb.model.message.DisambiguatedOrganization)3 FuzzyDate (org.orcid.jaxb.model.message.FuzzyDate)3 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)3 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)3