use of com.furyviewer.domain.ArtistType in project FuryViewer by TheDoctor-95.
the class ArtistTypeResourceIntTest method createArtistType.
@Test
@Transactional
public void createArtistType() throws Exception {
int databaseSizeBeforeCreate = artistTypeRepository.findAll().size();
// Create the ArtistType
restArtistTypeMockMvc.perform(post("/api/artist-types").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(artistType))).andExpect(status().isCreated());
// Validate the ArtistType in the database
List<ArtistType> artistTypeList = artistTypeRepository.findAll();
assertThat(artistTypeList).hasSize(databaseSizeBeforeCreate + 1);
ArtistType testArtistType = artistTypeList.get(artistTypeList.size() - 1);
assertThat(testArtistType.getName()).isEqualTo(DEFAULT_NAME);
}
use of com.furyviewer.domain.ArtistType in project FuryViewer by TheDoctor-95.
the class ArtistTypeResourceIntTest method updateArtistType.
@Test
@Transactional
public void updateArtistType() throws Exception {
// Initialize the database
artistTypeRepository.saveAndFlush(artistType);
int databaseSizeBeforeUpdate = artistTypeRepository.findAll().size();
// Update the artistType
ArtistType updatedArtistType = artistTypeRepository.findOne(artistType.getId());
updatedArtistType.name(UPDATED_NAME);
restArtistTypeMockMvc.perform(put("/api/artist-types").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedArtistType))).andExpect(status().isOk());
// Validate the ArtistType in the database
List<ArtistType> artistTypeList = artistTypeRepository.findAll();
assertThat(artistTypeList).hasSize(databaseSizeBeforeUpdate);
ArtistType testArtistType = artistTypeList.get(artistTypeList.size() - 1);
assertThat(testArtistType.getName()).isEqualTo(UPDATED_NAME);
}
use of com.furyviewer.domain.ArtistType 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.ArtistType 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.ArtistType 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;
}
Aggregations