Search in sources :

Example 21 with Affiliations

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

the class OrcidProfileManagerImplTest method testOrgReuse.

@Test
@Transactional
@Rollback(true)
public void testOrgReuse() {
    OrcidProfile profile1 = createBasicProfile();
    OrcidHistory history = new OrcidHistory();
    history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    profile1.setOrcidHistory(history);
    history.setClaimed(new Claimed(true));
    OrcidActivities orcidActivities = profile1.getOrcidActivities();
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    Affiliation affiliation = new Affiliation();
    affiliations.getAffiliation().add(affiliation);
    Organization organization = new Organization();
    affiliation.setOrganization(organization);
    organization.setName("New College");
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization.setAddress(organizationAddress);
    organizationAddress.setCity("Edinburgh");
    organizationAddress.setCountry(Iso3166Country.GB);
    orcidProfileManager.createOrcidProfile(profile1, false, false);
    ProfileEntity profileEntity = profileDao.find(TEST_ORCID);
    assertEquals(1, profileEntity.getOrgAffiliationRelations().size());
    OrgEntity orgEntity = profileEntity.getOrgAffiliationRelations().iterator().next().getOrg();
    assertNotNull(orgEntity);
    // Now create another profile with the same affiliation and check that
    // the org is reused;
    String otherOrcid = "4444-4444-4444-4448";
    OrcidProfile profile2 = createBasicProfile();
    profile2.setOrcidIdentifier(otherOrcid);
    List<Email> emailList2 = profile2.getOrcidBio().getContactDetails().getEmail();
    emailList2.clear();
    emailList2.add(new Email("another@semantico.com"));
    profile2.getOrcidActivities().setAffiliations(affiliations);
    orcidProfileManager.createOrcidProfile(profile2, false, false);
    ProfileEntity profileEntity2 = profileDao.find(otherOrcid);
    assertEquals(1, profileEntity2.getOrgAffiliationRelations().size());
    OrgEntity orgEntity2 = profileEntity2.getOrgAffiliationRelations().iterator().next().getOrg();
    assertNotNull(orgEntity);
    assertEquals(orgEntity.getId(), orgEntity2.getId());
}
Also used : Organization(org.orcid.jaxb.model.message.Organization) Email(org.orcid.jaxb.model.message.Email) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Date(java.util.Date) ApprovalDate(org.orcid.jaxb.model.message.ApprovalDate) Claimed(org.orcid.jaxb.model.message.Claimed) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) Affiliation(org.orcid.jaxb.model.message.Affiliation) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with Affiliations

use of org.orcid.jaxb.model.message.Affiliations 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 Affiliations

use of org.orcid.jaxb.model.message.Affiliations 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 Affiliations

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

the class Jpa2JaxbAdapterTest method checkSourceOnAllElements.

@Test
@Transactional
public void checkSourceOnAllElements() {
    ProfileEntity profileEntity = profileDao.find(userOrcid);
    assertNotNull(profileEntity);
    assertEquals(userOrcid, profileEntity.getId());
    OrcidProfile orcidProfile = adapter.toOrcidProfile(profileEntity);
    assertNotNull(orcidProfile);
    testOrcidIdentifier(orcidProfile.getOrcidIdentifier());
    assertNotNull(orcidProfile.getOrcidActivities());
    // Check works
    OrcidWorks orcidWorks = orcidProfile.getOrcidActivities().getOrcidWorks();
    if (orcidWorks != null && orcidWorks.getOrcidWork() != null && !orcidWorks.getOrcidWork().isEmpty()) {
        for (OrcidWork work : orcidWorks.getOrcidWork()) {
            checkSource(work.getSource(), null);
        }
    }
    // Check affiliations
    Affiliations affiliations = orcidProfile.getOrcidActivities().getAffiliations();
    if (affiliations != null && affiliations.getAffiliation() != null && !affiliations.getAffiliation().isEmpty()) {
        for (Affiliation affiliation : affiliations.getAffiliation()) {
            checkSource(affiliation.getSource(), null);
        }
    }
    // Check fundings
    FundingList fundings = orcidProfile.getOrcidActivities().getFundings();
    if (fundings != null && fundings.getFundings() != null && !fundings.getFundings().isEmpty()) {
        for (Funding funding : fundings.getFundings()) {
            checkSource(funding.getSource(), null);
        }
    }
    assertNotNull(orcidProfile.getOrcidBio());
    // Check external identifiers
    ExternalIdentifiers extIds = orcidProfile.getOrcidBio().getExternalIdentifiers();
    if (extIds != null && extIds.getExternalIdentifier() != null && !extIds.getExternalIdentifier().isEmpty()) {
        for (ExternalIdentifier extId : extIds.getExternalIdentifier()) {
            checkSource(extId.getSource(), null);
        }
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) Affiliations(org.orcid.jaxb.model.message.Affiliations) Funding(org.orcid.jaxb.model.message.Funding) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

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