use of org.orcid.jaxb.model.record_rc3.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;
}
use of org.orcid.jaxb.model.record_rc3.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());
}
use of org.orcid.jaxb.model.record_rc3.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());
}
use of org.orcid.jaxb.model.record_rc3.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());
}
use of org.orcid.jaxb.model.record_rc3.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() });
}
}
}
}
Aggregations