Jess likes to work with JavaBeans properties, and your 'Message' class
isn't very Bean-like, so it will be somewhat awkward to work with. I
think what you want your rule to do is print "valid" whenever a
RoutingMessage with a non-nil "EBID" property is asserted, right? So
your rule could look like
(defrule valid-message
(RoutingMessage (OBJECT ?o&:(neq (?o getProperty "EBID") nil)))
=>
(printout t "valid " crlf))
The lines on the left-hand-side of the rule -- i.e., before the "=>
-- are "patterns" that match facts in working memory. They are not
function calls. In the "{}" syntax you were using (but that I have not
used here) the left-hand-side of each expression is the name of a
property (a "slot") in a fact; since your object has no JavaBeans
properties of interest, this syntax is basically useless (see, I told
you your class would be awkward to work with.)
The syntax I've used here is a color followed by a function call that
returns boolean; it's called a "predicate constraint" and you can read
about that in the manual.
On Feb 17, 2010, at 11:59 AM, Kumar, Amitesh wrote:
Hi guys ,
I new to Jess rules and im struggling on the syntax
What im trying to do is execute a function on an object added to the
rete engine
Object been added
engine.getEngine().add(message);
engine.getEngine().run();
CLP file
1 (import com.standardbank.cibi.infra.zippy.dataobject.*)
2 (import com.standardbank.cibi.infra.zippy.jess.functions.*)
3
4 (deftemplate RoutingMessage (declare (from-class
RoutingMessage)))
5 (load-function GetProperties)
6
7 (defrule valid-message
8 ?ebid<- ( get-property OBJECT "EBID" )
9 (RoutingMessage {?ebid <> nil})
10 =>
11 (printout t "valid " crlf)
12 )
I get an exception
Caused by: Jess reported an error in routine Jesp.parsePattern.
Message: Bad slot name at token '?ebid'.
Program text: ( defrule valid-message ?ebid <- ( get-property
OBJECT "EBID" ) ( RoutingMessage { ?ebid at line 9 in file zippy.clp.
If I remove line 9) then it compiles but the rule doesn’t fire
Can anyone help me out
All my Function does Is
public class GetProperties implements Userfunction
{
public String getName() {
return "get-property";
}
public Value call(ValueVector valueVector, Context context)
throws JessException
{
String key = valueVector.get(2).stringValue(context);
RoutingMessage routingMessage = (RoutingMessage)
valueVector.get(1).externalAddressValue(context);
try {
return new Value(routingMessage.getProperty(key));
} catch (JMSException e) {
e.printStackTrace();
}
return null;
}
}
******************************************************************************************
More information on Standard Bank is available at www.standardbank.com
Everything in this email and any attachments relating to the
official business
of Standard Bank Group Limited and any or all subsidiaries, ("the
Company"), is
proprietary to the Company. It is confidential, legally privileged
and protected
by relevant laws. The Company does not own and endorse any other
content.
Views and opinions are those of the sender unless clearly stated as
being
that of the Company.
The person or persons addressed in this email are the sole authorised
recipient. Please notify the sender immediately if it has
unintentionally,
or inadvertently reached you and do not read, disclose or use the
content
in any way and delete this e-mail from your system.
The Company cannot ensure that the integrity of this email has been
maintained nor that it is free of errors, virus, interception or
interference.
The sender therefore does not accept liability for any errors or
omissions
in the contents of this message which arise as a result of e-mail
transmission.
If verification is required please request a hard-copy version. This
message
is provided for informational purposes and should not be construed
as a
solicitation or offer to buy or sell any securities or related
financial instruments.
******************************************************************************************
This message has been scanned for viruses by BlackSpider MailControl
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs
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].
--------------------------------------------------------------------