On Jun 18, 2007, at 7:19 AM, Henrique Lopes Cardoso wrote:
QueryResult qr = jess.runQueryStar("q", new ValueVector().add(1));
qr.next();
qr.get("x").factValue(engine.getGlobalContext()).getDeftemplate
().getBaseName()
Is there an easier way to do it?
No, not really. There's two parts to this: getting the Fact, and
finding out the template name. For getting facts, your choices are 1)
pattern matching with rules or queries, or 2) iterating through
working memory (optionally using a Filter.) For finding out the
template name, that's the best way.
Henrique
Henrique Lopes Cardoso wrote:
Hi,
I am trying to get the real deftemplate of a fact belonging to a
sub-deftemplate. Something like this:
(deftemplate t
(slot foo) )
(deftemplate t1 extends t
(slot bar))
(deftemplate t2 extends t
(slot qwe))
; The facts
(t1 (foo 1) (bar 2))
(t2 (foo 2) (qwe 1))
Now, I am trying to get the real deftemplate name for a fact:
(defrule r
(t (foo 1))
=>
(printout t "The real deftemplate name for this fact is "
???t1_or_t2??? crlf))
I want to get this from Java, so I thought of defining a defquery and
access its results (is there an easier way, e.g. through the Rete
class
API?).
(defquery get-real-deftemplate-name
(declare (variables ?foo))
?context <- (t (foo ?foo))
; NOW WHAT?
)
There is probably an easy way to do this, right?
Thanks,
Henrique
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users
[EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify owner-jess-
[EMAIL PROTECTED]
--------------------------------------------------------------------
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------