Search in sources :

Example 31 with OrcidWorks

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

the class ValidationManagerImpl method checkActivities.

private void checkActivities(OrcidActivities orcidActivities) {
    if (orcidActivities != null) {
        OrcidWorks works = orcidActivities.getOrcidWorks();
        if (works != null && works.getOrcidWork() != null && !works.getOrcidWork().isEmpty()) {
            checkWorks(works.getOrcidWork());
        }
        FundingList funding = orcidActivities.getFundings();
        if (funding != null && funding.getFundings() != null && !funding.getFundings().isEmpty()) {
            checkFunding(funding.getFundings());
        }
    }
}
Also used : FundingList(org.orcid.jaxb.model.message.FundingList) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Example 32 with OrcidWorks

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

the class MarshallingTest method testMarshallingFullMessage.

@Test
public void testMarshallingFullMessage() throws JAXBException {
    OrcidMessage orcidMessage = getOrcidMessage();
    assertNotNull(orcidMessage);
    OrcidProfile orcidProfile = orcidMessage.getOrcidProfile();
    assertNotNull(orcidProfile);
    assertEquals("4444-4444-4444-4446", orcidProfile.getOrcidIdentifier().getPath());
    OrcidActivities orcidActivities = orcidProfile.getOrcidActivities();
    assertNotNull(orcidActivities);
    assertEquals(4, orcidActivities.getAffiliations().getAffiliation().size());
    OrcidWorks orcidWorks = orcidProfile.retrieveOrcidWorks();
    assertTrue(orcidWorks != null && orcidWorks.getOrcidWork().size() == 1);
    OrcidWork orcidWork = orcidWorks.getOrcidWork().get(0);
    assertEquals("journal-article", orcidWork.getWorkType().value());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Test(org.junit.Test)

Example 33 with OrcidWorks

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

the class CheckAndFixContributorNameVisibility method processOrcid.

private void processOrcid(final String orcid) {
    LOG.info("Checking and fixing profile: {}", orcid);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            OrcidProfile orcidProfile = orcidProfileManager.retrieveOrcidProfile(orcid);
            OrcidWorks orcidWorks = orcidProfile.retrieveOrcidWorks();
            if (orcidWorks != null) {
                for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
                    WorkContributors workContributors = orcidWork.getWorkContributors();
                    if (workContributors != null) {
                        for (Contributor contributor : workContributors.getContributor()) {
                            ContributorOrcid contributorOrcid = contributor.getContributorOrcid();
                            if (contributorOrcid != null) {
                                String orcid = contributorOrcid.getPath();
                                ProfileEntity contributorProfile = profileDao.find(orcid);
                                if (contributorProfile.getRecordNameEntity() != null && contributorProfile.getRecordNameEntity().getVisibility() != null) {
                                    if (!Visibility.PUBLIC.value().equals(contributorProfile.getRecordNameEntity().getVisibility().value())) {
                                        contributor.setCreditName(null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            orcidProfileManager.updateOrcidProfile(orcidProfile);
        }
    });
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkContributors(org.orcid.jaxb.model.message.WorkContributors) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) TransactionStatus(org.springframework.transaction.TransactionStatus) Contributor(org.orcid.jaxb.model.message.Contributor) ContributorOrcid(org.orcid.jaxb.model.message.ContributorOrcid) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Example 34 with OrcidWorks

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

the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsPublic.

@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorksWhenDefaultVisibilityIsPublic() {
    OrcidProfile profile1 = createBasicProfile();
    OrcidHistory history = new OrcidHistory();
    history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    profile1.setOrcidHistory(history);
    history.setClaimed(new Claimed(true));
    profile1.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.PUBLIC));
    orcidProfileManager.createOrcidProfile(profile1, false, false);
    OrcidProfile profile2 = new OrcidProfile();
    profile2.setOrcidIdentifier(TEST_ORCID);
    OrcidWorks orcidWorks = new OrcidWorks();
    profile2.setOrcidWorks(orcidWorks);
    WorkTitle workTitle1 = new WorkTitle();
    workTitle1.setTitle(new Title("Another Title"));
    workTitle1.setSubtitle(new Subtitle("Journal of Cloud Spotting"));
    OrcidWork work1 = createWork1(workTitle1);
    Source source = new Source(TEST_ORCID);
    work1.setSource(source);
    orcidWorks.getOrcidWork().add(work1);
    WorkTitle workTitle2 = new WorkTitle();
    workTitle2.setTitle(new Title("New Title"));
    workTitle2.setSubtitle(new Subtitle("Another New subtitle"));
    OrcidWork work2 = createWork2(workTitle2);
    orcidWorks.getOrcidWork().add(work2);
    // Try to add a duplicate
    WorkTitle workTitle3 = new WorkTitle();
    workTitle3.setTitle(new Title("Further Title"));
    workTitle3.setSubtitle(new Subtitle("Further subtitle"));
    OrcidWork work3 = createWork3(workTitle3);
    work3.setVisibility(Visibility.LIMITED);
    orcidWorks.getOrcidWork().add(work3);
    orcidProfileManager.addOrcidWorks(profile2);
    OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    assertEquals("Will", resultProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
    List<OrcidWork> works = resultProfile.retrieveOrcidWorks().getOrcidWork();
    assertEquals(4, works.size());
    assertEquals("Another Title", works.get(0).getWorkTitle().getTitle().getContent());
    assertEquals("Journal of Cloud Spotting", works.get(0).getWorkTitle().getSubtitle().getContent());
    for (OrcidWork work : works) {
        if ("Test Title".equals(work.getWorkTitle().getTitle().getContent()))
            assertEquals(Visibility.PRIVATE, work.getVisibility());
        else
            assertEquals(Visibility.PUBLIC, work.getVisibility());
    }
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Date(java.util.Date) ApprovalDate(org.orcid.jaxb.model.message.ApprovalDate) Claimed(org.orcid.jaxb.model.message.Claimed) Source(org.orcid.jaxb.model.message.Source) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Subtitle(org.orcid.jaxb.model.message.Subtitle) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 35 with OrcidWorks

use of org.orcid.jaxb.model.message.OrcidWorks 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)

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