Search in sources :

Example 1 with PublicationDate

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

the class PublicationTest method testGetOrcidWork.

@Test
public void testGetOrcidWork() {
    String doi = "10.1029\\/2002JD002436";
    String title = "5 on chemistry and nitrate aerosol formation in the lower troposphere under photosmog conditions";
    String fullCitation = "Riemer, N, 2003, '5 on chemistry and nitrate aerosol formation in the lower troposphere under photosmog conditions', <i>Journal of Geophysical Research<\\/i>, vol. 30, no. D4, p. 1255.";
    String coins = "ctx_ver=Z39.88-2004&rft_val_fmt=info:ofi\\/fmt:kev:mtx:journal&rft_id=info:doi\\/10.1029\\/2002JD002436&rtf.genre=journal-article&rtf.spage=1255&rtf.date=2003&rtf.aulast=Riemer&rtf.aufirst=N.&rtf.auinit=N&rtf.atitle=5 on chemistry and nitrate aerosol formation in the lower troposphere under photosmog conditions&rtf.jtitle=Journal of Geophysical Research&rtf.volume=30&rtf.issue=D4";
    Publication publication = new Publication();
    publication.setDoi(doi);
    publication.setTitle(title);
    publication.setFullCitation(fullCitation);
    publication.setCoins(coins);
    OrcidWork orcidWork = publication.getOrcidWork();
    assertNotNull(orcidWork);
    assertEquals(doi, orcidWork.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierId().getContent());
    assertEquals(WorkExternalIdentifierType.DOI, orcidWork.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierType());
    assertEquals(title, orcidWork.getWorkTitle().getTitle().getContent());
    assertEquals(fullCitation, orcidWork.getWorkCitation().getCitation());
    PublicationDate publicationDate = orcidWork.getPublicationDate();
    assertNotNull(publicationDate);
    assertEquals(null, publicationDate.getDay());
    assertEquals(null, publicationDate.getMonth());
    assertEquals("2003", publicationDate.getYear().getValue());
    assertEquals(1, orcidWork.getWorkContributors().getContributor().size());
    Contributor contributor = orcidWork.getWorkContributors().getContributor().get(0);
    assertEquals("Riemer N.", contributor.getCreditName().getContent());
    assertEquals(ContributorRole.AUTHOR, contributor.getContributorAttributes().getContributorRole());
    assertEquals(SequenceType.FIRST, contributor.getContributorAttributes().getContributorSequence());
}
Also used : PublicationDate(org.orcid.jaxb.model.message.PublicationDate) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Contributor(org.orcid.jaxb.model.message.Contributor) Test(org.junit.Test)

Example 2 with PublicationDate

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

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

the class Jaxb2JpaAdapterImpl method getWorkPublicationDate.

private PublicationDateEntity getWorkPublicationDate(OrcidWork orcidWork) {
    if (orcidWork != null && orcidWork.getPublicationDate() != null) {
        PublicationDate publicationDate = orcidWork.getPublicationDate();
        Integer year = publicationDate.getYear() != null ? toInteger(publicationDate.getYear().getValue()) : null;
        Integer month = publicationDate.getMonth() != null ? toInteger(publicationDate.getMonth().getValue()) : null;
        Integer day = publicationDate.getDay() != null ? toInteger(publicationDate.getDay().getValue()) : null;
        return new PublicationDateEntity(year, month, day);
    }
    return null;
}
Also used : PublicationDate(org.orcid.jaxb.model.message.PublicationDate) PublicationDateEntity(org.orcid.persistence.jpa.entities.PublicationDateEntity)

Aggregations

PublicationDate (org.orcid.jaxb.model.message.PublicationDate)3 Contributor (org.orcid.jaxb.model.message.Contributor)2 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 Test (org.junit.Test)1 Citation (org.orcid.jaxb.model.message.Citation)1 CitationType (org.orcid.jaxb.model.message.CitationType)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 Month (org.orcid.jaxb.model.message.Month)1 Title (org.orcid.jaxb.model.message.Title)1 WorkContributors (org.orcid.jaxb.model.message.WorkContributors)1 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)1 WorkExternalIdentifierId (org.orcid.jaxb.model.message.WorkExternalIdentifierId)1 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)1 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)1 Year (org.orcid.jaxb.model.message.Year)1 PublicationDateEntity (org.orcid.persistence.jpa.entities.PublicationDateEntity)1