Search in sources :

Example 1 with IssueOutputView

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);
}
Also used : IssueOutputView(org.ambraproject.rhino.view.journal.IssueOutputView) RestClientException(org.ambraproject.rhino.rest.RestClientException) Journal(org.ambraproject.rhino.model.Journal) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with IssueOutputView

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);
}
Also used : IssueOutputView(org.ambraproject.rhino.view.journal.IssueOutputView) Volume(org.ambraproject.rhino.model.Volume) VolumeIdentifier(org.ambraproject.rhino.identity.VolumeIdentifier) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IssueOutputView (org.ambraproject.rhino.view.journal.IssueOutputView)2 Transactional (org.springframework.transaction.annotation.Transactional)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 VolumeIdentifier (org.ambraproject.rhino.identity.VolumeIdentifier)1 Journal (org.ambraproject.rhino.model.Journal)1 Volume (org.ambraproject.rhino.model.Volume)1 RestClientException (org.ambraproject.rhino.rest.RestClientException)1