暫無描述

ModelsBuilder.scala 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package fr.natan.akkastreamfileprocessingapi.models
  2. import ModelsAndJsonMap.{Episode, Person, TvSerie}
  3. object ModelsBuilder {
  4. def buildPersonModel(personMap: Map[String, String]): Person = {
  5. Person(
  6. personMap("nconst"),
  7. personMap("primaryName"),
  8. Option( personMap("birthYear")),
  9. Option(personMap("deathYear")),
  10. personMap("primaryProfession").split(",").toList,
  11. personMap("knownForTitles").split(",").toList
  12. )
  13. }
  14. def buildTvSerieModel(tvSerieMap: Map[String, String]): TvSerie = {
  15. val tvSerie: TvSerie = TvSerie(
  16. tvSerieMap("tconst"),
  17. tvSerieMap("titleType"),
  18. tvSerieMap("primaryTitle"),
  19. tvSerieMap("originalTitle"),
  20. tvSerieMap("startYear"),
  21. Option(tvSerieMap("endYear")),
  22. tvSerieMap("runtimeMinutes"),
  23. tvSerieMap("genres").split(",").toList
  24. )
  25. tvSerie
  26. }
  27. def buildEpisodeModel(episodeMap: Map[String, String]): Episode = {
  28. val episode: Episode = Episode(
  29. episodeMap("tconst"),
  30. episodeMap("parentTconst"),
  31. Option(episodeMap("seasonNumber")),
  32. Option(episodeMap("episodeNumber")),
  33. )
  34. episode
  35. }
  36. }

Powered by TurnKey Linux.