Search in sources :

Example 1 with Contributor

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

the class OrcidProfileManagerContributorVisibilityTest method emailProvidedButDoesNotExistInDb.

@Test
@Transactional
public void emailProvidedButDoesNotExistInDb() {
    // Unmarshall message containing contributor email that does not exist
    // in DB
    OrcidMessage orcidMessage = unmarshallOrcidMessage("new_work_with_contributor_email_and_name.xml");
    // Add the work
    orcidProfileManager.addOrcidWorks(orcidMessage.getOrcidProfile());
    // Get it back from the API
    OrcidWork retrievedWork = retrieveAddedWorkFromApi();
    Contributor workContributor = retrievedWork.getWorkContributors().getContributor().get(0);
    // Check that the contributor name is included in the resulting work
    assertEquals("Test Contributor Name", workContributor.getCreditName().getContent());
    // Check that the email is not included in the resulting work, because
    // never want to show email
    assertNull(workContributor.getContributorEmail());
    // Get the contributor directly from the DB so can see stuff not
    // included in the API
    Contributor workContributorDirectFromDb = retrieveWorkContributorEntityDirectlyFromDb(retrievedWork);
    // Check the email is in the DB for later use if needed
    assertEquals("doesnotexist@orcid.org", workContributorDirectFromDb.getContributorEmail().getValue());
}
Also used : OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Contributor(org.orcid.jaxb.model.message.Contributor) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Contributor

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

the class OrcidProfileManagerContributorVisibilityTest method onlyNameProvided.

@Test
@Transactional
public void onlyNameProvided() {
    // Unmarshall message containing contributor name only
    OrcidMessage orcidMessage = unmarshallOrcidMessage("new_work_with_contributor_name.xml");
    // Add the work
    orcidProfileManager.addOrcidWorks(orcidMessage.getOrcidProfile());
    // Get it back from the API
    OrcidWork retrievedWork = retrieveAddedWorkFromApi();
    Contributor workContributor = retrievedWork.getWorkContributors().getContributor().get(0);
    // Check that the contributor name is included in the resulting work
    assertEquals("Test Contributor Name", workContributor.getCreditName().getContent());
    // Check that the email is not included in the resulting work, because
    // never want to show email
    assertNull(workContributor.getContributorEmail());
}
Also used : OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Contributor(org.orcid.jaxb.model.message.Contributor) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Contributor

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

the class CurrentWorkContributor method getContributor.

public Contributor getContributor() {
    Contributor contributor = new Contributor();
    if (StringUtils.isNotBlank(orcid)) {
        contributor.setContributorOrcid(new ContributorOrcid(orcid));
    }
    if (StringUtils.isNotBlank(creditName)) {
        contributor.setCreditName(new CreditName(creditName));
    }
    if (StringUtils.isNotBlank(email)) {
        contributor.setContributorEmail(new ContributorEmail(email));
    }
    if (StringUtils.isNotBlank(role)) {
        ContributorAttributes attributes = retrieveContributorAttributes(contributor);
        ContributorRole contributorRole = ContributorRole.fromValue(role);
        attributes.setContributorRole(contributorRole);
    }
    if (StringUtils.isNotBlank(sequence)) {
        ContributorAttributes attributes = retrieveContributorAttributes(contributor);
        SequenceType sequenceType = SequenceType.fromValue(sequence);
        attributes.setContributorSequence(sequenceType);
    }
    return contributor;
}
Also used : ContributorRole(org.orcid.jaxb.model.message.ContributorRole) ContributorAttributes(org.orcid.jaxb.model.message.ContributorAttributes) CreditName(org.orcid.jaxb.model.message.CreditName) Contributor(org.orcid.jaxb.model.message.Contributor) ContributorOrcid(org.orcid.jaxb.model.message.ContributorOrcid) SequenceType(org.orcid.jaxb.model.message.SequenceType) ContributorEmail(org.orcid.jaxb.model.message.ContributorEmail)

Example 4 with Contributor

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

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

the class JsonUtilsTest method testWorkContributorsToJsonString.

@Test
public void testWorkContributorsToJsonString() {
    WorkContributors workContributors = new WorkContributors();
    Contributor contributor1 = new Contributor();
    workContributors.getContributor().add(contributor1);
    contributor1.setCreditName(new CreditName("A Contributor"));
    String result = JsonUtils.convertToJsonString(workContributors);
    assertEquals("{\"contributor\":[{\"contributorOrcid\":null,\"creditName\":{\"content\":\"A Contributor\",\"visibility\":null},\"contributorEmail\":null,\"contributorAttributes\":null}]}", result);
}
Also used : WorkContributors(org.orcid.jaxb.model.message.WorkContributors) CreditName(org.orcid.jaxb.model.message.CreditName) Contributor(org.orcid.jaxb.model.message.Contributor) Test(org.junit.Test)

Aggregations

Contributor (org.orcid.jaxb.model.message.Contributor)15 Test (org.junit.Test)11 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)11 Transactional (org.springframework.transaction.annotation.Transactional)9 BaseTest (org.orcid.core.BaseTest)7 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)7 WorkContributors (org.orcid.jaxb.model.message.WorkContributors)5 CreditName (org.orcid.jaxb.model.message.CreditName)4 ContributorAttributes (org.orcid.jaxb.model.message.ContributorAttributes)3 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)3 ContributorOrcid (org.orcid.jaxb.model.message.ContributorOrcid)2 PublicationDate (org.orcid.jaxb.model.message.PublicationDate)2 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 Citation (org.orcid.jaxb.model.message.Citation)1 CitationType (org.orcid.jaxb.model.message.CitationType)1 ContributorEmail (org.orcid.jaxb.model.message.ContributorEmail)1 ContributorRole (org.orcid.jaxb.model.message.ContributorRole)1 Day (org.orcid.jaxb.model.message.Day)1 Month (org.orcid.jaxb.model.message.Month)1