I have a trouble. I want to confirm that a user has logged in.
I take the user data and assert it into RETE.
I don't know how to be sure if I succeed on that; so I create
a query of one answer and ask RETE about the fact I introduced earlier.
If I debug this piece of code it works fine, but it doesn't when doing a
normal execution...
It seems the jess RETE takes a bit to be ready for the query.. and it
returns nothing ?!
How can I made jess faster, or mi code to wait for jess answering a
confirmation?
thankyou
Diego Alonso
.....
try {
//Assert the login
String usr = login.getUser();
String pwd = login.getPassword();
String goal="(SOLUTION::goal (subject "+ usr +") (action login)
(complement "+ pwd +"))";
Fact f1 = this.jess.assertString(goal);
//execute jess-RETE, should I execute only one step?
int n=this.jess.run();
System.out.println(n+" rules have been fired because of this
fact"+f1.toStringWithParens());
//See if the user was logged in or not by querying
this.jess.executeCommand("(defquery who-is-logged (declare (variables
?name))(AUTHORISATION::is-logged (driver ?name)))");
Iterator it = this.jess.runQuery("who-is-logged",new ValueVector().add(new
Value(usr,1)));
if (it.hasNext()){//there is an object to analise
Token t = (Token)it.next();
Fact f=t.topFact();
System.out.println("The fact is " + f.toStringWithParens());
weHaveSomething = true;
}
else{
......}
...
--------------------------------------------------------------------
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]
--------------------------------------------------------------------