use of org.orcid.jaxb.model.message.Organization in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method checkAndUpdateDisambiguatedOrganization.
private void checkAndUpdateDisambiguatedOrganization(List<Affiliation> affiliations) {
if (affiliations != null && !affiliations.isEmpty()) {
for (Affiliation affiliation : affiliations) {
Organization org = affiliation.getOrganization();
OrgEntity orgEntity = orgManager.getOrgEntity(org);
// If the org exists
if (orgEntity != null) {
// And it have a disambiguated org
if (orgEntity.getOrgDisambiguated() != null) {
// Update the desambiguated org
org.setDisambiguatedOrganization(adapter.getDisambiguatedOrganization(orgEntity.getOrgDisambiguated()));
} else {
// Null the disambiguated organization
org.setDisambiguatedOrganization(null);
}
}
}
}
}
use of org.orcid.jaxb.model.message.Organization in project ORCID-Source by ORCID.
the class Api12Helper method addAffiliation.
protected static void addAffiliation(String userOrcid, String token, String orgName, T2OAuthAPIService<ClientResponse> oauthT2Client) {
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
Affiliation affiliation = new Affiliation();
affiliation.setVisibility(Visibility.LIMITED);
affiliations.getAffiliation().add(affiliation);
affiliation.setType(AffiliationType.EDUCATION);
Organization organization = new Organization();
affiliation.setOrganization(organization);
organization.setName(orgName);
OrganizationAddress organizationAddress = new OrganizationAddress();
organization.setAddress(organizationAddress);
organizationAddress.setCity("Edinburgh");
organizationAddress.setCountry(Iso3166Country.GB);
ClientResponse clientResponse = oauthT2Client.addAffiliationsXml(userOrcid, orcidMessage, token);
assertEquals(201, clientResponse.getStatus());
}
use of org.orcid.jaxb.model.message.Organization 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());
}
use of org.orcid.jaxb.model.message.Organization 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());
}
use of org.orcid.jaxb.model.message.Organization in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method getAffiliation.
public Affiliation getAffiliation() throws DatatypeConfigurationException {
GregorianCalendar cal = new GregorianCalendar();
XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
Affiliation affiliation = new Affiliation();
affiliation.setStartDate(new FuzzyDate(calendar.getYear(), calendar.getMonth(), calendar.getDay()));
affiliation.setEndDate(new FuzzyDate(calendar.getYear(), calendar.getMonth(), calendar.getDay()));
affiliation.setType(AffiliationType.EDUCATION);
affiliation.setRoleTitle("A Role");
affiliation.setDepartmentName("A Department");
Organization organization = new Organization();
affiliation.setOrganization(organization);
organization.setName("Past Institution");
OrganizationAddress address = new OrganizationAddress();
address.setCountry(Iso3166Country.GB);
organization.setAddress(address);
return affiliation;
}
Aggregations