[rules-users] Using Servlet rule hosting instead of JBRMS
All, Just want to know if its possible for one to write a servlet that can host the packages (That is, instead of using JBRMS) that can be polled by RuleAgent.newRuleAgent(Properties prop) with the following prop. url=http://server:port/servletname/packages/ poll=300 localCacheDir=/home/username/resources/rules Regards Wilson ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision Tree input?
Mark Proctor wrote: Wilson O Ojwang wrote: All, Is there something in the works to support Decision Tree Inputs in addition to Decision Table? Someone in the community is working on this in eclipse, but they start and stop work on it, nothing is commited yet so no idea if they will deliver or when. Thanks Mark. Regards Wilson ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Calling EntityManager from DRL--DRL Parser attempts to parse sql query instead of passing as string to createNativeQuery method
David, Here is what I did to make this work. This example assume that you have a Person POJO and you want to query all persons with the age lest than or equal to 20. public class DroolsTest { public static final void main(String[] args) { try { //load up the rulebase RuleBase ruleBase = readRule(); WorkingMemory workingMemory = ruleBase.newStatefulSession(); // Start EntityManagerFactory EntityManagerFactory emf = Persistence.createEntityManagerFactory(persons); // Second unit of work EntityManager newEm = emf.createEntityManager(); EntityTransaction newTx = newEm.getTransaction(); newTx.begin(); workingMemory.setGlobal(entity,newEm); ArrayListPerson presult = new ArrayListPerson(); workingMemory.setGlobal(presult,presult); workingMemory.fireAllRules(); System.out.println(=List Results=); for ( Person p : presult ){ System.out.println(Person: \ + p.getFirstName() + \, + p.getLastName() + \, + p.getAge()); } System.out.println(=End List Results=\n\n); newTx.commit(); newEm.close(); // Shutting down the application emf.close(); } catch (Throwable t) { t.printStackTrace(); } } /** * Please note that this is the low level rule assembly API. */ private static RuleBase readRule() throws Exception { //read in the source Reader source = new InputStreamReader( DroolsTest.class.getResourceAsStream( /Sample.drl ) ); PackageBuilder builder = new PackageBuilder(); builder.addPackageFromDrl( source ); //get the compiled package (which is serializable) Package pkg = builder.getPackage(); //add the package to a rulebase (deploy the rule package). RuleBase ruleBase = RuleBaseFactory.newRuleBase(); ruleBase.addPackage( pkg ); return ruleBase; } } == Here is the rule sample.drl package com.sample import com.sample.DroolsTest.Message; import com.sample.Person; import javax.persistence.EntityManager; global javax.persistence.EntityManager entity; global java.util.ArrayList presult; rule age when $p: Person() from entity.createQuery(from Person p where p.age = 20).getResultList(); then presult.add($p); end == Wilson David Siefert wrote: Hello, I am trying to use the EntityManager within a rule. I pass the EntityManager instance in from my test (currently just a mock of the interface using EasyMock) using setGlobal(em, entitymanager); so in my drls, I have: code global javax.persistence.EntityManager em; /code And then I use this in my LHS of the rule with a from: code rule query-db when SampleObject(property from (em.createNativeQuery(select PROP from SAMPLEOBJECT).getResultList())) then System.out.println(Got an object!); end /code However, when I run my JUnit test, I get an error saying unexpected token 'PROP'. So it looks like the Drools parser is trying to interpret what is in my string. Is there a special way to pass a string to the Java operation? Or can I simply not do this? How would I be able to get a result set from the db to use in pattern matching? The rule is dependent upon data from a table to make a decision. Thanks, David Siefert ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Drools Maven repository error
All, I am getting the following error while updating drools 4.0.7 repo. using the following ant task artifact:dependencies pathId=dependency.class.path dependency groupId=org.drools artifactId=drools-repository version=4.0.7/ /artifact:dependencies OR using artifact:dependencies pathId=dependency.class.path dependency groupId=org.drools artifactId=drools-core version=4.0.7/ dependency groupId=org.drools artifactId=drools-compiler version=4.0.7/ /artifact:dependencies Here is the error == ant Buildfile: build.xml [artifact:dependencies] Downloading: org/drools/drools-repository/4.0.7/drools-repository-4.0.7.pom from central [artifact:dependencies] Downloading: org/drools/drools-repository/4.0.7/drools-repository-4.0.7.pom from central [artifact:dependencies] Downloading: org/drools/drools-repository/4.0.7/drools-repository-4.0.7.jar from central [artifact:dependencies] Downloading: org/drools/drools-repository/4.0.7/drools-repository-4.0.7.jar from central [artifact:dependencies] An error has occurred while processing the Maven artifact tasks. [artifact:dependencies] Diagnosis: [artifact:dependencies] [artifact:dependencies] Unable to resolve artifact: Missing: [artifact:dependencies] -- [artifact:dependencies] 1) org.drools:drools-repository:jar:4.0.7 [artifact:dependencies] [artifact:dependencies] Try downloading the file manually from the project website. [artifact:dependencies] [artifact:dependencies] Then, install it using the command: [artifact:dependencies] mvn install:install-file -DgroupId=org.drools -DartifactId=drools-repository -Dversion=4.0.7 -Dpackaging=jar -Dfile=/path/to/file [artifact:dependencies] [artifact:dependencies] Alternatively, if you host your own repository you can deploy the file there: [artifact:dependencies] mvn deploy:deploy-file -DgroupId=org.drools -DartifactId=drools-repository -Dversion=4.0.7 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] [artifact:dependencies] [artifact:dependencies] Path to dependency: [artifact:dependencies] 1) org.apache.maven:super-pom:jar:2.0 [artifact:dependencies] 2) org.drools:drools-repository:jar:4.0.7 [artifact:dependencies] [artifact:dependencies] -- [artifact:dependencies] 1 required artifact is missing. [artifact:dependencies] [artifact:dependencies] for artifact: [artifact:dependencies] org.apache.maven:super-pom:jar:2.0 [artifact:dependencies] [artifact:dependencies] from the specified remote repositories: [artifact:dependencies] central (http://repo1.maven.org/maven2) [artifact:dependencies] BUILD FAILED /home/wojwang/workspace_5350/HibernateDrools/build.xml:13: Unable to resolve artifact: Missing: -- 1) org.drools:drools-repository:jar:4.0.7 Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=org.drools -DartifactId=drools-repository -Dversion=4.0.7 -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=org.drools -DartifactId=drools-repository -Dversion=4.0.7 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] Path to dependency: 1) org.apache.maven:super-pom:jar:2.0 2) org.drools:drools-repository:jar:4.0.7 -- 1 required artifact is missing. for artifact: org.apache.maven:super-pom:jar:2.0 from the specified remote repositories: central (http://repo1.maven.org/maven2) = Thanks for your help. Regards Wilson ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to Configure Hibernate and use in Drools
All, sorry to ask, but does anyone have a complete example of how to use hibernate query within drools? Regards Wilson RAJA SEKHAR REDDY MAYALURU wrote: hi , i need to connect to data from a .drl file from a rule . i need to get the dynamic data from DB to frmae a rule . I have seen that Drools support Hibernate . so how can i connect to DB from a drl to DB using hibernate . i need to have dynamic (data ) rules in my drl file . we can configure hibernate on top of pojo , my main intrest is to know how to invoke hibernate from a drl file . how to execute named queries in the rule project . please send me the steps to configure hibernate and use it in rules project . thanks for the help in advance regards , Sekhar . ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users