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);
}
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();
}
}
}
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();
}
}
}
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);
}
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));
}
Aggregations