use of com.dubion.domain.Album in project dubion by valsamiq.
the class AlbumResource method createAlbum.
/**
* POST /albums : Create a new album.
*
* @param album the album to create
* @return the ResponseEntity with status 201 (Created) and with body the new album, or with status 400 (Bad Request) if the album has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/albums")
@Timed
public ResponseEntity<Album> createAlbum(@RequestBody Album album) throws URISyntaxException {
log.debug("REST request to save Album : {}", album);
if (album.getId() != null) {
throw new BadRequestAlertException("A new album cannot already have an ID", ENTITY_NAME, "idexists");
}
Album result = albumService.save(album);
return ResponseEntity.created(new URI("/api/album/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.dubion.domain.Album in project dubion by valsamiq.
the class NapsterDTOService method createAlbumByName.
public Album createAlbumByName(String nombre) {
Album album = new Album();
album.setName(nombre);
album = albumRepository.save(album);
return album;
}
use of com.dubion.domain.Album in project dubion by valsamiq.
the class AlbumResource method getAlbum.
/**
* GET /albums/:id : get the "id" album.
*
* @param id the id of the album to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the album, or with status 404 (Not Found)
*/
@GetMapping("/albums/{id}")
@Timed
public ResponseEntity<Album> getAlbum(@PathVariable Long id) {
log.debug("REST request to get Album : {}", id);
Album album = albumService.findOne(id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(album));
}
use of com.dubion.domain.Album in project dubion by valsamiq.
the class AlbumResource method updateAlbum.
/**
* PUT /albums : Updates an existing album.
*
* @param album the album to update
* @return the ResponseEntity with status 200 (OK) and with body the updated album,
* or with status 400 (Bad Request) if the album is not valid,
* or with status 500 (Internal Server Error) if the album couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/albums")
@Timed
public ResponseEntity<Album> updateAlbum(@RequestBody Album album) throws URISyntaxException {
log.debug("REST request to update Album : {}", album);
if (album.getId() == null) {
return createAlbum(album);
}
Album result = albumService.save(album);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, album.getId().toString())).body(result);
}
use of com.dubion.domain.Album in project dubion by valsamiq.
the class NapsterDTOService method importTopAlbum.
public List<Album> importTopAlbum() {
NapsterAlbum topAlbumNapster = getTopAlbumNap();
List<Album> topAlbums = new ArrayList<>();
for (com.dubion.service.dto.NapsterAPI.Albums.Album t : topAlbumNapster.getAlbums()) {
if (albumRepository.findByName(t.getName()) == null) {
Album s = new Album();
s.setName(t.getName());
String genre = t.getLinks().getGenres().getIds().get(0);
System.out.println(genre);
Call<NapsterGenre> callTopAlbums = apiService.getGenresById("ES", apiKey, genre);
s = albumRepository.save(s);
topAlbums.add(s);
} else {
topAlbums.add(albumRepository.findByName(t.getName()));
}
}
return topAlbums;
}
Aggregations