Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to askDactor issue?? #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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))
))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down