use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validateFunding_invalidPutCodeTest.
@Test(expected = InvalidPutCodeException.class)
public void validateFunding_invalidPutCodeTest() {
Funding funding = getFunding();
funding.setPutCode(1L);
activityValidator.validateFunding(funding, null, true, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validateFunding_invalidTranslatedTitleLanguageCodeTest.
@Test(expected = ActivityTypeValidationException.class)
public void validateFunding_invalidTranslatedTitleLanguageCodeTest() {
Funding funding = getFunding();
funding.getTitle().getTranslatedTitle().setLanguageCode("xx");
activityValidator.validateFunding(funding, null, true, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingFundingsTest method generateFundings.
/**
* funding-1 -> A, B, C
* funding-2 -> C, D, E
* funding-3 -> X, Y, Z
* funding-4 -> Y, B, 1
* funding-5 -> M, N, O
* funding-6 -> O, P, Q
* funding-7 -> 1, 2, B
* funding-8 -> No external identifiers
* funding-9 -> No external identifiers
* */
private Map<String, FundingSummary> generateFundings() {
Map<String, FundingSummary> result = new HashMap<String, FundingSummary>();
for (int i = 1; i < 10; i++) {
String name = "funding-" + i;
FundingSummary funding = new FundingSummary();
FundingTitle title = new FundingTitle();
title.setTitle(new Title(name));
funding.setTitle(title);
ExternalIDs fei = new ExternalIDs();
switch(i) {
case 1:
ExternalID f1 = new ExternalID();
f1.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f1.setValue("A");
ExternalID f2 = new ExternalID();
f2.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f2.setValue("B");
ExternalID f3 = new ExternalID();
f3.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f3.setValue("C");
fei.getExternalIdentifier().add(f1);
fei.getExternalIdentifier().add(f2);
fei.getExternalIdentifier().add(f3);
break;
case 2:
ExternalID f4 = new ExternalID();
f4.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f4.setValue("C");
ExternalID f5 = new ExternalID();
f5.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f5.setValue("D");
ExternalID f6 = new ExternalID();
f6.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f6.setValue("E");
fei.getExternalIdentifier().add(f4);
fei.getExternalIdentifier().add(f5);
fei.getExternalIdentifier().add(f6);
break;
case 3:
ExternalID f7 = new ExternalID();
f7.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f7.setValue("X");
ExternalID f8 = new ExternalID();
f8.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f8.setValue("Y");
ExternalID f9 = new ExternalID();
f9.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f9.setValue("Z");
fei.getExternalIdentifier().add(f7);
fei.getExternalIdentifier().add(f8);
fei.getExternalIdentifier().add(f9);
break;
case 4:
ExternalID f10 = new ExternalID();
f10.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f10.setValue("Y");
ExternalID f11 = new ExternalID();
f11.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f11.setValue("B");
ExternalID f12 = new ExternalID();
f12.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f12.setValue("1");
fei.getExternalIdentifier().add(f10);
fei.getExternalIdentifier().add(f11);
fei.getExternalIdentifier().add(f12);
break;
case 5:
ExternalID f13 = new ExternalID();
f13.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f13.setValue("M");
ExternalID f14 = new ExternalID();
f14.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f14.setValue("N");
ExternalID f15 = new ExternalID();
f15.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f15.setValue("O");
fei.getExternalIdentifier().add(f13);
fei.getExternalIdentifier().add(f14);
fei.getExternalIdentifier().add(f15);
break;
case 6:
ExternalID f16 = new ExternalID();
f16.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f16.setValue("O");
ExternalID f17 = new ExternalID();
f17.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f17.setValue("P");
ExternalID f18 = new ExternalID();
f18.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f18.setValue("Q");
fei.getExternalIdentifier().add(f16);
fei.getExternalIdentifier().add(f17);
fei.getExternalIdentifier().add(f18);
break;
case 7:
ExternalID f19 = new ExternalID();
f19.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f19.setValue("1");
ExternalID f20 = new ExternalID();
f20.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f20.setValue("2");
ExternalID f21 = new ExternalID();
f21.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f21.setValue("B");
fei.getExternalIdentifier().add(f19);
fei.getExternalIdentifier().add(f20);
fei.getExternalIdentifier().add(f21);
break;
}
funding.setExternalIdentifiers(fei);
result.put(name, funding);
}
return result;
}
use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.
the class BlackBoxBase method unmarshallFromPath.
public Object unmarshallFromPath(String path, Class<?> type) {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type);
Object result = null;
if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Education.class.equals(type)) {
result = (Education) obj;
} else if (Employment.class.equals(type)) {
result = (Employment) obj;
} else if (Funding.class.equals(type)) {
result = (Funding) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Work.class.equals(type)) {
result = (Work) obj;
} else if (PeerReview.class.equals(type)) {
result = (PeerReview) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.
the class MemberV2Test method testTokenWorksOnlyForTheScopeItWasIssued.
@SuppressWarnings({ "deprecation", "rawtypes" })
@Test
public void testTokenWorksOnlyForTheScopeItWasIssued() throws JSONException, InterruptedException, URISyntaxException {
long time = System.currentTimeMillis();
List<String> scopes = getScopes(ScopePathType.FUNDING_CREATE, ScopePathType.FUNDING_UPDATE);
String accessToken = getAccessToken(scopes);
Work work1 = (Work) unmarshallFromPath("/record_2.0/samples/read_samples/work-2.0.xml", Work.class);
work1.setPutCode(null);
work1.getExternalIdentifiers().getExternalIdentifier().clear();
org.orcid.jaxb.model.record_v2.WorkTitle title1 = new org.orcid.jaxb.model.record_v2.WorkTitle();
title1.setTitle(new Title("Work # 1"));
work1.setWorkTitle(title1);
ExternalID wExtId1 = new ExternalID();
wExtId1.setValue("Work Id " + time);
wExtId1.setType(WorkExternalIdentifierType.AGR.value());
wExtId1.setRelationship(Relationship.SELF);
wExtId1.setUrl(new Url("http://orcid.org/work#1"));
work1.getExternalIdentifiers().getExternalIdentifier().clear();
work1.getExternalIdentifiers().getExternalIdentifier().add(wExtId1);
//Add the work
ClientResponse postResponse = memberV2ApiClient.createWorkXml(this.getUser1OrcidId(), work1, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), postResponse.getStatus());
Funding funding = (Funding) unmarshallFromPath("/record_2.0/samples/read_samples/funding-2.0.xml", Funding.class);
funding.setPutCode(null);
funding.setVisibility(Visibility.PUBLIC);
funding.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID fExtId = new ExternalID();
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
fExtId.setValue("Funding Id " + time);
fExtId.setRelationship(Relationship.SELF);
funding.getExternalIdentifiers().getExternalIdentifier().add(fExtId);
//Add the funding
postResponse = memberV2ApiClient.createFundingXml(this.getUser1OrcidId(), funding, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
// Delete funding
Map map = postResponse.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List resultWithPutCode = (List) map.get("Location");
String location = resultWithPutCode.get(0).toString();
Long putCode = Long.valueOf(location.substring(location.lastIndexOf('/') + 1));
ClientResponse deleteResponse = memberV2ApiClient.deleteFundingXml(this.getUser1OrcidId(), putCode, accessToken);
assertNotNull(deleteResponse);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Aggregations