Search in sources :

Example 6 with Artist

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

the class ArtistTmdbDTOService method importArtist.

/**
 * Convierte la informacion de un Artist de TMDB al formato de FuryViewer.
 * @param artistName String | Nombre del artista a buscar.
 * @param artistType ArtistType | Tipo del artista.
 * @return Artist | Contiene la informacion de un artist en el formato FuryViewer.
 */
public Artist importArtist(String artistName, ArtistType artistType) {
    Artist artist = new Artist();
    artist.setName(artistName);
    artist.addArtistType(artistType);
    System.out.println("==================\nImportanto artista " + artistName + "\n==================");
    // podemos realizar la peticiĆ³n a la api.
    getArtist: for (int i = 0; i < 3; i++) {
        try {
            CompleteArtistTmdbDTO completeArtistTmdbDTO = getArtistComplete(artistName);
            if (completeArtistTmdbDTO != null) {
                if (completeArtistTmdbDTO.getBirthday() != null) {
                    artist.setBirthdate(dateConversorService.releaseDateOMDBSeason(completeArtistTmdbDTO.getBirthday().toString()));
                }
                if (completeArtistTmdbDTO.getDeathday() != null) {
                    if (completeArtistTmdbDTO.getDeathday().toString().split("-").length == 3) {
                        artist.setDeathdate(dateConversorService.releaseDateOMDBSeason(completeArtistTmdbDTO.getDeathday().toString()));
                    }
                }
                if (completeArtistTmdbDTO.getGender() != null) {
                    switch(completeArtistTmdbDTO.getGender()) {
                        case 0:
                            artist.setSex("Undefined");
                            break;
                        case 1:
                            artist.setSex("Female");
                            break;
                        case 2:
                            artist.setSex("Male");
                            break;
                    }
                }
                if (completeArtistTmdbDTO.getProfilePath() != null) {
                    artist.setImgUrl(pathImage + completeArtistTmdbDTO.getProfilePath());
                }
                if (completeArtistTmdbDTO.getImdbId() != null) {
                    artist.setImdb_id(completeArtistTmdbDTO.getImdbId());
                }
                if (completeArtistTmdbDTO.getPlaceOfBirth() != null) {
                    artist.setCountry(countryService.importCountry(completeArtistTmdbDTO.getPlaceOfBirth().toString()));
                }
                if (completeArtistTmdbDTO.getBiography() != null) {
                    artist.setBiography(stringApiCorrectorService.eraserEvilBytes(completeArtistTmdbDTO.getBiography()));
                }
            }
            // Salimos del bucle
            break getArtist;
        } catch (IOException e) {
            e.printStackTrace();
            try {
                System.out.println("Durmiendo el thread 5 segundos");
                Thread.sleep(5000L);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
    artist = artistRepository.save(artist);
    System.out.println("==================\nArtista guardado " + artistName + "\n==================");
    return artist;
}
Also used : Artist(com.furyviewer.domain.Artist) IOException(java.io.IOException) CompleteArtistTmdbDTO(com.furyviewer.service.dto.TheMovieDB.Artist.CompleteArtistTmdbDTO)

Example 7 with Artist

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

the class ArtistResource method getDirectorBySeries.

/**
 * Encuentra el director de una serie que ha dirigido mas directores
 *
 * @param id Long | ID de la serie
 * @return ResponseEntity | Director
 */
@GetMapping("/DirectorBySeriesID/{id}")
@Timed
@Transactional
public ResponseEntity<Artist> getDirectorBySeries(@PathVariable Long id) {
    log.debug("REST request to get Artist : {}", id);
    Artist artists = artistService.findDirectorBySerieId(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(artists));
}
Also used : Artist(com.furyviewer.domain.Artist) Timed(com.codahale.metrics.annotation.Timed) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Artist

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

the class FavouriteArtistResource method favouriteSeries.

@PostMapping("/favourite-artists/id/{idArtist}/liked")
@Timed
public ResponseEntity<FavouriteArtist> favouriteSeries(@PathVariable Long idArtist) throws URISyntaxException {
    log.debug("REST request to save FavouriteArtist : {}", idArtist);
    Artist a = artistRepository.findOne(idArtist);
    FavouriteArtist fA = new FavouriteArtist();
    fA.setArtist(a);
    fA.setLiked(true);
    return createFavouriteArtist(fA);
}
Also used : Artist(com.furyviewer.domain.Artist) FavouriteArtist(com.furyviewer.domain.FavouriteArtist) FavouriteArtist(com.furyviewer.domain.FavouriteArtist) Timed(com.codahale.metrics.annotation.Timed)

Example 9 with Artist

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

the class ArtistResource method getScripwiterBySeries.

/**
 * Encuentra el esctriror de una serie segun que ha escrito mas episodios
 *
 * @param id Long | ID de la serie
 * @return ResponseEntity | Escritor
 */
@GetMapping("/ScripwiterBySeriesID/{id}")
@Timed
@Transactional
public ResponseEntity<Artist> getScripwiterBySeries(@PathVariable Long id) {
    log.debug("REST request to get Artist : {}", id);
    Artist artists = artistService.findScriprirterBySerieId(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(artists));
}
Also used : Artist(com.furyviewer.domain.Artist) Timed(com.codahale.metrics.annotation.Timed) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with Artist

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

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
@Transactional
public ResponseEntity<Artist> getArtist(@PathVariable Long id) {
    log.debug("REST request to get Artist : {}", id);
    Artist artist = artistRepository.findOneWithEagerRelationships(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(artist));
}
Also used : Artist(com.furyviewer.domain.Artist) Timed(com.codahale.metrics.annotation.Timed) Transactional(org.springframework.transaction.annotation.Transactional)

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