Search in sources :

Example 1 with Alpha

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

the class AlphaResource method createAlpha.

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

Example 2 with Alpha

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

the class AlphaResource method updateAlpha.

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

Example 3 with Alpha

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

the class AlphaResource method getAlpha.

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

Aggregations

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