Search in sources :

Example 6 with Contributor

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

the class MemberV2ApiServiceImplV2_0_rc3 method compareWorkAndCreditNameVisibility.

private void compareWorkAndCreditNameVisibility(Work work) {
    Visibility workVisibility = work.getVisibility();
    if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
        for (Contributor contributor : work.getWorkContributors().getContributor()) {
            if (contributor.getCreditName() != null && contributor.getCreditName().getVisibility() != null && contributor.getCreditName().getVisibility().isMoreRestrictiveThan(workVisibility)) {
                String title = (work.getWorkTitle() == null || work.getWorkTitle().getTitle() == null) ? null : work.getWorkTitle().getTitle().getContent();
                LOGGER.error("Client posting work '{}' with visibility ({}) less restrictive than its contributor credit name '{}' ({})", new Object[] { title, workVisibility, contributor.getCreditName().getContent(), contributor.getCreditName().getVisibility() });
            }
        }
    }
}
Also used : FundingContributor(org.orcid.jaxb.model.record_rc3.FundingContributor) Contributor(org.orcid.jaxb.model.common_rc3.Contributor) Visibility(org.orcid.jaxb.model.common_rc3.Visibility)

Example 7 with Contributor

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

the class ContributorUtils method filterContributorPrivateData.

public void filterContributorPrivateData(Work work) {
    if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
        for (Contributor contributor : work.getWorkContributors().getContributor()) {
            contributor.setContributorEmail(null);
            if (!PojoUtil.isEmpty(contributor.getContributorOrcid())) {
                String contributorOrcid = contributor.getContributorOrcid().getPath();
                if (profileEntityManager.orcidExists(contributorOrcid)) {
                    // contributor is an ORCID user - visibility of user's
                    // name in record must be taken into account
                    ProfileEntity profileEntity = profileEntityCacheManager.retrieve(contributorOrcid);
                    String publicContributorCreditName = cacheManager.getPublicCreditName(profileEntity);
                    CreditName creditName = new CreditName(publicContributorCreditName != null ? publicContributorCreditName : "");
                    contributor.setCreditName(creditName);
                }
            }
        }
    }
}
Also used : CreditName(org.orcid.jaxb.model.common_v2.CreditName) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) Contributor(org.orcid.jaxb.model.common_v2.Contributor) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 8 with Contributor

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

the class WorkToCiteprocTranslator method translateFromWorkMetadata.

/**
     * Use the ORCID work metadata to generate a *limited* citation. You'll most
     * likely get a title, doi, url, date and author.
     * 
     * Translates type according to https://docs.google.com/spreadsheets/d/
     * 1h4nTF6DKNEpWcGNQVMDwt0ea09qmkBnkWisxkJE-li4/edit#gid=754644608
     * 
     * Informed by mendley tranforms at
     * http://support.mendeley.com/customer/portal/articles/364144-csl-type-
     * mapping
     * 
     * See also:
     * http://docs.citationstyles.org/en/stable/specification.html#appendix-iii-
     * types http://members.orcid.org/api/supported-work-types datacite and
     * crossref mappings here:
     * https://github.com/lagotto/lagotto/blob/master/config/initializers/
     * constants.rb
     * @param creditName 
     * 
     * @param worktype
     * @return a CSLItemData, default CSLType.ARTICLE if cannot map type
     */
private CSLItemData translateFromWorkMetadata(Work work, String creditName) {
    CSLItemDataBuilder builder = new CSLItemDataBuilder();
    builder.title((work.getWorkTitle() != null) ? StringUtils.stripAccents(work.getWorkTitle().getTitle().getContent()) : "No Title");
    String doi = extractID(work, WorkExternalIdentifierType.DOI);
    String url = extractID(work, WorkExternalIdentifierType.URI);
    if (doi != null) {
        builder.DOI(doi);
    }
    if (url != null) {
        builder.URL(url);
    } else if (doi != null) {
        builder.URL("http://doi.org/" + doi);
    } else {
        url = extractID(work, WorkExternalIdentifierType.HANDLE);
        if (url != null) {
            builder.URL(url);
        }
    }
    if (work.getJournalTitle() != null) {
        builder.containerTitle(StringUtils.stripAccents(work.getJournalTitle().getContent()));
    }
    List<String> names = new ArrayList<String>();
    // TODO: Pass in credit name
    names.add(creditName);
    if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
        for (Contributor c : work.getWorkContributors().getContributor()) {
            if (c.getCreditName() != null && c.getCreditName().getContent() != null) {
                names.add(StringUtils.stripAccents(c.getCreditName().getContent()));
            }
        }
    }
    CSLNameBuilder name = new CSLNameBuilder();
    name.literal(Joiner.on(" and ").skipNulls().join(names));
    builder.author(name.build());
    // TODO: make it work with "Spring", "August", whatever...
    if (work.getPublicationDate() != null) {
        int year = 0;
        int month = 0;
        int day = 0;
        try {
            year = Integer.parseInt(work.getPublicationDate().getYear().getValue());
            month = Integer.parseInt(work.getPublicationDate().getMonth().getValue());
            day = Integer.parseInt(work.getPublicationDate().getDay().getValue());
        } catch (Exception e) {
        }
        if (year > 0 && month > 0 && day > 0) {
            builder.issued(year, month, day);
        } else if (year > 0 && month > 0) {
            builder.issued(year, month);
        } else if (year > 0) {
            builder.issued(year);
        }
    }
    switch(work.getWorkType()) {
        case ARTISTIC_PERFORMANCE:
            break;
        case BOOK:
            builder.type(CSLType.BOOK);
            break;
        case BOOK_CHAPTER:
            builder.type(CSLType.CHAPTER);
            break;
        case BOOK_REVIEW:
            builder.type(CSLType.REVIEW_BOOK);
            break;
        case CONFERENCE_ABSTRACT:
            builder.type(CSLType.PAPER_CONFERENCE);
            break;
        case CONFERENCE_PAPER:
            builder.type(CSLType.PAPER_CONFERENCE);
            break;
        case CONFERENCE_POSTER:
            builder.type(CSLType.PAPER_CONFERENCE);
            break;
        case DATA_SET:
            builder.type(CSLType.DATASET);
            break;
        case DICTIONARY_ENTRY:
            builder.type(CSLType.ENTRY_DICTIONARY);
            break;
        case DISSERTATION:
            builder.type(CSLType.THESIS);
            break;
        case ENCYCLOPEDIA_ENTRY:
            builder.type(CSLType.ENTRY_ENCYCLOPEDIA);
            break;
        case JOURNAL_ARTICLE:
            builder.type(CSLType.ARTICLE_JOURNAL);
            break;
        case MAGAZINE_ARTICLE:
            builder.type(CSLType.ARTICLE_MAGAZINE);
            break;
        case NEWSLETTER_ARTICLE:
            builder.type(CSLType.ARTICLE_NEWSPAPER);
            break;
        case NEWSPAPER_ARTICLE:
            builder.type(CSLType.ARTICLE_NEWSPAPER);
            break;
        case ONLINE_RESOURCE:
            builder.type(CSLType.WEBPAGE);
            break;
        case REPORT:
            builder.type(CSLType.REPORT);
            break;
        case WEBSITE:
            builder.type(CSLType.WEBPAGE);
            break;
        case WORKING_PAPER:
            builder.type(CSLType.ARTICLE);
            break;
        case DISCLOSURE:
        case EDITED_BOOK:
        case INVENTION:
        case JOURNAL_ISSUE:
        case LECTURE_SPEECH:
        case LICENSE:
        case MANUAL:
        case OTHER:
        case PATENT:
        case REGISTERED_COPYRIGHT:
        case RESEARCH_TECHNIQUE:
        case RESEARCH_TOOL:
        case SPIN_OFF_COMPANY:
        case STANDARDS_AND_POLICY:
        case SUPERVISED_STUDENT_PUBLICATION:
        case TECHNICAL_STANDARD:
        case TEST:
        case TRADEMARK:
        case TRANSLATION:
        case UNDEFINED:
        default:
            // builder.type(CSLType.ARTICLE);
            break;
    }
    return builder.build();
}
Also used : ArrayList(java.util.ArrayList) CSLNameBuilder(de.undercouch.citeproc.csl.CSLNameBuilder) Contributor(org.orcid.jaxb.model.common_v2.Contributor) CSLItemDataBuilder(de.undercouch.citeproc.csl.CSLItemDataBuilder) IOException(java.io.IOException) ParseException(org.jbibtex.ParseException)

Example 9 with Contributor

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

the class MemberV2ApiServiceImplV2_0_rc2 method compareWorkAndCreditNameVisibility.

private void compareWorkAndCreditNameVisibility(Work work) {
    Visibility workVisibility = work.getVisibility();
    if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
        for (Contributor contributor : work.getWorkContributors().getContributor()) {
            if (contributor.getCreditName() != null && contributor.getCreditName().getVisibility() != null && contributor.getCreditName().getVisibility().isMoreRestrictiveThan(workVisibility)) {
                String title = (work.getWorkTitle() == null || work.getWorkTitle().getTitle() == null) ? null : work.getWorkTitle().getTitle().getContent();
                LOGGER.error("Client posting work '{}' with visibility ({}) less restrictive than its contributor credit name '{}' ({})", new Object[] { title, workVisibility, contributor.getCreditName().getContent(), contributor.getCreditName().getVisibility() });
            }
        }
    }
}
Also used : FundingContributor(org.orcid.jaxb.model.record_rc2.FundingContributor) Contributor(org.orcid.jaxb.model.common_rc2.Contributor) Visibility(org.orcid.jaxb.model.common_rc2.Visibility)

Example 10 with Contributor

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

the class ContributorUtilsTest method testFilterContributorPrivateDataForWorkWithInvalidOrcidRecord.

@Test
public void testFilterContributorPrivateDataForWorkWithInvalidOrcidRecord() {
    when(profileEntityManager.orcidExists(anyString())).thenReturn(false);
    Work work = getWorkWithOrcidContributor();
    contributorUtils.filterContributorPrivateData(work);
    Contributor contributor = work.getWorkContributors().getContributor().get(0);
    assertNull(contributor.getContributorEmail());
    assertEquals("original credit name", contributor.getCreditName().getContent());
}
Also used : Work(org.orcid.jaxb.model.record_v2.Work) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) Contributor(org.orcid.jaxb.model.common_v2.Contributor) Test(org.junit.Test)

Aggregations

Contributor (org.orcid.jaxb.model.common_v2.Contributor)11 FundingContributor (org.orcid.jaxb.model.record_v2.FundingContributor)8 Work (org.orcid.jaxb.model.record_v2.Work)6 Test (org.junit.Test)4 CreditName (org.orcid.jaxb.model.common_v2.CreditName)4 WorkContributors (org.orcid.jaxb.model.record_v2.WorkContributors)4 ContributorEmail (org.orcid.jaxb.model.common_v2.ContributorEmail)3 ContributorOrcid (org.orcid.jaxb.model.common_v2.ContributorOrcid)3 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)3 ArrayList (java.util.ArrayList)2 Visibility (org.orcid.jaxb.model.common_rc2.Visibility)2 Iso3166Country (org.orcid.jaxb.model.common_v2.Iso3166Country)2 PublicationDate (org.orcid.jaxb.model.common_v2.PublicationDate)2 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)2 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)2 CSLItemDataBuilder (de.undercouch.citeproc.csl.CSLItemDataBuilder)1 CSLNameBuilder (de.undercouch.citeproc.csl.CSLNameBuilder)1 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1