use of org.orcid.jaxb.model.record_rc4.Work 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_rc4.Work 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_rc4.Work in project ORCID-Source by ORCID.
the class PublicV2ApiServiceVersionedDelegatorTest method testViewBulkWorks.
@Test
public void testViewBulkWorks() {
Response response = serviceDelegator.viewBulkWorks("0000-0000-0000-0003", "11,12,13,16");
WorkBulk workBulk = (WorkBulk) response.getEntity();
assertNotNull(workBulk);
assertNotNull(workBulk.getBulk());
assertEquals(4, workBulk.getBulk().size());
assertTrue(workBulk.getBulk().get(0) instanceof Work);
assertTrue(workBulk.getBulk().get(1) instanceof OrcidError);
assertTrue(workBulk.getBulk().get(2) instanceof OrcidError);
assertTrue(workBulk.getBulk().get(3) instanceof OrcidError);
}
use of org.orcid.jaxb.model.record_rc4.Work in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_WorksTest method testCreateBulkWorksWithBlankTitles.
@Test
public void testCreateBulkWorksWithBlankTitles() {
RequestAttributes previousAttrs = RequestContextHolder.getRequestAttributes();
RequestAttributes attrs = new ServletRequestAttributes(new MockHttpServletRequest());
attrs.setAttribute(ApiVersionFilter.API_VERSION_REQUEST_ATTRIBUTE_NAME, "2.0", RequestAttributes.SCOPE_REQUEST);
RequestContextHolder.setRequestAttributes(attrs);
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(i == 0 ? new Title(" ") : new Title("title " + i));
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++) {
if (i == 0) {
assertTrue(bulk.getBulk().get(i) instanceof OrcidError);
} else {
assertTrue(bulk.getBulk().get(i) instanceof Work);
serviceDelegator.deleteWork(ORCID, ((Work) bulk.getBulk().get(i)).getPutCode());
}
}
RequestContextHolder.setRequestAttributes(previousAttrs);
}
use of org.orcid.jaxb.model.record_rc4.Work in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testViewBulkWorks.
@Test
public void testViewBulkWorks() {
Response response = serviceDelegator.viewBulkWorks(ORCID, "11,12,13");
assertNotNull(response);
WorkBulk workBulk = (WorkBulk) response.getEntity();
assertNotNull(workBulk);
assertNotNull(workBulk.getBulk());
assertEquals(3, workBulk.getBulk().size());
assertTrue(workBulk.getBulk().get(0) instanceof Work);
assertTrue(workBulk.getBulk().get(1) instanceof OrcidError);
assertTrue(workBulk.getBulk().get(2) instanceof OrcidError);
Work work = (Work) workBulk.getBulk().get(0);
assertNotNull(work);
assertNotNull(work.getLastModifiedDate());
assertNotNull(work.getLastModifiedDate().getValue());
assertNotNull(work.getWorkTitle());
assertNotNull(work.getWorkTitle().getTitle());
assertEquals("PUBLIC", work.getWorkTitle().getTitle().getContent());
assertEquals(Long.valueOf(11), work.getPutCode());
assertEquals("/0000-0000-0000-0003/work/11", work.getPath());
assertEquals(WorkType.JOURNAL_ARTICLE, work.getWorkType());
assertEquals("APP-5555555555555555", work.getSource().retrieveSourcePath());
assertNotNull(work.getWorkContributors());
assertNotNull(work.getWorkContributors().getContributor());
assertEquals(1, work.getWorkContributors().getContributor().size());
assertNotNull(work.getWorkContributors().getContributor().get(0).getContributorOrcid());
assertEquals("0000-0000-0000-0000", work.getWorkContributors().getContributor().get(0).getContributorOrcid().getPath());
assertNull(work.getWorkContributors().getContributor().get(0).getCreditName());
}
Aggregations