use of com.furyviewer.domain.Episode in project FuryViewer by TheDoctor-95.
the class EpisodeResourceIntTest method updateEpisode.
@Test
@Transactional
public void updateEpisode() throws Exception {
// Initialize the database
episodeRepository.saveAndFlush(episode);
int databaseSizeBeforeUpdate = episodeRepository.findAll().size();
// Update the episode
Episode updatedEpisode = episodeRepository.findOne(episode.getId());
updatedEpisode.number(UPDATED_NUMBER).name(UPDATED_NAME).duration(UPDATED_DURATION).releaseDate(UPDATED_RELEASE_DATE);
restEpisodeMockMvc.perform(put("/api/episodes").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedEpisode))).andExpect(status().isOk());
// Validate the Episode in the database
List<Episode> episodeList = episodeRepository.findAll();
assertThat(episodeList).hasSize(databaseSizeBeforeUpdate);
Episode testEpisode = episodeList.get(episodeList.size() - 1);
assertThat(testEpisode.getNumber()).isEqualTo(UPDATED_NUMBER);
assertThat(testEpisode.getName()).isEqualTo(UPDATED_NAME);
assertThat(testEpisode.getDuration()).isEqualTo(UPDATED_DURATION);
assertThat(testEpisode.getReleaseDate()).isEqualTo(UPDATED_RELEASE_DATE);
}
use of com.furyviewer.domain.Episode in project FuryViewer by TheDoctor-95.
the class SeriesTmdbDTOService method importEpisode.
/**
* Convierte la informacion de un episode de TMDB al formato de Furyviewer.
* @param seriesName String | Titulo de la series a buscar.
* @param episodeNum int | Numero del episode a buscar.
* @param season Season | Season a la que pertenece el episode.
* @throws IOException En caso de que no se pueda hacer la peticion a la api se lanza la execpcion.
*/
public void importEpisode(String seriesName, int episodeNum, com.furyviewer.domain.Season season) throws IOException {
int seriesId = getIdTmdbSeries(seriesName);
SeasonTmdbDTO se;
Call<SeasonTmdbDTO> callSeason = apiTMDB.getSeason(seriesId, season.getNumber(), apikey);
Response<SeasonTmdbDTO> response = callSeason.execute();
if (response.isSuccessful()) {
se = response.body();
Episode ep = new Episode();
ep.setNumber(episodeNum);
episodeNum = episodeNum - 1;
if (se.getEpisodes().get(episodeNum).getName() != null) {
ep.setName(se.getEpisodes().get(episodeNum).getName());
}
double duration = getDurationEpisode(seriesId);
if (duration != -1) {
ep.setDuration(duration);
}
if (se.getEpisodes().get(episodeNum).getAirDate() != null) {
ep.setReleaseDate(dateConversorService.releaseDateOMDBSeason(se.getEpisodes().get(episodeNum).getAirDate()));
}
String imdbId = getImdbId(seriesId, season.getNumber(), episodeNum);
if (imdbId != null) {
ep.setImdbId(imdbId);
}
ep.setSeason(season);
if (se.getEpisodes().get(episodeNum).getOverview() != null) {
ep.setDescription(stringApiCorrectorService.eraserEvilBytes(se.getEpisodes().get(episodeNum).getOverview()));
}
if (se.getEpisodes().get(episodeNum).getCrew() != null) {
for (Crew crew : se.getEpisodes().get(episodeNum).getCrew()) {
if (crew.getJob().equalsIgnoreCase("Director")) {
ep.setDirector(artistService.importDirector(crew.getName()));
} else if (crew.getJob().equalsIgnoreCase("Writer")) {
ep.setScriptwriter(artistService.importScripwriter(crew.getName()));
}
}
}
ep = episodeRepository.save(ep);
importActors(seriesId, ep);
System.out.println("==================\nImportado..." + seriesName + " " + season.getNumber() + "x" + episodeNum + "\n==================");
} else {
throw new IOException(response.message());
}
}
use of com.furyviewer.domain.Episode in project FuryViewer by TheDoctor-95.
the class EpisodeResource method createEpisode.
/**
* POST /episodes : Create a new episode.
*
* @param episode the episode to create
* @return the ResponseEntity with status 201 (Created) and with body the new episode, or with status 400 (Bad Request) if the episode has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/episodes")
@Timed
public ResponseEntity<Episode> createEpisode(@RequestBody Episode episode) throws URISyntaxException {
log.debug("REST request to save Episode : {}", episode);
if (episode.getId() != null) {
throw new BadRequestAlertException("A new episode cannot already have an ID", ENTITY_NAME, "idexists");
}
Episode result = episodeRepository.save(episode);
return ResponseEntity.created(new URI("/api/episodes/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Aggregations