Dear All,
I have created simple rule file and created model in that rule file only
package com.sample
import java.lang.String;
declare Rating
rate : int
band : String
name : String
end
query "employee with band E"
ratg : Rating(band == "EBand")
end
rule "for E band"
when
r : Rating( rate == 1)
then
r.setBand("EBand");
System.out.println( "in E band" );
end
rule "for D band"
when
r : Rating( rate == 2)
then
r.setBand("EBand");
System.out.println( "in E band" );
end
rule "for C band"
when
r : Rating( rate == 3)
then
r.setBand("EBand");
System.out.println( "in E band" );
end
rule "for B band"
when
r : Rating( rate == 4)
then
r.setBand("EBand");
System.out.println( "in E band" );
end
At the end I want to know how many employees have got E band and so have
written query for it in the rule file .and obtained the query results as
below
FactType bandType = kbase.getFactType( "com.source", "Rating" );
QueryResults results = ksession.getQueryResults(
"employee with band E");
System.out.println( "we have " + results.size() +
"employee with band E" );
System.out.println( "employee with band E:" );
for (Iterator i = results.iterator();
i.hasNext();) {
QueryResultsRow row =
(QueryResultsRow)i.next();
Object ratg = row.get("rating");
String name = (String) bandType.get( ratg,
"name" );
System.out.println(name);
}
But am getting the result of query as 0 records.
i am inserting objects one by one ( this for testing just purpose ) to
learn how query works.
Can someone plz point out what is wrong.Its Urgent ................
Thanks in advance.
Nilu
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you