I'm passing a string into a drools rule with Drools 7:
public static void main(String[] args) {
log("Starting");
KieContainer kc = KieServices.Factory.get().getKieClasspathContainer();
KieSession ksession = kc.newKieSession("RulesKS");
ksession.insert( "asdf" );
ksession.fireAllRules();
ksession.dispose();
log("Done");
}
Note that I'm setting a "fact" with a value of asdf
to run the rule against. Here is my rule file:
package drools7
function boolean ifContains(String target, String searchFor) {
return target.indexOf(searchFor) != -1;
}
rule "First Rule"
salience 90
when
eval(ifContains("target", "et"))
then
System.out.println("Does contain");
end
Now, when I run my main method I see:
Does contain
printed to stdout, but how would I check in the drools rule file the actual fact that I inserted?
How does this work? I want to see if the fact contains "et", not a scalar value?