Search in sources :

Example 26 with Affiliation

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

the class OrcidProfileManagerImpl method addAffiliations.

/**
 * Adds a new {@link List<org.orcid.jaxb.model.message.Affiliation<}
 * to the {@link} OrcidProfile} and returns the updated values
 *
 * @param updatedOrcidProfile
 * @return
 */
@Override
@Transactional
public void addAffiliations(OrcidProfile updatedOrcidProfile) {
    String orcid = updatedOrcidProfile.getOrcidIdentifier().getPath();
    OrcidProfile existingProfile = retrieveOrcidProfile(orcid);
    if (existingProfile == null) {
        throw new IllegalArgumentException("No record found for " + orcid);
    }
    Affiliations existingAffiliations = existingProfile.retrieveAffiliations();
    Affiliations updatedAffiliations = updatedOrcidProfile.retrieveAffiliations();
    Visibility workVisibilityDefault = existingProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue();
    Boolean claimed = existingProfile.getOrcidHistory().isClaimed();
    setAffiliationPrivacy(updatedAffiliations, workVisibilityDefault, claimed == null ? false : claimed);
    updatedAffiliations = dedupeAffiliations(updatedAffiliations);
    addSourceToAffiliations(updatedAffiliations, getSource());
    List<Affiliation> updatedAffiliationsList = updatedAffiliations.getAffiliation();
    checkAndUpdateDisambiguatedOrganization(updatedAffiliationsList);
    checkForAlreadyExistingAffiliations(existingAffiliations, updatedAffiliationsList);
    persistAddedAffiliations(orcid, updatedAffiliationsList);
    profileDao.flush();
    boolean notificationsEnabled = existingProfile.getOrcidInternal().getPreferences().getNotificationsEnabled();
    if (notificationsEnabled) {
        notificationManager.sendAmendEmail(orcid, AmendedSection.AFFILIATION, null);
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Affiliations(org.orcid.jaxb.model.message.Affiliations) Visibility(org.orcid.jaxb.model.message.Visibility) Affiliation(org.orcid.jaxb.model.message.Affiliation) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with Affiliation

use of org.orcid.jaxb.model.message.Affiliation 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, LoadOptions.ALL);
    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)

Example 28 with Affiliation

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

the class T2OrcidApiServiceVersionedDelegatorTest method addAffiliationTest.

@Test
public void addAffiliationTest() {
    setUpSecurityContext();
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2");
    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.v3.dev1.record.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 29 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)

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