use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.
the class WorksController method createWorksIdList.
/**
* created a work id list and sorts a map associated with the list in in the
* session
*
*/
private List<String> createWorksIdList(HttpServletRequest request) {
String orcid = getEffectiveUserOrcid();
List<Work> works = workManager.findWorks(orcid, profileEntityManager.getLastModified(orcid));
HashMap<Long, WorkForm> worksMap = new HashMap<Long, WorkForm>();
List<String> workIds = new ArrayList<String>();
if (works != null) {
for (Work work : works) {
try {
worksMap.put(work.getPutCode(), WorkForm.valueOf(work));
workIds.add(String.valueOf(work.getPutCode()));
} catch (Exception e) {
LOGGER.error("ProfileWork failed to parse as Work. Put code" + work.getPutCode());
}
}
request.getSession().setAttribute(WORKS_MAP, worksMap);
}
return workIds;
}
use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_WorksTest method testUpdateWorkLeavingVisibilityNullTest.
@Test
public void testUpdateWorkLeavingVisibilityNullTest() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewWork("4444-4444-4444-4447", 10L);
assertNotNull(response);
Work work = (Work) response.getEntity();
assertNotNull(work);
assertEquals(Visibility.PUBLIC, work.getVisibility());
work.setVisibility(null);
response = serviceDelegator.updateWork("4444-4444-4444-4447", 10L, work);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
work = (Work) response.getEntity();
assertNotNull(work);
Utils.verifyLastModified(work.getLastModifiedDate());
assertEquals(Visibility.PUBLIC, work.getVisibility());
}
use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_WorksTest method testDeleteWork.
@Test(expected = NoResultException.class)
public void testDeleteWork() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewWork("4444-4444-4444-4447", 9L);
assertNotNull(response);
Work work = (Work) response.getEntity();
assertNotNull(work);
response = serviceDelegator.deleteWork("4444-4444-4444-4447", 9L);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
serviceDelegator.viewWork("4444-4444-4444-4447", 9L);
}
use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_WorksTest method testUpdateWork.
@Test
public void testUpdateWork() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewWork("4444-4444-4444-4443", 1L);
assertNotNull(response);
Work work = (Work) response.getEntity();
assertNotNull(work);
Utils.verifyLastModified(work.getLastModifiedDate());
assertEquals(Long.valueOf(1), work.getPutCode());
assertNotNull(work.getWorkTitle());
assertNotNull(work.getWorkTitle().getTitle());
assertEquals("A day in the life", work.getWorkTitle().getTitle().getContent());
assertEquals(WorkType.BOOK, work.getWorkType());
assertEquals(Visibility.PUBLIC, work.getVisibility());
work.setWorkType(WorkType.EDITED_BOOK);
work.getWorkTitle().getTitle().setContent("Updated work title");
response = serviceDelegator.updateWork("4444-4444-4444-4443", 1L, work);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewWork("4444-4444-4444-4443", 1L);
assertNotNull(response);
work = (Work) response.getEntity();
assertNotNull(work);
Utils.verifyLastModified(work.getLastModifiedDate());
assertEquals(Long.valueOf(1), work.getPutCode());
assertNotNull(work.getWorkTitle());
assertNotNull(work.getWorkTitle().getTitle());
assertEquals("Updated work title", work.getWorkTitle().getTitle().getContent());
assertEquals(WorkType.EDITED_BOOK, work.getWorkType());
// Rollback changes so we dont break other tests
work.setWorkType(WorkType.BOOK);
work.getWorkTitle().getTitle().setContent("A day in the life");
response = serviceDelegator.updateWork("4444-4444-4444-4443", 1L, work);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.
the class MemberV2ApiServiceVersionedDelegatorTest method testViewBulkWorksWithBadPutCode.
@Test
public void testViewBulkWorksWithBadPutCode() {
SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0003", ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewBulkWorks("0000-0000-0000-0003", "11,12,13,bad");
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 Work);
// private work
assertTrue(workBulk.getBulk().get(2) instanceof Work);
// bad put code
assertTrue(workBulk.getBulk().get(3) instanceof OrcidError);
}
Aggregations