use of org.ambraproject.rhino.view.journal.VolumeInputView in project rhino by PLOS.
the class VolumeCrudController method update.
@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/journals/{journalKey}/volumes/{volumeDoi:.+}", method = RequestMethod.PATCH)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "VolumeInputView", value = "example #1: {\"doi\": \"10.1371/volume.pmed.v01\"}<br>" + "example #2: {\"displayName\": \"2004\"}")
public ResponseEntity<?> update(HttpServletRequest request, @PathVariable("journalKey") String journalKey, @PathVariable("volumeDoi") String volumeDoi) throws IOException {
// TODO: Validate journalKey
VolumeIdentifier volumeId = getVolumeId(volumeDoi);
VolumeInputView input = readJsonFromRequest(request, VolumeInputView.class);
Volume updated = volumeCrudService.update(volumeId, input);
VolumeOutputView view = volumeOutputViewFactory.getView(updated);
return ServiceResponse.serveView(view).asJsonResponse(entityGson);
}
use of org.ambraproject.rhino.view.journal.VolumeInputView in project rhino by PLOS.
the class VolumeCrudServiceTest method testCreate.
@Test(enabled = false)
public void testCreate() {
Doi volumeId = Doi.create("10.1371/volume.pmed.v05");
String displayName = "volumeDisplay";
String json = String.format("{\"volumeUri\": \"%s\", \"displayName\": \"%s\"}", volumeId.getName(), displayName);
VolumeInputView input = entityGson.fromJson(json, VolumeInputView.class);
Journal testJournal = createTestJournal();
volumeCrudService.create(testJournal.getJournalKey(), input);
testJournal = getTestJournal();
List<Volume> testJournalVolumes = testJournal.getVolumes();
assertFalse(testJournalVolumes.isEmpty());
}
use of org.ambraproject.rhino.view.journal.VolumeInputView in project rhino by PLOS.
the class VolumeCrudController method create.
@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/journals/{journalKey}/volumes", method = RequestMethod.POST)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "VolumeInputView", value = "example: {\"doi\": \"10.1371/volume.pmed.v01\", \"displayName\": \"2004\"}")
public ResponseEntity<?> create(HttpServletRequest request, @PathVariable String journalKey) throws IOException {
VolumeInputView input = readJsonFromRequest(request, VolumeInputView.class);
if (StringUtils.isBlank(input.getDoi())) {
throw new RestClientException("Volume DOI required", HttpStatus.BAD_REQUEST);
}
Volume volume = volumeCrudService.create(journalKey, input);
return ServiceResponse.reportCreated(volumeOutputViewFactory.getView(volume)).asJsonResponse(entityGson);
}
Aggregations