Search in sources :

Example 61 with Funding

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

the class SourceInActivitiesTest method getFunding.

private Funding getFunding(String userOrcid) {
    Funding funding = new Funding();
    funding.setOrganization(getOrganization());
    FundingTitle title = new FundingTitle();
    title.setTitle(new Title("Title " + System.currentTimeMillis()));
    funding.setTitle(title);
    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"));
    extId.setRelationship(Relationship.PART_OF);
    ExternalIDs extIdentifiers = new ExternalIDs();
    extIdentifiers.getExternalIdentifier().add(extId);
    funding.setExternalIdentifiers(extIdentifiers);
    funding = profileFundingManager.createFunding(userOrcid, funding, true);
    return profileFundingManager.getFunding(userOrcid, 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) 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)

Example 62 with Funding

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

the class ProfileFundingManagerTest method testAddFundingToClaimedRecordPreserveUserDefaultVisibility.

@Test
public void testAddFundingToClaimedRecordPreserveUserDefaultVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Funding funding = getFunding(null);
    funding = profileFundingManager.createFunding(claimedOrcid, funding, true);
    funding = profileFundingManager.getFunding(claimedOrcid, funding.getPutCode());
    assertNotNull(funding);
    assertEquals("Funding title", funding.getTitle().getTitle().getContent());
    assertEquals(Visibility.LIMITED, funding.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 63 with Funding

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

the class ProfileFundingManagerTest method getFunding.

private Funding getFunding(String grantNumber) {
    Funding funding = new Funding();
    ExternalIDs extIds = new ExternalIDs();
    ExternalID extId = new ExternalID();
    extId.setRelationship(Relationship.SELF);
    extId.setType("grant_number");
    extId.setUrl(new Url("http://orcid.org"));
    if (grantNumber == null) {
        extId.setValue("ext-id-value");
    } else {
        extId.setValue(grantNumber);
    }
    extIds.getExternalIdentifier().add(extId);
    funding.setExternalIdentifiers(extIds);
    FundingTitle title = new FundingTitle();
    if (grantNumber == null) {
        title.setTitle(new Title("Funding title"));
    } else {
        title.setTitle(new Title("Funding title " + grantNumber));
    }
    funding.setTitle(title);
    Organization org = new Organization();
    org.setName("org-name");
    OrganizationAddress address = new OrganizationAddress();
    address.setCity("city");
    address.setCountry(Iso3166Country.US);
    org.setAddress(address);
    funding.setOrganization(org);
    funding.setVisibility(Visibility.PUBLIC);
    funding.setType(FundingType.AWARD);
    return funding;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Organization(org.orcid.jaxb.model.common_v2.Organization) Funding(org.orcid.jaxb.model.record_v2.Funding) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) 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)

Example 64 with Funding

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

the class ProfileFundingManagerTest method testAddFundingToUnclaimedRecordPreserveFundingVisibility.

@Test
public void testAddFundingToUnclaimedRecordPreserveFundingVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Funding funding = getFunding(null);
    funding = profileFundingManager.createFunding(unclaimedOrcid, funding, true);
    funding = profileFundingManager.getFunding(unclaimedOrcid, funding.getPutCode());
    assertNotNull(funding);
    assertEquals("Funding title", funding.getTitle().getTitle().getContent());
    assertEquals(Visibility.PUBLIC, funding.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 65 with Funding

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

the class JpaJaxbFundingAdapterTest method getFunding.

private Funding getFunding(boolean full) throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(new Class[] { Funding.class });
    Unmarshaller unmarshaller = context.createUnmarshaller();
    String name = "/record_2.0/samples/read_samples/funding-2.0.xml";
    if (full) {
        name = "/record_2.0/samples/read_samples/funding-full-2.0.xml";
    }
    InputStream inputStream = getClass().getResourceAsStream(name);
    return (Funding) unmarshaller.unmarshal(inputStream);
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

Funding (org.orcid.jaxb.model.record_v2.Funding)82 Test (org.junit.Test)73 ClientResponse (com.sun.jersey.api.client.ClientResponse)28 ArrayList (java.util.ArrayList)16 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)16 Response (javax.ws.rs.core.Response)15 DBUnitTest (org.orcid.test.DBUnitTest)15 Url (org.orcid.jaxb.model.common_v2.Url)14 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 Funding (org.orcid.jaxb.model.record_rc1.Funding)8 IOException (java.io.IOException)7 InputStreamReader (java.io.InputStreamReader)6 Reader (java.io.Reader)6 BaseTest (org.orcid.core.BaseTest)6 Funding (org.orcid.jaxb.model.record_rc4.Funding)6 Education (org.orcid.jaxb.model.record_v2.Education)6