Search in sources :

Example 1 with Series

use of com.furyviewer.domain.Series in project FuryViewer by TheDoctor-95.

the class SeriesResourceIntTest method equalsVerifier.

@Test
@Transactional
public void equalsVerifier() throws Exception {
    TestUtil.equalsVerifier(Series.class);
    Series series1 = new Series();
    series1.setId(1L);
    Series series2 = new Series();
    series2.setId(series1.getId());
    assertThat(series1).isEqualTo(series2);
    series2.setId(2L);
    assertThat(series1).isNotEqualTo(series2);
    series1.setId(null);
    assertThat(series1).isNotEqualTo(series2);
}
Also used : Series(com.furyviewer.domain.Series) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Series

use of com.furyviewer.domain.Series in project FuryViewer by TheDoctor-95.

the class SeriesOmdbDTOService method importSeriesByImdbId.

/**
 * Devuelve una Series a partir del ide de IMDB existente en la base de datos o en caso de no existir hace una
 * peticion a la api.
 * @param imdbId String | Titulo de la series.
 * @return Series | Contiene la informacion de una serie en el formato FuryViewer.
 */
@Transactional
public Series importSeriesByImdbId(String imdbId) {
    // Comprobamos si ya está en nuestra base de datos.
    SeriesOmdbDTO seriesOmdbDTO = getSeriesByImdbId(imdbId);
    Optional<Series> s = seriesRepository.findByImdb_id(seriesOmdbDTO.getImdbID());
    if (s.isPresent()) {
        return s.get();
    }
    Series ss = new Series();
    // Comprobamos que la API nos devuelve información.
    if (seriesOmdbDTO.getResponse().equalsIgnoreCase("true")) {
        ss = importSeries(seriesOmdbDTO);
    } else {
        System.out.println("==================\nBúsqueda sin resultados\n==================");
    }
    return ss;
}
Also used : Series(com.furyviewer.domain.Series) SeriesOmdbDTO(com.furyviewer.service.dto.OpenMovieDatabase.SeriesOmdbDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Series

use of com.furyviewer.domain.Series in project FuryViewer by TheDoctor-95.

the class SeriesResource method importSeriesByName.

/**
 * Importar series a partir del titulo.
 * @param name String | Titulo de la serie a buscar.
 * @return ResponseEntity | Series que coincide con el titulo buscado.
 */
@GetMapping("/importSeriesByName/{name}")
@Timed
@Transactional
public ResponseEntity<Series> importSeriesByName(@PathVariable String name) {
    log.debug("REST request to get Series by name", name);
    Series series = seriesOmdbDTOService.importSeriesByTitle(name);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(series));
}
Also used : Series(com.furyviewer.domain.Series) Timed(com.codahale.metrics.annotation.Timed) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Series

use of com.furyviewer.domain.Series in project FuryViewer by TheDoctor-95.

the class SeriesResource method getSeries.

/**
 * GET  /series/:id : get the "id" series.
 *
 * @param id the id of the series to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the series, or with status 404 (Not Found)
 */
@GetMapping("/series/{id}")
@Timed
public ResponseEntity<Series> getSeries(@PathVariable Long id) {
    log.debug("REST request to get Series : {}", id);
    Series series = seriesRepository.findOneWithEagerRelationships(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(series));
}
Also used : Series(com.furyviewer.domain.Series) Timed(com.codahale.metrics.annotation.Timed)

Example 5 with Series

use of com.furyviewer.domain.Series in project FuryViewer by TheDoctor-95.

the class SeriesResource method updateSeries.

/**
 * PUT  /series : Updates an existing series.
 *
 * @param series the series to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated series,
 * or with status 400 (Bad Request) if the series is not valid,
 * or with status 500 (Internal Server Error) if the series couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/series")
@Timed
public ResponseEntity<Series> updateSeries(@RequestBody Series series) throws URISyntaxException {
    log.debug("REST request to update Series : {}", series);
    if (series.getId() == null) {
        return createSeries(series);
    }
    Series result = seriesRepository.save(series);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, series.getId().toString())).body(result);
}
Also used : Series(com.furyviewer.domain.Series) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Series (com.furyviewer.domain.Series)11 Transactional (org.springframework.transaction.annotation.Transactional)6 Timed (com.codahale.metrics.annotation.Timed)5 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 SeriesOmdbDTO (com.furyviewer.service.dto.OpenMovieDatabase.SeriesOmdbDTO)2 FavouriteSeries (com.furyviewer.domain.FavouriteSeries)1 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1