| 
				
			 | 
			
			
				@@ -6,23 +6,11 @@ import com.typesafe.scalalogging.slf4j.Logger 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				6
			 | 
			
			
				 import fr.natan.akkastreamfileprocessingapi.datasource.Datasource.{nameBasics, titleBasics} 
			 | 
		
	
		
			
			| 
				7
			 | 
			
				7
			 | 
			
			
				 import fr.natan.akkastreamfileprocessingapi.models.Models.{Person, TvSerie} 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				8
			 | 
			
			
				 import fr.natan.akkastreamfileprocessingapi.service.AkkaStreamComponents.{ 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				
			 | 
			
			
				-  actorSystem, 
			 | 
		
	
		
			
			| 
				10
			 | 
			
				
			 | 
			
			
				-  buildAllPersonsSink, 
			 | 
		
	
		
			
			| 
				11
			 | 
			
				
			 | 
			
			
				-  buildAllTvSeriesSink, 
			 | 
		
	
		
			
			| 
				12
			 | 
			
				
			 | 
			
			
				-  buildAndValidateSource, 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				
			 | 
			
			
				-  buildPersonFlow, 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				
			 | 
			
			
				-  buildSource, 
			 | 
		
	
		
			
			| 
				15
			 | 
			
				
			 | 
			
			
				-  buildTvSerieFlow, 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				
			 | 
			
			
				-  filterPersonByIdFlow, 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				
			 | 
			
			
				-  filterPersonByNameFlow, 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				
			 | 
			
			
				-  filterTvSerieByIdFlow, 
			 | 
		
	
		
			
			| 
				19
			 | 
			
				
			 | 
			
			
				-  filterTvSerieByPrimaryTitleFlow 
			 | 
		
	
		
			
			| 
				
			 | 
			
				9
			 | 
			
			
				+  actorSystem, buildAllPersonsSink, buildAllTvSeriesSink, buildAndValidateSource, buildPersonFlow, buildSource, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				10
			 | 
			
			
				+  buildTvSerieFlow, filterPersonByIdFlow, filterPersonByNameFlow, filterTvSerieByIdFlow, filterTvSerieByPrimaryTitleFlow 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				11
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				12
			 | 
			
			
				 import fr.natan.akkastreamfileprocessingapi.service.UtilitiesClass.{ 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				
			 | 
			
			
				-  getListOfPersonsForTvSerie, 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				
			 | 
			
			
				-  getListOfPersonsIDByTvSerieID, 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				
			 | 
			
			
				-  getTvSerieIDFuture, 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				
			 | 
			
			
				-  getTvSerieIdByPrimaryTitle 
			 | 
		
	
		
			
			| 
				
			 | 
			
				13
			 | 
			
			
				+  getListOfPersonsForTvSerie, getListOfPersonsIDByTvSerieID, getTvSerieIDFuture, getTvSerieIdByPrimaryTitle 
			 | 
		
	
		
			
			| 
				26
			 | 
			
				14
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				15
			 | 
			
			
				 import org.slf4j.LoggerFactory 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				16
			 | 
			
			
				 import org.springframework.stereotype.Component 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -38,17 +26,17 @@ class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessingFuture { 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				26
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				39
			 | 
			
				27
			 | 
			
			
				   implicit val logger: Logger = Logger(LoggerFactory.getLogger(this.getClass)) 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				28
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				41
			 | 
			
				
			 | 
			
			
				-  override def getPersonByIdFuture(personID: String): Future[Person] = { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				29
			 | 
			
			
				+  override def getPersonByIdFuture(personID: String): Future[Option[Person]] = { 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				30
			 | 
			
			
				     val source: Source[Map[String, String], _] = buildSource(inputFile = nameBasics) 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				31
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				44
			 | 
			
				32
			 | 
			
			
				     val start: Long = System.currentTimeMillis() 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				
			 | 
			
			
				-    val personFuture: Future[Person] = source 
			 | 
		
	
		
			
			| 
				
			 | 
			
				33
			 | 
			
			
				+    val personFuture: Future[Option[Person]] = source 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				34
			 | 
			
			
				       .via(flow = filterPersonByIdFlow(personID = personID)) 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				
			 | 
			
			
				-      .runWith(Sink.head) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				+      .runWith(Sink.headOption) 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				36
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				49
			 | 
			
				37
			 | 
			
			
				     personFuture.andThen({ 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				38
			 | 
			
			
				       case Failure(exception) => logger.info(s"$exception") 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				
			 | 
			
			
				-      case Success(value:Person) => 
			 | 
		
	
		
			
			| 
				
			 | 
			
				39
			 | 
			
			
				+      case Success(value:Option[Person]) => 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				40
			 | 
			
			
				         logger.info(s"$value") 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				41
			 | 
			
			
				         logger.info(s"SUCCESS, elapsed time:${(System.currentTimeMillis() - start) / 1000} sec") 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				42
			 | 
			
			
				     }) 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -56,34 +44,28 @@ class AkkaStreamFileProcessingImpl extends AkkaStreamFileProcessingFuture { 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				44
			 | 
			
			
				     personFuture 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				45
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				46
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				-  override def getPersonByNameFuture(primaryName: String): Future[Person] = { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				+  override def getPersonByNameFuture(primaryName: String):  Future[Option[Person]]= { 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				48
			 | 
			
			
				     val source: Source[Map[String, String], _] = buildSource(inputFile = nameBasics) 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				49
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				62
			 | 
			
				50
			 | 
			
			
				     val start: Long = System.currentTimeMillis() 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				-    val personFuture: Future[Person] = source 
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+    val personFuture:  Future[Option[Person]] = source 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				52
			 | 
			
			
				       .via(flow = filterPersonByNameFlow(primaryName = primaryName)) 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				
			 | 
			
			
				-      .runWith(Sink.head) 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				-    personFuture.onComplete({ 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				
			 | 
			
			
				-      case Failure(exception) => logger.error(s"$exception") 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				
			 | 
			
			
				-      case Success(value: Person) => logger.info(s"$value") 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				
			 | 
			
			
				-        logger.info(s"SUCCESS, elapsed time:${(System.currentTimeMillis() - start) / 1000} sec") 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				
			 | 
			
			
				-    }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+      .runWith(Sink.headOption) 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				54
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				73
			 | 
			
				55
			 | 
			
			
				     personFuture 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				56
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				57
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				76
			 | 
			
				
			 | 
			
			
				-  override def getTvSerieByIdFuture(tvSerieID: String): Future[TvSerie] = { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+  override def getTvSerieByIdFuture(tvSerieID: String): Future[Option[TvSerie]] = { 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				59
			 | 
			
			
				     val source: Source[Map[String, String], _] = buildSource(inputFile = titleBasics) 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				60
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				79
			 | 
			
				61
			 | 
			
			
				     val start: Long = System.currentTimeMillis() 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				
			 | 
			
			
				-    val tvSerieFuture: Future[TvSerie] = source 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+    val tvSerieFuture: Future[Option[TvSerie]]= source 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				63
			 | 
			
			
				       .via(flow = filterTvSerieByIdFlow(tvSerieID = tvSerieID)) 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				
			 | 
			
			
				-      .runWith(Sink.head) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				+      .runWith(Sink.headOption) 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				65
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				84
			 | 
			
				66
			 | 
			
			
				     tvSerieFuture.onComplete({ 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				67
			 | 
			
			
				       case Failure(exception) => logger.info(s"$exception") 
			 | 
		
	
		
			
			| 
				86
			 | 
			
				
			 | 
			
			
				-      case Success(value: TvSerie) => 
			 | 
		
	
		
			
			| 
				
			 | 
			
				68
			 | 
			
			
				+      case Success(value: Option[TvSerie]) => 
			 | 
		
	
		
			
			| 
				87
			 | 
			
				69
			 | 
			
			
				         logger.info(s"$value") 
			 | 
		
	
		
			
			| 
				88
			 | 
			
				70
			 | 
			
			
				         logger.info(s"SUCCESS, elapsed time:${(System.currentTimeMillis() - start) / 1000} sec") 
			 | 
		
	
		
			
			| 
				89
			 | 
			
				71
			 | 
			
			
				     }) 
			 |