use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAffiliations.
@Test
@Transactional
@Rollback(true)
public void testAffiliations() throws DatatypeConfigurationException {
OrcidProfile profile1 = createBasicProfile();
orcidProfileManager.createOrcidProfile(profile1, false, false);
OrcidProfile profile2 = new OrcidProfile();
profile2.setOrcidIdentifier(TEST_ORCID);
OrcidBio orcidBio = new OrcidBio();
orcidBio.setPersonalDetails(new PersonalDetails());
OrcidActivities orcidActivities = new OrcidActivities();
profile2.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
Affiliation affiliation1 = getAffiliation();
Affiliation affiliation2 = getAffiliation();
affiliation2.setType(AffiliationType.EDUCATION);
affiliation2.getOrganization().setName("Past Institution 2");
affiliations.getAffiliation().add(affiliation1);
affiliations.getAffiliation().add(affiliation2);
profile2.setOrcidBio(orcidBio);
orcidProfileManager.addAffiliations(profile2);
OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertNotNull(retrievedProfile);
assertEquals(2, retrievedProfile.getOrcidActivities().getAffiliations().getAffiliation().size());
for (Affiliation affiliation : retrievedProfile.getOrcidActivities().getAffiliations().getAffiliation()) {
assertNotNull(affiliation.getPutCode());
}
// Remove an affiliation
profile2 = createFullOrcidProfile();
affiliations.getAffiliation().clear();
affiliations.getAffiliation().add(affiliation1);
profile2.setOrcidActivities(orcidActivities);
orcidProfileManager.updateOrcidProfile(profile2);
OrcidProfile profile3 = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertEquals(1, profile3.getOrcidActivities().getAffiliations().getAffiliation().size());
assertEquals(IndexingStatus.PENDING, profileDao.find(TEST_ORCID).getIndexingStatus());
}
use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createBasicProfile.
protected OrcidProfile createBasicProfile() {
OrcidProfile profile = new OrcidProfile();
profile.setPassword("password");
profile.setVerificationCode("1234");
profile.setSecurityQuestionAnswer("random answer");
profile.setOrcidIdentifier(TEST_ORCID);
OrcidBio bio = new OrcidBio();
ContactDetails contactDetails = new ContactDetails();
contactDetails.addOrReplacePrimaryEmail(new Email("will@semantico.com"));
bio.setContactDetails(contactDetails);
profile.setOrcidBio(bio);
PersonalDetails personalDetails = new PersonalDetails();
bio.setPersonalDetails(personalDetails);
personalDetails.setGivenNames(new GivenNames("Will"));
personalDetails.setFamilyName(new FamilyName("Simpson"));
bio.setBiography(new Biography("Will is a software developer"));
ResearcherUrls researcherUrls = new ResearcherUrls();
bio.setResearcherUrls(researcherUrls);
researcherUrls.getResearcherUrl().add(new ResearcherUrl(new Url("http://www.wjrs.co.uk"), null));
OrcidWorks orcidWorks = new OrcidWorks();
profile.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = createWork1();
// TODO JB - needs test
// orcidWork.setAddedToProfileDate(new
// AddedToProfileDate(DateUtils.convertToXMLGregorianCalendar("2010-03-04")));
// orcidWork.setAddedToProfileDate(new
// AddedToProfileDate(DateUtils.convertToXMLGregorianCalendar("2010-03-04")));
orcidWorks.getOrcidWork().add(orcidWork);
OrcidInternal orcidInternal = new OrcidInternal();
profile.setOrcidInternal(orcidInternal);
SecurityDetails securityDetails = new SecurityDetails();
securityDetails.setSecurityQuestionId(new SecurityQuestionId(3));
orcidInternal.setSecurityDetails(securityDetails);
Preferences preferences = new Preferences();
orcidInternal.setPreferences(preferences);
return profile;
}
use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createFullOrcidProfile.
protected OrcidProfile createFullOrcidProfile() {
OrcidProfile profile2 = new OrcidProfile();
profile2.setPassword("password");
profile2.setVerificationCode("1234");
profile2.setOrcidIdentifier(TEST_ORCID);
OrcidBio bio = new OrcidBio();
ContactDetails contactDetails = new ContactDetails();
contactDetails.addOrReplacePrimaryEmail(new Email("will@orcid.org"));
bio.setContactDetails(contactDetails);
profile2.setOrcidBio(bio);
PersonalDetails personalDetails = new PersonalDetails();
personalDetails.setGivenNames(new GivenNames("William"));
personalDetails.setFamilyName(new FamilyName("Simpson"));
personalDetails.setCreditName(new CreditName("W. J. R. Simpson"));
bio.setPersonalDetails(personalDetails);
ResearcherUrls researcherUrls = new ResearcherUrls();
researcherUrls.getResearcherUrl().add(new ResearcherUrl(new Url("http://www.wjrs.co.uk"), null));
bio.setResearcherUrls(researcherUrls);
Keywords keywords = new Keywords();
bio.setKeywords(keywords);
keywords.getKeyword().add(new Keyword("Java", null));
bio.setBiography(new Biography("Will is a software developer at Semantico"));
return profile2;
}
use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testUpdateCreditNamePreservingVisibility.
@Test
public void testUpdateCreditNamePreservingVisibility() throws Exception {
OrcidBio existingOrcidBioProtected = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
OrcidBio updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
PersonalDetails existingOrcidPersonalDetails = protectedOrcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails();
PersonalDetails updatedOrcidPersonalDetails = publicOrcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails();
// set default of credit to limited on existing and null on updated
// -should remain as limited and not 'downgrade'
assertEquals(existingOrcidPersonalDetails.getCreditName().getContent(), "J. S. Carberry");
assertEquals(Visibility.LIMITED, existingOrcidPersonalDetails.getCreditName().getVisibility());
updatedOrcidPersonalDetails.setCreditName(new CreditName("Don"));
updatedOrcidPersonalDetails.getCreditName().setVisibility(Visibility.PRIVATE);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
assertEquals(existingOrcidPersonalDetails.getCreditName().getContent(), "Don");
assertEquals(Visibility.PRIVATE, existingOrcidPersonalDetails.getCreditName().getVisibility());
updatedOrcidPersonalDetails.setCreditName(new CreditName("Jimmy"));
updatedOrcidPersonalDetails.getCreditName().setVisibility(null);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
assertEquals("Don", existingOrcidBioProtected.getPersonalDetails().getCreditName().getContent());
assertEquals(Visibility.PRIVATE, existingOrcidPersonalDetails.getCreditName().getVisibility());
}
use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testCopyToAPrivateBio.
@Test
public void testCopyToAPrivateBio() {
final String privateSufix = "private_";
final String publicSufix = "public_";
OrcidBio privateBio = getBio(privateSufix, Visibility.PRIVATE, 3);
OrcidBio publicBio = getBio(publicSufix, Visibility.PUBLIC, 3);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(privateBio, publicBio);
assertEquals(privateSufix + "My Biography", privateBio.getBiography().getContent());
assertEquals(Visibility.PRIVATE, privateBio.getBiography().getVisibility());
assertEquals(Iso3166Country.US, privateBio.getContactDetails().getAddress().getCountry().getValue());
assertEquals(Visibility.PRIVATE, privateBio.getContactDetails().getAddress().getCountry().getVisibility());
//Remains same as client cannot add/update emails.
assertEquals(3, privateBio.getContactDetails().getEmail().size());
assertEquals("private_Email0", privateBio.getContactDetails().getEmail().get(0).getValue());
assertEquals("private_Email1", privateBio.getContactDetails().getEmail().get(1).getValue());
assertEquals("private_Email2", privateBio.getContactDetails().getEmail().get(2).getValue());
assertEquals(3, privateBio.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("public_CommonName0", privateBio.getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals("public_CommonName1", privateBio.getExternalIdentifiers().getExternalIdentifier().get(1).getExternalIdCommonName().getContent());
assertEquals("public_CommonName2", privateBio.getExternalIdentifiers().getExternalIdentifier().get(2).getExternalIdCommonName().getContent());
assertTrue(privateBio.getExternalIdentifiers().getExternalIdentifier().containsAll(publicBio.getExternalIdentifiers().getExternalIdentifier()));
assertEquals(Visibility.PUBLIC, privateBio.getExternalIdentifiers().getVisibility());
assertEquals(3, privateBio.getKeywords().getKeyword().size());
assertEquals("public_Keyword0", privateBio.getKeywords().getKeyword().get(0).getContent());
assertEquals("public_Keyword1", privateBio.getKeywords().getKeyword().get(1).getContent());
assertEquals("public_Keyword2", privateBio.getKeywords().getKeyword().get(2).getContent());
assertTrue(privateBio.getKeywords().getKeyword().containsAll(publicBio.getKeywords().getKeyword()));
assertEquals(Visibility.PUBLIC, privateBio.getKeywords().getVisibility());
assertEquals(3, privateBio.getResearcherUrls().getResearcherUrl().size());
assertEquals("http://www.rurl.com/public_/0", privateBio.getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue());
assertEquals("http://www.rurl.com/public_/1", privateBio.getResearcherUrls().getResearcherUrl().get(1).getUrl().getValue());
assertEquals("http://www.rurl.com/public_/2", privateBio.getResearcherUrls().getResearcherUrl().get(2).getUrl().getValue());
assertTrue(privateBio.getResearcherUrls().getResearcherUrl().containsAll(publicBio.getResearcherUrls().getResearcherUrl()));
assertEquals(Visibility.PUBLIC, privateBio.getResearcherUrls().getVisibility());
assertEquals(privateSufix + "Credit name", privateBio.getPersonalDetails().getCreditName().getContent());
assertEquals(Visibility.PRIVATE, privateBio.getPersonalDetails().getCreditName().getVisibility());
assertEquals(publicSufix + "Family", privateBio.getPersonalDetails().getFamilyName().getContent());
assertEquals(publicSufix + "Given", privateBio.getPersonalDetails().getGivenNames().getContent());
assertEquals(3, privateBio.getPersonalDetails().getOtherNames().getOtherName().size());
assertEquals("public_Other0", privateBio.getPersonalDetails().getOtherNames().getOtherName().get(0).getContent());
assertEquals("public_Other1", privateBio.getPersonalDetails().getOtherNames().getOtherName().get(1).getContent());
assertEquals("public_Other2", privateBio.getPersonalDetails().getOtherNames().getOtherName().get(2).getContent());
assertTrue(privateBio.getPersonalDetails().getOtherNames().getOtherName().containsAll(publicBio.getPersonalDetails().getOtherNames().getOtherName()));
}
Aggregations