placidenduwayo vor 2 Jahren
Ursprung
Commit
d64b422d9c

+ 41
- 17
src/main/java/fr/natan/akkastreamfileprocessingapi/controller/TvSeriesController.java Datei anzeigen

@@ -1,8 +1,8 @@
1 1
 package fr.natan.akkastreamfileprocessingapi.controller;
2 2
 
3
-import fr.natan.akkastreamfileprocessingapi.futurecompleteness.CompletableFutureResult;
3
+import fr.natan.akkastreamfileprocessingapi.futurecompleteness.CompletableFutureBuilder;
4 4
 import fr.natan.akkastreamfileprocessingapi.models.Models;
5
-import fr.natan.akkastreamfileprocessingapi.service.AkkaStreamFileProcessing;
5
+import fr.natan.akkastreamfileprocessingapi.service.AkkaStreamFileProcessingFuture;
6 6
 import org.slf4j.Logger;
7 7
 import org.slf4j.LoggerFactory;
8 8
 import org.springframework.http.HttpStatus;
@@ -27,18 +27,19 @@ import java.util.concurrent.ExecutionException;
27 27
 @RestController
28 28
 public class TvSeriesController {
29 29
 
30
-    private final AkkaStreamFileProcessing akkaStreamFilesProcessing;
30
+    private final AkkaStreamFileProcessingFuture akkaStreamFilesProcessing;
31 31
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
32 32
     private static final int BORN_INF = 500, BORN_SUP = 5000;
33 33
 
34
-    public TvSeriesController(AkkaStreamFileProcessing akkaStreamFilesProcessing) {
34
+    public TvSeriesController(AkkaStreamFileProcessingFuture akkaStreamFilesProcessing) {
35 35
         this.akkaStreamFilesProcessing = akkaStreamFilesProcessing;
36 36
     }
37 37
 
38 38
     @RequestMapping(value = "/persons/id/{personID}", method = RequestMethod.GET)
39 39
     private String getPersonByID(@PathVariable(name = "personID") String personID) throws ExecutionException, InterruptedException {
40
-        Future<Models.Person> futurePerson = akkaStreamFilesProcessing.getPersonById(personID);
41
-        CompletableFuture<Models.Person> completableFuture = CompletableFutureResult.buildcompletableFuture1(futurePerson);
40
+        Future<Models.Person> futurePerson = akkaStreamFilesProcessing.getPersonByIdFuture(personID);
41
+        CompletableFuture<Models.Person> completableFuture = CompletableFutureBuilder
42
+                .buildcompletableFuture1(futurePerson);
42 43
         while (!completableFuture.isDone()) {
43 44
             logger.info("IS PROCESSING...");
44 45
             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
@@ -52,8 +53,9 @@ public class TvSeriesController {
52 53
     private String getPersonByName(@PathVariable(name = "primaryName") String primaryName)
53 54
             throws ExecutionException, InterruptedException {
54 55
 
55
-        Future<Models.Person> personFuture = akkaStreamFilesProcessing.getPersonByName(primaryName);
56
-        CompletableFuture<Models.Person> personCompletableFuture = CompletableFutureResult.buildcompletableFuture1(personFuture);
56
+        Future<Models.Person> personFuture = akkaStreamFilesProcessing.getPersonByNameFuture(primaryName);
57
+        CompletableFuture<Models.Person> personCompletableFuture = CompletableFutureBuilder
58
+                .buildcompletableFuture1(personFuture);
57 59
         while (!personCompletableFuture.isDone()) {
58 60
             logger.info("IS PROCESSING...");
59 61
             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
@@ -65,8 +67,9 @@ public class TvSeriesController {
65 67
     @RequestMapping(value = "/tvseries/id/{tvSerieId}", method = RequestMethod.GET)
66 68
     private String getTvSerieByID(@PathVariable(name = "tvSerieId") String tvSerieID)
67 69
             throws ExecutionException, InterruptedException {
68
-        Future<Models.TvSerie> tvSerieFuture = akkaStreamFilesProcessing.getTvSerieById(tvSerieID);
69
-        CompletableFuture<Models.TvSerie> tvSerieCompletableFuture = CompletableFutureResult.buildcompletableFuture1(tvSerieFuture);
70
+        Future<Models.TvSerie> tvSerieFuture = akkaStreamFilesProcessing.getTvSerieByIdFuture(tvSerieID);
71
+        CompletableFuture<Models.TvSerie> tvSerieCompletableFuture = CompletableFutureBuilder
72
+                .buildcompletableFuture1(tvSerieFuture);
70 73
         while (!tvSerieCompletableFuture.isDone()) {
71 74
             logger.info("IS PROCESSING...");
72 75
             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
@@ -79,9 +82,9 @@ public class TvSeriesController {
79 82
     private List<String> getTvserieByPrimaryTitle(
80 83
             @PathVariable(name = "tvseriePrimaryTitle") String tvseriePrimaryTitle) throws InterruptedException, ExecutionException {
81 84
 
82
-        Future<IndexedSeq<Models.TvSerie>> listFuture = akkaStreamFilesProcessing.getTvSerieByPrimaryTitle(tvseriePrimaryTitle);
85
+        Future<IndexedSeq<Models.TvSerie>> listFuture = akkaStreamFilesProcessing.getTvSeriesByPrimaryTitleFuture(tvseriePrimaryTitle);
83 86
         CompletableFuture<IndexedSeq<Models.TvSerie>> completableFuture =
84
-                CompletableFutureResult.buildcompletableFuture2(listFuture);
87
+                CompletableFutureBuilder.buildcompletableFuture2(listFuture);
85 88
         while (!completableFuture.isDone()) {
86 89
             logger.info("IS PROCESSING...");
87 90
             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
@@ -98,11 +101,11 @@ public class TvSeriesController {
98 101
     }
99 102
 
100 103
     @RequestMapping(value = "/persons/tvseries/title/{tvSerieTitle}", method = RequestMethod.GET)
101
-    private List<String> getPersonsForTvSerie(@PathVariable(name = "tvSerieTitle") String tvSerieTitle)
104
+    private List<String> getPersonsForTvSerieByTvSerieTitle(@PathVariable(name = "tvSerieTitle") String tvSerieTitle)
102 105
             throws InterruptedException, ExecutionException {
103 106
 
104
-        Future<IndexedSeq<Models.Person>> futurePersonSeq = akkaStreamFilesProcessing.getTeamOfPersonsForTvSerie(tvSerieTitle);
105
-        CompletableFuture<IndexedSeq<Models.Person>> completableFuture = CompletableFutureResult.buildcompletableFuture2(futurePersonSeq);
107
+        Future<IndexedSeq<Models.Person>> futurePersonSeq = akkaStreamFilesProcessing.getPersonsForTvSerieByTvSerieTitleFuture(tvSerieTitle);
108
+        CompletableFuture<IndexedSeq<Models.Person>> completableFuture = CompletableFutureBuilder.buildcompletableFuture2(futurePersonSeq);
106 109
         while (!completableFuture.isDone()){
107 110
             logger.info("IS PROCESSING...");
108 111
             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
@@ -119,15 +122,36 @@ public class TvSeriesController {
119 122
         return persons;
120 123
     }
121 124
 
125
+    @RequestMapping(value = "/persons/tvseries/id/{tvSerieID}", method = RequestMethod.GET)
126
+    private List<String> getPersonsForTvSerieByTvSerieID(@PathVariable(name = "tvSerieID") String tvSerieID)
127
+            throws InterruptedException, ExecutionException {
128
+
129
+        Future<IndexedSeq<Models.Person>> futureIndexedSeqPersons = akkaStreamFilesProcessing.getPersonsForTvSerieByTvSerieIdFuture(tvSerieID);
130
+        CompletableFuture<IndexedSeq<Models.Person>> seqCompletableFuture = CompletableFutureBuilder.buildcompletableFuture2(futureIndexedSeqPersons);
131
+
132
+        while (!seqCompletableFuture.isDone()){
133
+            logger.info("IS PROCESSING");
134
+            Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
135
+        }
136
+        IndexedSeq<Models.Person> personIndexedSeq = seqCompletableFuture.get();
137
+        List<String> personsList = new ArrayList<>();
138
+        personIndexedSeq.foreach(person ->{
139
+            personsList.add(Json.toJson(person, person.personFormat()).toString());
140
+            return null;
141
+        });
142
+
143
+        return personsList;
144
+    }
145
+
122 146
     @RequestMapping(value = "/persons", method = RequestMethod.GET)
123 147
     private ResponseEntity<String> getAllPersons() {
124
-        akkaStreamFilesProcessing.getAllPersons();
148
+        akkaStreamFilesProcessing.getAllPersonsFuture();
125 149
         return new ResponseEntity<>("is running", HttpStatus.OK);
126 150
     }
127 151
 
128 152
     @RequestMapping(value = "/tvseries", method = RequestMethod.GET)
129 153
     private ResponseEntity<String> getAllvSeries() {
130
-        akkaStreamFilesProcessing.getAllTvSeries();
154
+        akkaStreamFilesProcessing.getAllTvSeriesFuture();
131 155
         return new ResponseEntity<>("is running", HttpStatus.OK);
132 156
     }
133 157
 }

src/main/java/fr/natan/akkastreamfileprocessingapi/futurecompleteness/CompletableFutureResult.java → src/main/java/fr/natan/akkastreamfileprocessingapi/futurecompleteness/CompletableFutureBuilder.java Datei anzeigen

@@ -9,7 +9,7 @@ import java.util.concurrent.Executors;
9 9
 
10 10
 
11 11
 
12
-public class CompletableFutureResult<T> {
12
+public class CompletableFutureBuilder<T> {
13 13
 
14 14
     public static<T> CompletableFuture<T> buildcompletableFuture1(Future<T> futureT) {
15 15
         CompletableFuture<T> completableFuture = new CompletableFuture<>();

+ 0
- 18
src/main/scala/fr/natan/akkastreamfileprocessingapi/service/AkkaStreamFileProcessing.scala Datei anzeigen

@@ -1,18 +0,0 @@
1
-package fr.natan.akkastreamfileprocessingapi.service
2
-
3
-import fr.natan.akkastreamfileprocessingapi.models.Models.{Person, TvSerie}
4
-
5
-import scala.concurrent.Future
6
-
7
-//noinspection SpellCheckingInspection,AccessorLikeMethodIsUnit
8
-trait AkkaStreamFileProcessing {
9
-  def getPersonById(personID: String): Future[Person]
10
-  def getPersonByName(primaryName: String): Future[Person]
11
-
12
-  def getTvSerieById(tvSerieID: String): Future[TvSerie]
13
-  def getTvSerieByPrimaryTitle(tvSerieTitle: String):Future[IndexedSeq[TvSerie]]
14
-
15
-  def getTeamOfPersonsForTvSerie(tvSeriePrimaryTitle: String): Future[IndexedSeq[Person]]
16
-  def getAllTvSeries(): Unit
17
-  def getAllPersons(): Unit
18
-}

+ 20
- 0
src/main/scala/fr/natan/akkastreamfileprocessingapi/service/AkkaStreamFileProcessingFuture.scala Datei anzeigen

@@ -0,0 +1,20 @@
1
+package fr.natan.akkastreamfileprocessingapi.service
2
+
3
+import akka.Done
4
+import fr.natan.akkastreamfileprocessingapi.models.Models.{Person, TvSerie}
5
+
6
+import scala.concurrent.Future
7
+
8
+//noinspection SpellCheckingInspection,AccessorLikeMethodIsUnit
9
+trait AkkaStreamFileProcessingFuture {
10
+  def getPersonByIdFuture(personID: String): Future[Person]
11
+  def getPersonByNameFuture(primaryName: String): Future[Person]
12
+
13
+  def getTvSerieByIdFuture(tvSerieID: String): Future[TvSerie]
14
+  def getTvSeriesByPrimaryTitleFuture(tvSerieTitle: String):Future[IndexedSeq[TvSerie]]
15
+
16
+  def getPersonsForTvSerieByTvSerieTitleFuture(tvSeriePrimaryTitle: String): Future[IndexedSeq[Person]]
17
+  def getPersonsForTvSerieByTvSerieIdFuture(tvSerieId: String): Future[IndexedSeq[Person]]
18
+  def getAllTvSeriesFuture(): Future[Done]
19
+  def getAllPersonsFuture(): Future[Done]
20
+}

+ 94
- 33
src/main/scala/fr/natan/akkastreamfileprocessingapi/service/AkkaStreamFileProcessingImpl.scala Datei anzeigen

@@ -4,10 +4,23 @@ import akka.Done
4 4
 import akka.actor.ActorSystem
5 5
 import akka.stream.scaladsl.{Sink, Source}
6 6
 import com.typesafe.scalalogging.slf4j.Logger
7
-import fr.natan.akkastreamfileprocessingapi.datasource.Datasource.{nameBasics, titleBasics, titlePrincipalsBasics}
7
+import fr.natan.akkastreamfileprocessingapi.datasource.Datasource.{
8
+  nameBasics, titleBasics, titlePrincipalsBasics
9
+}
8 10
 import fr.natan.akkastreamfileprocessingapi.models.Models.{Person, TvSerie}
9 11
 import fr.natan.akkastreamfileprocessingapi.models.ModelsBuilder.buildPersonModel
10
-import fr.natan.akkastreamfileprocessingapi.service.AkkaStreamComponents.{buildAllPersonsSink, buildAllTvSeriesSink, buildAndValidateSource, buildPersonFlow, buildSource, buildTvSerieFlow, filterPersonByIdFlow, filterPersonByNameFlow, filterTvSerieByIdFlow, filterTvSerieByPrimaryTitleFlow}
12
+import fr.natan.akkastreamfileprocessingapi.service.AkkaStreamComponents.{
13
+  buildAllPersonsSink,
14
+  buildAllTvSeriesSink,
15
+  buildAndValidateSource,
16
+  buildPersonFlow,
17
+  buildSource,
18
+  buildTvSerieFlow,
19
+  filterPersonByIdFlow,
20
+  filterPersonByNameFlow,
21
+  filterTvSerieByIdFlow,
22
+  filterTvSerieByPrimaryTitleFlow
23
+}
11 24
 import org.slf4j.LoggerFactory
12 25
 import org.springframework.stereotype.Component
13 26
 
@@ -18,87 +31,87 @@ import scala.util.{Failure, Success}
18 31
 
19 32
 //noinspection SpellCheckingInspection
20 33
 @Component
21
-class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessing {
34
+class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessingFuture {
22 35
 
23 36
   implicit val actorSystem: ActorSystem = ActorSystem("AkkaStreamActor")
24 37
   implicit val logger: Logger = Logger(LoggerFactory.getLogger(this.getClass))
25 38
 
26
-  override def getPersonById(personID: String): Future[Person] = {
39
+  override def getPersonByIdFuture(personID: String): Future[Person] = {
27 40
     val source: Source[Map[String, String], _] = buildSource(inputFile = nameBasics)
28
-    val res: Future[Person] = source
41
+    val personFuture: Future[Person] = source
29 42
       .via(flow = filterPersonByIdFlow(personID = personID))
30 43
       .runWith(Sink.head)
31 44
 
32
-    res.andThen({
45
+    personFuture.andThen({
33 46
       case Failure(exception) => logger.info(s"$exception")
34 47
       case Success(value:Person) => logger.info(s"$value")
35 48
     })
36 49
 
37
-    res
50
+    personFuture
38 51
   }
39 52
 
40
-  override def getPersonByName(primaryName: String): Future[Person] = {
53
+  override def getPersonByNameFuture(primaryName: String): Future[Person] = {
41 54
     val source: Source[Map[String, String], _] = buildSource(inputFile = nameBasics)
42
-    val persons: Future[Person] = source
55
+    val personFuture: Future[Person] = source
43 56
       .via(flow = filterPersonByNameFlow(primaryName = primaryName))
44 57
       .runWith(Sink.head)
45 58
 
46
-    persons.onComplete({
59
+    personFuture.onComplete({
47 60
       case Failure(exception) => logger.error(s"$exception")
48 61
       case Success(value: Person) => logger.info(s"$value")
49 62
         logger.info("SUCCESS")
50 63
     })
51 64
 
52
-    persons
65
+    personFuture
53 66
   }
54 67
 
55
-  override def getTvSerieById(tvSerieID: String): Future[TvSerie] = {
68
+  override def getTvSerieByIdFuture(tvSerieID: String): Future[TvSerie] = {
56 69
     val source: Source[Map[String, String], _] = buildSource(inputFile = titleBasics)
57
-    val res: Future[TvSerie] = source
70
+    val tvSerieFuture: Future[TvSerie] = source
58 71
       .via(flow = filterTvSerieByIdFlow(tvSerieID = tvSerieID))
59 72
       .runWith(Sink.head)
60 73
 
61
-    res.onComplete({
74
+    tvSerieFuture.onComplete({
62 75
       case Failure(exception) => logger.info(s"$exception")
63 76
       case Success(value: TvSerie) => logger.info(s"$value")
64 77
     })
65
-    res
78
+    tvSerieFuture
66 79
   }
67
-  override def getTvSerieByPrimaryTitle(tvSeriePrimaryTitle: String): Future[IndexedSeq[TvSerie]] = {
80
+  override def getTvSeriesByPrimaryTitleFuture(tvSeriePrimaryTitle: String): Future[IndexedSeq[TvSerie]] = {
68 81
 
69 82
     val tvSeriesSource: Source[Map[String, String], _] = buildAndValidateSource(inputFile = titleBasics)
70 83
 
71
-    val tvSries: Future[IndexedSeq[TvSerie]] = tvSeriesSource
84
+    val tvSriesFuture: Future[IndexedSeq[TvSerie]] = tvSeriesSource
72 85
       .via(flow = filterTvSerieByPrimaryTitleFlow(tvSeriePrimaryTitle = tvSeriePrimaryTitle))
73 86
       .runWith(Sink.collection)
74 87
 
75
-    tvSries.onComplete({
88
+    tvSriesFuture.onComplete({
76 89
       case Failure(exception) => logger.info(s"$exception")
77 90
       case Success(value: IndexedSeq[TvSerie]) =>
78 91
         value.foreach((tvSrie: TvSerie) => logger.info(s"$tvSrie"))
79 92
         logger.info("SUCCESS")
80 93
     })
81 94
 
82
-    tvSries
95
+    tvSriesFuture
83 96
   }
84 97
 
85 98
 
86 99
   private def getTvSerieIdByPrimaryTitle(primaryTitle: String): Future[Option[String]] = {
87 100
     val source: Source[Map[String, String], _] = buildSource(inputFile = titleBasics)
88 101
 
89
-    val res: Future[Option[String]] = source
102
+    val tvSerieIdFuture: Future[Option[String]] = source
90 103
       .filter((rowMap: Map[String, String]) => {
91
-        rowMap.getOrElse(key = "primaryTitle", "") == primaryTitle
104
+        rowMap.getOrElse(key = "primaryTitle", default = "") == primaryTitle
92 105
       })
93 106
       .map((rowMap: Map[String, String]) => rowMap.get("tconst"))
94 107
       .runWith(Sink.head)
95 108
 
96
-    res
109
+    tvSerieIdFuture
97 110
   }
98 111
 
99 112
   private def getListOfPersonsIDByTvSerieID(tvSerieIdFuture: Future[Option[String]]): Future[IndexedSeq[Option[String]]] = {
100 113
     val source: Source[Map[String, String], _] = buildSource(inputFile = titlePrincipalsBasics)
101
-    val res: Future[IndexedSeq[Option[String]]] = source
114
+    val personsIDsFuture: Future[IndexedSeq[Option[String]]] = source
102 115
       .filter((rowMaps: Map[String, String]) => {
103 116
         rowMaps.getOrElse(key = "tconst", default = "") == tvSerieIdFuture.value.get.get.get
104 117
       })
@@ -107,14 +120,13 @@ class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessing {
107 120
       })
108 121
       .runWith(Sink.collection)
109 122
 
110
-    res
123
+    personsIDsFuture
111 124
   }
112 125
 
113
-  private def getListOfPersonsForTvSerie(listPersonsIDsFuture: Future[IndexedSeq[Option[String]]]):
114
-  Future[IndexedSeq[Person]] = {
126
+  private def getListOfPersonsForTvSerie(listPersonsIDsFuture: Future[IndexedSeq[Option[String]]]): Future[IndexedSeq[Person]] = {
115 127
 
116 128
     val source: Source[Map[String, String], _] = buildSource(inputFile = nameBasics)
117
-    val res: Future[IndexedSeq[Person]] = source
129
+    val personsFuture: Future[IndexedSeq[Person]] = source
118 130
       .filter((rowMaps: Map[String, String]) => {
119 131
         listPersonsIDsFuture.value.get.get.contains(rowMaps.get(key = "nconst"))
120 132
       })
@@ -123,10 +135,10 @@ class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessing {
123 135
       })
124 136
       .runWith(Sink.collection)
125 137
 
126
-    res
138
+    personsFuture
127 139
   }
128 140
 
129
-  override def getTeamOfPersonsForTvSerie(tvSeriePrimaryTitle: String): Future[IndexedSeq[Person]] = {
141
+  override def getPersonsForTvSerieByTvSerieTitleFuture(tvSeriePrimaryTitle: String): Future[IndexedSeq[Person]] = {
130 142
 
131 143
     //futures chaining
132 144
     logger.info("STEP 1/3 START")
@@ -150,7 +162,7 @@ class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessing {
150 162
                 logger.info("STEP 2/3 END")
151 163
             })
152 164
               .flatMap({
153
-                future =>
165
+                _ =>
154 166
                   logger.info("STEP 3/3 START")
155 167
                   val personsTeamFuture: Future[IndexedSeq[Person]] = getListOfPersonsForTvSerie(listPersonsIDsFuture = listPersonIDsFuture)
156 168
                   personsTeamFuture.andThen({
@@ -165,7 +177,51 @@ class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessing {
165 177
     finalFuture
166 178
   }
167 179
 
168
-  override def getAllPersons(): Unit = {
180
+  private def getTvSerieIDFuture(tvSerieId: String): Future[Option[String]] ={
181
+    val source: Source[Map[String, String], _] = buildSource(inputFile = titlePrincipalsBasics)
182
+
183
+    val tvSerieIdFuture : Future[Option[String]]= source.
184
+      filter((rowMap: Map[String, String]) => rowMap.getOrElse(key = "tconst", default = "") == tvSerieId)
185
+      .map((rowMap: Map[String, String])=>rowMap.get(key = "tconst"))
186
+      .runWith(Sink.head)
187
+
188
+    tvSerieIdFuture
189
+  }
190
+
191
+  override def getPersonsForTvSerieByTvSerieIdFuture(tvSerieId: String): Future[IndexedSeq[Person]] = {
192
+
193
+    val tvSerieIdFuture: Future[Option[String]] = getTvSerieIDFuture(tvSerieId = tvSerieId)
194
+    logger.info("STEP 1/3")
195
+    tvSerieIdFuture.andThen({
196
+      case Failure(exception) => logger.error(s"${exception.printStackTrace()}")
197
+      case Success(value:Option[String]) =>
198
+        logger.info(s"$value")
199
+        logger.info("STEP 1/3")
200
+
201
+    })
202
+      .flatMap({
203
+        _ => logger.info("STEP 2/3")
204
+          val  listOfPersonsIDsFuture : Future[IndexedSeq[Option[String]]] = getListOfPersonsIDByTvSerieID(tvSerieIdFuture = tvSerieIdFuture)
205
+          listOfPersonsIDsFuture.andThen({
206
+            case Failure(exception) => logger.error(s"${exception.printStackTrace()}")
207
+            case Success(value) =>
208
+              value.foreach((personID: Option[String]) => logger.info(s"Person ID:$personID"))
209
+              logger.info("STEP 2/3 END")
210
+          })
211
+            .flatMap({
212
+              _ => logger.info("STEP 3/3")
213
+                val personsTeamFuture: Future[IndexedSeq[Person]] = getListOfPersonsForTvSerie(listPersonsIDsFuture = listOfPersonsIDsFuture)
214
+                personsTeamFuture.andThen({
215
+                  case Failure(exception) => logger.error(s"$exception")
216
+                  case Success(value: IndexedSeq[Person]) =>
217
+                    value.foreach((person: Person) => logger.info(s"${person.toString}"))
218
+                    logger.info("STEP 3/3 END")
219
+                })
220
+            })
221
+      })
222
+
223
+  }
224
+  override def getAllPersonsFuture(): Future[Done] = {
169 225
     val personSource: Source[Map[String, String], _] = buildSource(inputFile = nameBasics)
170 226
     //graph
171 227
     val startTime: Long = System.currentTimeMillis()
@@ -180,15 +236,17 @@ class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessing {
180 236
         val time: Long = (System.currentTimeMillis() - startTime) / 100
181 237
         logger.info(s"elapsed time: $time")
182 238
     }
239
+
240
+    result
183 241
   }
184 242
 
185
-  override def getAllTvSeries(): Unit = {
243
+  override def getAllTvSeriesFuture(): Future[Done] = {
186 244
     val source: Source[Map[String, String], _] = buildAndValidateSource(inputFile = titleBasics)
187 245
     val sink: Sink[TvSerie, Future[Done]] = buildAllTvSeriesSink(logger = logger)
188 246
 
189 247
     val startingTime: Long = System.currentTimeMillis()
190 248
     //graph sink->flow->sink
191
-    source
249
+    val results: Future[Done] = source
192 250
       .via(flow = buildTvSerieFlow())
193 251
       .runWith(sink = sink)
194 252
       .andThen {
@@ -197,7 +255,10 @@ class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessing {
197 255
           logger.info(s"$value: successfully processing file, elapsed time $titleBasics: $elapsedTime sec")
198 256
         case Failure(error: Error) => logger.error(s"$error")
199 257
       }
258
+
259
+    results
200 260
   }
261
+
201 262
 }
202 263
 
203 264
 

Powered by TurnKey Linux.