Hello jess users.
I am evaluating jess for using it in online-trading.
I have a java class called "order" in my jess code, which has "order_type"(BUY or SELL) and "qty"(number of shares) attributes.Supposing a client has made several buy orders on the same share, I want to sum all quantities of these orders. I made a defquery which returns all buy or sell orders. The problem is that when I get the elements of the defquery, they are not recognized as instances of 'order' class, so I get the following error: "No method named 'getQty' found" when I try to call the "getQty" method on it.
Is there a way to cast the elements of a defquery into a class?
thank you in advance
Celine
here is part of my jess code:
(defquery searchOrders
(declare (variables ?BUYorSELL))
(order (order_type ?BUYorSELL)))
(deffunction sumBuyQuantities ()
(bind ?listeOrdres (run-query searchOrders "BUY"))
(bind ?result 0)
(while (?listeOrdres hasNext)
(bind ?order (?listeOrdres next))
(bind ?qty (?order getQty))
(bind ?result (+ ?result ?qty))
)
(return ?result)
)
