Search in sources :

Example 46 with OrcidWork

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

the class OrcidIndexManagerImplTest method getStandardOrcidWithDoiInformation.

private OrcidProfile getStandardOrcidWithDoiInformation() {
    OrcidProfile orcidProfile = getStandardOrcid();
    OrcidWork orcidWork1 = orcidProfile.retrieveOrcidWorks().getOrcidWork().get(0);
    OrcidWork orcidWork2 = orcidProfile.retrieveOrcidWorks().getOrcidWork().get(1);
    OrcidWork orcidWork3 = orcidProfile.retrieveOrcidWorks().getOrcidWork().get(2);
    WorkExternalIdentifiers work1ExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier work1ExternalIdentifier1 = new WorkExternalIdentifier();
    work1ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    work1ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-doi1"));
    WorkExternalIdentifier work1ExternalIdentifier2 = new WorkExternalIdentifier();
    work1ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
    work1ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-pmid"));
    work1ExternalIdentifiers.getWorkExternalIdentifier().add(work1ExternalIdentifier1);
    work1ExternalIdentifiers.getWorkExternalIdentifier().add(work1ExternalIdentifier2);
    orcidWork1.setWorkExternalIdentifiers(work1ExternalIdentifiers);
    WorkExternalIdentifiers work2ExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier work2ExternalIdentifier1 = new WorkExternalIdentifier();
    work2ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    work2ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work2-doi1"));
    WorkExternalIdentifier work2ExternalIdentifier2 = new WorkExternalIdentifier();
    work2ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    work2ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work2-doi2"));
    work2ExternalIdentifiers.getWorkExternalIdentifier().add(work2ExternalIdentifier1);
    work2ExternalIdentifiers.getWorkExternalIdentifier().add(work2ExternalIdentifier2);
    orcidWork2.setWorkExternalIdentifiers(work2ExternalIdentifiers);
    WorkExternalIdentifiers work3ExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier work3ExternalIdentifier1 = new WorkExternalIdentifier();
    work3ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    work3ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work3-doi1"));
    WorkExternalIdentifier work3ExternalIdentifier2 = new WorkExternalIdentifier();
    work3ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    work3ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work3-doi2"));
    work3ExternalIdentifiers.getWorkExternalIdentifier().add(work3ExternalIdentifier1);
    work3ExternalIdentifiers.getWorkExternalIdentifier().add(work3ExternalIdentifier2);
    orcidWork3.setWorkExternalIdentifiers(work3ExternalIdentifiers);
    return orcidProfile;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier)

Example 47 with OrcidWork

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

the class Publication method getOrcidWork.

public OrcidWork getOrcidWork() {
    initCrossRefContext();
    OrcidWork orcidWork = new OrcidWork();
    if (StringUtils.isNotBlank(doi)) {
        WorkExternalIdentifier doiExtId = new WorkExternalIdentifier();
        doiExtId.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
        doiExtId.setWorkExternalIdentifierId(new WorkExternalIdentifierId(doi));
        WorkExternalIdentifiers workExtIds = new WorkExternalIdentifiers();
        orcidWork.setWorkExternalIdentifiers(workExtIds);
        workExtIds.getWorkExternalIdentifier().add(doiExtId);
    }
    if (StringUtils.isNotBlank(title)) {
        WorkTitle workTitle = new WorkTitle();
        orcidWork.setWorkTitle(workTitle);
        workTitle.setTitle(new Title(title));
    }
    // Will throw an IllegalArgumentException if not valid
    CitationType cType = CitationType.fromValue(citationType);
    Citation citation = new Citation(fullCitation, cType);
    orcidWork.setWorkCitation(citation);
    String publicationDateString = crossRefContext.getDate();
    if (StringUtils.isNotBlank(publicationDateString)) {
        XMLGregorianCalendar publicationDateGregCal = DateUtils.convertToXMLGregorianCalendar(publicationDateString);
        if (publicationDateGregCal != null) {
            Year publicationyear = new Year(publicationDateGregCal.getYear());
            Month publicationMonth = publicationDateGregCal.getMonth() == DatatypeConstants.FIELD_UNDEFINED ? null : new Month(publicationDateGregCal.getMonth());
            Day publicationDay = publicationDateGregCal.getDay() == DatatypeConstants.FIELD_UNDEFINED ? null : new Day(publicationDateGregCal.getDay());
            orcidWork.setPublicationDate(new PublicationDate(publicationyear, publicationMonth, publicationDay));
        }
    }
    String author = crossRefContext.getAuthor();
    if (StringUtils.isNotBlank(author)) {
        WorkContributors workContributors = new WorkContributors();
        orcidWork.setWorkContributors(workContributors);
        Contributor contributor = new Contributor();
        workContributors.getContributor().add(contributor);
        contributor.setCreditName(new CreditName(author));
        ContributorAttributes contributorAttributes = new ContributorAttributes();
        contributor.setContributorAttributes(contributorAttributes);
        contributorAttributes.setContributorRole(ContributorRole.AUTHOR);
        contributorAttributes.setContributorSequence(SequenceType.FIRST);
    }
    return orcidWork;
}
Also used : PublicationDate(org.orcid.jaxb.model.message.PublicationDate) ContributorAttributes(org.orcid.jaxb.model.message.ContributorAttributes) WorkContributors(org.orcid.jaxb.model.message.WorkContributors) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) CreditName(org.orcid.jaxb.model.message.CreditName) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) Contributor(org.orcid.jaxb.model.message.Contributor) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Month(org.orcid.jaxb.model.message.Month) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) Year(org.orcid.jaxb.model.message.Year) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) CitationType(org.orcid.jaxb.model.message.CitationType) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) Citation(org.orcid.jaxb.model.message.Citation) Day(org.orcid.jaxb.model.message.Day)

Example 48 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork 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 49 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork 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 50 with OrcidWork

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

Aggregations

OrcidWork (org.orcid.jaxb.model.message.OrcidWork)81 Test (org.junit.Test)44 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)42 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)32 Transactional (org.springframework.transaction.annotation.Transactional)26 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)24 Title (org.orcid.jaxb.model.message.Title)23 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)20 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)18 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)16 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)16 Source (org.orcid.jaxb.model.message.Source)14 Rollback (org.springframework.test.annotation.Rollback)13 ArrayList (java.util.ArrayList)12 Funding (org.orcid.jaxb.model.message.Funding)12 WorkExternalIdentifierId (org.orcid.jaxb.model.message.WorkExternalIdentifierId)12 BaseTest (org.orcid.core.BaseTest)11 Contributor (org.orcid.jaxb.model.message.Contributor)11 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)11 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)10