| 
				
			 | 
			
			
				@@ -1,7 +1,7 @@ 
			 | 
		
	
		
			
			| 
				1
			 | 
			
				1
			 | 
			
			
				 package fr.natan.akkastreamfileprocessingapi.controller; 
			 | 
		
	
		
			
			| 
				2
			 | 
			
				2
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				3
			 | 
			
				3
			 | 
			
			
				 import fr.natan.akkastreamfileprocessingapi.futurecompleteness.CompletableFutureBuilder; 
			 | 
		
	
		
			
			| 
				4
			 | 
			
				
			 | 
			
			
				-import fr.natan.akkastreamfileprocessingapi.models.Models; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4
			 | 
			
			
				+import fr.natan.akkastreamfileprocessingapi.models.ModelsAndJsonMap; 
			 | 
		
	
		
			
			| 
				5
			 | 
			
				5
			 | 
			
			
				 import fr.natan.akkastreamfileprocessingapi.service.AkkaStreamFileProcessingFuture; 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				6
			 | 
			
			
				 import org.slf4j.Logger; 
			 | 
		
	
		
			
			| 
				7
			 | 
			
				7
			 | 
			
			
				 import org.slf4j.LoggerFactory; 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -23,8 +23,6 @@ import java.util.Random; 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				23
			 | 
			
			
				 import java.util.concurrent.CompletableFuture; 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				24
			 | 
			
			
				 import java.util.concurrent.ExecutionException; 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				25
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				26
			 | 
			
				
			 | 
			
			
				-import java.util.concurrent.TimeoutException; 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				26
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				29
			 | 
			
				27
			 | 
			
			
				 @SuppressWarnings("SpellCheckingInspection") 
			 | 
		
	
		
			
			| 
				30
			 | 
			
				28
			 | 
			
			
				 @RestController 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -40,16 +38,16 @@ public class TvSeriesController { 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				38
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				41
			 | 
			
				39
			 | 
			
			
				     @RequestMapping(value = "/persons/id/{personID}", method = RequestMethod.GET) 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				40
			 | 
			
			
				     private String getPersonByID(@PathVariable(name = "personID") String personID) throws ExecutionException, InterruptedException { 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				
			 | 
			
			
				-        Future<Option<Models.Person>> futurePerson = akkaStreamFilesProcessing.getPersonByIdFuture(personID); 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				
			 | 
			
			
				-        CompletableFuture<Models.Person> completableFuture = CompletableFutureBuilder 
			 | 
		
	
		
			
			| 
				
			 | 
			
				41
			 | 
			
			
				+        Future<Option<ModelsAndJsonMap.Person>> futurePerson = akkaStreamFilesProcessing.getPersonByIdFuture(personID); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				+        CompletableFuture<ModelsAndJsonMap.Person> completableFuture = CompletableFutureBuilder 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				43
			 | 
			
			
				                 .buildcompletableFuture1(futurePerson); 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				44
			 | 
			
			
				         while (!completableFuture.isDone()) { 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				45
			 | 
			
			
				             logger.info("IS PROCESSING..."); 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				46
			 | 
			
			
				             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF); 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				47
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				
			 | 
			
			
				-        Models.Person person = completableFuture.get(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				+        ModelsAndJsonMap.Person person = completableFuture.get(); 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				49
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				52
			 | 
			
				
			 | 
			
			
				-        JsValue personJs = Json.toJson(person, person.personFormat()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				+        JsValue personJs = Json.toJson(person, person.personJsonFormatter()); 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				51
			 | 
			
			
				         return Json.prettyPrint(personJs); 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				52
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				53
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -57,30 +55,30 @@ public class TvSeriesController { 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				55
			 | 
			
			
				     private String getPersonByName(@PathVariable(name = "primaryName") String primaryName) 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				56
			 | 
			
			
				             throws ExecutionException, InterruptedException { 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				57
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				-        Future<Option<Models.Person>> personFuture = akkaStreamFilesProcessing.getPersonByNameFuture(primaryName); 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				-        CompletableFuture<Models.Person> personCompletableFuture = CompletableFutureBuilder 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+        Future<Option<ModelsAndJsonMap.Person>> personFuture = akkaStreamFilesProcessing.getPersonByNameFuture(primaryName); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+        CompletableFuture<ModelsAndJsonMap.Person> personCompletableFuture = CompletableFutureBuilder 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				60
			 | 
			
			
				                 .buildcompletableFuture1(personFuture); 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				61
			 | 
			
			
				         while (!personCompletableFuture.isDone()) { 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				62
			 | 
			
			
				             logger.info("IS PROCESSING..."); 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				63
			 | 
			
			
				             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF); 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				64
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				-        Models.Person person = personCompletableFuture.get(); 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				
			 | 
			
			
				-        JsValue personJs = Json.toJson(person, person.personFormat()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+        ModelsAndJsonMap.Person person = personCompletableFuture.get(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				66
			 | 
			
			
				+        JsValue personJs = Json.toJson(person, person.personJsonFormatter()); 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				67
			 | 
			
			
				         return Json.prettyPrint(personJs); 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				68
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				69
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				72
			 | 
			
				70
			 | 
			
			
				     @RequestMapping(value = "/tvseries/id/{tvSerieId}", method = RequestMethod.GET) 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				71
			 | 
			
			
				     private String getTvSerieByID(@PathVariable(name = "tvSerieId") String tvSerieID) 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				72
			 | 
			
			
				             throws ExecutionException, InterruptedException { 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				
			 | 
			
			
				-        Future<Option<Models.TvSerie>> tvSerieFuture = akkaStreamFilesProcessing.getTvSerieByIdFuture(tvSerieID); 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				
			 | 
			
			
				-        CompletableFuture<Models.TvSerie> tvSerieCompletableFuture = CompletableFutureBuilder 
			 | 
		
	
		
			
			| 
				
			 | 
			
				73
			 | 
			
			
				+        Future<Option<ModelsAndJsonMap.TvSerie>> tvSerieFuture = akkaStreamFilesProcessing.getTvSerieByIdFuture(tvSerieID); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				+        CompletableFuture<ModelsAndJsonMap.TvSerie> tvSerieCompletableFuture = CompletableFutureBuilder 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				75
			 | 
			
			
				                 .buildcompletableFuture1(tvSerieFuture); 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				76
			 | 
			
			
				         while (!tvSerieCompletableFuture.isDone()) { 
			 | 
		
	
		
			
			| 
				79
			 | 
			
				77
			 | 
			
			
				             logger.info("IS PROCESSING..."); 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				78
			 | 
			
			
				             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF); 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				79
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				
			 | 
			
			
				-        Models.TvSerie tvSerie = tvSerieCompletableFuture.get(); 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				
			 | 
			
			
				-        JsValue tvSerieJs = Json.toJson(tvSerie, tvSerie.tvSerieFormat()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				+        ModelsAndJsonMap.TvSerie tvSerie = tvSerieCompletableFuture.get(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+        JsValue tvSerieJs = Json.toJson(tvSerie, tvSerie.tvSerieJsonFormatter()); 
			 | 
		
	
		
			
			| 
				84
			 | 
			
				82
			 | 
			
			
				         return Json.prettyPrint(tvSerieJs); 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				83
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				86
			 | 
			
				84
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -88,18 +86,18 @@ public class TvSeriesController { 
			 | 
		
	
		
			
			| 
				88
			 | 
			
				86
			 | 
			
			
				     private List<String> getTvserieByPrimaryTitle( 
			 | 
		
	
		
			
			| 
				89
			 | 
			
				87
			 | 
			
			
				             @PathVariable(name = "tvseriePrimaryTitle") String tvseriePrimaryTitle) throws InterruptedException, ExecutionException { 
			 | 
		
	
		
			
			| 
				90
			 | 
			
				88
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				91
			 | 
			
				
			 | 
			
			
				-        Future<IndexedSeq<Models.TvSerie>> listFuture = akkaStreamFilesProcessing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				89
			 | 
			
			
				+        Future<IndexedSeq<ModelsAndJsonMap.TvSerie>> listFuture = akkaStreamFilesProcessing 
			 | 
		
	
		
			
			| 
				92
			 | 
			
				90
			 | 
			
			
				                 .getTvSeriesByPrimaryTitleFuture(tvseriePrimaryTitle); 
			 | 
		
	
		
			
			| 
				93
			 | 
			
				
			 | 
			
			
				-        CompletableFuture<IndexedSeq<Models.TvSerie>> completableFuture = 
			 | 
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				+        CompletableFuture<IndexedSeq<ModelsAndJsonMap.TvSerie>> completableFuture = 
			 | 
		
	
		
			
			| 
				94
			 | 
			
				92
			 | 
			
			
				                 CompletableFutureBuilder.buildcompletableFuture2(listFuture); 
			 | 
		
	
		
			
			| 
				95
			 | 
			
				93
			 | 
			
			
				         while (!completableFuture.isDone()) { 
			 | 
		
	
		
			
			| 
				96
			 | 
			
				94
			 | 
			
			
				             logger.info("IS PROCESSING..."); 
			 | 
		
	
		
			
			| 
				97
			 | 
			
				95
			 | 
			
			
				             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF); 
			 | 
		
	
		
			
			| 
				98
			 | 
			
				96
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				
			 | 
			
			
				-        IndexedSeq<Models.TvSerie> tvSerieList = completableFuture.get(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				97
			 | 
			
			
				+        IndexedSeq<ModelsAndJsonMap.TvSerie> tvSerieList = completableFuture.get(); 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				98
			 | 
			
			
				         List<String> tvSeries = new ArrayList<>(); 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				99
			 | 
			
			
				         tvSerieList.foreach(tvSerie -> { 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				
			 | 
			
			
				-            JsValue tvSerieJs = Json.toJson(tvSerie, tvSerie.tvSerieFormat()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				+            JsValue tvSerieJs = Json.toJson(tvSerie, tvSerie.tvSerieJsonFormatter()); 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				101
			 | 
			
			
				             tvSeries.add(Json.prettyPrint(tvSerieJs)); 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				102
			 | 
			
			
				             return null; 
			 | 
		
	
		
			
			| 
				105
			 | 
			
				103
			 | 
			
			
				         }); 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -111,19 +109,19 @@ public class TvSeriesController { 
			 | 
		
	
		
			
			| 
				111
			 | 
			
				109
			 | 
			
			
				     private List<String> getPersonsForTvSerieByTvSerieTitle(@PathVariable(name = "tvSerieTitle") String tvSerieTitle) 
			 | 
		
	
		
			
			| 
				112
			 | 
			
				110
			 | 
			
			
				             throws InterruptedException, ExecutionException { 
			 | 
		
	
		
			
			| 
				113
			 | 
			
				111
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				114
			 | 
			
				
			 | 
			
			
				-        Future<IndexedSeq<Models.Person>> futurePersonSeq = akkaStreamFilesProcessing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				112
			 | 
			
			
				+        Future<IndexedSeq<ModelsAndJsonMap.Person>> futurePersonSeq = akkaStreamFilesProcessing 
			 | 
		
	
		
			
			| 
				115
			 | 
			
				113
			 | 
			
			
				                 .getPersonsForTvSerieByTvSerieTitleFuture(tvSerieTitle); 
			 | 
		
	
		
			
			| 
				116
			 | 
			
				
			 | 
			
			
				-        CompletableFuture<IndexedSeq<Models.Person>> completableFuture = CompletableFutureBuilder 
			 | 
		
	
		
			
			| 
				
			 | 
			
				114
			 | 
			
			
				+        CompletableFuture<IndexedSeq<ModelsAndJsonMap.Person>> completableFuture = CompletableFutureBuilder 
			 | 
		
	
		
			
			| 
				117
			 | 
			
				115
			 | 
			
			
				                 .buildcompletableFuture2(futurePersonSeq); 
			 | 
		
	
		
			
			| 
				118
			 | 
			
				116
			 | 
			
			
				         while (!completableFuture.isDone()){ 
			 | 
		
	
		
			
			| 
				119
			 | 
			
				117
			 | 
			
			
				             logger.info("IS PROCESSING..."); 
			 | 
		
	
		
			
			| 
				120
			 | 
			
				118
			 | 
			
			
				             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF); 
			 | 
		
	
		
			
			| 
				121
			 | 
			
				119
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				122
			 | 
			
				120
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				123
			 | 
			
				
			 | 
			
			
				-        IndexedSeq<Models.Person> personIndexedSeq = completableFuture.get(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				121
			 | 
			
			
				+        IndexedSeq<ModelsAndJsonMap.Person> personIndexedSeq = completableFuture.get(); 
			 | 
		
	
		
			
			| 
				124
			 | 
			
				122
			 | 
			
			
				         List<String> personList = new ArrayList<>(); 
			 | 
		
	
		
			
			| 
				125
			 | 
			
				123
			 | 
			
			
				         personIndexedSeq.foreach(person -> { 
			 | 
		
	
		
			
			| 
				126
			 | 
			
				
			 | 
			
			
				-            JsValue personJs = Json.toJson(person, person.personFormat()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				124
			 | 
			
			
				+            JsValue personJs = Json.toJson(person, person.personJsonFormatter()); 
			 | 
		
	
		
			
			| 
				127
			 | 
			
				125
			 | 
			
			
				             personList.add(Json.prettyPrint(personJs)); 
			 | 
		
	
		
			
			| 
				128
			 | 
			
				126
			 | 
			
			
				             return null; 
			 | 
		
	
		
			
			| 
				129
			 | 
			
				127
			 | 
			
			
				         }); 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -135,19 +133,19 @@ public class TvSeriesController { 
			 | 
		
	
		
			
			| 
				135
			 | 
			
				133
			 | 
			
			
				     private List<String> getPersonsForTvSerieByTvSerieID(@PathVariable(name = "tvSerieID") String tvSerieID) 
			 | 
		
	
		
			
			| 
				136
			 | 
			
				134
			 | 
			
			
				             throws InterruptedException, ExecutionException { 
			 | 
		
	
		
			
			| 
				137
			 | 
			
				135
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				138
			 | 
			
				
			 | 
			
			
				-        Future<IndexedSeq<Models.Person>> futureIndexedSeqPersons = akkaStreamFilesProcessing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				136
			 | 
			
			
				+        Future<IndexedSeq<ModelsAndJsonMap.Person>> futureIndexedSeqPersons = akkaStreamFilesProcessing 
			 | 
		
	
		
			
			| 
				139
			 | 
			
				137
			 | 
			
			
				                 .getPersonsForTvSerieByTvSerieIDFuture(tvSerieID); 
			 | 
		
	
		
			
			| 
				140
			 | 
			
				
			 | 
			
			
				-        CompletableFuture<IndexedSeq<Models.Person>> seqCompletableFuture = CompletableFutureBuilder 
			 | 
		
	
		
			
			| 
				
			 | 
			
				138
			 | 
			
			
				+        CompletableFuture<IndexedSeq<ModelsAndJsonMap.Person>> seqCompletableFuture = CompletableFutureBuilder 
			 | 
		
	
		
			
			| 
				141
			 | 
			
				139
			 | 
			
			
				                 .buildcompletableFuture2(futureIndexedSeqPersons); 
			 | 
		
	
		
			
			| 
				142
			 | 
			
				140
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				143
			 | 
			
				141
			 | 
			
			
				         while (!seqCompletableFuture.isDone()){ 
			 | 
		
	
		
			
			| 
				144
			 | 
			
				142
			 | 
			
			
				             logger.info("IS PROCESSING..."); 
			 | 
		
	
		
			
			| 
				145
			 | 
			
				143
			 | 
			
			
				             Thread.sleep(new Random().nextInt(BORN_SUP-BORN_INF)+BORN_INF); 
			 | 
		
	
		
			
			| 
				146
			 | 
			
				144
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				147
			 | 
			
				
			 | 
			
			
				-        IndexedSeq<Models.Person> personIndexedSeq = seqCompletableFuture.get(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				145
			 | 
			
			
				+        IndexedSeq<ModelsAndJsonMap.Person> personIndexedSeq = seqCompletableFuture.get(); 
			 | 
		
	
		
			
			| 
				148
			 | 
			
				146
			 | 
			
			
				         List<String> personsList = new ArrayList<>(); 
			 | 
		
	
		
			
			| 
				149
			 | 
			
				147
			 | 
			
			
				         personIndexedSeq.foreach(person ->{ 
			 | 
		
	
		
			
			| 
				150
			 | 
			
				
			 | 
			
			
				-            JsValue personJs = Json.toJson(person, person.personFormat()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				148
			 | 
			
			
				+            JsValue personJs = Json.toJson(person, person.personJsonFormatter()); 
			 | 
		
	
		
			
			| 
				151
			 | 
			
				149
			 | 
			
			
				             personsList.add(Json.prettyPrint(personJs)); 
			 | 
		
	
		
			
			| 
				152
			 | 
			
				150
			 | 
			
			
				             return null; 
			 | 
		
	
		
			
			| 
				153
			 | 
			
				151
			 | 
			
			
				         }); 
			 |