Search in sources :

Example 1 with FundingContributor

use of org.orcid.jaxb.model.v3.dev1.record.FundingContributor in project ORCID-Source by ORCID.

the class Contributor method valueOf.

public static Contributor valueOf(FundingContributor contributor) {
    Contributor c = new Contributor();
    if (contributor != null) {
        if (contributor.getContributorAttributes() != null) {
            contributor.getContributorAttributes();
            if (contributor.getContributorAttributes().getContributorRole() != null)
                c.setContributorRole(Text.valueOf(contributor.getContributorAttributes().getContributorRole().value()));
        }
        if (contributor.getContributorOrcid() != null) {
            c.setOrcid(Text.valueOf(contributor.getContributorOrcid().getPath()));
            c.setUri(Text.valueOf(contributor.getContributorOrcid().getUri()));
        }
        if (contributor.getCreditName() != null) {
            c.setCreditName(Text.valueOf(contributor.getCreditName().getContent()));
        }
    }
    return c;
}
Also used : FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor)

Example 2 with FundingContributor

use of org.orcid.jaxb.model.v3.dev1.record.FundingContributor in project ORCID-Source by ORCID.

the class ContributorUtils method filterContributorPrivateData.

public void filterContributorPrivateData(Funding funding) {
    if (funding.getContributors() != null && funding.getContributors().getContributor() != null) {
        for (FundingContributor contributor : funding.getContributors().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 : FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 3 with FundingContributor

use of org.orcid.jaxb.model.v3.dev1.record.FundingContributor in project ORCID-Source by ORCID.

the class ContributorUtilsTest method testFilterContributorPrivateDataForFundingWithInvalidOrcidRecord.

@Test
public void testFilterContributorPrivateDataForFundingWithInvalidOrcidRecord() {
    when(profileEntityManager.orcidExists(anyString())).thenReturn(false);
    Funding funding = getFundingWithOrcidContributor();
    contributorUtils.filterContributorPrivateData(funding);
    FundingContributor contributor = funding.getContributors().getContributor().get(0);
    assertNull(contributor.getContributorEmail());
    assertEquals("original credit name", contributor.getCreditName().getContent());
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) Test(org.junit.Test)

Example 4 with FundingContributor

use of org.orcid.jaxb.model.v3.dev1.record.FundingContributor in project ORCID-Source by ORCID.

the class ContributorUtilsTest method testFilterContributorPrivateDataForFundingWithPublicName.

@Test
public void testFilterContributorPrivateDataForFundingWithPublicName() {
    when(profileEntityManager.orcidExists(anyString())).thenReturn(true);
    when(profileEntityCacheManager.retrieve(anyString())).thenReturn(new ProfileEntity());
    when(cacheManager.getPublicCreditName(any(ProfileEntity.class))).thenReturn("a public name");
    Funding funding = getFundingWithOrcidContributor();
    contributorUtils.filterContributorPrivateData(funding);
    FundingContributor contributor = funding.getContributors().getContributor().get(0);
    assertNull(contributor.getContributorEmail());
    assertEquals("a public name", contributor.getCreditName().getContent());
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Test(org.junit.Test)

Example 5 with FundingContributor

use of org.orcid.jaxb.model.v3.dev1.record.FundingContributor in project ORCID-Source by ORCID.

the class ContributorUtilsTest method getFundingContributorWithOrcid.

private FundingContributors getFundingContributorWithOrcid() {
    ContributorOrcid contributorOrcid = new ContributorOrcid();
    contributorOrcid.setPath("0000-0003-4902-6327");
    contributorOrcid.setHost("orcid.org");
    contributorOrcid.setUri("http://orcid.org/0000-0003-4902-6327");
    FundingContributor contributor = new FundingContributor();
    contributor.setContributorOrcid(contributorOrcid);
    contributor.setContributorEmail(new ContributorEmail("never@show.this"));
    contributor.setCreditName(new CreditName("original credit name"));
    FundingContributors fundingContributors = new FundingContributors();
    fundingContributors.getContributor().add(contributor);
    return fundingContributors;
}
Also used : FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FundingContributors(org.orcid.jaxb.model.v3.dev1.record.FundingContributors) ContributorOrcid(org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid) ContributorEmail(org.orcid.jaxb.model.v3.dev1.common.ContributorEmail)

Aggregations

FundingContributor (org.orcid.jaxb.model.v3.dev1.record.FundingContributor)12 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)6 CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)5 Test (org.junit.Test)4 FundingContributors (org.orcid.jaxb.model.v3.dev1.record.FundingContributors)4 ContributorEmail (org.orcid.jaxb.model.v3.dev1.common.ContributorEmail)3 ContributorOrcid (org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid)3 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)3 FundingContributorAttributes (org.orcid.jaxb.model.v3.dev1.record.FundingContributorAttributes)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 Amount (org.orcid.jaxb.model.v3.dev1.common.Amount)1 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)1 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)1 OrganizationAddress (org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress)1 OrganizationDefinedFundingSubType (org.orcid.jaxb.model.v3.dev1.common.OrganizationDefinedFundingSubType)1 Source (org.orcid.jaxb.model.v3.dev1.common.Source)1 Title (org.orcid.jaxb.model.v3.dev1.common.Title)1 TranslatedTitle (org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle)1