Search in sources :

Example 1 with VolumeOutputView

use of org.ambraproject.rhino.view.journal.VolumeOutputView 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);
}
Also used : Volume(org.ambraproject.rhino.model.Volume) VolumeInputView(org.ambraproject.rhino.view.journal.VolumeInputView) VolumeOutputView(org.ambraproject.rhino.view.journal.VolumeOutputView) VolumeIdentifier(org.ambraproject.rhino.identity.VolumeIdentifier) ApiImplicitParam(com.wordnik.swagger.annotations.ApiImplicitParam) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with VolumeOutputView

use of org.ambraproject.rhino.view.journal.VolumeOutputView in project rhino by PLOS.

the class VolumeCrudController method readVolumesForJournal.

@Transactional(readOnly = true)
@RequestMapping(value = "/journals/{journalKey}/volumes", method = RequestMethod.GET)
public ResponseEntity<?> readVolumesForJournal(@PathVariable("journalKey") String journalKey) throws IOException {
    Journal journal = journalCrudService.readJournal(journalKey);
    List<VolumeOutputView> views = journal.getVolumes().stream().map(volumeOutputViewFactory::getView).collect(Collectors.toList());
    return ServiceResponse.serveView(views).asJsonResponse(entityGson);
}
Also used : VolumeOutputView(org.ambraproject.rhino.view.journal.VolumeOutputView) Journal(org.ambraproject.rhino.model.Journal) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

VolumeOutputView (org.ambraproject.rhino.view.journal.VolumeOutputView)2 Transactional (org.springframework.transaction.annotation.Transactional)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ApiImplicitParam (com.wordnik.swagger.annotations.ApiImplicitParam)1 VolumeIdentifier (org.ambraproject.rhino.identity.VolumeIdentifier)1 Journal (org.ambraproject.rhino.model.Journal)1 Volume (org.ambraproject.rhino.model.Volume)1 VolumeInputView (org.ambraproject.rhino.view.journal.VolumeInputView)1