Search in sources :

Example 1 with RatingBand

use of com.dubion.domain.RatingBand in project dubion by valsamiq.

the class RatingBandResource method createRatingBand.

/**
 * POST  /rating-bands : Create a new ratingBand.
 *
 * @param ratingBand the ratingBand to create
 * @return the ResponseEntity with status 201 (Created) and with body the new ratingBand, or with status 400 (Bad Request) if the ratingBand has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/rating-bands")
@Timed
public ResponseEntity<RatingBand> createRatingBand(@RequestBody RatingBand ratingBand) throws URISyntaxException {
    log.debug("REST request to save RatingBand : {}", ratingBand);
    if (ratingBand.getId() != null) {
        throw new BadRequestAlertException("A new ratingBand cannot already have an ID", ENTITY_NAME, "idexists");
    }
    RatingBand result = ratingBandRepository.save(ratingBand);
    return ResponseEntity.created(new URI("/api/rating-bands/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(com.dubion.web.rest.errors.BadRequestAlertException) RatingBand(com.dubion.domain.RatingBand) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 2 with RatingBand

use of com.dubion.domain.RatingBand in project dubion by valsamiq.

the class RatingBandResource method getRatingBand.

/**
 * GET  /rating-bands/:id : get the "id" ratingBand.
 *
 * @param id the id of the ratingBand to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the ratingBand, or with status 404 (Not Found)
 */
@GetMapping("/rating-bands/{id}")
@Timed
public ResponseEntity<RatingBand> getRatingBand(@PathVariable Long id) {
    log.debug("REST request to get RatingBand : {}", id);
    RatingBand ratingBand = ratingBandRepository.findOne(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(ratingBand));
}
Also used : RatingBand(com.dubion.domain.RatingBand) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with RatingBand

use of com.dubion.domain.RatingBand in project dubion by valsamiq.

the class RatingBandResource method updateRatingBand.

/**
 * PUT  /rating-bands : Updates an existing ratingBand.
 *
 * @param ratingBand the ratingBand to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated ratingBand,
 * or with status 400 (Bad Request) if the ratingBand is not valid,
 * or with status 500 (Internal Server Error) if the ratingBand couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/rating-bands")
@Timed
public ResponseEntity<RatingBand> updateRatingBand(@RequestBody RatingBand ratingBand) throws URISyntaxException {
    log.debug("REST request to update RatingBand : {}", ratingBand);
    if (ratingBand.getId() == null) {
        return createRatingBand(ratingBand);
    }
    RatingBand result = ratingBandRepository.save(ratingBand);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, ratingBand.getId().toString())).body(result);
}
Also used : RatingBand(com.dubion.domain.RatingBand) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)3 RatingBand (com.dubion.domain.RatingBand)3 BadRequestAlertException (com.dubion.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1