JESS: [EXTERNAL] Usage of abstract classes in rules

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

JESS: [EXTERNAL] Usage of abstract classes in rules

Tom De Costere
Hello,
 
I currently have some abstract classes which are then implemented in various other classes extending those abstract classes. Now I’ve been trying to get Jess to work with both the abstract class as the implementation class, but somehow Jess cannot reach to the fields/methods specified in the abstract classes?
 
Is this normal functionality of Jess or must I make such a conversion object that contains both the fields from the abstract class as the fields from the implementation class?
 
 
Example:
 
My abstract class AbstractApplicationEvent contains following protected fields:
- eventID
- eventName
- eventTimestamp
 
My subclass ConnectionMadeEvent extending the abstract class above no extra fields, but can be extended in the future.
 
Rule:
 
(defrule connection_established
    (declare (salience 50))
    ?f1 <- (ConnectionMadeEvent (eventID ?id) (eventTimestamp ?eventTimestamp))
    =>
    (assert (Notification (icon "ICON_CONNECTION_ACTIVE") (generationTime ?eventTimestamp) (event ?f1)))
)
 
Error message:
 
SEVERE: Error loading Ruleset from: rules/global_rules.clp
Jess reported an error in routine Jesp.parsePattern.
  Message: No such slot eventTimestamp in template MAIN::ConnectionMadeEvent at token 'eventTimestamp'.
  Program text: ( defrule connection_established ( declare ( salience 50 ) ) ?f1 <- ( ConnectionMadeEvent ( eventID ?id ) ( eventTimestamp  at line 110 in file rules/global_rules.clp.
...
 
 
Thanks in advance!
 
Tom DC
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: JESS: [EXTERNAL] Usage of abstract classes in rules

Friedman-Hill, Ernest

Typically slots come from JavaBeans properties, not fields – i.e., accessor methods like getEventID(). But if you specify “include-variables” when you create a deftemplate from a class, then public (and only public!) member fields will be used as well. See  http://www.jessrules.com/jess/docs/71/memory.html#shadow_facts  .

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Tom De Costere
Sent: Tuesday, May 21, 2013 6:24 AM
To: jess-users
Subject: JESS: [EXTERNAL] Usage of abstract classes in rules

 

Hello,

 

I currently have some abstract classes which are then implemented in various other classes extending those abstract classes. Now I’ve been trying to get Jess to work with both the abstract class as the implementation class, but somehow Jess cannot reach to the fields/methods specified in the abstract classes?

 

Is this normal functionality of Jess or must I make such a conversion object that contains both the fields from the abstract class as the fields from the implementation class?

 

 

Example:

 

My abstract class AbstractApplicationEvent contains following protected fields:

- eventID

- eventName

- eventTimestamp

 

My subclass ConnectionMadeEvent extending the abstract class above no extra fields, but can be extended in the future.

 

Rule:

 

(defrule connection_established

    (declare (salience 50))

    ?f1 <- (ConnectionMadeEvent (eventID ?id) (eventTimestamp ?eventTimestamp))

    =>

    (assert (Notification (icon "ICON_CONNECTION_ACTIVE") (generationTime ?eventTimestamp) (event ?f1)))

)

 

Error message:

 

SEVERE: Error loading Ruleset from: rules/global_rules.clp

Jess reported an error in routine Jesp.parsePattern.

  Message: No such slot eventTimestamp in template MAIN::ConnectionMadeEvent at token 'eventTimestamp'.

  Program text: ( defrule connection_established ( declare ( salience 50 ) ) ?f1 <- ( ConnectionMadeEvent ( eventID ?id ) ( eventTimestamp  at line 110 in file rules/global_rules.clp.

...

 

 

Thanks in advance!

 

Tom DC

 

Loading...