<div dir="ltr"><div><div>By "list collection" you mean the argument you pass to ksession.execute()? This collection ist a one way ticket, not meant to be changed by the execute method.<br><br></div>I'm not sure about what you did when you tried to "change a value on the SearchState object". Only code will tell ;-)<br>
<br></div>-W<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 9 April 2013 19:39, dfsmith <span dir="ltr"><<a href="mailto:dfsmith@llbean.com" target="_blank">dfsmith@llbean.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am new to Drools and Guvnor, so I am likely overlooking something simple.<br>
I am prototyping a proof of concept for integrating Drools into SOLR and<br>
using Guvnor for business rule management.<br>
<br>
I have a Guvnor generated rule that looks like this:<br>
<br>
rule "t1"<br>
dialect "mvel"<br>
when<br>
SearchState( searchTerms == "monitor" )<br>
then<br>
SearchActions fact0 = new SearchActions();<br>
fact0.setUrlRedirect( "junk" );<br>
insert( fact0 );<br>
System.out.println("Created junk!!!");<br>
end<br>
<br>
In a custom SOLR search component, the Drools POC integration code is as<br>
follows:<br>
<br>
try {<br>
<br>
if (rb.stage == ResponseBuilder.STAGE_START) {<br>
<br>
// load package<br>
kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
<br>
kbuilder.add( ResourceFactory.newFileResource(new<br>
File("c:\\data\\guvnor\\searchLatest.pkg")), ResourceType.PKG);<br>
<br>
// create the knowledge base<br>
kbase = KnowledgeBaseFactory.newKnowledgeBase();<br>
<br>
// add the package to the kbase<br>
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );<br>
<br>
System.out.println("In QueryInterceptorComponent.handleRequestBody(). q =<br>
" + rb.req.getParams().get("q"));<br>
<br>
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();<br>
<br>
SearchState searchState = new SearchState();<br>
searchState.setSearchTerms(rb.req.getParams().get("q"));<br>
<br>
//More search state attribute setting here ...<br>
<br>
Collection list = new ArrayList();<br>
list.add(searchState);<br>
<br>
ksession.execute(list);<br>
<br>
System.out.println("EXECUTED RULES");<br>
<br>
}<br>
<br>
} catch(Exception e) {<br>
System.out.println("Caught exception " + e);<br>
}<br>
<br>
Running in Debug mode on Tomcat and searching on "monitor", I can see that I<br>
step through all of the code above without any exceptions. The console<br>
output shows me that the rule successfully fired and that the When condition<br>
was satisfied as it performed the When side of the rule; it wrote the sysout<br>
message I expected.<br>
<br>
In QueryInterceptorComponent.handleRequestBody(). q = monitor<br>
/*Created junk!!!*/<br>
EXECUTED RULES<br>
<br>
But when I then access the list collection again in the debugger, there is<br>
no SearchActions object added to the list. I've also tried modifying the<br>
rule to just change a value on the SearchState object that is driving the<br>
When condition. That doesn't result in any object changes either.<br>
<br>
Can someone point me in the right direction? Again, I'm new at this.<br>
<br>
Any assistance most greatly appreciated.<br>
<br>
Thanks,<br>
<br>
David<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Rules-Firing-Java-Objects-Not-Manipulated-tp4023270.html" target="_blank">http://drools.46999.n3.nabble.com/Rules-Firing-Java-Objects-Not-Manipulated-tp4023270.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br></div>