You cannot use a variable (userModel) in a rule's CE. (The scope of each rule and the scope surrounding all rules result in distinct evaluation contexts. The inheritance rule of block structured languages does not apply here.) The rule would have to be written to achieve a local binding, within the LHS, e.g.
(UserModel( OBJECT ?objUserModel )) (test (> (call ?objUserModel getExpertise "command") 2) This will also take care of the notification problem, provided you do proper notification for all updates of UserModel objects, especially those that change the Map you most likely have. As to "design", you'll have to realize that eval results in poorer efficiency since the power of the Rete engine is not put to full use. Whether this is critical or not depends on the number of UserModel facts you have, how frequently they change, etc. -W On Mon, Mar 1, 2010 at 1:03 AM, Manolis Mavrikis <mavri...@gmail.com> wrote: > Dear all, > > > I wonder what would be the best design for a Java class to allow for some > sort of `queries' from JESS rules rather than the usual pattern matching of > facts. > > > For example, I have a class, say User, but it doesn't have pre-specified > member variables. > > I 'd like, if possible, the class to have a method that I could call with a > String parameter and return an appropriate value (say boolean or integer). > > > I am not sure how to achieve that, or even if that is a good design. > > > So I now have: > > > (defclass UserModel um.UserModel) > > (bind ?userModel (fetch USER-MODEL)) > > (definstance UserModel ?userModel dynamic) > > and then was hoping that > > (test (> (call userModel getExpertise "command") 2)) > > would be appropriate. But apart from the fact that I get a "variable used > before definition" error, I also realize that even if this works in some > appropriate syntax, I will have problems with JESS recognizing changes in > the class automatically as there is nothing to make a Bean of or notify in > relation to this particular rule. > > Not sure what's the best way to go about this. Is there an example that > could show me how to do that? > > Thanks, > Manolis > >