Search in sources :

Example 1 with Citation

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

the class JpaJaxbEntityAdapterToOrcidProfileTest method checkOrcidWorks.

private void checkOrcidWorks(OrcidWorks orcidWorks) {
    assertNotNull(orcidWorks);
    List<OrcidWork> orcidWorkList = orcidWorks.getOrcidWork();
    assertEquals(3, orcidWorkList.size());
    boolean putCode1Found = false;
    boolean putCode4Found = false;
    for (OrcidWork orcidWork : orcidWorkList) {
        if (orcidWork.getPutCode().equals("1")) {
            putCode1Found = true;
            assertEquals("1", orcidWork.getPutCode());
            Citation workCitation = orcidWork.getWorkCitation();
            assertNotNull(workCitation);
            assertEquals("Bobby Ewing, ", workCitation.getCitation());
            assertEquals(CitationType.FORMATTED_IEEE, workCitation.getWorkCitationType());
            WorkContributors contributors = orcidWork.getWorkContributors();
            assertNotNull(contributors);
            assertEquals(2, contributors.getContributor().size());
            assertEquals("Jaylen Kessler", contributors.getContributor().get(0).getCreditName().getContent());
            assertEquals(Visibility.PUBLIC, contributors.getContributor().get(0).getCreditName().getVisibility());
            assertEquals(Visibility.PUBLIC, orcidWork.getVisibility());
            assertNull(orcidWork.getJournalTitle());
        } else if (orcidWork.getPutCode().equals("3")) {
            WorkContributors contributors = orcidWork.getWorkContributors();
            assertNotNull(contributors);
            assertEquals(1, contributors.getContributor().size());
            assertEquals("0000-0003-0172-7925", contributors.getContributor().get(0).getContributorOrcid().getPath());
        } else if (orcidWork.getPutCode().equals("4")) {
            putCode4Found = true;
            assertNotNull(orcidWork.getWorkTitle());
            assertNotNull(orcidWork.getWorkTitle().getTitle());
            assertEquals("A book with a Journal Title", orcidWork.getWorkTitle().getTitle().getContent());
            assertNotNull(orcidWork.getJournalTitle());
            assertEquals("My Journal Title", orcidWork.getJournalTitle().getContent());
            assertNotNull(orcidWork.getPublicationDate());
            assertNotNull(orcidWork.getPublicationDate().getDay());
            assertNotNull(orcidWork.getPublicationDate().getMonth());
            assertNotNull(orcidWork.getPublicationDate().getYear());
            assertEquals("01", orcidWork.getPublicationDate().getDay().getValue());
            assertEquals("02", orcidWork.getPublicationDate().getMonth().getValue());
            assertEquals("2011", orcidWork.getPublicationDate().getYear().getValue());
            assertNotNull(orcidWork.getWorkCitation());
            assertEquals("Sue Ellen ewing", orcidWork.getWorkCitation().getCitation());
            assertEquals(CitationType.FORMATTED_IEEE, orcidWork.getWorkCitation().getWorkCitationType());
            assertNotNull(orcidWork.getWorkType());
            assertEquals(WorkType.BOOK, orcidWork.getWorkType());
        }
    }
    assertTrue(putCode1Found);
    assertTrue(putCode4Found);
}
Also used : WorkContributors(org.orcid.jaxb.model.message.WorkContributors) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Citation(org.orcid.jaxb.model.message.Citation)

Example 2 with Citation

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

the class Jaxb2JpaAdapterImpl method getWorkEntity.

public WorkEntity getWorkEntity(OrcidWork orcidWork, WorkEntity workEntity) {
    if (orcidWork != null) {
        if (workEntity == null) {
            String putCode = orcidWork.getPutCode();
            if (StringUtils.isNotBlank(putCode) && !"-1".equals(putCode)) {
                throw new IllegalArgumentException("Invalid put-code was supplied: " + putCode);
            }
            workEntity = new WorkEntity();
        } else {
            workEntity.clean();
        }
        Citation workCitation = orcidWork.getWorkCitation();
        if (workCitation != null && StringUtils.isNotBlank(workCitation.getCitation()) && workCitation.getWorkCitationType() != null) {
            workEntity.setCitation(workCitation.getCitation());
            workEntity.setCitationType(CitationType.fromValue(workCitation.getWorkCitationType().value()));
        }
        // New way of doing work contributors
        workEntity.setContributorsJson(getWorkContributorsJson(orcidWork.getWorkContributors()));
        workEntity.setDescription(orcidWork.getShortDescription() != null ? orcidWork.getShortDescription() : null);
        // New way of doing work external ids
        workEntity.setExternalIdentifiersJson(getWorkExternalIdsJson(orcidWork));
        workEntity.setPublicationDate(getWorkPublicationDate(orcidWork));
        WorkTitle workTitle = orcidWork.getWorkTitle();
        if (workTitle != null) {
            workEntity.setSubtitle(workTitle.getSubtitle() != null ? workTitle.getSubtitle().getContent() : null);
            workEntity.setTitle(workTitle.getTitle() != null ? workTitle.getTitle().getContent().trim() : null);
            TranslatedTitle translatedTitle = workTitle.getTranslatedTitle();
            if (translatedTitle != null) {
                workEntity.setTranslatedTitle(StringUtils.isEmpty(translatedTitle.getContent()) ? null : translatedTitle.getContent());
                workEntity.setTranslatedTitleLanguageCode(StringUtils.isEmpty(translatedTitle.getLanguageCode()) ? null : translatedTitle.getLanguageCode());
            }
        }
        workEntity.setJournalTitle(orcidWork.getJournalTitle() != null ? orcidWork.getJournalTitle().getContent() : null);
        workEntity.setLanguageCode(orcidWork.getLanguageCode() != null ? orcidWork.getLanguageCode() : null);
        if (orcidWork.getCountry() != null && orcidWork.getCountry().getValue() != null) {
            workEntity.setIso2Country(org.orcid.jaxb.model.common_v2.Iso3166Country.fromValue(orcidWork.getCountry().getValue().value()));
        }
        workEntity.setWorkUrl(orcidWork.getUrl() != null ? orcidWork.getUrl().getValue() : null);
        if (orcidWork.getWorkType() != null) {
            workEntity.setWorkType(org.orcid.jaxb.model.record_v2.WorkType.fromValue(orcidWork.getWorkType().value()));
        }
        if (orcidWork.getVisibility() != null) {
            workEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(orcidWork.getVisibility().value()));
        } else {
            workEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
        }
        workEntity.setAddedToProfileDate(new Date());
        //Set source
        setSource(orcidWork.getSource(), workEntity);
        if (workEntity.getDisplayIndex() == null) {
            workEntity.setDisplayIndex(0L);
        }
        return workEntity;
    }
    return null;
}
Also used : WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) TranslatedTitle(org.orcid.jaxb.model.message.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) Citation(org.orcid.jaxb.model.message.Citation) CompletionDate(org.orcid.jaxb.model.message.CompletionDate) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Date(java.util.Date) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) PublicationDate(org.orcid.jaxb.model.message.PublicationDate) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate)

Example 3 with Citation

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

Aggregations

Citation (org.orcid.jaxb.model.message.Citation)3 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)2 PublicationDate (org.orcid.jaxb.model.message.PublicationDate)2 WorkContributors (org.orcid.jaxb.model.message.WorkContributors)2 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)2 Date (java.util.Date)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 CitationType (org.orcid.jaxb.model.message.CitationType)1 CompletionDate (org.orcid.jaxb.model.message.CompletionDate)1 Contributor (org.orcid.jaxb.model.message.Contributor)1 ContributorAttributes (org.orcid.jaxb.model.message.ContributorAttributes)1 CreditName (org.orcid.jaxb.model.message.CreditName)1 Day (org.orcid.jaxb.model.message.Day)1 DeactivationDate (org.orcid.jaxb.model.message.DeactivationDate)1 FuzzyDate (org.orcid.jaxb.model.message.FuzzyDate)1 Month (org.orcid.jaxb.model.message.Month)1 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)1 Title (org.orcid.jaxb.model.message.Title)1 TranslatedTitle (org.orcid.jaxb.model.message.TranslatedTitle)1 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)1