use of com.dubion.domain.Genre in project dubion by valsamiq.
the class GenreResource method updateGenre.
/**
* PUT /genres : Updates an existing genre.
*
* @param genre the genre to update
* @return the ResponseEntity with status 200 (OK) and with body the updated genre,
* or with status 400 (Bad Request) if the genre is not valid,
* or with status 500 (Internal Server Error) if the genre couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/genres")
@Timed
public ResponseEntity<Genre> updateGenre(@RequestBody Genre genre) throws URISyntaxException {
log.debug("REST request to update Genre : {}", genre);
if (genre.getId() == null) {
return createGenre(genre);
}
Genre result = genreRepository.save(genre);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, genre.getId().toString())).body(result);
}
use of com.dubion.domain.Genre in project dubion by valsamiq.
the class GenreResource method getGenre.
/**
* GET /genres/:id : get the "id" genre.
*
* @param id the id of the genre to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the genre, or with status 404 (Not Found)
*/
@GetMapping("/genres/{id}")
@Timed
public ResponseEntity<Genre> getGenre(@PathVariable Long id) {
log.debug("REST request to get Genre : {}", id);
Genre genre = genreRepository.findOne(id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(genre));
}
use of com.dubion.domain.Genre in project dubion by valsamiq.
the class GenreResource method createGenre.
/**
* POST /genres : Create a new genre.
*
* @param genre the genre to create
* @return the ResponseEntity with status 201 (Created) and with body the new genre, or with status 400 (Bad Request) if the genre has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/genres")
@Timed
public ResponseEntity<Genre> createGenre(@RequestBody Genre genre) throws URISyntaxException {
log.debug("REST request to save Genre : {}", genre);
if (genre.getId() != null) {
throw new BadRequestAlertException("A new genre cannot already have an ID", ENTITY_NAME, "idexists");
}
Genre result = genreRepository.save(genre);
return ResponseEntity.created(new URI("/api/genres/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.dubion.domain.Genre in project dubion by valsamiq.
the class NapsterDTOService method importGenres.
public List<Genre> importGenres() {
NapsterGenre NapsterGenres = getGenres();
List<Genre> genres = new ArrayList<>();
for (com.dubion.service.dto.NapsterAPI.Genre.Genre t : NapsterGenres.getGenre()) {
if (genreRepository.findByName(t.getName()) == null) {
Genre s = new Genre();
s.setName(t.getName());
s = genreRepository.save(s);
genres.add(s);
} else {
genres.add(genreRepository.findByName(t.getName()));
}
}
return genres;
}
Aggregations