Search in sources :

Example 1 with Funding

use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method updateFunding.

@Override
public Response updateFunding(String orcid, Long putCode, Funding funding) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.FUNDING_UPDATE);
    if (!putCode.equals(funding.getPutCode())) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("urlPutCode", String.valueOf(putCode));
        params.put("bodyPutCode", String.valueOf(funding.getPutCode()));
        throw new MismatchedPutCodeException(params);
    }
    clearSource(funding);
    Funding f = profileFundingManager.updateFunding(orcid, funding, true);
    sourceUtils.setSourceName(f);
    return Response.ok(f).build();
}
Also used : HashMap(java.util.HashMap) Funding(org.orcid.jaxb.model.record_v2.Funding) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Example 2 with Funding

use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.

the class Utils method getFunding.

public static Funding getFunding() {
    Funding newFunding = new Funding();
    FundingTitle title = new FundingTitle();
    title.setTitle(new Title("Public Funding # 2"));
    newFunding.setTitle(title);
    newFunding.setType(FundingType.AWARD);
    ExternalID fExtId = new ExternalID();
    fExtId.setRelationship(Relationship.PART_OF);
    fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
    fExtId.setUrl(new Url("http://fundingExtId.com"));
    fExtId.setValue("new-funding-ext-id");
    ExternalIDs fExtIds = new ExternalIDs();
    fExtIds.getExternalIdentifier().add(fExtId);
    newFunding.setExternalIdentifiers(fExtIds);
    newFunding.setOrganization(getOrganization());
    return newFunding;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Funding(org.orcid.jaxb.model.record_v2.Funding) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Title(org.orcid.jaxb.model.common_v2.Title) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Example 3 with Funding

use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.

the class FundingForm method toFunding.

public Funding toFunding() {
    Funding result = new Funding();
    Amount orcidAmount = new Amount();
    if (!PojoUtil.isEmpty(amount))
        orcidAmount.setContent(amount.getValue());
    if (!PojoUtil.isEmpty(currencyCode))
        orcidAmount.setCurrencyCode(currencyCode.getValue());
    result.setAmount(orcidAmount);
    if (!PojoUtil.isEmpty(description))
        result.setDescription(description.getValue());
    if (!PojoUtil.isEmpty(startDate))
        result.setStartDate(new FuzzyDate(startDate.toFuzzyDate()));
    if (!PojoUtil.isEmpty(endDate))
        result.setEndDate(new FuzzyDate(endDate.toFuzzyDate()));
    if (!PojoUtil.isEmpty(putCode))
        result.setPutCode(Long.valueOf(putCode.getValue()));
    if (fundingTitle != null) {
        result.setTitle(fundingTitle.toFundingTitle());
    }
    if (!PojoUtil.isEmpty(fundingType))
        result.setType(FundingType.fromValue(fundingType.getValue()));
    if (organizationDefinedFundingSubType != null && !PojoUtil.isEmpty(organizationDefinedFundingSubType.getSubtype()))
        result.setOrganizationDefinedType(new OrganizationDefinedFundingSubType(organizationDefinedFundingSubType.getSubtype().getValue()));
    if (!PojoUtil.isEmpty(url))
        result.setUrl(new Url(url.getValue()));
    else
        result.setUrl(new Url());
    if (visibility != null)
        result.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(visibility.getVisibility().value()));
    // Set Organization
    Organization organization = new Organization();
    if (!PojoUtil.isEmpty(fundingName))
        organization.setName(fundingName.getValue());
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization.setAddress(organizationAddress);
    if (!PojoUtil.isEmpty(city))
        organizationAddress.setCity(city.getValue());
    if (!PojoUtil.isEmpty(region)) {
        organizationAddress.setRegion(region.getValue());
    }
    if (!PojoUtil.isEmpty(country)) {
        organizationAddress.setCountry(Iso3166Country.fromValue(country.getValue()));
    }
    if (!PojoUtil.isEmpty(disambiguatedFundingSourceId)) {
        organization.setDisambiguatedOrganization(new DisambiguatedOrganization());
        organization.getDisambiguatedOrganization().setDisambiguatedOrganizationIdentifier(disambiguatedFundingSourceId.getValue());
        organization.getDisambiguatedOrganization().setDisambiguationSource(disambiguationSource.getValue());
    }
    result.setOrganization(organization);
    // Set contributors
    if (contributors != null && !contributors.isEmpty()) {
        FundingContributors fContributors = new FundingContributors();
        for (Contributor contributor : contributors) {
            if (!PojoUtil.isEmtpy(contributor))
                fContributors.getContributor().add(contributor.toFundingContributor());
        }
        result.setContributors(fContributors);
    }
    // Set external identifiers
    if (externalIdentifiers != null && !externalIdentifiers.isEmpty()) {
        ExternalIDs fExternalIdentifiers = new ExternalIDs();
        for (FundingExternalIdentifierForm fExternalIdentifier : externalIdentifiers) {
            if (!PojoUtil.isEmtpy(fExternalIdentifier))
                fExternalIdentifiers.getExternalIdentifier().add(fExternalIdentifier.toFundingExternalIdentifier());
        }
        result.setExternalIdentifiers(fExternalIdentifiers);
    }
    return result;
}
Also used : DisambiguatedOrganization(org.orcid.jaxb.model.common_v2.DisambiguatedOrganization) Organization(org.orcid.jaxb.model.common_v2.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.common_v2.DisambiguatedOrganization) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Funding(org.orcid.jaxb.model.record_v2.Funding) Amount(org.orcid.jaxb.model.common_v2.Amount) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) FundingContributors(org.orcid.jaxb.model.record_v2.FundingContributors) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) Url(org.orcid.jaxb.model.common_v2.Url) OrganizationDefinedFundingSubType(org.orcid.jaxb.model.common_v2.OrganizationDefinedFundingSubType)

Example 4 with Funding

use of org.orcid.jaxb.model.record_rc1.Funding in project ORCID-Source by ORCID.

the class SourceInActivitiesTest method getFundingWithoutTitle.

private ProfileFundingEntity getFundingWithoutTitle(String userOrcid) {
    Funding funding = new Funding();
    funding.setOrganization(getOrganization());
    funding.setType(org.orcid.jaxb.model.record_v2.FundingType.AWARD);
    ExternalID extId = new ExternalID();
    extId.setValue("111");
    extId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
    extId.setUrl(new Url("http://test.com"));
    ExternalIDs extIdentifiers = new ExternalIDs();
    extIdentifiers.getExternalIdentifier().add(extId);
    funding.setExternalIdentifiers(extIdentifiers);
    funding = profileFundingManager.createFunding(userOrcid, funding, true);
    return profileFundingManager.getProfileFundingEntity(funding.getPutCode());
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Funding(org.orcid.jaxb.model.record_v2.Funding) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url)

Example 5 with Funding

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

Aggregations

Funding (org.orcid.jaxb.model.record_v2.Funding)82 Test (org.junit.Test)70 ClientResponse (com.sun.jersey.api.client.ClientResponse)28 ArrayList (java.util.ArrayList)17 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)16 Response (javax.ws.rs.core.Response)15 Url (org.orcid.jaxb.model.common_v2.Url)15 DBUnitTest (org.orcid.test.DBUnitTest)15 Title (org.orcid.jaxb.model.common_v2.Title)11 Work (org.orcid.jaxb.model.record_v2.Work)10 List (java.util.List)9 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)9 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)9 IOException (java.io.IOException)8 Funding (org.orcid.jaxb.model.record_rc1.Funding)8 Education (org.orcid.jaxb.model.record_v2.Education)8 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)8 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)8 InputStreamReader (java.io.InputStreamReader)7 Reader (java.io.Reader)7