diff --git a/adbms/src/main/scala/de/up/hpi/informationsystems/adbms/Dactor.scala b/adbms/src/main/scala/de/up/hpi/informationsystems/adbms/Dactor.scala index 5bf7d9e..a56cdcf 100644 --- a/adbms/src/main/scala/de/up/hpi/informationsystems/adbms/Dactor.scala +++ b/adbms/src/main/scala/de/up/hpi/informationsystems/adbms/Dactor.scala @@ -95,7 +95,6 @@ object Dactor { .map(dactorId => { val msg = messages(dactorId) val answer: Future[Any] = akka.pattern.ask(dactorSelection(system, dactorClass, dactorId), msg)(timeout) - // FIXME: match on result and handle success / failure differences!!!! answer .mapTo[RequestResponseProtocol.Response] .map{ @@ -105,7 +104,12 @@ object Dactor { .map(obj => Relation(obj)) }) - FutureRelation(Future.sequence(results).map(_.reduce( (rel1, rel2) => rel1.union(rel2)))) + FutureRelation(Future.sequence(results).map(relations => + if(relations.isEmpty) + Relation(scala.util.Success(Seq.empty)) + else + relations.reduce( (rel1, rel2) => rel1.union(rel2)) + )) } /** diff --git a/sampleapp/src/main/scala/de/up/hpi/informationsystems/sampleapp/dactors/Cart.scala b/sampleapp/src/main/scala/de/up/hpi/informationsystems/sampleapp/dactors/Cart.scala index 61f574b..af10bb3 100644 --- a/sampleapp/src/main/scala/de/up/hpi/informationsystems/sampleapp/dactors/Cart.scala +++ b/sampleapp/src/main/scala/de/up/hpi/informationsystems/sampleapp/dactors/Cart.scala @@ -96,11 +96,11 @@ object Cart { // FutureRelation: i_id, i_price, i_min_price, fixed_disc val orderRecordBuilder = Record(Set(CartPurchases.inventoryId, CartPurchases.sectionId, CartPurchases.quantity)) - val orderRelation = FutureRelation.fromRecordSeq(Future{orders.map(order => orderRecordBuilder( + val orderRelation = Relation(orders.map(order => orderRecordBuilder( CartPurchases.inventoryId ~> order.inventoryId & CartPurchases.sectionId ~> order.sectionId & CartPurchases.quantity ~> order.quantity - ).build())}) + ).build())) val priceDiscOrder: FutureRelation = priceDisc.innerJoin(orderRelation, (priceRec, orderRec) => priceRec.get(CartPurchases.inventoryId) == orderRec.get(CartPurchases.inventoryId) ) diff --git a/sampleapp/src/test/scala/de/up/hpi/informationsystems/sampleapp/test/dactors/SystemTest.scala b/sampleapp/src/test/scala/de/up/hpi/informationsystems/sampleapp/test/dactors/SystemTest.scala index cde1ca8..b18c5e8 100644 --- a/sampleapp/src/test/scala/de/up/hpi/informationsystems/sampleapp/test/dactors/SystemTest.scala +++ b/sampleapp/src/test/scala/de/up/hpi/informationsystems/sampleapp/test/dactors/SystemTest.scala @@ -168,11 +168,7 @@ class SystemTest(_system: ActorSystem) ).build()))) } - cart42.tell(Cart.AddItems.Request(Seq(Cart.AddItems.Order( - inventoryId = 2001, - sectionId = 14, - quantity = 5 - )), 22), probe.ref) + cart42.tell(Cart.AddItems.Request(Seq.empty, 22), probe.ref) within(200 milliseconds) { probe.expectMsg(Cart.AddItems.Success(Seq(Record(Set(ColumnDef[Int]("session_id")))( ColumnDef[Int]("session_id") ~> 2