Search in sources :

Example 6 with ArtistType

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);
}
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 7 with ArtistType

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);
}
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 8 with ArtistType

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());
    }
}
Also used : Artist(com.furyviewer.domain.Artist) BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) ArtistTypeEnum(com.furyviewer.domain.enumeration.ArtistTypeEnum) ArtistType(com.furyviewer.domain.ArtistType) Timed(com.codahale.metrics.annotation.Timed)

Example 9 with ArtistType

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

Example 10 with ArtistType

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