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;
}
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);
}
}
}
}
}
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());
}
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());
}
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;
}
Aggregations