Search in sources :

Example 1 with Artist

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

the class ArtistResource method getArtist.

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

Example 2 with Artist

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

the class ArtistResource method createArtist.

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

Example 3 with Artist

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

the class ArtistResource method updateArtist.

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

Example 4 with Artist

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

the class NapsterDTOService method importTopArtist.

public List<Artist> importTopArtist() {
    NapsterArtist topArtistNapster = getTopArtistNap();
    List<Artist> topArtists = new ArrayList<>();
    for (com.dubion.service.dto.NapsterAPI.Artist.Artist t : topArtistNapster.getArtists()) {
        if (artistRepository.findByName(t.getName()) == null) {
            Artist s = new Artist();
            String a = "";
            s.setName(t.getName());
            for (String b : t.getBlurbs()) {
                a = b;
            }
            s.setBio(a);
            s = artistRepository.save(s);
            topArtists.add(s);
        } else {
            topArtists.add(artistRepository.findByName(t.getName()));
        }
    }
    return topArtists;
}
Also used : Artist(com.dubion.domain.Artist) ArrayList(java.util.ArrayList)

Aggregations

Artist (com.dubion.domain.Artist)4 Timed (com.codahale.metrics.annotation.Timed)3 NapsterArtist (com.dubion.service.dto.NapsterAPI.NapsterArtist)3 BadRequestAlertException (com.dubion.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1