<font size="2"><font face="courier new,monospace">Hey Luciano, Meanwhile i tries pumping in the rule with a webdav api (Sardine in my case) and that seems to work and trigger ok for me. this is how i did that</font></font><div>
<font size="2"><font face="courier new,monospace"><br></font></font></div><div><font size="2"><font face="courier new,monospace"><div>public class SardineTest {</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public static void main(String[] args) throws SardineException {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>Sardine sardine = SardineFactory.begin("admin", "admin");</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>List<DavResource> resources = sardine</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>.getResources("<a href="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/packages">http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/packages</a>");</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>for (DavResource res : resources) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>System.out.println(res); // calls the .toString() method.</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>addARule();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private static void addARule() throws SardineException {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Sardine sardine = SardineFactory.begin("username", "password");</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>String ruleDescription = "when Entity(entityName==\"Car1s\") then System.out.println( \"*************rule executed\")";</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>byte[] data = ruleDescription.getBytes();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>sardine.put("<a href="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/packages/Analytics/SimpleDRLRule.drl">http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/packages/Analytics/SimpleDRLRule.drl</a>", data);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>System.out.println("Rule added ...");</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><br></div><div>}</div><div>
<br></div><div><br></div><div>once i did this, I could see the rule added as a technical rule on the guvnor web app ... the and then triggered to rule with something like this</div><div><br></div><div><br></div><div><div>
public class GuvnorTest {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>@Test</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public void testDroolsWithGuvnor() throws Exception {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>KnowledgeBase knowledgeBase = createKnowledgeBase();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>StatefulKnowledgeSession session = knowledgeBase.newStatefulKnowledgeSession();</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>try {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>Entity entity = new Entity();</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>entity.setEntityName("Car1s");</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>session.insert(entity);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>Assert.assertTrue(session.getFactCount() == 1);</div><div>
<span class="Apple-tab-span" style="white-space:pre">                        </span>System.out.println("And the count is " + session.getFactCount());</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div>
<span class="Apple-tab-span" style="white-space:pre">                        </span>session.fireAllRules();</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>System.out.println("And the count is " + session.getFactCount());</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>Assert.assertEquals(1, session.getFactCount());</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>finally {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>session.dispose();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private static KnowledgeBase createKnowledgeBase() {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> KnowledgeAgentConfiguration kaconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span> kaconf.setProperty( "drools.agent.scanDirectories", "false" );</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "test agent", kaconf );</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span> kagent.applyChangeSet( ResourceFactory.newClassPathResource("opal-guvnor.xml"));</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> return kagent.getKnowledgeBase();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div>}</div></div><div><br></div><div>where opal-guvnor.xml is my change set file and goes like this</div>
<div><br></div><div><div><change-set xmlns='<a href="http://drools.org/drools-5.0/change-set">http://drools.org/drools-5.0/change-set</a>'</div><div> xmlns:xs='<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>'</div>
<div> xs:schemaLocation='<a href="http://drools.org/drools-5.0/change-set">http://drools.org/drools-5.0/change-set</a> <a href="http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd">http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd</a>' ></div>
<div> <add></div><div> <resource source='<a href="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Analytics/LATEST.drl">http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Analytics/LATEST.drl</a>' type='DRL' basicAuthentication="enabled" username="admin" password="admin"/></div>
<div> </add></div><div></change-set></div></div><div><br></div><div><br></div><div>not sure if this is the right / best way but at least could add a rule to the repository with this. Ideally, </div><div><br>
</div><div>1) I would like to run a validate / verify to see that the rule has been added correctly, I dont know the api to do that</div><div>2) I would like to rebuild my package and/or create a new snapshot, dont know how to do that either though the rule seems to execute without doing that.</div>
<div>3) Have not given any thoughts about security etc right now ...</div><div><br></div><div><br></div><div>@Drools experts, your thoughts?</div><div><br></div><div>Regards | Vikas</div><div><br></div></font></font><br><div class="gmail_quote">
On Sat, Feb 12, 2011 at 12:20 AM, Luciano A. Andrade <span dir="ltr"><<a href="mailto:andrade.luciano@gmail.com">andrade.luciano@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I think i am in the same situation, i following<br>
<a href="http://www.reverttoconsole.com/blog/java/accessing-drools-5-rules-via-a-restful-api-using-drools-server-and-groovy-restclient/" target="_blank">http://www.reverttoconsole.com/blog/java/accessing-drools-5-rules-via-a-restful-api-using-drools-server-and-groovy-restclient/</a><br>
it recomends<br>
<a href="http://www.amazon.com/JBoss-Drools-Business-Rules-Browne/dp/1847196063/ref=sr_1_1?ie=UTF8&s=books&qid=1259786026&sr=8-1" target="_blank">http://www.amazon.com/JBoss-Drools-Business-Rules-Browne/dp/1847196063/ref=sr_1_1?ie=UTF8&s=books&qid=1259786026&sr=8-1</a><br>
but i found a similar example on the chapter 11 of<br>
<a href="http://www.amazon.com/Drools-JBoss-Rules-Developers-Guide/dp/1847195644/ref=pd_bxgy_b_text_b#reader_1847195644" target="_blank">http://www.amazon.com/Drools-JBoss-Rules-Developers-Guide/dp/1847195644/ref=pd_bxgy_b_text_b#reader_1847195644</a><br>
<br>
i didn't manage to run properly first and foremost since i didn't have<br>
the rules in place as the example requires, and since i have to run it<br>
from PHP, i am working on it, so if you make any progress please i am<br>
really interested.<br>
<br>
Also i don't really understand how it sopuse to run the rules from the<br>
webdav interface.<br>
<div><div></div><div class="h5"><br>
2011/2/11 Vikas Hazrati <<a href="mailto:vhazrati@inphina.com">vhazrati@inphina.com</a>>:<br>
> Hi Luciano,<br>
> Believe me ;) I already did that before posting to the group but the<br>
> information that I found is skeletal or anywhere near it. Do we have the api<br>
> documented somewhere?<br>
> Also i see that people on this group talk about the KnowledgeAgent and<br>
> KBuilder etc. Where is all that documented? I would like to use the api to<br>
> pump rules into the govrnor from my flex UI. Any pointers to the api which I<br>
> can explore to do that are appreciated.<br>
> On the IRC channel i met Rikkola who suggested to use the webdav, I would<br>
> like to explore that but at the same time I would like to see if REST or any<br>
> alternate api suits my need. Again, help appreciated :)<br>
> Regards | Vikas<br>
><br>
> On Fri, Feb 11, 2011 at 8:01 PM, Luciano A. Andrade<br>
> <<a href="mailto:andrade.luciano@gmail.com">andrade.luciano@gmail.com</a>> wrote:<br>
>><br>
>> I think you are looking for the "Drools REST API", google it and you<br>
>> find some documentation.<br>
>><br>
>> 2011/2/11 Vikas Hazrati <<a href="mailto:vhazrati@inphina.com">vhazrati@inphina.com</a>>:<br>
>> ><br>
>> > Hi,<br>
>> ><br>
>> > I am looking at using Guvnor for our project where users would be<br>
>> > creating<br>
>> > rules using our UI. For this i need to add / modify rule or any asset<br>
>> > for<br>
>> > that matter using an api.<br>
>> ><br>
>> > Unfortunately, i could not find enough documentation to suggest the best<br>
>> > way<br>
>> > to use the REST api, which I guess is provided by Guvnor. Could someone<br>
>> > let<br>
>> > me know the location of where i can get some information for this api. I<br>
>> > also see that the issue GUVNOR-1080<br>
>> > (<a href="https://issues.jboss.org/browse/GUVNOR-1080" target="_blank">https://issues.jboss.org/browse/GUVNOR-1080</a>) is marked resolved so the<br>
>> > api<br>
>> > should exist right? or that we cannot access it remotely until we have<br>
>> > the<br>
>> > Atom Pub Interface done?<br>
>> ><br>
>> > Help appreciated .<br>
>> > --<br>
>> > View this message in context:<br>
>> > <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Guvnor-API-information-tp2471798p2471798.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Guvnor-API-information-tp2471798p2471798.html</a><br>
>> > Sent from the Drools - User 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>
>> ><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>
><br>
><br>
><br>
> --<br>
> Best Regards | Vikas<br>
><br>
> Inphina Technologies<br>
> Co-Founder and Technical Architect<br>
> Mobile: +91-9899174194<br>
> Landline: +91-11-25126026<br>
> <a href="http://inphina.com" target="_blank">http://inphina.com</a><br>
> <a href="http://thoughts.inphina.com" target="_blank">http://thoughts.inphina.com</a><br>
> <a href="http://twitter.com/inphina" target="_blank">http://twitter.com/inphina</a><br>
><br>
><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>
><br>
><br>
<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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div>Best Regards | Vikas<br><br></div><div>Inphina Technologies<br>Co-Founder and Technical Architect<br>Mobile: +91-9899174194</div><div>Landline: +91-11-25126026 </div>
<div><br></div><div><a href="http://inphina.com" target="_blank">http://inphina.com</a><br><a href="http://thoughts.inphina.com" target="_blank">http://thoughts.inphina.com</a><br><a href="http://twitter.com/inphina" target="_blank">http://twitter.com/inphina</a></div>
<div><br></div><br>
</div>