Search in sources :

Example 1 with FundingContributor

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

Example 2 with FundingContributor

use of org.orcid.jaxb.model.record_v2.FundingContributor in project ORCID-Source by ORCID.

the class ContributorUtilsTest method testFilterContributorPrivateDataForFundingWithPrivateName.

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

Example 3 with FundingContributor

use of org.orcid.jaxb.model.record_v2.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.record_v2.Funding) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Test(org.junit.Test)

Example 4 with FundingContributor

use of org.orcid.jaxb.model.record_v2.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.record_v2.Funding) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) Test(org.junit.Test)

Example 5 with FundingContributor

use of org.orcid.jaxb.model.record_v2.FundingContributor in project ORCID-Source by ORCID.

the class MemberV2ApiServiceImplV2_0_rc1 method compareFundingAndCreditNameVisibility.

private void compareFundingAndCreditNameVisibility(Funding funding) {
    Visibility fundingVisibility = funding.getVisibility();
    if (funding.getContributors() != null && funding.getContributors().getContributor() != null) {
        for (FundingContributor contributor : funding.getContributors().getContributor()) {
            if (contributor.getCreditName() != null && contributor.getCreditName().getVisibility() != null && contributor.getCreditName().getVisibility().isMoreRestrictiveThan(fundingVisibility)) {
                String title = (funding.getTitle() == null || funding.getTitle().getTitle() == null) ? null : funding.getTitle().getTitle().getContent();
                LOGGER.error("Client posting funding '{}' with visibility ({}) less restrictive than its contributor credit name '{}' ({})", new Object[] { title, fundingVisibility, contributor.getCreditName().getContent(), contributor.getCreditName().getVisibility() });
            }
        }
    }
}
Also used : FundingContributor(org.orcid.jaxb.model.record_rc1.FundingContributor) Visibility(org.orcid.jaxb.model.common_rc1.Visibility)

Aggregations

FundingContributor (org.orcid.jaxb.model.record_v2.FundingContributor)11 Funding (org.orcid.jaxb.model.record_v2.Funding)5 Test (org.junit.Test)4 CreditName (org.orcid.jaxb.model.common_v2.CreditName)4 ContributorEmail (org.orcid.jaxb.model.common_v2.ContributorEmail)3 ContributorOrcid (org.orcid.jaxb.model.common_v2.ContributorOrcid)3 FundingContributors (org.orcid.jaxb.model.record_v2.FundingContributors)3 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)3 FundingContributorAttributes (org.orcid.jaxb.model.record_v2.FundingContributorAttributes)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 Visibility (org.orcid.jaxb.model.common_rc1.Visibility)1 Visibility (org.orcid.jaxb.model.common_rc2.Visibility)1 Visibility (org.orcid.jaxb.model.common_rc3.Visibility)1 Amount (org.orcid.jaxb.model.common_v2.Amount)1 DisambiguatedOrganization (org.orcid.jaxb.model.common_v2.DisambiguatedOrganization)1 Organization (org.orcid.jaxb.model.common_v2.Organization)1 OrganizationAddress (org.orcid.jaxb.model.common_v2.OrganizationAddress)1 OrganizationDefinedFundingSubType (org.orcid.jaxb.model.common_v2.OrganizationDefinedFundingSubType)1