浏览代码

first commit

placidenduwayo 2 年前
父节点
当前提交
3ddccfb40b

+ 2
- 2
src/main/java/fr/natan/akkastreamfileprocessingapi/controller/MovieController.java 查看文件

@@ -61,8 +61,8 @@ public class MovieController {
61 61
     }
62 62
 
63 63
     @RequestMapping(value = "/tvseries/title/{tvseriePrimaryTitle}", method = RequestMethod.GET)
64
-    private ResponseEntity<List<Models.TvSerie>> getTvserieByPrimaryTitle(@PathVariable(name = "tvseriePrimaryTitle") String tvseriePrimaryTitle) {
65
-       List<Models.TvSerie> listFuture = akkaStreamFilesProcessing.getTvSerieByPrimaryTitle(tvseriePrimaryTitle);
64
+    private ResponseEntity<Future<List<Models.TvSerie>>> getTvserieByPrimaryTitle(@PathVariable(name = "tvseriePrimaryTitle") String tvseriePrimaryTitle) {
65
+       Future<List<Models.TvSerie>> listFuture = akkaStreamFilesProcessing.getTvSerieByPrimaryTitle(tvseriePrimaryTitle);
66 66
 
67 67
        return new ResponseEntity<>(listFuture, HttpStatus.OK);
68 68
     }

+ 1
- 1
src/main/scala/fr/natan/akkastreamfileprocessingapi/service/AkkaStreamFileProcessing.scala 查看文件

@@ -10,7 +10,7 @@ trait AkkaStreamFileProcessing {
10 10
   def getPersonByName(primaryName: String): Future[Person]
11 11
 
12 12
   def getTvSerieById(tvSerieID: String): Future[TvSerie]
13
-  def getTvSerieByPrimaryTitle(tvSerieTitle: String):List[TvSerie]
13
+  def getTvSerieByPrimaryTitle(tvSerieTitle: String):Future[List[TvSerie]]
14 14
 
15 15
   def getTeamOfPersonsForTvSerie(tvSeriePrimaryTitle: String): Future[IndexedSeq[Person]]
16 16
   def getAllTvSeries(): Unit

+ 5
- 6
src/main/scala/fr/natan/akkastreamfileprocessingapi/service/AkkaStreamFileProcessingImpl.scala 查看文件

@@ -1,8 +1,8 @@
1 1
 package fr.natan.akkastreamfileprocessingapi.service
2 2
 
3
-import akka.Done
4 3
 import akka.actor.ActorSystem
5
-import akka.stream.scaladsl.{Sink, Source}
4
+import akka.stream.scaladsl.{Flow, Sink, Source}
5
+import akka.{Done, NotUsed}
6 6
 import com.typesafe.scalalogging.slf4j.Logger
7 7
 import fr.natan.akkastreamfileprocessingapi.datasource.Datasource.{nameBasics, titleBasics, titlePrincipalsBasics}
8 8
 import fr.natan.akkastreamfileprocessingapi.models.Models.{Person, TvSerie}
@@ -65,7 +65,7 @@ class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessing {
65 65
     })
66 66
     res
67 67
   }
68
-  override def getTvSerieByPrimaryTitle(tvSeriePrimaryTitle: String): List[TvSerie] = {
68
+  override def getTvSerieByPrimaryTitle(tvSeriePrimaryTitle: String): Future[List[TvSerie]] = {
69 69
 
70 70
     val tvSeriesSource: Source[Map[String, String], _] = buildAndValidateSource(inputFile = titleBasics)
71 71
 
@@ -79,9 +79,8 @@ class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessing {
79 79
         value.foreach((tvSrie: TvSerie) => logger.info(s"$tvSrie"))
80 80
         logger.info("SUCCESS")
81 81
     })
82
-    Await.result(tvSries,2 minutes)
83
-    val tvSriesList : List[TvSerie] = tvSries.value.get.get
84
-    tvSriesList
82
+
83
+    tvSries
85 84
   }
86 85
 
87 86
 

Powered by TurnKey Linux.