Search in sources :

Example 41 with OrcidBio

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());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Affiliations(org.orcid.jaxb.model.message.Affiliations) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 42 with OrcidBio

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;
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) SecurityQuestionId(org.orcid.jaxb.model.message.SecurityQuestionId) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails) Preferences(org.orcid.jaxb.model.message.Preferences)

Example 43 with OrcidBio

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;
}
Also used : Email(org.orcid.jaxb.model.message.Email) Keywords(org.orcid.jaxb.model.message.Keywords) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Keyword(org.orcid.jaxb.model.message.Keyword) FamilyName(org.orcid.jaxb.model.message.FamilyName) CreditName(org.orcid.jaxb.model.message.CreditName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl)

Example 44 with OrcidBio

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());
}
Also used : OrcidBio(org.orcid.jaxb.model.message.OrcidBio) CreditName(org.orcid.jaxb.model.message.CreditName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 45 with OrcidBio

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()));
}
Also used : OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

OrcidBio (org.orcid.jaxb.model.message.OrcidBio)56 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)38 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)28 Test (org.junit.Test)27 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)23 Email (org.orcid.jaxb.model.message.Email)20 GivenNames (org.orcid.jaxb.model.message.GivenNames)20 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)19 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)16 FamilyName (org.orcid.jaxb.model.message.FamilyName)16 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)15 CreditName (org.orcid.jaxb.model.message.CreditName)14 BaseTest (org.orcid.core.BaseTest)13 ExternalIdReference (org.orcid.jaxb.model.message.ExternalIdReference)11 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)11 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)10 ExternalIdCommonName (org.orcid.jaxb.model.message.ExternalIdCommonName)9 OtherNames (org.orcid.jaxb.model.message.OtherNames)9 Biography (org.orcid.jaxb.model.message.Biography)8 Keyword (org.orcid.jaxb.model.message.Keyword)8