Search in sources :

Example 71 with Transactional

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

Example 72 with Transactional

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);
}
Also used : ArticleListIdentity(org.ambraproject.rhino.identity.ArticleListIdentity) ResponseEntity(org.springframework.http.ResponseEntity) ListInputView(org.ambraproject.rhino.view.article.ListInputView) ApiImplicitParam(com.wordnik.swagger.annotations.ApiImplicitParam) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 73 with Transactional

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);
}
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 74 with Transactional

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);
}
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 75 with Transactional

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);
}
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

Transactional (org.springframework.transaction.annotation.Transactional)1415 Test (org.junit.Test)507 Query (javax.persistence.Query)166 Date (java.util.Date)121 ArrayList (java.util.ArrayList)99 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)89 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)87 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)84 OnmsNode (org.opennms.netmgt.model.OnmsNode)83 TypedQuery (javax.persistence.TypedQuery)81 Rollback (org.springframework.test.annotation.Rollback)81 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)67 HashMap (java.util.HashMap)65 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)61 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)58 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)58 DBUnitTest (org.orcid.test.DBUnitTest)57 List (java.util.List)56 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)41 User (com.arnaugarcia.uplace.domain.User)39