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