|
@@ -25,54 +25,54 @@ import java.util.concurrent.ExecutionException;
|
25
|
25
|
|
26
|
26
|
@SuppressWarnings("SpellCheckingInspection")
|
27
|
27
|
@RestController
|
28
|
|
-public class MovieController {
|
|
28
|
+public class TvSeriesController {
|
29
|
29
|
|
30
|
30
|
private final AkkaStreamFileProcessing akkaStreamFilesProcessing;
|
31
|
|
- private final CompletableFutureResult completableFutureResult = new CompletableFutureResult();
|
32
|
31
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
33
|
|
- private static final int BORN_INF = 1000, BORN_SUP = 5000;
|
|
32
|
+ private static final int BORN_INF = 500, BORN_SUP = 5000;
|
34
|
33
|
|
35
|
|
- public MovieController(AkkaStreamFileProcessing akkaStreamFilesProcessing) {
|
|
34
|
+ public TvSeriesController(AkkaStreamFileProcessing akkaStreamFilesProcessing) {
|
36
|
35
|
this.akkaStreamFilesProcessing = akkaStreamFilesProcessing;
|
37
|
36
|
}
|
38
|
37
|
|
39
|
38
|
@RequestMapping(value = "/persons/id/{personID}", method = RequestMethod.GET)
|
40
|
|
- private ResponseEntity<String> getPersonByID(@PathVariable(name = "personID") String personID) throws ExecutionException, InterruptedException {
|
|
39
|
+ private String getPersonByID(@PathVariable(name = "personID") String personID) throws ExecutionException, InterruptedException {
|
41
|
40
|
Future<Models.Person> futurePerson = akkaStreamFilesProcessing.getPersonById(personID);
|
42
|
|
- CompletableFuture<Models.Person> completableFuture = completableFutureResult.buildcompletableFuture(futurePerson);
|
|
41
|
+ CompletableFuture<Models.Person> completableFuture = CompletableFutureResult.buildcompletableFuture1(futurePerson);
|
43
|
42
|
while (!completableFuture.isDone()) {
|
44
|
43
|
logger.info("IS PROCESSING...");
|
45
|
44
|
Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
|
46
|
45
|
}
|
47
|
46
|
Models.Person person = completableFuture.get();
|
48
|
|
- return new ResponseEntity<>(Json.toJson(person, person.personFormat()).toString(), HttpStatus.OK);
|
|
47
|
+
|
|
48
|
+ return Json.toJson(person, person.personFormat()).toString();
|
49
|
49
|
}
|
50
|
50
|
|
51
|
51
|
@RequestMapping(value = "/persons/name/{primaryName}", method = RequestMethod.GET)
|
52
|
|
- private ResponseEntity<String> getPersonByName(@PathVariable(name = "primaryName") String primaryName)
|
|
52
|
+ private String getPersonByName(@PathVariable(name = "primaryName") String primaryName)
|
53
|
53
|
throws ExecutionException, InterruptedException {
|
54
|
54
|
|
55
|
55
|
Future<Models.Person> personFuture = akkaStreamFilesProcessing.getPersonByName(primaryName);
|
56
|
|
- CompletableFuture<Models.Person> personCompletableFuture = completableFutureResult.buildcompletableFuture(personFuture);
|
|
56
|
+ CompletableFuture<Models.Person> personCompletableFuture = CompletableFutureResult.buildcompletableFuture1(personFuture);
|
57
|
57
|
while (!personCompletableFuture.isDone()) {
|
58
|
58
|
logger.info("IS PROCESSING...");
|
59
|
59
|
Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
|
60
|
60
|
}
|
61
|
61
|
Models.Person person = personCompletableFuture.get();
|
62
|
|
- return new ResponseEntity<>(Json.toJson(person, person.personFormat()).toString(), HttpStatus.OK);
|
|
62
|
+ return Json.toJson(person, person.personFormat()).toString();
|
63
|
63
|
}
|
64
|
64
|
|
65
|
65
|
@RequestMapping(value = "/tvseries/id/{tvSerieId}", method = RequestMethod.GET)
|
66
|
|
- private ResponseEntity<String> getTvSerieByID(@PathVariable(name = "tvSerieId") String tvSerieID)
|
|
66
|
+ private String getTvSerieByID(@PathVariable(name = "tvSerieId") String tvSerieID)
|
67
|
67
|
throws ExecutionException, InterruptedException {
|
68
|
68
|
Future<Models.TvSerie> tvSerieFuture = akkaStreamFilesProcessing.getTvSerieById(tvSerieID);
|
69
|
|
- CompletableFuture<Models.TvSerie> tvSerieCompletableFuture = completableFutureResult.buildcompletableFuture(tvSerieFuture);
|
|
69
|
+ CompletableFuture<Models.TvSerie> tvSerieCompletableFuture = CompletableFutureResult.buildcompletableFuture1(tvSerieFuture);
|
70
|
70
|
while (!tvSerieCompletableFuture.isDone()) {
|
71
|
71
|
logger.info("IS PROCESSING...");
|
72
|
72
|
Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
|
73
|
73
|
}
|
74
|
74
|
Models.TvSerie tvSerie = tvSerieCompletableFuture.get();
|
75
|
|
- return new ResponseEntity<>(Json.toJson(tvSerie, tvSerie.tvSerieFormat()).toString(), HttpStatus.OK);
|
|
75
|
+ return Json.toJson(tvSerie, tvSerie.tvSerieFormat()).toString();
|
76
|
76
|
}
|
77
|
77
|
|
78
|
78
|
@RequestMapping(value = "/tvseries/title/{tvseriePrimaryTitle}", method = RequestMethod.GET)
|
|
@@ -81,7 +81,7 @@ public class MovieController {
|
81
|
81
|
|
82
|
82
|
Future<IndexedSeq<Models.TvSerie>> listFuture = akkaStreamFilesProcessing.getTvSerieByPrimaryTitle(tvseriePrimaryTitle);
|
83
|
83
|
CompletableFuture<IndexedSeq<Models.TvSerie>> completableFuture =
|
84
|
|
- completableFutureResult.buildcompletableFuture_(listFuture);
|
|
84
|
+ CompletableFutureResult.buildcompletableFuture2(listFuture);
|
85
|
85
|
while (!completableFuture.isDone()) {
|
86
|
86
|
logger.info("IS PROCESSING...");
|
87
|
87
|
Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
|
|
@@ -94,17 +94,15 @@ public class MovieController {
|
94
|
94
|
return null;
|
95
|
95
|
});
|
96
|
96
|
|
97
|
|
- return tvSeries;
|
|
97
|
+ return tvSeries;
|
98
|
98
|
}
|
99
|
99
|
|
100
|
|
- ;
|
101
|
|
-
|
102
|
100
|
@RequestMapping(value = "/persons/tvseries/title/{tvSerieTitle}", method = RequestMethod.GET)
|
103
|
101
|
private List<String> getPersonsForTvSerie(@PathVariable(name = "tvSerieTitle") String tvSerieTitle)
|
104
|
102
|
throws InterruptedException, ExecutionException {
|
105
|
103
|
|
106
|
104
|
Future<IndexedSeq<Models.Person>> futurePersonSeq = akkaStreamFilesProcessing.getTeamOfPersonsForTvSerie(tvSerieTitle);
|
107
|
|
- CompletableFuture<IndexedSeq<Models.Person>> completableFuture = completableFutureResult.buildcompletableFuture_(futurePersonSeq);
|
|
105
|
+ CompletableFuture<IndexedSeq<Models.Person>> completableFuture = CompletableFutureResult.buildcompletableFuture2(futurePersonSeq);
|
108
|
106
|
while (!completableFuture.isDone()){
|
109
|
107
|
logger.info("IS PROCESSING...");
|
110
|
108
|
Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF);
|