Thanks for the immediate response.
It's obvious that I haven't understand something that must be simple...
First of all I have a JessUser.java file with some beans(such as:reportsLock
and specificUser
which is a User Class Object).
Then I have a JessCaller.java file which implements my userfunction that is
named 'calling':
public class JessCaller implements Userfunction {
public String getName() { return "calling"; } public Value
call(ValueVector vv, Context context) throws JessException { String type
= vv.get(1).stringValue(context); User
specificUser=(User)vv.get(2).javaObjectValue(context);
if(type.equals("DynamicReplanning")){ (new
DynamicReplanning()).executeDynReplanning(specificUser); } return
Funcall.NIL; }}
Finally I have a clp file,which I batch and run it in another java file, with
the rule:
(deftemplate JessUser (declare (from-class JessUser)))
(load-function JessCaller)
(defrule lockRule "Testing the rule." (JessUser { reportsLock == TRUE }
(reportsLock ?value))=> (printout t "ReportsLock: " ?value crlf)(calling
DynamicReplanning specificUser))
where i want to express that if reportsLock bean of JessUser class is
true,call(through calling variable) JessCaller file with a String
argument(DynamicReplanning) and a User Object argument(specificUser).
When I batch and run the clp file,I get the first argument right,but when I get
the java object:
'User specificUser=(User)vv.get(2).javaObjectValue(context);'
I have a java.lang.ClassCastException: java.lang.String cannot be cast to
ProtegeCode.User.
I imagine that the wrong part is in the defrule and I should declare
'specificUser' Object in another way,but I don't know exactly.
Thank You,
Manolis> From: [EMAIL PROTECTED]> Subject: Re: JESS: Userfunction arguments>
Date: Wed, 9 Jan 2008 09:29:13 -0500> To: [email protected]> > To retrieve
a Java object, instead of vv.get(1).stringValue(context), > you'd use
vv.get(2).javaObjectValue(context) . If your Userfunction > is seeing a String
instead of the object you expect, you're probably > calling the function wrong;
can you show us the real function call on > the right-hand-side of this rule,
instead of the pseudocode below?> > > On Jan 9, 2008, at 6:10 AM, manos wrote:>
> >> > Happy new year to everyone.> >> > I have created a defrule:> >> >
(deftemplate JessUser (declare (from-class JessUser)))> > (load-function
JessCaller)> >> > (defrule lockRule> > "Testing the rule."> > ( JessUser {
reportsLock == TRUE } )=> (calling DynamicReplanning> > specificUser )> > )> >>
> and from my JessCaller.java file i want to call DynamicReplanning > >
function> > with argument 'specificUser'.> > I get 'DynamicReplanning' as a
string with:> > vv.get(1).stringValue(context),but i don't know how to get > >
'specificUser'> > which is a java object of a class that I've created(User
Class).> > specificUser is also a bean> > in JessUser.java so that jess can
access it.In all my attempts I > > get it as a> > string.> >> > Thanks for your
time,> > Manolis> >> > -- > > View this message in context:
http://www.nabble.com/Userfunction- > > arguments-tp14709740p14709740.html> >
Sent from the Jess mailing list archive at Nabble.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 owner-jess- > > [EMAIL PROTECTED]> >
--------------------------------------------------------------------> >
---------------------------------------------------------> Ernest
Friedman-Hill> Informatics & Decision Sciences Phone: (925) 294-2154> Sandia
National Labs FAX: (925) 294-2234> 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]>
-------------------------------------------------------------------->
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/