Search in sources :

Example 6 with FundingContributor

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

the class ContributorUtilsTest method getFundingContributorWithoutOrcid.

private FundingContributors getFundingContributorWithoutOrcid() {
    FundingContributor contributor = new FundingContributor();
    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) ContributorEmail(org.orcid.jaxb.model.v3.dev1.common.ContributorEmail)

Example 7 with FundingContributor

use of org.orcid.jaxb.model.v3.dev1.record.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.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 8 with FundingContributor

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

the class ActivityUtilsTest method getEmptyFunding.

private Funding getEmptyFunding() {
    Funding f = new Funding();
    FundingContributors fcs = new FundingContributors();
    FundingContributor fc = new FundingContributor();
    fc.setCreditName(new CreditName(""));
    fcs.getContributor().add(fc);
    f.setContributors(fcs);
    return f;
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) FundingContributors(org.orcid.jaxb.model.v3.dev1.record.FundingContributors) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName)

Example 9 with FundingContributor

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

the class Contributor method toFundingContributor.

public FundingContributor toFundingContributor() {
    FundingContributor c = new FundingContributor();
    if (this.getContributorRole() != null || this.getContributorSequence() != null) {
        FundingContributorAttributes ca = new FundingContributorAttributes();
        if (!PojoUtil.isEmpty(this.getContributorRole()))
            ca.setContributorRole(FundingContributorRole.fromValue(this.getContributorRole().getValue()));
        c.setContributorAttributes(ca);
    }
    if (this.getEmail() != null)
        c.setContributorEmail(new ContributorEmail(this.getEmail().getValue()));
    if (this.getOrcid() != null) {
        ContributorOrcid contributorOrcid = new ContributorOrcid(this.getOrcid().getValue());
        if (this.getUri() != null) {
            String uriString = this.getUri().getValue();
            if (StringUtils.isNotBlank(uriString)) {
                try {
                    URI uri = new URI(uriString);
                    contributorOrcid.setHost(uri.getHost());
                } catch (URISyntaxException e) {
                    throw new RuntimeException("Problem parsing contributor orcid uri", e);
                }
            }
        }
        contributorOrcid.setUri(this.getUri().getValue());
        c.setContributorOrcid(contributorOrcid);
    }
    if (this.getCreditName() != null) {
        CreditName cn = new CreditName(this.getCreditName().getValue());
        c.setCreditName(cn);
    }
    return c;
}
Also used : FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FundingContributorAttributes(org.orcid.jaxb.model.v3.dev1.record.FundingContributorAttributes) ContributorOrcid(org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid) URISyntaxException(java.net.URISyntaxException) ContributorEmail(org.orcid.jaxb.model.v3.dev1.common.ContributorEmail) URI(java.net.URI)

Example 10 with FundingContributor

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

the class FundingForm method valueOf.

public static FundingForm valueOf(Funding funding) {
    FundingForm result = new FundingForm();
    result.setDateSortString(PojoUtil.createDateSortString(funding.getStartDate(), funding.getEndDate()));
    if (funding.getPutCode() != null)
        result.setPutCode(Text.valueOf(funding.getPutCode()));
    if (funding.getAmount() != null) {
        if (StringUtils.isNotEmpty(funding.getAmount().getContent())) {
            String cleanNumber = funding.getAmount().getContent().trim();
            result.setAmount(Text.valueOf(cleanNumber));
        }
        if (funding.getAmount().getCurrencyCode() != null)
            result.setCurrencyCode(Text.valueOf(funding.getAmount().getCurrencyCode()));
        else
            result.setCurrencyCode(new Text());
    } else {
        result.setAmount(new Text());
        result.setCurrencyCode(new Text());
    }
    if (StringUtils.isNotEmpty(funding.getDescription()))
        result.setDescription(Text.valueOf(funding.getDescription()));
    else
        result.setDescription(new Text());
    if (funding.getStartDate() != null)
        result.setStartDate(Date.valueOf(funding.getStartDate()));
    if (funding.getEndDate() != null)
        result.setEndDate(Date.valueOf(funding.getEndDate()));
    if (funding.getType() != null)
        result.setFundingType(Text.valueOf(funding.getType().value()));
    else
        result.setFundingType(new Text());
    if (funding.getOrganizationDefinedType() != null) {
        OrgDefinedFundingSubType OrgDefinedFundingSubType = new OrgDefinedFundingSubType();
        OrgDefinedFundingSubType.setSubtype(Text.valueOf(funding.getOrganizationDefinedType().getContent()));
        OrgDefinedFundingSubType.setAlreadyIndexed(false);
        result.setOrganizationDefinedFundingSubType(OrgDefinedFundingSubType);
    }
    Source source = funding.getSource();
    if (source != null) {
        result.setSource(source.retrieveSourcePath());
        if (source.getSourceName() != null) {
            result.setSourceName(source.getSourceName().getContent());
        }
    }
    if (funding.getTitle() != null) {
        FundingTitleForm fundingTitle = new FundingTitleForm();
        if (funding.getTitle().getTitle() != null)
            fundingTitle.setTitle(Text.valueOf(funding.getTitle().getTitle().getContent()));
        else
            fundingTitle.setTitle(new Text());
        if (funding.getTitle().getTranslatedTitle() != null) {
            TranslatedTitleForm translatedTitle = new TranslatedTitleForm();
            translatedTitle.setContent(funding.getTitle().getTranslatedTitle().getContent());
            translatedTitle.setLanguageCode(funding.getTitle().getTranslatedTitle().getLanguageCode());
            fundingTitle.setTranslatedTitle(translatedTitle);
        }
        result.setFundingTitle(fundingTitle);
    } else {
        FundingTitleForm fundingTitle = new FundingTitleForm();
        fundingTitle.setTitle(new Text());
        result.setFundingTitle(fundingTitle);
    }
    if (funding.getUrl() != null)
        result.setUrl(Text.valueOf(funding.getUrl().getValue()));
    else
        result.setUrl(new Text());
    if (funding.getVisibility() != null)
        result.setVisibility(Visibility.valueOf(funding.getVisibility()));
    // Set the disambiguated organization
    Organization organization = funding.getOrganization();
    result.setFundingName(Text.valueOf(organization.getName()));
    DisambiguatedOrganization disambiguatedOrganization = organization.getDisambiguatedOrganization();
    if (disambiguatedOrganization != null) {
        if (StringUtils.isNotEmpty(disambiguatedOrganization.getDisambiguatedOrganizationIdentifier())) {
            result.setDisambiguatedFundingSourceId(Text.valueOf(disambiguatedOrganization.getDisambiguatedOrganizationIdentifier()));
            result.setDisambiguationSource(Text.valueOf(disambiguatedOrganization.getDisambiguationSource()));
        }
    }
    OrganizationAddress organizationAddress = organization.getAddress();
    if (organizationAddress != null) {
        if (!PojoUtil.isEmpty(organizationAddress.getCity()))
            result.setCity(Text.valueOf(organizationAddress.getCity()));
        else
            result.setCity(new Text());
        if (!PojoUtil.isEmpty(organizationAddress.getRegion()))
            result.setRegion(Text.valueOf(organizationAddress.getRegion()));
        else
            result.setRegion(new Text());
        if (organizationAddress.getCountry() != null)
            result.setCountry(Text.valueOf(organizationAddress.getCountry().value()));
        else
            result.setCountry(new Text());
    } else {
        result.setCountry(new Text());
        result.setCity(new Text());
        result.setRegion(new Text());
    }
    // Set contributors
    if (funding.getContributors() != null) {
        List<Contributor> contributors = new ArrayList<Contributor>();
        for (FundingContributor fContributor : funding.getContributors().getContributor()) {
            Contributor contributor = Contributor.valueOf(fContributor);
            contributors.add(contributor);
        }
        result.setContributors(contributors);
    }
    List<FundingExternalIdentifierForm> externalIdentifiersList = new ArrayList<FundingExternalIdentifierForm>();
    // Set external identifiers
    if (funding.getExternalIdentifiers() != null) {
        for (ExternalID fExternalIdentifier : funding.getExternalIdentifiers().getExternalIdentifier()) {
            FundingExternalIdentifierForm fundingExternalIdentifierForm = FundingExternalIdentifierForm.valueOf(fExternalIdentifier);
            externalIdentifiersList.add(fundingExternalIdentifierForm);
        }
    }
    result.setExternalIdentifiers(externalIdentifiersList);
    result.setCreatedDate(Date.valueOf(funding.getCreatedDate()));
    result.setLastModified(Date.valueOf(funding.getLastModifiedDate()));
    return result;
}
Also used : Organization(org.orcid.jaxb.model.v3.dev1.common.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) OrganizationAddress(org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) ArrayList(java.util.ArrayList) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) Source(org.orcid.jaxb.model.v3.dev1.common.Source) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)

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