Search in sources :

Example 1 with Funding

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

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

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

the class OrcidIndexManagerImplTest method getOrcidWithGrants.

private OrcidProfile getOrcidWithGrants() {
    OrcidProfile orcidWithGrants = getStandardOrcid();
    FundingList orcidFundings = new FundingList();
    Funding funding1 = new Funding();
    funding1.setVisibility(Visibility.PUBLIC);
    FundingTitle title = new FundingTitle();
    title.setTitle(new Title("grant 1"));
    funding1.setTitle(title);
    Funding funding2 = new Funding();
    funding2.setVisibility(Visibility.PUBLIC);
    FundingTitle title2 = new FundingTitle();
    title2.setTitle(new Title("grant 2"));
    funding2.setTitle(title2);
    Funding funding3 = new Funding();
    funding3.setVisibility(Visibility.LIMITED);
    FundingTitle title3 = new FundingTitle();
    title3.setTitle(new Title("grant 3"));
    funding3.setTitle(title3);
    Funding funding4 = new Funding();
    funding4.setVisibility(Visibility.PUBLIC);
    orcidFundings.getFundings().addAll(Arrays.asList(new Funding[] { funding1, funding2, funding3, funding4 }));
    orcidWithGrants.setFundings(orcidFundings);
    return orcidWithGrants;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) Funding(org.orcid.jaxb.model.message.Funding) 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)

Example 4 with Funding

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

the class OrcidSearchManagerImplTest method getOrcidProfileAllIndexFieldsPopulated.

private OrcidProfile getOrcidProfileAllIndexFieldsPopulated() {
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier("5678");
    OrcidBio orcidBio = new OrcidBio();
    PersonalDetails personalDetails = new PersonalDetails();
    personalDetails.setFamilyName(new FamilyName("Logan"));
    personalDetails.setGivenNames(new GivenNames("Donald Edward"));
    personalDetails.setCreditName(new CreditName("Stanley Higgins"));
    OtherNames otherNames = new OtherNames();
    otherNames.getOtherName().add(new OtherName("Edward Bass", null));
    otherNames.getOtherName().add(new OtherName("Gareth Dove", null));
    personalDetails.setOtherNames(otherNames);
    orcidBio.setPersonalDetails(personalDetails);
    orcidProfile.setOrcidBio(orcidBio);
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidProfile.setOrcidWorks(orcidWorks);
    OrcidWork orcidWork1 = new OrcidWork();
    OrcidWork orcidWork2 = new OrcidWork();
    assignWorkIdentifers(orcidWork1, orcidWork2);
    orcidWorks.getOrcidWork().add(orcidWork1);
    orcidWorks.getOrcidWork().add(orcidWork2);
    orcidProfile.setOrcidWorks(orcidWorks);
    FundingList orcidFundings = new FundingList();
    orcidProfile.setFundings(orcidFundings);
    Funding funding1 = new Funding();
    funding1.setVisibility(Visibility.PUBLIC);
    FundingTitle title = new FundingTitle();
    title.setTitle(new Title("grant1"));
    funding1.setTitle(title);
    funding1.setDescription("Grant 1 - a short description");
    funding1.setPutCode("grant 1 - put-code");
    Funding funding2 = new Funding();
    funding2.setVisibility(Visibility.PUBLIC);
    FundingTitle title2 = new FundingTitle();
    title2.setTitle(new Title("grant2"));
    funding2.setTitle(title2);
    funding2.setDescription("Grant 2 - a short description");
    funding2.setPutCode("grant 2 - put-code");
    orcidFundings.getFundings().add(funding1);
    orcidFundings.getFundings().add(funding2);
    return orcidProfile;
}
Also used : OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) OtherNames(org.orcid.jaxb.model.message.OtherNames) Funding(org.orcid.jaxb.model.message.Funding) CreditName(org.orcid.jaxb.model.message.CreditName) OtherName(org.orcid.jaxb.model.message.OtherName) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Title(org.orcid.jaxb.model.message.Title) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) Affiliations(org.orcid.jaxb.model.message.Affiliations) GivenNames(org.orcid.jaxb.model.message.GivenNames) FundingTitle(org.orcid.jaxb.model.message.FundingTitle)

Example 5 with Funding

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

the class Api12MembersTest method activitiesReadLimitedTest.

@Test
public void activitiesReadLimitedTest() throws InterruptedException, JSONException {
    changeDefaultUserVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
    String clientId = getClient1ClientId();
    String clientRedirectUri = getClient1RedirectUri();
    String clientSecret = getClient1ClientSecret();
    String userId = getUser1OrcidId();
    String password = getUser1Password();
    String workTitle = "Work " + System.currentTimeMillis();
    String fundingTitle = "Funding " + System.currentTimeMillis();
    String orgName = "Org_" + System.currentTimeMillis();
    String accessToken = getAccessToken(userId, password, Arrays.asList("/read-limited", "/activities/update"), clientId, clientSecret, clientRedirectUri, true);
    Long workPutCode = null;
    Api12Helper.addWork(userId, accessToken, workTitle, t2OAuthClient_1_2);
    Long fundingPutCode = null;
    Api12Helper.addFunding(userId, accessToken, fundingTitle, t2OAuthClient_1_2);
    Long affiliationPutCode = null;
    Api12Helper.addAffiliation(userId, accessToken, orgName, t2OAuthClient_1_2);
    ClientResponse worksResponse = t2OAuthClient_1_2.viewWorksDetailsXml(userId, accessToken);
    assertNotNull(worksResponse);
    assertEquals(200, worksResponse.getStatus());
    assertEquals("application/vnd.orcid+xml; charset=UTF-8; qs=5", worksResponse.getType().toString());
    OrcidMessage orcidMessageWithNewWork = worksResponse.getEntity(OrcidMessage.class);
    assertNotNull(orcidMessageWithNewWork);
    assertNotNull(orcidMessageWithNewWork.getOrcidProfile());
    assertNotNull(orcidMessageWithNewWork.getOrcidProfile().getOrcidActivities());
    assertNotNull(orcidMessageWithNewWork.getOrcidProfile().getOrcidActivities().getOrcidWorks());
    assertNotNull(orcidMessageWithNewWork.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork());
    assertTrue(orcidMessageWithNewWork.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().size() > 0);
    boolean workFound = false;
    for (OrcidWork work : orcidMessageWithNewWork.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork()) {
        if (workTitle.equals(work.getWorkTitle().getTitle().getContent())) {
            // Default user visibility should be public
            assertEquals(Visibility.PUBLIC, work.getVisibility());
            assertNotNull(work.getPutCode());
            workPutCode = Long.valueOf(work.getPutCode());
            workFound = true;
        }
    }
    assertTrue(workFound);
    ClientResponse fundingResponse = t2OAuthClient_1_2.viewFundingDetailsXml(userId, accessToken);
    assertNotNull(fundingResponse);
    assertEquals(200, fundingResponse.getStatus());
    assertEquals("application/vnd.orcid+xml; charset=UTF-8; qs=5", fundingResponse.getType().toString());
    OrcidMessage orcidMessageWithNewFunding = fundingResponse.getEntity(OrcidMessage.class);
    assertNotNull(orcidMessageWithNewFunding);
    assertNotNull(orcidMessageWithNewFunding.getOrcidProfile());
    assertNotNull(orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities());
    assertNotNull(orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities().getFundings());
    assertNotNull(orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities().getFundings().getFundings());
    assertTrue(orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities().getFundings().getFundings().size() > 0);
    boolean fundingFound = false;
    for (Funding funding : orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities().getFundings().getFundings()) {
        if (fundingTitle.equals(funding.getTitle().getTitle().getContent())) {
            // Default user visibility should be public
            assertEquals(Visibility.PUBLIC, funding.getVisibility());
            assertNotNull(funding.getPutCode());
            fundingPutCode = Long.valueOf(funding.getPutCode());
            fundingFound = true;
        }
    }
    assertTrue(fundingFound);
    ClientResponse affiliationResponse = t2OAuthClient_1_2.viewAffiliationDetailsXml(userId, accessToken);
    assertNotNull(affiliationResponse);
    assertEquals(200, affiliationResponse.getStatus());
    assertEquals("application/vnd.orcid+xml; charset=UTF-8; qs=5", affiliationResponse.getType().toString());
    OrcidMessage orcidMessageWithNewAffiliation = affiliationResponse.getEntity(OrcidMessage.class);
    assertNotNull(orcidMessageWithNewAffiliation);
    assertNotNull(orcidMessageWithNewAffiliation.getOrcidProfile());
    assertNotNull(orcidMessageWithNewAffiliation.getOrcidProfile().getOrcidActivities());
    assertNotNull(orcidMessageWithNewAffiliation.getOrcidProfile().getOrcidActivities().getAffiliations());
    assertNotNull(orcidMessageWithNewAffiliation.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation());
    assertTrue(orcidMessageWithNewAffiliation.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation().size() > 0);
    boolean affiliationFound = false;
    for (Affiliation affiliation : orcidMessageWithNewAffiliation.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation()) {
        if (orgName.equals(affiliation.getOrganization().getName())) {
            // Default user visibility should be public
            assertEquals(Visibility.PUBLIC, affiliation.getVisibility());
            assertNotNull(affiliation.getPutCode());
            affiliationPutCode = Long.valueOf(affiliation.getPutCode());
            affiliationFound = true;
        }
    }
    assertTrue(affiliationFound);
    // Delete work
    ClientResponse deleteResponse = memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), workPutCode, accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
    // Delete funding
    deleteResponse = memberV2ApiClient.deleteFundingXml(this.getUser1OrcidId(), fundingPutCode, accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
    // Delete affiliation
    deleteResponse = memberV2ApiClient.deleteEducationXml(this.getUser1OrcidId(), affiliationPutCode, accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Funding(org.orcid.jaxb.model.message.Funding) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Affiliation(org.orcid.jaxb.model.message.Affiliation) Test(org.junit.Test)

Aggregations

Funding (org.orcid.jaxb.model.message.Funding)21 FundingList (org.orcid.jaxb.model.message.FundingList)12 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)11 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)9 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)9 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)7 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)7 Title (org.orcid.jaxb.model.message.Title)7 Test (org.junit.Test)6 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)5 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)5 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 Affiliation (org.orcid.jaxb.model.message.Affiliation)4 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)4 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)4 OtherName (org.orcid.jaxb.model.message.OtherName)4 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)4 ArrayList (java.util.ArrayList)3 Affiliations (org.orcid.jaxb.model.message.Affiliations)3 Email (org.orcid.jaxb.model.message.Email)3