Search in sources :

Example 31 with OrcidActivities

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

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

the class OrcidProfileManagerImpl method dedupeAffiliations.

private void dedupeAffiliations(OrcidProfile orcidProfile) {
    OrcidActivities orcidActivities = orcidProfile.getOrcidActivities();
    if (orcidActivities != null) {
        Affiliations affiliations = orcidActivities.getAffiliations();
        if (affiliations != null) {
            Affiliations dedupedAffiliations = dedupeAffiliations(affiliations);
            orcidActivities.setAffiliations(dedupedAffiliations);
        }
    }
}
Also used : Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities)

Example 33 with OrcidActivities

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

the class OrcidProfileManagerImpl method dedupeFundings.

private void dedupeFundings(OrcidProfile orcidProfile) {
    OrcidActivities orcidActivities = orcidProfile.getOrcidActivities();
    if (orcidActivities != null) {
        FundingList fungins = orcidActivities.getFundings();
        if (fungins != null) {
            FundingList dedupedFundings = dedupeFundings(fungins);
            orcidActivities.setFundings(dedupedFundings);
        }
    }
}
Also used : FundingList(org.orcid.jaxb.model.message.FundingList) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities)

Example 34 with OrcidActivities

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

the class OrcidProfileManagerImpl method updateFundings.

@Override
@Transactional
public OrcidProfile updateFundings(OrcidProfile updatedOrcidProfile) {
    OrcidProfile existingProfile = retrieveOrcidProfile(updatedOrcidProfile.getOrcidIdentifier().getPath());
    if (existingProfile == null) {
        return null;
    }
    FundingList updatedFundingList = updatedOrcidProfile.retrieveFundings();
    if (updatedFundingList == null) {
        return null;
    } else {
        // Parse the amount in the new funding
        setFundingAmountsWithTheCorrectFormat(updatedOrcidProfile);
        // Update the funding list with the new values
        updatedFundingList = updatedOrcidProfile.retrieveFundings();
    }
    OrcidActivities existingActivities = existingProfile.getOrcidActivities();
    if (existingActivities == null) {
        existingActivities = new OrcidActivities();
        existingProfile.setOrcidActivities(existingActivities);
    }
    FundingList existingFundingList = existingActivities.getFundings();
    if (existingFundingList == null) {
        existingFundingList = new FundingList();
        existingActivities.setFundings(existingFundingList);
    }
    orcidJaxbCopyManager.copyFundingListToExistingPreservingVisibility(existingFundingList, updatedFundingList);
    OrcidProfile profileToReturn = updateOrcidProfile(existingProfile, UpdateOptions.FUNDINGS_ONLY);
    notificationManager.sendAmendEmail(profileToReturn, AmendedSection.FUNDING);
    return profileToReturn;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Transactional(org.springframework.transaction.annotation.Transactional)

Example 35 with OrcidActivities

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

the class OrcidProfileManagerImpl method dedupeWorks.

private void dedupeWorks(OrcidProfile orcidProfile) {
    OrcidActivities orcidActivities = orcidProfile.getOrcidActivities();
    if (orcidActivities != null) {
        OrcidWorks orcidWorks = orcidActivities.getOrcidWorks();
        if (orcidWorks != null) {
            OrcidWorks dedupedOrcidWorks = dedupeWorks(orcidWorks);
            orcidActivities.setOrcidWorks(dedupedOrcidWorks);
        }
    }
}
Also used : OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Aggregations

OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)37 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)28 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)20 Affiliations (org.orcid.jaxb.model.message.Affiliations)18 Test (org.junit.Test)16 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)14 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)14 DBUnitTest (org.orcid.test.DBUnitTest)13 Affiliation (org.orcid.jaxb.model.message.Affiliation)11 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)11 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)11 Organization (org.orcid.jaxb.model.message.Organization)11 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)11 Title (org.orcid.jaxb.model.message.Title)11 Transactional (org.springframework.transaction.annotation.Transactional)11 FundingList (org.orcid.jaxb.model.message.FundingList)9 Response (javax.ws.rs.core.Response)8 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)8 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)8 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)8