Search in sources :

Example 16 with Artist

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

the class ArtistService method importScripwriter.

/**
 * Metodo que se encarga de convertir un String en un objeto de la clase Artist que contiene su nombre y
 * scripwriter como tipo de artista.
 *
 * @param scripwriter String | Contiene el nombre del artista.
 * @return Artist | Objeto que contiene la informacion del artista.
 */
public Artist importScripwriter(String scripwriter) {
    Artist artist = null;
    if (stringApiCorrectorService.eraserNA(scripwriter) != null) {
        String[] scripwriterArray = scripwriter.split(", | \\(");
        Optional<Artist> optionalScripwriter = artistRepository.findByName(scripwriterArray[0]);
        ArtistType atScripwriter = artistTypeRepository.findByName(ArtistTypeEnum.SCRIPTWRITER);
        // En caso de que el artista exista se comprueba si ya tiene asignado el tipo scriptwriter.
        if (optionalScripwriter.isPresent()) {
            artist = optionalScripwriter.get();
            if (!artist.getArtistTypes().contains(atScripwriter)) {
                artist.addArtistType(atScripwriter);
                artistRepository.save(artist);
            }
        } else {
            // Se crea un artista desde cero.
            artist = artistTmdbDTOService.importArtist(scripwriterArray[0], atScripwriter);
        }
    }
    return artist;
}
Also used : Artist(com.furyviewer.domain.Artist) ArtistType(com.furyviewer.domain.ArtistType)

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