use of org.orcid.jaxb.model.record_rc3.ExternalID 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.ExternalID 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.ExternalID in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method testUnmarshallWorks.
@Test
public void testUnmarshallWorks() throws JAXBException, SAXException, URISyntaxException {
Works works = (Works) unmarshallFromPath("/record_2.0/samples/read_samples/works-2.0.xml", Works.class, "/record_2.0/activities-2.0.xsd");
assertNotNull(works);
assertNotNull(works.getLastModifiedDate());
assertNotNull(works.getLastModifiedDate().getValue());
assertEquals(3, works.getWorkGroup().size());
boolean foundWorkWithNoExtIds = false;
for (WorkGroup group : works.getWorkGroup()) {
assertNotNull(group.getLastModifiedDate().getValue());
assertNotNull(group.getIdentifiers().getExternalIdentifier());
if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
WorkSummary summary = group.getWorkSummary().get(0);
assertEquals("1", summary.getDisplayIndex());
assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("doi", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("https://doi.org/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("/8888-8888-8888-8880/work/3356", summary.getPath());
assertEquals("03", summary.getPublicationDate().getDay().getValue());
assertEquals("03", summary.getPublicationDate().getMonth().getValue());
assertEquals("2017", summary.getPublicationDate().getYear().getValue());
assertEquals("Work # 0", summary.getTitle().getTitle().getContent());
assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
assertEquals(Visibility.PUBLIC, summary.getVisibility());
foundWorkWithNoExtIds = true;
} else {
assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
ExternalID extId = group.getIdentifiers().getExternalIdentifier().get(0);
if (extId.getType().equals("arxiv")) {
assertEquals(Relationship.SELF, extId.getRelationship());
assertEquals("http://arxiv.org/abs/123456", extId.getUrl().getValue());
assertEquals("123456", extId.getValue());
} else if (extId.getType().equals("bibcode")) {
assertEquals(Relationship.SELF, extId.getRelationship());
assertEquals("http://adsabs.harvard.edu/abs/4567", extId.getUrl().getValue());
assertEquals("4567", extId.getValue());
} else {
fail("Invalid ext id type " + extId.getType());
}
assertEquals(1, group.getWorkSummary().size());
WorkSummary summary = group.getWorkSummary().get(0);
if (summary.getPutCode().equals(Long.valueOf(3357))) {
assertEquals("1", summary.getDisplayIndex());
assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("arxiv", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("http://arxiv.org/abs/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("/8888-8888-8888-8880/work/3357", summary.getPath());
assertEquals("02", summary.getPublicationDate().getDay().getValue());
assertEquals("02", summary.getPublicationDate().getMonth().getValue());
assertEquals("2017", summary.getPublicationDate().getYear().getValue());
assertEquals("Work # 1", summary.getTitle().getTitle().getContent());
assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
assertEquals(Visibility.PUBLIC, summary.getVisibility());
} else if (summary.getPutCode().equals(Long.valueOf(3358))) {
assertEquals("1", summary.getDisplayIndex());
assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("bibcode", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("http://adsabs.harvard.edu/abs/4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("/8888-8888-8888-8880/work/3358", summary.getPath());
assertEquals("03", summary.getPublicationDate().getDay().getValue());
assertEquals("03", summary.getPublicationDate().getMonth().getValue());
assertEquals("2017", summary.getPublicationDate().getYear().getValue());
assertEquals("Work # 2", summary.getTitle().getTitle().getContent());
assertEquals(WorkType.JOURNAL_ARTICLE, summary.getType());
assertEquals(Visibility.PUBLIC, summary.getVisibility());
} else {
fail("Invalid put code " + summary.getPutCode());
}
}
}
assertTrue(foundWorkWithNoExtIds);
}
use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method testUnmarshallWorks.
@Test
public void testUnmarshallWorks() throws JAXBException, SAXException, URISyntaxException {
Works works = (Works) unmarshallFromPath("/record_2.1/samples/read_samples/works-2.1.xml", Works.class, "/record_2.1/activities-2.1.xsd");
assertNotNull(works);
assertNotNull(works.getLastModifiedDate());
assertNotNull(works.getLastModifiedDate().getValue());
assertEquals(3, works.getWorkGroup().size());
boolean foundWorkWithNoExtIds = false;
for (WorkGroup group : works.getWorkGroup()) {
assertNotNull(group.getLastModifiedDate().getValue());
assertNotNull(group.getIdentifiers().getExternalIdentifier());
if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
WorkSummary summary = group.getWorkSummary().get(0);
validateSourceInHttps(summary.getSource());
assertEquals("1", summary.getDisplayIndex());
assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("doi", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("https://doi.org/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("/8888-8888-8888-8880/work/3356", summary.getPath());
assertEquals("03", summary.getPublicationDate().getDay().getValue());
assertEquals("03", summary.getPublicationDate().getMonth().getValue());
assertEquals("2017", summary.getPublicationDate().getYear().getValue());
assertEquals("Work # 0", summary.getTitle().getTitle().getContent());
assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
assertEquals(Visibility.PUBLIC, summary.getVisibility());
foundWorkWithNoExtIds = true;
} else {
assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
ExternalID extId = group.getIdentifiers().getExternalIdentifier().get(0);
if (extId.getType().equals("arxiv")) {
assertEquals(Relationship.SELF, extId.getRelationship());
assertEquals("http://arxiv.org/abs/123456", extId.getUrl().getValue());
assertEquals("123456", extId.getValue());
} else if (extId.getType().equals("bibcode")) {
assertEquals(Relationship.SELF, extId.getRelationship());
assertEquals("http://adsabs.harvard.edu/abs/4567", extId.getUrl().getValue());
assertEquals("4567", extId.getValue());
} else {
fail("Invalid ext id type " + extId.getType());
}
assertEquals(1, group.getWorkSummary().size());
WorkSummary summary = group.getWorkSummary().get(0);
validateSourceInHttps(summary.getSource());
if (summary.getPutCode().equals(Long.valueOf(3357))) {
assertEquals("1", summary.getDisplayIndex());
assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("arxiv", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("http://arxiv.org/abs/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("/8888-8888-8888-8880/work/3357", summary.getPath());
assertEquals("02", summary.getPublicationDate().getDay().getValue());
assertEquals("02", summary.getPublicationDate().getMonth().getValue());
assertEquals("2017", summary.getPublicationDate().getYear().getValue());
assertEquals("Work # 1", summary.getTitle().getTitle().getContent());
assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
assertEquals(Visibility.PUBLIC, summary.getVisibility());
} else if (summary.getPutCode().equals(Long.valueOf(3358))) {
assertEquals("1", summary.getDisplayIndex());
assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("bibcode", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("http://adsabs.harvard.edu/abs/4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("/8888-8888-8888-8880/work/3358", summary.getPath());
assertEquals("03", summary.getPublicationDate().getDay().getValue());
assertEquals("03", summary.getPublicationDate().getMonth().getValue());
assertEquals("2017", summary.getPublicationDate().getYear().getValue());
assertEquals("Work # 2", summary.getTitle().getTitle().getContent());
assertEquals(WorkType.JOURNAL_ARTICLE, summary.getType());
assertEquals(Visibility.PUBLIC, summary.getVisibility());
} else {
fail("Invalid put code " + summary.getPutCode());
}
}
}
assertTrue(foundWorkWithNoExtIds);
}
use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_PeerReviewsTest method testAddPeerReviewWithSameExtIdValueButDifferentExtIdType.
@Test
public void testAddPeerReviewWithSameExtIdValueButDifferentExtIdType() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
PeerReview peerReview1 = new PeerReview();
ExternalIDs weis1 = new ExternalIDs();
ExternalID wei1 = new ExternalID();
wei1.setRelationship(null);
wei1.setValue("same_but_different_type");
wei1.setType(WorkExternalIdentifierType.DOI.value());
weis1.getExternalIdentifier().add(wei1);
peerReview1.setExternalIdentifiers(weis1);
peerReview1.setGroupId("issn:0000003");
peerReview1.setOrganization(Utils.getOrganization());
peerReview1.setRole(Role.CHAIR);
peerReview1.setSubjectContainerName(new Title("subject-container-name"));
peerReview1.setSubjectExternalIdentifier(wei1);
WorkTitle workTitle1 = new WorkTitle();
workTitle1.setTitle(new Title("work-title"));
peerReview1.setSubjectName(workTitle1);
peerReview1.setSubjectType(WorkType.DATA_SET);
peerReview1.setType(PeerReviewType.EVALUATION);
Response response1 = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview1);
assertNotNull(response1);
assertEquals(Response.Status.CREATED.getStatusCode(), response1.getStatus());
Map<?, ?> map = response1.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode1 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
PeerReview peerReview2 = new PeerReview();
ExternalIDs weis2 = new ExternalIDs();
ExternalID wei2 = new ExternalID();
wei2.setRelationship(null);
// Same value
wei2.setValue("same_but_different_type");
// But different
wei2.setType(WorkExternalIdentifierType.ARXIV.value());
// type
weis2.getExternalIdentifier().add(wei2);
peerReview2.setExternalIdentifiers(weis2);
peerReview2.setGroupId("issn:0000003");
peerReview2.setOrganization(Utils.getOrganization());
peerReview2.setRole(Role.CHAIR);
peerReview2.setSubjectContainerName(new Title("subject-container-name"));
peerReview2.setSubjectExternalIdentifier(wei2);
WorkTitle workTitle2 = new WorkTitle();
workTitle2.setTitle(new Title("work-title"));
peerReview2.setSubjectName(workTitle2);
peerReview2.setSubjectType(WorkType.DATA_SET);
peerReview2.setType(PeerReviewType.EVALUATION);
Response response2 = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview2);
assertNotNull(response2);
assertEquals(Response.Status.CREATED.getStatusCode(), response2.getStatus());
map = response2.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
resultWithPutCode = (List<?>) map.get("Location");
Long putCode2 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
// Delete new peer reviews so they don't affect other tests
serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode1);
serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode2);
}
Aggregations