Hi,
Just to let you know that I solved my own problem.
I had not realized that with a query like
(defquery q
(declare (variables ?foo))
?x <- (t (foo ?foo))
)
I can access variable ?x and turn it into a fact object (although I have
done it before). I then did something like:
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?
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 [EMAIL PROTECTED]
--------------------------------------------------------------------