use of org.ambraproject.rhino.view.journal.IssueOutputView in project rhino by PLOS.
the class JournalCrudController method readCurrentIssue.
@Transactional(readOnly = true)
@RequestMapping(value = "/journals/{journalKey}/currentIssue", method = RequestMethod.GET)
public ResponseEntity<?> readCurrentIssue(@PathVariable String journalKey) throws IOException {
Journal journal = journalCrudService.readJournal(journalKey);
IssueOutputView view = issueOutputViewFactory.getCurrentIssueViewFor(journal).orElseThrow(() -> new RestClientException("Current issue is not set for " + journalKey, HttpStatus.NOT_FOUND));
return ServiceResponse.serveView(view).asJsonResponse(entityGson);
}
use of org.ambraproject.rhino.view.journal.IssueOutputView in project rhino by PLOS.
the class IssueCrudController method readIssuesForVolume.
@Transactional(readOnly = true)
@RequestMapping(value = "/journals/{journalKey}/volumes/{volumeDoi}/issues", method = RequestMethod.GET)
public ResponseEntity<?> readIssuesForVolume(@PathVariable("journalKey") String journalKey, @PathVariable("volumeDoi") String volumeDoi) throws IOException {
// TODO: Validate journalKey
VolumeIdentifier volumeId = VolumeIdentifier.create(DoiEscaping.unescape(volumeDoi));
Volume volume = volumeCrudService.readVolume(volumeId);
List<IssueOutputView> views = volume.getIssues().stream().map(issueOutputViewFactory::getView).collect(Collectors.toList());
return ServiceResponse.serveView(views).asJsonResponse(entityGson);
}
Aggregations