Search in sources :

Example 1 with Instrument

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

the class InstrumentResource method createInstrument.

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

Example 2 with Instrument

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

the class InstrumentResource method getInstrument.

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

Example 3 with Instrument

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

the class InstrumentResource method updateInstrument.

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

Aggregations

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