Search in sources :

Example 1 with FundingExternalIdentifier

use of org.orcid.jaxb.model.message.FundingExternalIdentifier in project ORCID-Source by ORCID.

the class T2OrcidApiServiceDelegatorTest method testAddFundingToDeprecatedAccount.

@Test(expected = OrcidDeprecatedException.class)
public void testAddFundingToDeprecatedAccount() {
    SecurityContextTestUtils.setUpSecurityContext();
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-444X"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    FundingList fundings = new FundingList();
    Funding funding = new Funding();
    OrganizationAddress address = new OrganizationAddress();
    address.setCity("City");
    address.setCountry(Iso3166Country.US);
    Organization org = new Organization();
    org.setAddress(address);
    org.setName("Testing org name");
    funding.setOrganization(org);
    FundingExternalIdentifiers fExtIds = new FundingExternalIdentifiers();
    FundingExternalIdentifier fExtId = new FundingExternalIdentifier();
    fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER);
    fExtId.setValue("FExtId");
    fExtIds.getFundingExternalIdentifier().add(fExtId);
    funding.setFundingExternalIdentifiers(fExtIds);
    funding.setType(FundingType.AWARD);
    funding.setOrganizationDefinedFundingType(new OrganizationDefinedFundingSubType("fType"));
    FundingTitle title = new FundingTitle();
    title.setTitle(new Title("Funding title"));
    funding.setTitle(title);
    fundings.getFundings().add(funding);
    orcidActivities.setFundings(fundings);
    t2OrcidApiServiceDelegator.addFunding(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
Also used : Organization(org.orcid.jaxb.model.message.Organization) Funding(org.orcid.jaxb.model.message.Funding) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) OrganizationDefinedFundingSubType(org.orcid.jaxb.model.message.OrganizationDefinedFundingSubType) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with FundingExternalIdentifier

use of org.orcid.jaxb.model.message.FundingExternalIdentifier in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method getFundingInsideOrcidProfile.

private OrcidProfile getFundingInsideOrcidProfile(String defaultTitle, String orcid) {
    Funding funding = new Funding();
    funding.setType(FundingType.AWARD);
    FundingTitle title = new FundingTitle();
    if (defaultTitle == null) {
        title.setTitle(new Title("New Funding"));
    } else {
        title.setTitle(new Title(defaultTitle));
    }
    funding.setTitle(title);
    FundingExternalIdentifiers fExtIds = new FundingExternalIdentifiers();
    FundingExternalIdentifier fExtId = new FundingExternalIdentifier();
    fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER);
    if (defaultTitle == null) {
        fExtId.setValue("123");
    } else {
        fExtId.setValue("123-" + defaultTitle);
    }
    fExtIds.getFundingExternalIdentifier().add(fExtId);
    funding.setFundingExternalIdentifiers(fExtIds);
    Organization org = new Organization();
    OrganizationAddress add = new OrganizationAddress();
    add.setCity("city");
    add.setCountry(Iso3166Country.US);
    org.setName("Test org");
    org.setAddress(add);
    funding.setOrganization(org);
    FundingList fList = new FundingList();
    fList.getFundings().add(funding);
    OrcidProfile profile = new OrcidProfile();
    profile.setOrcidIdentifier(orcid);
    profile.setFundings(fList);
    return profile;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) Organization(org.orcid.jaxb.model.message.Organization) Funding(org.orcid.jaxb.model.message.Funding) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier)

Example 3 with FundingExternalIdentifier

use of org.orcid.jaxb.model.message.FundingExternalIdentifier in project ORCID-Source by ORCID.

the class Api12Helper method addFunding.

protected static void addFunding(String userOrcid, String token, String title, T2OAuthAPIService<ClientResponse> oauthT2Client) {
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    FundingList fundings = new FundingList();
    Funding funding = new Funding();
    funding.setVisibility(Visibility.LIMITED);
    FundingTitle fundingTitle = new FundingTitle();
    fundingTitle.setTitle(new Title(title));
    funding.setTitle(fundingTitle);
    funding.setType(FundingType.SALARY_AWARD);
    Amount amount = new Amount();
    amount.setCurrencyCode("CRC");
    amount.setContent("1,250,000");
    funding.setAmount(amount);
    funding.setStartDate(new FuzzyDate(2010, 1, 1));
    funding.setEndDate(new FuzzyDate(2013, 1, 1));
    funding.setDescription("My Grant description");
    funding.setUrl(new Url("http://url.com"));
    Organization org = new Organization();
    org.setName("Orcid Integration Test Org");
    OrganizationAddress add = new OrganizationAddress();
    add.setCity("My City");
    add.setCountry(Iso3166Country.CR);
    org.setAddress(add);
    funding.setOrganization(org);
    FundingExternalIdentifier extIdentifier = new FundingExternalIdentifier();
    extIdentifier.setType(FundingExternalIdentifierType.fromValue("grant_number"));
    extIdentifier.setUrl(new Url("http://url.com"));
    extIdentifier.setValue("My value");
    FundingExternalIdentifiers extIdentifiers = new FundingExternalIdentifiers();
    extIdentifiers.getFundingExternalIdentifier().add(extIdentifier);
    funding.setFundingExternalIdentifiers(extIdentifiers);
    FundingContributors contributors = new FundingContributors();
    FundingContributor contributor = new FundingContributor();
    contributor.setCreditName(new CreditName("My Credit Name"));
    contributor.setContributorEmail(new ContributorEmail("my.email@orcid-integration-test.com"));
    FundingContributorAttributes attributes = new FundingContributorAttributes();
    attributes.setContributorRole(FundingContributorRole.LEAD);
    contributor.setContributorAttributes(attributes);
    contributors.getContributor().add(contributor);
    funding.setFundingContributors(contributors);
    fundings.getFundings().add(funding);
    orcidMessage.getOrcidProfile().getOrcidActivities().setFundings(fundings);
    ClientResponse clientResponse = oauthT2Client.addFundingXml(userOrcid, orcidMessage, token);
    assertEquals(201, clientResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Organization(org.orcid.jaxb.model.message.Organization) Funding(org.orcid.jaxb.model.message.Funding) Amount(org.orcid.jaxb.model.message.Amount) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) FundingContributor(org.orcid.jaxb.model.message.FundingContributor) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) CreditName(org.orcid.jaxb.model.message.CreditName) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) ContributorEmail(org.orcid.jaxb.model.message.ContributorEmail) Url(org.orcid.jaxb.model.message.Url) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) FundingContributors(org.orcid.jaxb.model.message.FundingContributors) FundingContributorAttributes(org.orcid.jaxb.model.message.FundingContributorAttributes) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers)

Aggregations

Funding (org.orcid.jaxb.model.message.Funding)3 FundingExternalIdentifier (org.orcid.jaxb.model.message.FundingExternalIdentifier)3 FundingExternalIdentifiers (org.orcid.jaxb.model.message.FundingExternalIdentifiers)3 FundingList (org.orcid.jaxb.model.message.FundingList)3 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)3 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)3 Organization (org.orcid.jaxb.model.message.Organization)3 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)3 Title (org.orcid.jaxb.model.message.Title)3 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)3 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)2 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 Test (org.junit.Test)1 Amount (org.orcid.jaxb.model.message.Amount)1 ContributorEmail (org.orcid.jaxb.model.message.ContributorEmail)1 CreditName (org.orcid.jaxb.model.message.CreditName)1 FundingContributor (org.orcid.jaxb.model.message.FundingContributor)1 FundingContributorAttributes (org.orcid.jaxb.model.message.FundingContributorAttributes)1 FundingContributors (org.orcid.jaxb.model.message.FundingContributors)1