Search in sources :

Example 1 with ArtistType

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);
}
Also used : ArtistType(com.furyviewer.domain.ArtistType) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ArtistType

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));
}
Also used : ArtistType(com.furyviewer.domain.ArtistType) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with 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);
}
Also used : BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) ArtistType(com.furyviewer.domain.ArtistType) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 4 with ArtistType

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);
}
Also used : ArtistType(com.furyviewer.domain.ArtistType) Timed(com.codahale.metrics.annotation.Timed)

Example 5 with ArtistType

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;
}
Also used : Artist(com.furyviewer.domain.Artist) ArtistType(com.furyviewer.domain.ArtistType)

Aggregations

ArtistType (com.furyviewer.domain.ArtistType)10 Timed (com.codahale.metrics.annotation.Timed)4 Artist (com.furyviewer.domain.Artist)4 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (org.springframework.transaction.annotation.Transactional)3 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)2 ArtistTypeEnum (com.furyviewer.domain.enumeration.ArtistTypeEnum)1 URI (java.net.URI)1