loading rules dynamically
by techy
Hi,
If the rules,conditions,consequences have to loaded from the database. I
can think of following two approach. what would be right approach( I will
have upto 1200 rules in the db)
1. Programmatically inject the rules into rule engine using drools API.
2. Read the rules from the database and create drl or dsl file for them and
inject into rule engine.
Thanks
--
View this message in context: http://www.nabble.com/loading-rules-dynamically-tp20274919p20274919.html
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 3 months
Why is a flat object recommended?
by Christie, Blair
In the documents this is dicussed briefly:
"). Object models can often have complex relationships and hierarchies
in them - for rules you will want to simplify and flatten the model
where possible, and let the rule engine infer relationships (as it
provides future flexibility."
What does it mean that the rule engine can infer relationships?
Are there performance reasons for having a flat model?
Cheers,
Blair
15 years, 4 months
Problems setting MySQL for the human task process server....
by Cristiano Gavião
Hi,
I was trying to change the persistence settings for human task process
server for using MySQL instead of H2DB.
I was following the Drools Flows Documentation on chapter 5.1.3.:
Configuring Persistence.(https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBui...
#d0e1157)
I read on docs that I should override the persistence.xml of the
drools-process-enterprise.jar, create the drools.session.conf with
some contents (i don`t undestand` what it is...) and put them on my
project META-INF directory... ok?
I created the files as stated on docs but it didn't work... My
example runned ok, but using the H2DB and not my MYSQL.
// Use persistence.xml configuration
emf =
Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
taskService = new TaskService(emf);
taskSession = taskService.createSession();
server = new MinaTaskServer(taskService);
Thread thread = new Thread(server);
thread.start();
Thread.sleep(500);
System.out.println("Server started ...");
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://
localhost/drools" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="" />
<property name="hibernate.connection.autocommit" value="false" />
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="true" />
</properties>
After some investigation I could see that the example recommended by
Mark Proctor (TaskLifeCycleTest.java, and others that use
MinaTaskServer) use <persistence-unit name = "org.drools.task"> that
is setting on drools-process-task.jar and not the
"org.drools.persistence.jpa" on drools-process-enterprise.jar as
stated on documentation...
First question, which one should I use for use the Drools Flows Server
and Client?
emf =
Persistence.createEntityManagerFactory( "org.drools.task" );
emf =
Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
I test the first option. I changed the persistence.xml file and use
the code below:
// Use persistence.xml configuration
emf = Persistence.createEntityManagerFactory("org.drools.task");
taskService = new TaskService(emf);
taskSession = taskService.createSession();
server = new MinaTaskServer(taskService);
Thread thread = new Thread(server);
thread.start();
Thread.sleep(500);
System.out.println("Server started ...");
Hummm.... It runs and connect well to my MySQL. but now it brings me a
error...
java.lang.IllegalArgumentException: Named query not found:
UnescalatedDeadlines
at
org
.hibernate
.ejb
.AbstractEntityManagerImpl
.createNamedQuery(AbstractEntityManagerImpl.java:108)
at org.drools.task.service.TaskService.<init>(TaskService.java:84)
at org.drools.task.service.TaskService.<init>(TaskService.java:68)
It sounds like it was not possible to find orm.xml that is on META-INF
of drools-process-task.jar.
But when I copy the orm.xml file to my project META-INF it works ok....
Could someone give some ideas how can I solve this problem..
Thanks a lot
Cristiano
15 years, 5 months
CEP functionality
by David Boaz
Dear all,
We posted this question two weeks ago, but with no replies. please forgive
me for posting it again.
In our business, most of the facts have time-stamp attributes. For example,
each laboratory test (a fact) has the time stamp when the sample was taken,
and when the machine produced the result value. In our business-logic, we
often analyze the relation between facts using these attributes.
For example:
1) finding two adjacent labResults with an increasing value
2) checking whether 3 facts are consecutive
3) counting the number of facts fulfilling a specific constraint within a
specific time window.
We were happy to read (in the blog) about the new CEP feature which is about
to be added to drools 5.0.
* Where can we find a more detailed description of CEP functionality in
drools?
* Is it a good idea to use CEP for analyzing historic data (retrieved from
the database)? or is it best for online data.
* Can we use CEP in a stateless session?
* As we understand, CEP attaches to each fact a temporal attribute of the
assertion time. Can we define that a particular attribute (e.g.,
LabResult.samplingDate) will be used as the time stamp? Or, should we assert
the facts by their temporal order, and advance the session-clock
appropriately?
* Can we use CEP to analyze the data in the examples above?
Many thanks for the help, David
--
View this message in context: http://www.nabble.com/CEP-functionality-tp19020709p19020709.html
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 7 months
Stateless session and rule flows
by Yoni Mazar
Hi Guys,
We are trying to work with drools with stateless session (Sequential) and to
apply rule flows.
we use the following code:
//define diagnosis and patient here
...
StatelessSession session = ruleBase.newStatelessSession();
//Here we would like to use: session.startProcess("ruleflow id") but this is
a method which belongs to
//StatefullSession only.
session.execute(new Object[] {diagnosis, patient});
How can we do that in steteless mode?
Thanks,
Yoni
--
View this message in context: http://www.nabble.com/Stateless-session-and-rule-flows-tp17863849p1786384...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 7 months
problem escaping quote in eval
by samlotti
Hello,
I'm trying to construct a rule in drool V4 that contains and eval and a
literal string that may contain quotes. I've tried escaping the quote but
get the error below. The \" works outside an eval.
rule "evalList2"
when
Var( eval( "tt".equals("t\"t")))
then
System.out.println( "evalList2" );
end
Error:
java.lang.NullPointerException:
at
org.drools.rule.PredicateConstraint.createContextEntry(PredicateConstraint.java:201)
at org.drools.reteoo.AlphaNode.createMemory(AlphaNode.java:230)
...
It looks like a change was made to V3 to fix this but doesnt appear to work
in V4, does anyone know how to construct this type of rule?
Thanks
Sam
--
View this message in context: http://www.nabble.com/problem-escaping-quote-in-eval-tp19186015p19186015....
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 8 months
Drools 4.0.7 - Rules not fired
by Benoit VILLAUMIE
Hello,
I am using Drools engine 4.0.7 and Eclipse 3.3 drools plugin.
I have a very basic/dumb problem but I do not understand where my error is :
I have 2 rules
---------------------------------
package poc
import poc.FlashFact;
*rule "HP one"*
when
FlashFact( homepage == "one");
then
System.out.println("*** HP one");
end
*rule "HP commons"*
when
FlashFact();
then
System.out.println("*** HP commons ");
end
----------------------------------
I insert a FlashFact which homepage is set with "one" value.
In my understanding, both rules "HP one" and "HP commons" should be
fired. Instead, only "HP commons" is launched. I have compared with the
Drools State example (which works fine), but I do not notice nothing.
Thanks for your help.
The code of the FlashFact class
---------------------------------
package poc;
public class FlashFact {
public FlashFact() {
this(null);
}
public FlashFact(String homepage) {
this.setHomepage(homepage);
}
private String homepage;
/**
* @return the homepage
*/
public final String getHomepage() {
return this.homepage;
}
/**
* @param homepage the homepage to set
*/
public final void setHomepage(String homepage) {
this.homepage = homepage;
}
}
---------------------------------
The code of the launcher
---------------------------------
package poc;
import java.io.InputStreamReader;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.compiler.PackageBuilder;
public class FlashUndeployedRulesMain {
public static void main(String[] args) throws Exception {
StatefulSession session = null;
WorkingMemoryFileLogger logger = null;
try {
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(new InputStreamReader(
FlashUndeployedRulesMain.class.getClassLoader()
.getResourceAsStream(RULE)));
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(builder.getPackage());
session = ruleBase.newStatefulSession();
logger = new WorkingMemoryFileLogger(
session);
logger.setFileName("log/flash");
// inserting facts
FlashFact HPFrance = new FlashFact("one");
session.insert(HPFrance);
session.fireAllRules();
} finally {
if(session != null) {session.dispose();}
if(logger != null) {logger.writeToDisk();}
}
}
private static final String RULE = "poc/Flash.drl";
---------------------------------
15 years, 8 months
using matches in a collection
by ygaurav
Hi All
i am new to drools and I am hoping that some body can help me out here.
I data in string array and I would like to check if one of the entry starts
with the string I have. How can check it ?
Code is shown below
@java
class ABC {
String[] array = new String[]{"abcdef","ghijkl","mnopqrst"}
}
@drools
rule "check something"
when
$abc : ( ABC.array contains a single entry which start with "abc" )
Is there a way I can do it ? If it is not possible what is way I can achive
it
Thanks
--
View this message in context: http://www.nabble.com/using-matches-in-a-collection-tp18115893p18115893.html
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 8 months