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;
}
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));
}
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);
}
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));
}
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));
}
Aggregations