Search in sources :

Example 1 with WorkContributors

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

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

the class JsonUtilsTest method testJsonStringToWorkContributors.

@Test
public void testJsonStringToWorkContributors() {
    String jsonString = "{\"contributor\":[{\"contributorOrcid\":null,\"creditName\":{\"content\":\"A Contributor\",\"visibility\":null},\"contributorEmail\":null,\"contributorAttributes\":null}]}";
    WorkContributors workContributors = JsonUtils.<WorkContributors>readObjectFromJsonString(jsonString, WorkContributors.class);
    assertEquals(1, workContributors.getContributor().size());
    assertEquals("A Contributor", workContributors.getContributor().get(0).getCreditName().getContent());
}
Also used : WorkContributors(org.orcid.jaxb.model.message.WorkContributors) Test(org.junit.Test)

Example 3 with WorkContributors

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

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

Example 5 with WorkContributors

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

Aggregations

WorkContributors (org.orcid.jaxb.model.message.WorkContributors)8 Contributor (org.orcid.jaxb.model.message.Contributor)5 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)4 Test (org.junit.Test)3 CreditName (org.orcid.jaxb.model.message.CreditName)3 Citation (org.orcid.jaxb.model.message.Citation)2 ContributorAttributes (org.orcid.jaxb.model.message.ContributorAttributes)2 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)2 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 CitationType (org.orcid.jaxb.model.message.CitationType)1 ContributorOrcid (org.orcid.jaxb.model.message.ContributorOrcid)1 Day (org.orcid.jaxb.model.message.Day)1 Month (org.orcid.jaxb.model.message.Month)1 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)1 PublicationDate (org.orcid.jaxb.model.message.PublicationDate)1 Title (org.orcid.jaxb.model.message.Title)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