use of org.springframework.transaction.annotation.Transactional in project rhino by PLOS.
the class ArticleCrudController method getCommentCount.
// TODO: Get rid of this?
@Transactional(readOnly = true)
@RequestMapping(value = "/articles/{doi:.+}/comments", method = RequestMethod.GET, params = "count")
public ResponseEntity<?> getCommentCount(@PathVariable("doi") String doi) throws IOException {
ArticleIdentifier id = ArticleIdentifier.create(DoiEscaping.unescape(doi));
Article article = articleCrudService.readArticle(id);
return commentCrudService.getCommentCount(article).asJsonResponse(entityGson);
}
use of org.springframework.transaction.annotation.Transactional in project rhino by PLOS.
the class ArticleListCrudController method update.
@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/lists/{type}/journals/{journal}/keys/{key}", method = RequestMethod.PATCH)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "ListInputView", value = "example #1: {\"title\": \"New Title\"}<br>" + "example #2: {\"articleDois\": [\"10.1371/journal.pone.0012345\", \"10.1371/journal.pone.0054321\"]}")
public ResponseEntity<?> update(HttpServletRequest request, @PathVariable("type") String type, @PathVariable("journal") String journalKey, @PathVariable("key") String key) throws IOException {
final ListInputView inputView;
try {
inputView = readJsonFromRequest(request, ListInputView.class);
} catch (ListInputView.PartialIdentityException e) {
throw complainAboutListIdentityOnPatch(e);
}
if (inputView.getIdentity().isPresent()) {
throw complainAboutListIdentityOnPatch(null);
}
ArticleListIdentity identity = new ArticleListIdentity(type, journalKey, key);
articleListCrudService.update(identity, inputView.getTitle(), inputView.getArticleIds());
return new ResponseEntity<>(HttpStatus.OK);
}
use of org.springframework.transaction.annotation.Transactional 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.springframework.transaction.annotation.Transactional 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.springframework.transaction.annotation.Transactional 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);
}
Aggregations