This is an excellent application of the JavaBean matching
capability. Basically, what you'll want to do is to write a (fairly
trivial) JavaBean class for each relation which reflects the columns
of that relation. The Jess defclass command will then generate the
deftemplates automatically from these Bean classes. If you have a lot
of different relations, it would be easy enough to write a program to
generate these wrappers for you rather than writing them by hand.

Then it's just a matter of issuing definstance commands to attach each
individual tuple to the Jess fact base.

If the tuples themselves change, it is important that the JavaBean
wrappers support PropertyChangeListeners. This is the mechanism by
which Jess is notified that a given tuple has changed. Your wrappers
will have to receive change notifications from the database, and
broadcast a PropertyChangeEvent in response. If the tuples don't
change, then you can use definstance with the 'static' modifier.

The manual tries to explain all of this stuff in reasonable detail,
but if you have further questions just ask.

I think [EMAIL PROTECTED] wrote:
> 
> Dies ist eine mehrteilige Nachricht im MIME-Format.
> 
> --Boundary_(ID_PGFgH0QEdGnkXDcRco/kdw)
> Content-type: text/plain; charset=iso-8859-1
> Content-transfer-encoding: quoted-printable
> 
> Hello list!
> 
> I have a question concerning something like "persistent facts"...=20
> 
> I deal with problems where I have to reason about states (stored=20
> persistently in relational databases) and events (e.g. insert, update, and =
> 
> delete events in a database). I can subscribe to the events and then=20
> actively assert a corresponding "event fact". The question is how to=20
> efficiently deal with "state facts" corresponding to relational tuples.
> 
> A relation corresponds to a JESS template defining an unordered fact:
> 
> (deftemplate <relation-name>
>   (slot <column-1> ...)
>   ...
>   (slot <column-n> ...)
> )
> 
> Each tuple corresponds to one fact, e.g.:
> 
> (<relation-name> (<column-1> <val-1>) ... (<column-n> <val-n>)).
> 
> How can I use these "state facts" in JESS rules
> - elegantly (yes, I do like "beautiful" code ;-))
> - in a uniform fashion (rendering itself to generation mechanisms)
> - on-demand (without prior "bulk assertion")
> 
> It would be nice to be able to write a rule like the following:
> 
> (defrule myrule
>   (some-triggering-event (key ?val) ...)
>   (<relation-name> (key ?val) (<column-1> <val-1>) ... (<column-n>=20
> <val-n>))
> =3D>
>   (assert (some-other-fact (key ?val) (<column-1> <val-1>) ... (column-n>=20
> <val-n>)))
> )
> 
> What would be the best way to solve this problem? I think a good solution=20
> could be of very general use...
> 
> Greetings
> 
> Thomas Barnekow
> 
> =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=
> =5F=5F=5F=5F=5F=5F=5F
> 
> Dipl.-Inform. Thomas Barnekow
> Fraunhofer IAO, Competence Center Software Technology
> 
> mail:
> Nobelstra=DFe 12, D-70569 Stuttgart, Germany
> phone:
> +49 (0) 711 / 970 - 2346
> fax:
> +49 (0) 711 / 970 - 2300
> email:
> [EMAIL PROTECTED]
> web:
> http://www.swt.iao.fhg.de
> 
> --Boundary_(ID_PGFgH0QEdGnkXDcRco/kdw)
> Content-type: text/html; charset=iso-8859-1
> Content-transfer-encoding: quoted-printable
> 
> 
> 
> 
> <br><font size=3D2 face=3D"sans-serif">Hello list!</font>
> <br>
> <br><font size=3D2 face=3D"sans-serif">I have a question concerning somethi=
> ng like &quot;persistent facts&quot;... </font>
> <br>
> <br><font size=3D2 face=3D"Arial">I deal with problems where I have to reas=
> on about states (stored persistently in relational databases) and events (e=
> .g. insert, update, and delete events in a database). I can subscribe to th=
> e events and then actively assert a corresponding &quot;event fact&quot;. T=
> he question is how to efficiently deal with &quot;state facts&quot; corresp=
> onding to relational tuples.</font>
> <br>
> <br><font size=3D2 face=3D"sans-serif">A relation corresponds to a JESS tem=
> plate defining an unordered fact:<br>
> </font>
> <br><font size=3D2 face=3D"sans-serif">(deftemplate &lt;relation-name&gt;</=
> font>
> <br><font size=3D2 face=3D"sans-serif">&nbsp; (slot &lt;co</font><font size=
> =3D2 face=3D"Arial">lumn-1&gt; ...)</font>
> <br><font size=3D2 face=3D"Arial">&nbsp; ...</font>
> <br><font size=3D2 face=3D"Arial">&nbsp; (slot &lt;column-n&gt; ...)</font>
> <br><font size=3D2 face=3D"Arial">)</font>
> <br>
> <br><font size=3D2 face=3D"sans-serif">Each tuple corresponds to one fact, =
> e.g.:</font>
> <br>
> <br><font size=3D2 face=3D"sans-serif">(&lt;relation-name&gt; (&lt;column-1=
> &gt; &lt;val-1&gt;) ... (&lt;column-n&gt; &lt;val-n&gt;)).</font>
> <br>
> <br><font size=3D2 face=3D"Arial">How can I use these &quot;state facts&quo=
> t; in JESS rules</font>
> <br><font size=3D2 face=3D"Arial">- elegantly (yes, I do like &quot;beautif=
> ul&quot; code ;-))</font>
> <br><font size=3D2 face=3D"Arial">- in a uniform fashion (rendering itself =
> to generation mechanisms)</font>
> <br><font size=3D2 face=3D"Arial">- on-demand (without prior &quot;bulk ass=
> ertion&quot;)</font>
> <br>
> <br><font size=3D2 face=3D"Arial">It would be nice to be able to write a ru=
> le like the following:</font>
> <br>
> <br><font size=3D2 face=3D"Arial">(defrule myrule</font>
> <br><font size=3D2 face=3D"Arial">&nbsp; (some-triggering-event (key ?val) =
> ...)</font>
> <br><font size=3D2 face=3D"Arial">&nbsp; (&lt;relation-name&gt; (key ?val) =
> (&lt;column-1&gt; &lt;val-1&gt;) ... (&lt;column-n&gt; &lt;val-n&gt;))</fon=
> t>
> <br><font size=3D2 face=3D"Arial">=3D&gt;</font>
> <br><font size=3D2 face=3D"Arial">&nbsp; (assert (some-other-fact (key ?val=
> ) (&lt;column-1&gt; &lt;val-1&gt;) ... (column-n&gt; &lt;val-n&gt;)))</font>
> <br><font size=3D2 face=3D"Arial">)</font>
> <br>
> <br><font size=3D2 face=3D"Arial">What would be the best way to solve this =
> problem? I think a good solution could be of very general use...</font>
> <br>
> <br><font size=3D2 face=3D"Arial">Greetings</font>
> <br>
> <br><font size=3D2 face=3D"Arial">Thomas Barnekow</font>
> <br><font size=3D2 face=3D"Arial"><br>
> =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=
> =5F=5F=5F=5F=5F=5F=5F<br>
> <b><br>
> Dipl.-Inform. Thomas Barnekow</b><br>
> Fraunhofer IAO, Competence Center Software Technology<br>
> </font>
> <table>
> <tr valign=3Dtop>
> <td><font size=3D2 face=3D"Arial">mail:</font>
> <td><font size=3D2 face=3D"Arial">Nobelstra=DFe 12, D-70569 Stuttgart, Germ=
> any</font>
> <tr valign=3Dtop>
> <td><font size=3D2 face=3D"Arial">phone:</font>
> <td><font size=3D2 face=3D"Arial">+49 (0) 711 / 970 - 2346</font>
> <tr valign=3Dtop>
> <td><font size=3D2 face=3D"Arial">fax:</font>
> <td><font size=3D2 face=3D"Arial">+49 (0) 711 / 970 - 2300</font>
> <tr valign=3Dtop>
> <td><font size=3D2 face=3D"Arial">email:</font>
> <td><a href=3Dmailto:[EMAIL PROTECTED]><font size=3D2 color=3Dblue=
>  face=3D"Arial"><u>[EMAIL PROTECTED]</u></font></a>
> <tr valign=3Dtop>
> <td><font size=3D2 face=3D"Arial">web:</font>
> <td><a href=3Dhttp://www.swt.iao.fhg.de/><font size=3D2 color=3Dblue face=
> =3D"Arial"><u>http://www.swt.iao.fhg.de</u></font></a></table>
> <br>
> 
> --Boundary_(ID_PGFgH0QEdGnkXDcRco/kdw)--
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
> 
> 


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

---------------------------------------------------------------------
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]
---------------------------------------------------------------------

Reply via email to