How to call Drools as a remote rules executor
by milen igrachev
Hello ,
What I want to do is use java and Drools for its nice rule engine capabilities. Currently I am not using java for my project. I have some implementation business classes and implemented logics that works fine for me, but I want to externalize the rules in BRMS. I gave Drools a try and I like it a lot. However I encounter one obsticle that I want to ask if I can skip. I read most of the Drools documentation and across the net in all the examples that are given we actually need the implementation business classes in order to instantiate facts that we want to feed to the Drools
KieSession . Well what I want is not to duplicate my class model in both my (non java) project and my java Drools project. All I want to keep in my Drools project is the Rules themselves. So is that possible, or I will need to duplicate the models? If anyone knows where I can read some info on that topic links are appriciated! Technical details: I am using Drools 6.0.0 in Eclipse Juno. Big thanks for the support! Best Regards!
Milen
12 years, 3 months
Semantic of rules with not and coincide
by IK81
Dear all,
I am currently stuck with a problem concerning the use of not and
conincide. I want to analyze a stream of error code events from a set of
devices and detect the following situations. Every event has a timestamp
(long), a device id (String) and an error code (String).
What I want to detect is the following
- If I get two events, one with code C1 and one with C2 from a single
device within 1 minute, it represents a special event combination. The
order of their appearence is not relevant.
- If I just get C1 (without the C2 within the time frame), just report
C1
- If I just get C2 (without the C1 within the time frame), just report
C2
I can successfully detect the special event combination with the
following rule
rule "Detect combination"
when
$e1 : Event ($d: device, code == "C1")
$e2 : Event (device == $d, code == "C2", this coincides [1m] $e1)
then
... do some output
end
Then I tried to implement the detection of C1 only as follows
rule "Detect code C1"
when
$e1 : Event ($d: device, code == "C1")
not ( $e2 : Event (device == $d, code == "C2", this coincides [1m]
$e1))
then
... do some other output
end
My understanding of the rule is that it should fire, if I get the event
with code C1 and there is no other event with error code C2 for the same
device that happens within one minute before and after the C1 event. To
my surprise, the rule fires immediately when I insert an event with
error code C1. Shouldn't the implementation wait at least 1 minute to be
sure that no C2 error event will be inserted?
BTW this is how I insert the events in my test case:
clock.advanceTime(70, TimeUnit.SECONDS);
FactHandle handle1 = ksession.insert( new Event(65000, "A", "C1") );
ksession.fireAllRules();
clock.advanceTime( 10, TimeUnit.SECONDS );
FactHandle handle2 = ksession.insert( new Event(75000, "A", "C2") );
ksession.fireAllRules();
clock.advanceTime( 2, TimeUnit.SECONDS );
And this is mainly the output I get:
detected code C1 @ 70000
event id=44b895e5-7287-404b-8204-3de5690b2360 timestamp=65000
device=A code=C1
detected combination @ 80000
event id=44b895e5-7287-404b-8204-3de5690b2360 timestamp=65000
device=A code=C1
event id=fc89715b-fc30-4b12-ab31-a3884dcd4886 timestamp=75000
device=A code=C2
Any ideas concerning an alternative solution are highly welcomed.
Thanks,
Ingo
12 years, 3 months
Need Help with Enumerations and Classpath
by SrjTx
I am trying to create a enumeration that uses a class to populate it, per
*16.10. Data enumerations (drop down list configurations)*.
I have added the jar that contains my class to the drools repository and
added it as a dependency to the project.
When building a guided rule, that object can be selected and the editor will
add
import dbAccessProto.ListAccess;
But, if I create an enumeration in the gui with Fact="a", field="b", and
context = "(new dbAccessProto.ListAccess()).getListOfLists()"
I get the error below.
Is there some other place I need to put the jar flle or specify it?
[Error: unable to resolve class: dbAccessProto.ListAccess from [Module
"deployment.guvnor.war:main" from Service Module Loader]] [Near : {... [
'a.b' : (new dbAccessProto.ListAccess()).ge ....}] ^ [Line: 1, Column: 16]
source:
1. | 'a.b' : (new dbAccessProto.ListAccess()).getListOfLists()
--
View this message in context: http://drools.46999.n3.nabble.com/Need-Help-with-Enumerations-and-Classpa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
Time and Date Picker in Guvnor 5.5.0.Final Decision Table
by nkhogen
Hi,
I am trying to achieve time selection in the web guided decision table of
Guvnor 5.5.0.Final. The preferences.properties files has been updated to
have drools.dateformat=dd-MMM-yyyy hh:mm:ss . When the cell (of
java.util.Date type) in the DT is clicked, the calendar pops up but it has
only days, years and months. When a day is selected, the cell value shows
time of 06-Dec-2013 12:00 and it is not editable. It does not make sense to
show the time when the time cannot be modified at all.
Is there a way to include time as well in the date picker?
org.drools.guvnor.client.common.DatePickerPopUp.java has logic to show time
but somehow it is not used in decision table.
Thanks.
--
View this message in context: http://drools.46999.n3.nabble.com/Time-and-Date-Picker-in-Guvnor-5-5-0-Fi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
6.0.0: Is this the right way to access DB on LHS?
by SrjTx
Before I go down the path of fleshing the rest of this out, I want to know if
this is the right approach.
I have a database with LOTS of data entries. I have a bean that provides
access to that data (ListAccess). It has a method "iHaveOne" that returns
true if the argument is contained in the list.
Is the following how one should go about this?
Other/better ways?
package blah;
import dba.ListAccess; // bean which access database
import goodstuff.Thing; // fact in drools
rule "qqq"
when
$thing:Thing()
$listAccess:ListAccess()
eval( $listAccess.iHaveOne($thing.id) )
then
do stuff
end
--
View this message in context: http://drools.46999.n3.nabble.com/6-0-0-Is-this-the-right-way-to-access-D...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
KieContainer kContainer = ks.newKieContaine ....
by Ravi Gupta
Have a question using drools 6 - I am following the example:
Repo looks fine, rules and artifact in:
.m2/repository/org/acme/brms/acmepoc/1.0
code seems straightforward:
// Install example1 in the local maven repo before to do this
KieContainer kContainer =
ks.newKieContainer(ks.newReleaseId("org.acme.brms", "acmepoc", "1.0"));
but get:
Exception in thread "main" java.lang.RuntimeException: Cannot find
KieModule: org.acme.brms:acmepoc:1.0
at org.drools.compiler.kie.
builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:86)
at
com.sample.KieContainerFromKieRepoExample.go(KieContainerFromKieRepoExample.java:15)
at
com.sample.KieContainerFromKieRepoExample.main(KieContainerFromKieRepoExample.java:26)
12 years, 4 months
Group-by rule without using a fact for grouping purposes
by IK81
Hi,
I am trying to figure out a rule for matching an incoming sequence of
events, but so far I was not really successful. Basically, I want to
process events from devices. Every event has a timestamp (long), an id
(a UUID string), a deviceId and an error code (both are strings).
What I want to have is a simple rule that fires, if a single device
reports a certain error code (e.g. ABCD) 3 times within 5 minutes (i.e.,
getting 3 such events within 5 minutes). So far, I suceeded in counting
the ABCD error codes in the time window as follows:
rule "Detect 3 occurrences of code ABCD for a certain device"
when
Number( intValue == 3 ) from accumulate(
Event( $i : id, code == "ABCD") over window:time( 5m ),
count( $i ) )
then
System.out.println("Raise alarm");
end
This first attempt does not distinguish which device sent the error
code. But how can I express to fire only if the events share the same
deviceId? I found many solutions that use a fact (e.g., a device fact)
to group by the device and do the accumulation. I successfully
implemented the group-by using the following when-part of the rule.
when
Device($deviceId : id)
Number( intValue == 2 ) from accumulate(
Event( $i : id, deviceId == $deviceId, code == "ABCD") over
window:time( 5m ),
count( $i ) )
then
Adding a device fact is however not practical in my case. Are there any
alternatives for expressing this group-by?
Thanks,
Ingo
12 years, 4 months
Http 401 error in drools 5.6.0.CR1
by nkhogen
If a change set has a resource pointing to Guvnor in 5.6.0.CR1, the resource
is rejected because of http 401 because basicAuthentication is enabled by
default.
Previously in 5.5.0.Final, in addResourceMapping(Resource resource, boolean
notify), there was no check for existence of the resource as
if ( notify && newMapping ) { ... }
In 5.6.0.CR1, it has been changed to
if ( notify && newMapping && ((InternalResource)resource).exists() ) { ..}
and the the exists() method simply invokes URL.openStream() which fails with
401 (unauthorized) and the resource is not added.
--
View this message in context: http://drools.46999.n3.nabble.com/Http-401-error-in-drools-5-6-0-CR1-tp40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months