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