Search in sources :

Example 1 with Album

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);
}
Also used : BadRequestAlertException(com.dubion.web.rest.errors.BadRequestAlertException) Album(com.dubion.domain.Album) NapsterAlbum(com.dubion.service.dto.NapsterAPI.NapsterAlbum) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 2 with Album

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;
}
Also used : Album(com.dubion.domain.Album)

Example 3 with 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));
}
Also used : Album(com.dubion.domain.Album) NapsterAlbum(com.dubion.service.dto.NapsterAPI.NapsterAlbum) Timed(com.codahale.metrics.annotation.Timed)

Example 4 with 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);
}
Also used : Album(com.dubion.domain.Album) NapsterAlbum(com.dubion.service.dto.NapsterAPI.NapsterAlbum) Timed(com.codahale.metrics.annotation.Timed)

Example 5 with Album

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;
}
Also used : ArrayList(java.util.ArrayList) Album(com.dubion.domain.Album)

Aggregations

Album (com.dubion.domain.Album)6 Timed (com.codahale.metrics.annotation.Timed)3 NapsterAlbum (com.dubion.service.dto.NapsterAPI.NapsterAlbum)3 AlbumDTO (com.dubion.service.dto.DiscogsAPI.AlbumDTO)1 Result (com.dubion.service.dto.DiscogsAPI.Result)1 BadRequestAlertException (com.dubion.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1