Search in sources :

Example 1 with Label

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

the class LabelResource method createLabel.

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

Example 2 with Label

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

the class LabelResource method getLabel.

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

Example 3 with Label

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

the class LabelResource method updateLabel.

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

Aggregations

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