use of com.furyviewer.domain.ArtistType in project FuryViewer by TheDoctor-95.
the class ArtistTypeResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(ArtistType.class);
ArtistType artistType1 = new ArtistType();
artistType1.setId(1L);
ArtistType artistType2 = new ArtistType();
artistType2.setId(artistType1.getId());
assertThat(artistType1).isEqualTo(artistType2);
artistType2.setId(2L);
assertThat(artistType1).isNotEqualTo(artistType2);
artistType1.setId(null);
assertThat(artistType1).isNotEqualTo(artistType2);
}
use of com.furyviewer.domain.ArtistType in project FuryViewer by TheDoctor-95.
the class ArtistTypeResource method getArtistType.
/**
* GET /artist-types/:id : get the "id" artistType.
*
* @param id the id of the artistType to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the artistType, or with status 404 (Not Found)
*/
@GetMapping("/artist-types/{id}")
@Timed
public ResponseEntity<ArtistType> getArtistType(@PathVariable Long id) {
log.debug("REST request to get ArtistType : {}", id);
ArtistType artistType = artistTypeRepository.findOne(id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(artistType));
}
use of com.furyviewer.domain.ArtistType in project FuryViewer by TheDoctor-95.
the class ArtistTypeResource method createArtistType.
/**
* POST /artist-types : Create a new artistType.
*
* @param artistType the artistType to create
* @return the ResponseEntity with status 201 (Created) and with body the new artistType, or with status 400 (Bad Request) if the artistType has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/artist-types")
@Timed
public ResponseEntity<ArtistType> createArtistType(@RequestBody ArtistType artistType) throws URISyntaxException {
log.debug("REST request to save ArtistType : {}", artistType);
if (artistType.getId() != null) {
throw new BadRequestAlertException("A new artistType cannot already have an ID", ENTITY_NAME, "idexists");
}
ArtistType result = artistTypeRepository.save(artistType);
return ResponseEntity.created(new URI("/api/artist-types/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.domain.ArtistType in project FuryViewer by TheDoctor-95.
the class ArtistTypeResource method updateArtistType.
/**
* PUT /artist-types : Updates an existing artistType.
*
* @param artistType the artistType to update
* @return the ResponseEntity with status 200 (OK) and with body the updated artistType,
* or with status 400 (Bad Request) if the artistType is not valid,
* or with status 500 (Internal Server Error) if the artistType couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/artist-types")
@Timed
public ResponseEntity<ArtistType> updateArtistType(@RequestBody ArtistType artistType) throws URISyntaxException {
log.debug("REST request to update ArtistType : {}", artistType);
if (artistType.getId() == null) {
return createArtistType(artistType);
}
ArtistType result = artistTypeRepository.save(artistType);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, artistType.getId().toString())).body(result);
}
use of com.furyviewer.domain.ArtistType in project FuryViewer by TheDoctor-95.
the class ArtistService method importDirector.
/**
* Metodo que se encarga de convertir un String en un objeto de la clase Artist que contiene su nombre y
* director como tipo de artista.
*
* @param director String | Contiene el nombre del artista.
* @return Artist | Objeto que contiene la informacion del artista.
*/
public Artist importDirector(String director) {
Artist artist = null;
if (stringApiCorrectorService.eraserNA(director) != null) {
String[] directorArray = director.split(", | \\(");
Optional<Artist> optionalDirector = artistRepository.findByName(directorArray[0]);
ArtistType atDirector = artistTypeRepository.findByName(ArtistTypeEnum.DIRECTOR);
// En caso de que el artista exista se comprueba si ya tiene asignado el tipo director.
if (optionalDirector.isPresent()) {
artist = optionalDirector.get();
if (!artist.getArtistTypes().contains(atDirector)) {
artist.addArtistType(atDirector);
artistRepository.save(artist);
}
} else {
// Se crea un artista desde cero.
artist = artistTmdbDTOService.importArtist(directorArray[0], atDirector);
}
}
return artist;
}
Aggregations