use of org.orcid.jaxb.model.record_v2.ExternalIDs in project ORCID-Source by ORCID.
the class ValidateV2RC3Identifiers method testActivities.
@Test
public void testActivities() {
ActivitiesSummary as = unmarshallFromPath("/record_2.0_rc3/samples/activities-2.0_rc3.xml", ActivitiesSummary.class);
ExternalIDs fundingIDs = as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getExternalIdentifiers();
ExternalIDs fundingIDs2 = as.getFundings().getFundingGroup().get(0).getIdentifiers();
assertEquals("grant_number", fundingIDs.getExternalIdentifier().get(0).getType());
assertEquals("external-id-value", fundingIDs.getExternalIdentifier().get(0).getValue());
assertEquals(new Url("http://tempuri.org"), fundingIDs.getExternalIdentifier().get(0).getUrl());
assertEquals(Relationship.SELF, fundingIDs.getExternalIdentifier().get(0).getRelationship());
assertEquals(fundingIDs.getExternalIdentifier().get(0).getType(), fundingIDs2.getExternalIdentifier().get(0).getType());
assertEquals(fundingIDs.getExternalIdentifier().get(0).getValue(), fundingIDs2.getExternalIdentifier().get(0).getValue());
ExternalIDs peerIDs = as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers();
ExternalIDs peerIDs2 = as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers();
assertEquals("something", peerIDs.getExternalIdentifier().get(0).getType());
assertEquals("external-id-value", peerIDs.getExternalIdentifier().get(0).getValue());
assertEquals(new Url("http://orcid.org"), peerIDs.getExternalIdentifier().get(0).getUrl());
assertEquals(Relationship.SELF, peerIDs.getExternalIdentifier().get(0).getRelationship());
assertEquals(peerIDs.getExternalIdentifier().get(0).getType(), peerIDs2.getExternalIdentifier().get(0).getType());
assertEquals(peerIDs.getExternalIdentifier().get(0).getValue(), peerIDs2.getExternalIdentifier().get(0).getValue());
ExternalIDs workIDs = as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getExternalIdentifiers();
ExternalIDs workIDs2 = as.getWorks().getWorkGroup().get(0).getIdentifiers();
assertEquals("agr", workIDs.getExternalIdentifier().get(0).getType());
assertEquals("external-id-value", workIDs.getExternalIdentifier().get(0).getValue());
assertEquals(new Url("http://orcid.org"), workIDs.getExternalIdentifier().get(0).getUrl());
assertEquals(Relationship.SELF, workIDs.getExternalIdentifier().get(0).getRelationship());
assertEquals(workIDs.getExternalIdentifier().get(0).getType(), workIDs2.getExternalIdentifier().get(0).getType());
assertEquals(workIDs.getExternalIdentifier().get(0).getValue(), workIDs2.getExternalIdentifier().get(0).getValue());
}
use of org.orcid.jaxb.model.record_v2.ExternalIDs in project ORCID-Source by ORCID.
the class ExternalIDValidatorTest method testValidExtIdsWorksFine_flagOff.
@Test
public void testValidExtIdsWorksFine_flagOff() {
ExternalIDs extIds = new ExternalIDs();
ExternalID id1 = new ExternalID();
id1.setRelationship(null);
id1.setType("doi");
id1.setValue("value1");
id1.setUrl(new Url("http://value1.com"));
ExternalID id2 = new ExternalID();
id2.setRelationship(null);
id2.setType("doi");
id2.setValue("value1");
id2.setUrl(new Url("http://value1.com"));
ExternalID id3 = new ExternalID();
id3.setRelationship(null);
id3.setType("doi");
id3.setValue("value1");
id3.setUrl(new Url("http://value1.com"));
extIds.getExternalIdentifier().add(id1);
extIds.getExternalIdentifier().add(id2);
extIds.getExternalIdentifier().add(id3);
validator.validateWorkOrPeerReview(extIds);
}
use of org.orcid.jaxb.model.record_v2.ExternalIDs in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_WorksTest method testCreateWorksWithBulkAllOK.
@Test
public void testCreateWorksWithBulkAllOK() {
Long time = System.currentTimeMillis();
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
WorkBulk bulk = new WorkBulk();
for (int i = 0; i < 5; i++) {
Work work = new Work();
WorkTitle title = new WorkTitle();
title.setTitle(new Title("Bulk work " + i + " " + time));
work.setWorkTitle(title);
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
extId.setType("doi");
extId.setUrl(new Url("http://doi/" + i + "/" + time));
extId.setValue("doi-" + i + "-" + time);
extIds.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIds);
work.setWorkType(WorkType.BOOK);
bulk.getBulk().add(work);
}
Response response = serviceDelegator.createWorks(ORCID, bulk);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
bulk = (WorkBulk) response.getEntity();
assertNotNull(bulk);
assertEquals(5, bulk.getBulk().size());
for (int i = 0; i < 5; i++) {
assertTrue(Work.class.isAssignableFrom(bulk.getBulk().get(i).getClass()));
Work w = (Work) bulk.getBulk().get(i);
Utils.verifyLastModified(w.getLastModifiedDate());
assertNotNull(w.getPutCode());
assertTrue(0L < w.getPutCode());
assertEquals("Bulk work " + i + " " + time, w.getWorkTitle().getTitle().getContent());
assertNotNull(w.getExternalIdentifiers().getExternalIdentifier());
assertEquals("doi-" + i + "-" + time, w.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
Response r = serviceDelegator.viewWork(ORCID, w.getPutCode());
assertNotNull(r);
assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
assertEquals("Bulk work " + i + " " + time, ((Work) r.getEntity()).getWorkTitle().getTitle().getContent());
// Delete the work
r = serviceDelegator.deleteWork(ORCID, w.getPutCode());
assertNotNull(r);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), r.getStatus());
}
}
use of org.orcid.jaxb.model.record_v2.ExternalIDs in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method getFundingWithPutCode.
private ProfileFundingEntity getFundingWithPutCode(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"));
ExternalIDs extIdentifiers = new ExternalIDs();
extIdentifiers.getExternalIdentifier().add(extId);
funding.setExternalIdentifiers(extIdentifiers);
funding.setPutCode(Long.valueOf(111));
funding = profileFundingManager.createFunding(userOrcid, funding, true);
return profileFundingManager.getProfileFundingEntity(funding.getPutCode());
}
use of org.orcid.jaxb.model.record_v2.ExternalIDs in project ORCID-Source by ORCID.
the class WorkExternalIdentifiersConversionsTest method testConvertFromExternalIDs.
@Test
public void testConvertFromExternalIDs() {
WorkExternalIDsConverter conv = new WorkExternalIDsConverter();
ExternalID id = new ExternalID();
id.setRelationship(Relationship.SELF);
id.setType("doi");
id.setUrl(new Url("http://what.com"));
id.setValue("value");
ExternalID id2 = new ExternalID();
id2.setRelationship(Relationship.PART_OF);
id2.setType("source-work-id");
id2.setUrl(new Url("http://whatnow.com"));
id2.setValue("value2");
ExternalIDs ids = new ExternalIDs();
ids.getExternalIdentifier().add(id);
ids.getExternalIdentifier().add(id2);
String externalIdentifiersAsString = conv.convertTo(ids, null);
assertEquals(expectedIDs, externalIdentifiersAsString);
}
Aggregations