use of org.orcid.jaxb.model.record_rc3.ExternalIDs in project ORCID-Source by ORCID.
the class WorksTest method getWork.
private Work getWork(String title, boolean randomExtId, String extIdValue) {
Long time = System.currentTimeMillis();
Work work = new Work();
WorkTitle workTitle = new WorkTitle();
Title wTitle = new Title(title);
workTitle.setTranslatedTitle(new TranslatedTitle(title, "en"));
workTitle.setTitle(wTitle);
work.setWorkTitle(workTitle);
work.setWorkType(WorkType.BOOK);
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
if (randomExtId) {
extId.setValue("work-ext-id-" + (Math.random() * 1000) + "-" + time);
} else {
extId.setValue("work-ext-id-" + extIdValue);
}
extId.setType("doi");
ExternalIDs extIds = new ExternalIDs();
extIds.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIds);
return work;
}
use of org.orcid.jaxb.model.record_rc3.ExternalIDs in project ORCID-Source by ORCID.
the class ValidateV2RC4Identifiers method testRecord.
@Test
public void testRecord() {
Record record = unmarshallFromPath("/record_2.0_rc4/samples/record-2.0_rc4.xml", Record.class);
ActivitiesSummary as = record.getActivitiesSummary();
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 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://tempuri.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_rc3.ExternalIDs in project ORCID-Source by ORCID.
the class ValidateV2IdentifiersTest method testActivities.
@Test
public void testActivities() {
ActivitiesSummary as = unmarshallFromPath("/record_2.0/samples/read_samples/activities-2.0.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_rc3.ExternalIDs in project ORCID-Source by ORCID.
the class ValidateV2IdentifiersTest method testRecord.
@Test
public void testRecord() {
Record record = unmarshallFromPath("/record_2.0/samples/read_samples/record-2.0.xml", Record.class);
ActivitiesSummary as = record.getActivitiesSummary();
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 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://tempuri.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_rc3.ExternalIDs in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_FundingTest method testUpdateFunding.
@Test
public void testUpdateFunding() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewFunding("4444-4444-4444-4447", 6L);
assertNotNull(response);
Funding funding = (Funding) response.getEntity();
assertNotNull(funding);
assertEquals("Public Funding # 1", funding.getTitle().getTitle().getContent());
assertEquals("This is the description for funding with id 6", funding.getDescription());
LastModifiedDate before = funding.getLastModifiedDate();
funding.getTitle().getTitle().setContent("Updated funding title");
funding.setDescription("This is an updated description");
ExternalID fExtId = new ExternalID();
fExtId.setRelationship(Relationship.PART_OF);
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
fExtId.setUrl(new Url("http://fundingExtId.com"));
fExtId.setValue("new-funding-ext-id");
ExternalIDs fExtIds = new ExternalIDs();
fExtIds.getExternalIdentifier().add(fExtId);
funding.setExternalIdentifiers(fExtIds);
response = serviceDelegator.updateFunding("4444-4444-4444-4447", 6L, funding);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewFunding("4444-4444-4444-4447", 6L);
assertNotNull(response);
funding = (Funding) response.getEntity();
assertNotNull(funding);
Utils.verifyLastModified(funding.getLastModifiedDate());
assertTrue(funding.getLastModifiedDate().after(before));
assertEquals("Updated funding title", funding.getTitle().getTitle().getContent());
assertEquals("This is an updated description", funding.getDescription());
// Rollback changes
funding.getTitle().getTitle().setContent("Public Funding # 1");
funding.setDescription("This is the description for funding with id 6");
response = serviceDelegator.updateFunding("4444-4444-4444-4447", 6L, funding);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Aggregations