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());
}
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);
}
}
}
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);
}
}
}
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;
}
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);
}
}
}
Aggregations