Search in sources :

Example 11 with Artist

use of com.furyviewer.domain.Artist in project FuryViewer by TheDoctor-95.

the class ArtistResource method getArtistB.

@GetMapping("/artist-bs/{id}")
@Timed
public ResponseEntity<Artist> getArtistB(@PathVariable Long id) {
    log.debug("REST request to get ArtistB : {}", id);
    Artist artist = artistServiceSmart.findOne(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(artist));
}
Also used : Artist(com.furyviewer.domain.Artist) Timed(com.codahale.metrics.annotation.Timed)

Example 12 with Artist

use of com.furyviewer.domain.Artist in project FuryViewer by TheDoctor-95.

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 = artistRepository.save(artist);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, artist.getId().toString())).body(result);
}
Also used : Artist(com.furyviewer.domain.Artist) Timed(com.codahale.metrics.annotation.Timed)

Example 13 with Artist

use of com.furyviewer.domain.Artist in project FuryViewer by TheDoctor-95.

the class ArtistResource method findArtistByArtistType.

@GetMapping("/artist-types-name/{artistTypeStr}")
@Timed
public ResponseEntity<List<Artist>> findArtistByArtistType(@PathVariable String artistTypeStr) {
    log.debug("REST request to get ArtistType : {}", artistTypeStr);
    try {
        ArtistTypeEnum ate = ArtistTypeEnum.valueOf(artistTypeStr.toUpperCase());
        ArtistType artistType = artistTypeRepository.findByName(ate);
        List<Artist> artists = artistRepository.findArtistByArtistType(artistType);
        return ResponseUtil.wrapOrNotFound(Optional.ofNullable(artists));
    } catch (IllegalArgumentException e) {
        throw new BadRequestAlertException(e.getMessage(), ENTITY_NAME, e.getLocalizedMessage());
    }
}
Also used : Artist(com.furyviewer.domain.Artist) BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) ArtistTypeEnum(com.furyviewer.domain.enumeration.ArtistTypeEnum) ArtistType(com.furyviewer.domain.ArtistType) Timed(com.codahale.metrics.annotation.Timed)

Example 14 with Artist

use of com.furyviewer.domain.Artist in project FuryViewer by TheDoctor-95.

the class ArtistService method importActors.

/**
 * Metodo que se encarga de convertir un String en los objetos de la clase Artist necesarios que contiene su nombre
 * y main_actor como tipo de artista.
 *
 * @param actorsListStr String | Contiene el nombre de los artistas.
 * @return Set | Set que contiene la informacion de los artistas.
 */
public Set<Artist> importActors(String actorsListStr) {
    Set<Artist> artists = new HashSet<>();
    if (stringApiCorrectorService.eraserNA(actorsListStr) != null) {
        String[] actors = actorsListStr.split(", ");
        ArtistType atMainActor = artistTypeRepository.findByName(ArtistTypeEnum.MAIN_ACTOR);
        for (String actorStr : actors) {
            Optional<Artist> optionalActor = artistRepository.findByName(actorStr);
            Artist artist;
            // En caso de que el artista exista se comprueba si ya tiene asignado el tipo main_actor.
            if (optionalActor.isPresent()) {
                artist = optionalActor.get();
                if (!artist.getArtistTypes().contains(atMainActor)) {
                    artist.addArtistType(atMainActor);
                    artist = artistRepository.save(artist);
                }
            } else {
                // Se crea un artista desde cero.
                artist = artistTmdbDTOService.importArtist(actorStr, atMainActor);
            }
            artists.add(artist);
        }
    }
    return artists;
}
Also used : Artist(com.furyviewer.domain.Artist) ArtistType(com.furyviewer.domain.ArtistType)

Example 15 with Artist

use of com.furyviewer.domain.Artist in project FuryViewer by TheDoctor-95.

the class ArtistService method importActorsTMdb.

/**
 * Metodo que se encarga de convertir un String en los objetos de la clase Artist necesarios que contiene su nombre
 * y main_actor como tipo de artista.
 *
 * @param casting String | Contiene el nombre de los artistas.
 * @return Set | Set que contiene la informacion de los artistas.
 */
public Set<Artist> importActorsTMdb(List<Cast> casting) {
    Set<Artist> artists = new HashSet<>();
    for (Cast cast : casting) {
        Optional<Artist> optionalActor = artistRepository.findByName(cast.getName());
        Artist artist;
        // En caso de que el artista exista se comprueba si ya tiene asignado el tipo main_actor.
        if (optionalActor.isPresent()) {
            artist = optionalActor.get();
            if (!artist.getArtistTypes().contains(artistTypeRepository.findByName(ArtistTypeEnum.MAIN_ACTOR))) {
                artist.addArtistType(artistTypeRepository.findByName(ArtistTypeEnum.MAIN_ACTOR));
                artist = artistRepository.save(artist);
            }
        } else {
            // Se crea un artista desde cero.
            artist = artistTmdbDTOService.importArtist(cast.getName(), artistTypeRepository.findByName(ArtistTypeEnum.MAIN_ACTOR));
        }
        artists.add(artist);
    }
    return artists;
}
Also used : Artist(com.furyviewer.domain.Artist) Cast(com.furyviewer.service.dto.TheMovieDB.Episode.Cast)

Aggregations

Artist (com.furyviewer.domain.Artist)16 Timed (com.codahale.metrics.annotation.Timed)8 Transactional (org.springframework.transaction.annotation.Transactional)6 ArtistType (com.furyviewer.domain.ArtistType)4 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)2 FavouriteArtist (com.furyviewer.domain.FavouriteArtist)1 ArtistTypeEnum (com.furyviewer.domain.enumeration.ArtistTypeEnum)1 CompleteArtistTmdbDTO (com.furyviewer.service.dto.TheMovieDB.Artist.CompleteArtistTmdbDTO)1 Cast (com.furyviewer.service.dto.TheMovieDB.Episode.Cast)1 IOException (java.io.IOException)1 URI (java.net.URI)1