Search in sources :

Example 6 with Social

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

the class SocialResourceIntTest method createSocial.

@Test
@Transactional
public void createSocial() throws Exception {
    int databaseSizeBeforeCreate = socialRepository.findAll().size();
    // Create the Social
    restSocialMockMvc.perform(post("/api/socials").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(social))).andExpect(status().isCreated());
    // Validate the Social in the database
    List<Social> socialList = socialRepository.findAll();
    assertThat(socialList).hasSize(databaseSizeBeforeCreate + 1);
    Social testSocial = socialList.get(socialList.size() - 1);
    assertThat(testSocial.getUrl()).isEqualTo(DEFAULT_URL);
    assertThat(testSocial.getType()).isEqualTo(DEFAULT_TYPE);
}
Also used : Social(com.furyviewer.domain.Social) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Social

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

the class TrailerTmdbDTOService method importMovieTrailer.

/**
 * Se convierte el trailer de la movie del formato de la api TMDB al formato de FuryViewer.
 * @param movie Movie | Movie de la que se quiere encontrar el trailer.
 */
public void importMovieTrailer(Movie movie) {
    Social social = new Social();
    int id = movieTmdbDTOService.getIdTmdbMovie(movie.getName());
    if (id != -1) {
        Call<TrailerTmdbDTO> callTrailer = apiTMDB.getMovieTrailer(id, apikey);
        try {
            Response<TrailerTmdbDTO> response = callTrailer.execute();
            if (response.isSuccessful()) {
                TrailerTmdbDTO trailerRes = response.body();
                if (!trailerRes.getResults().isEmpty()) {
                    int size = trailerRes.getResults().get(0).getSize();
                    List<Result> resultTrailer = trailerRes.getResults();
                    // Buscamos el trailer con mejor resoluciĆ³n.
                    for (Result trailer : resultTrailer) {
                        if (size <= trailer.getSize()) {
                            social.setUrl(pathVideo + trailer.getKey());
                            social.setType("Trailer");
                            social.setMovie(movie);
                            size = trailer.getSize();
                        }
                    }
                    socialRepository.save(social);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : Social(com.furyviewer.domain.Social) TrailerTmdbDTO(com.furyviewer.service.dto.TheMovieDB.Trailer.TrailerTmdbDTO) IOException(java.io.IOException) Result(com.furyviewer.service.dto.TheMovieDB.Trailer.Result)

Example 8 with Social

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

the class TrailerTmdbDTOService method importSeriesTrailer.

/**
 * Se convierte el trailer de la series del formato de la api TMDB al formato de FuryViewer.
 * @param ss Series | Series de la que se quiere encontrar el trailer.
 */
public void importSeriesTrailer(Series ss) {
    Social social = new Social();
    int id = seriesTmdbDTOService.getIdTmdbSeries(ss.getName());
    if (id != -1) {
        Call<TrailerTmdbDTO> callTrailer = apiTMDB.getSeriesTrailer(id, apikey);
        try {
            Response<TrailerTmdbDTO> response = callTrailer.execute();
            if (response.isSuccessful()) {
                TrailerTmdbDTO trailerRes = response.body();
                if (!trailerRes.getResults().isEmpty()) {
                    int size = trailerRes.getResults().get(0).getSize();
                    List<Result> resultTrailer = trailerRes.getResults();
                    // Buscamos el trailer con mejor resoluciĆ³n.
                    for (Result trailer : resultTrailer) {
                        if (size <= trailer.getSize()) {
                            social.setUrl(pathVideo + trailer.getKey());
                            social.setType("Trailer");
                            social.setSeries(ss);
                            size = trailer.getSize();
                        }
                    }
                    socialRepository.save(social);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : Social(com.furyviewer.domain.Social) TrailerTmdbDTO(com.furyviewer.service.dto.TheMovieDB.Trailer.TrailerTmdbDTO) IOException(java.io.IOException) Result(com.furyviewer.service.dto.TheMovieDB.Trailer.Result)

Example 9 with Social

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

the class SocialResource method updateSocial.

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

Example 10 with Social

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

the class SocialResource method getSocial.

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

Aggregations

Social (com.furyviewer.domain.Social)10 Timed (com.codahale.metrics.annotation.Timed)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (org.springframework.transaction.annotation.Transactional)3 Rating (com.furyviewer.service.dto.OpenMovieDatabase.Rating)2 Result (com.furyviewer.service.dto.TheMovieDB.Trailer.Result)2 TrailerTmdbDTO (com.furyviewer.service.dto.TheMovieDB.Trailer.TrailerTmdbDTO)2 IOException (java.io.IOException)2 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1