Search in sources :

Example 1 with FundingContributor

use of org.orcid.jaxb.model.record_rc2.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 2 with FundingContributor

use of org.orcid.jaxb.model.record_rc2.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 3 with FundingContributor

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

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

Example 5 with FundingContributor

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

the class MemberV2ApiServiceImplV2_0_rc2 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_rc2.FundingContributor) Visibility(org.orcid.jaxb.model.common_rc2.Visibility)

Aggregations

FundingContributor (org.orcid.jaxb.model.record_v2.FundingContributor)9 Funding (org.orcid.jaxb.model.record_v2.Funding)6 Test (org.junit.Test)4 CreditName (org.orcid.jaxb.model.common_v2.CreditName)4 FundingContributors (org.orcid.jaxb.model.record_v2.FundingContributors)4 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)3 ContributorEmail (org.orcid.jaxb.model.common_v2.ContributorEmail)2 ContributorOrcid (org.orcid.jaxb.model.common_v2.ContributorOrcid)2 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 OrganizationDefinedFundingSubType (org.orcid.jaxb.model.common_v2.OrganizationDefinedFundingSubType)1 Title (org.orcid.jaxb.model.common_v2.Title)1 TranslatedTitle (org.orcid.jaxb.model.common_v2.TranslatedTitle)1 Url (org.orcid.jaxb.model.common_v2.Url)1 FundingContributor (org.orcid.jaxb.model.record_rc1.FundingContributor)1 FundingContributor (org.orcid.jaxb.model.record_rc2.FundingContributor)1 FundingContributor (org.orcid.jaxb.model.record_rc3.FundingContributor)1 FundingContributorAttributes (org.orcid.jaxb.model.record_v2.FundingContributorAttributes)1