Search in sources :

Example 6 with OrcidWorks

use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.

the class OrcidJaxbCopyManagerTest method testCopyUpdatedWorksToExistingWithVisibility.

@Test
public void testCopyUpdatedWorksToExistingWithVisibility() throws Exception {
    OrcidWorks worksToUpdate = publicOrcidMessage.getOrcidProfile().retrieveOrcidWorks();
    OrcidWorks existingWorks = protectedOrcidMessage.getOrcidProfile().retrieveOrcidWorks();
    checkWorksVisibility(null, worksToUpdate.getOrcidWork());
    // update is private, so the update should persist and alter the
    // existing as well
    assertEquals("Work title 1", existingWorks.getOrcidWork().get(0).getWorkTitle().getTitle().getContent());
    assertEquals(Visibility.PUBLIC, existingWorks.getOrcidWork().get(0).getVisibility());
    assertEquals("Work title 2", existingWorks.getOrcidWork().get(1).getWorkTitle().getTitle().getContent());
    assertNull(existingWorks.getOrcidWork().get(1).getVisibility());
    assertEquals("Work Title 3", existingWorks.getOrcidWork().get(2).getWorkTitle().getTitle().getContent());
    assertNull(existingWorks.getOrcidWork().get(2).getVisibility());
    worksToUpdate.getOrcidWork().get(0).getWorkTitle().getTitle().setContent("updated-work-title-1");
    worksToUpdate.getOrcidWork().get(0).setVisibility(Visibility.PRIVATE);
    worksToUpdate.getOrcidWork().get(1).getWorkTitle().getTitle().setContent("updated-work-title-2");
    worksToUpdate.getOrcidWork().get(2).getWorkTitle().getTitle().setContent("updated-work-title-3");
    orcidJaxbCopyManager.copyUpdatedWorksPreservingVisbility(existingWorks, worksToUpdate);
    assertEquals("updated-work-title-1", existingWorks.getOrcidWork().get(0).getWorkTitle().getTitle().getContent());
    assertEquals("updated-work-title-2", existingWorks.getOrcidWork().get(1).getWorkTitle().getTitle().getContent());
    assertEquals("updated-work-title-3", existingWorks.getOrcidWork().get(2).getWorkTitle().getTitle().getContent());
    // check the update was copied across
    assertEquals(Visibility.PRIVATE, existingWorks.getOrcidWork().get(0).getVisibility());
    // check that as null was supplied as an update, the works default was
    // used
    assertEquals(Visibility.PUBLIC, existingWorks.getOrcidWork().get(1).getVisibility());
}
Also used : OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 7 with OrcidWorks

use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.

the class RegistrationControllerTest method createBasicProfile.

protected OrcidProfile createBasicProfile() {
    OrcidProfile profile = new OrcidProfile();
    profile.setPassword("password");
    profile.setVerificationCode("1234");
    profile.setSecurityQuestionAnswer("random answer");
    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);
    return profile;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) FamilyName(org.orcid.jaxb.model.message.FamilyName) 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) 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)

Example 8 with OrcidWorks

use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method addSourceToWorks.

/**
     * Add source to the profile works
     * 
     * @param orcidProfile
     *            The profile
     * @param amenderOrcid
     *            The orcid of the user or client that add the work to the
     *            profile user
     * */
private void addSourceToWorks(OrcidProfile orcidProfile, String amenderOrcid) {
    OrcidWorks orcidWorks = orcidProfile.getOrcidActivities() == null ? null : orcidProfile.getOrcidActivities().getOrcidWorks();
    addSourceToWorks(orcidWorks, amenderOrcid);
}
Also used : OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Example 9 with OrcidWorks

use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method setWorkPrivacy.

private void setWorkPrivacy(OrcidProfile updatedOrcidProfile, Visibility defaultWorkVisibility) {
    OrcidHistory orcidHistory = updatedOrcidProfile.getOrcidHistory();
    boolean isClaimed = orcidHistory != null ? orcidHistory.getClaimed().isValue() : false;
    OrcidActivities incomingActivities = updatedOrcidProfile.getOrcidActivities();
    if (incomingActivities != null) {
        OrcidWorks incomingWorks = incomingActivities.getOrcidWorks();
        if (incomingWorks != null) {
            setWorkPrivacy(incomingWorks, defaultWorkVisibility, isClaimed);
        }
    }
}
Also used : OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Example 10 with OrcidWorks

use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method dedupeWorks.

@Override
public OrcidWorks dedupeWorks(OrcidWorks orcidWorks) {
    Set<OrcidWork> workSet = new LinkedHashSet<OrcidWork>();
    for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
        orcidProfileCleaner.clean(orcidWork);
        workSet.add(orcidWork);
    }
    OrcidWorks dedupedOrcidWorks = new OrcidWorks();
    dedupedOrcidWorks.getOrcidWork().addAll(workSet);
    return dedupedOrcidWorks;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Aggregations

OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)46 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)35 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)32 Test (org.junit.Test)24 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)19 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)15 Title (org.orcid.jaxb.model.message.Title)15 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)13 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)13 Transactional (org.springframework.transaction.annotation.Transactional)12 FundingList (org.orcid.jaxb.model.message.FundingList)9 Funding (org.orcid.jaxb.model.message.Funding)8 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)8 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)8 DBUnitTest (org.orcid.test.DBUnitTest)8 Rollback (org.springframework.test.annotation.Rollback)8 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)7 Date (java.util.Date)6 Affiliations (org.orcid.jaxb.model.message.Affiliations)6 Subtitle (org.orcid.jaxb.model.message.Subtitle)6