Drools Applications Google Group
by Mark Proctor
A while back there was a discussion on the volume of posts and the range of post discussions. OptaPlanner already has it’s own google group, which has helped reduce the volume. There is still the discussion on whether to split Drools.
My initial idea is to leave this list for installation, setup, configuration, deployment and getting started (hello world won’t run) - this tends to be a fairly shallow knowledge area, that new people will need to deal with. Then also create a separate google group for those wanting help on writing rule applications, that’s authoring (drl, score cards, decision tables etc) and running (insert, fireAllRules etc); this would become a deep knowledge area. In the google group you would not ask how to install the workbench, or how to deploy your app, or how to setup HA etc.
Thoughts?
We are about to do 6.1 final. For this we are revamping the websites, and sorting out our communications (lists etc) at the same time.
Mark
11 years, 5 months
how to count distinct nested property?
by richardhands
Hi,
I’m trying to wrap my head around how to use a combination of accumulate
from and collect from to get a count of how many unique items there are of a
nested child property and run the RHS of a rule if it’s > 1
So I have
Many of Object A
Each one contains
An object B
An object C
Object C contains a nested child property
So
A
+-+-B
|
+-C – property myId
(many of these in the working memory)
The rule I’m working with right now is
rule "B must only be at 1 myId per day"
when
$b : B()
$c : C()
$aList : ArrayList (size > 1)
from collect(
A(b == $b, c.getDate() == $c.getDate()) )
eval ( RulesUtils.countIdsForC ($aList) > 1 )
then
//fire some rules here
end
and the RulesUtils method is
public static int countIdsForC (List aList)
{
Set<Integer> myIds = new HashSet<Integer>();
for (A a : aList)
{
myIds.add(a.getC().getMyId());
}
return myIds.size();
}
Now I’m well aware that this is sub-optimal, and indeed is firing lots of
extra times and is really (Really) slow. I can vizualise that this should
easily be possible with some combination of compound accumulate and collect
statements, but for the life of me I can’t work out the correct arrangement
(This is actually for use in an optaplanner ruleset so it will potentially
be working on lots of data, over many iterations).
Any suggestions on how to do this the way I know it needs to be, greatfully
appreciated
--
View this message in context: http://drools.46999.n3.nabble.com/how-to-count-distinct-nested-property-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months
Using java enums in guvnor test scenarios (6.0.1Final)
by pacovalsera
Hi all, I'm defining a test scenario within guvnor (now called kie-workbench)
and I'm experiencing some issues about using java enums.
The case is simple, I have a java model (deploying a jar) with a class
having a member of enum type. The enum is defined in the same package but in
a different java file, not an inner class. This is packed in a jar that I
deploy manually uploading the file to the embedded maven repo using the
workbench.
/
public class ClassWithMemberAsEnum { private EnumType enumMember;
/*getters/setters included*/}
public enum EnumType {HELLO, BYE}
/
Then I write a dummy rule with the guided editor like this:
/
import es.shin.test.ClassWithMemberAsEnum;
import es.shin.test.EnumType;
rule "DummyRule"
dialect "mvel"
when
x : ClassWithMemberAsEnum( enumMember == EnumType.HELLO )
then
x.setEnumMember( EnumType.BYE );
end
/
And finally a test scenario inserting a ClassWithMemberAsEnum initialized
with enumMember=EnumType.HELLO and checking that it is changed to
EnumType.BYE after firing all rules.
The error message returned in the reporting console is:
/
EnumTest : [Error: unable to resolve method using strict-mode:
java.lang.Object.es()] [Near : {... es.shin.test.EnumType.HELLO ....}] ^
[Line: 1, Column: 1]
/
I have tried the same case but defining the class in the data modeler and
the enum with the enumeration editor, without using any jar artifact. The
case worked as expected.
Has anybody experienced the same issue? Thanks for your help.
--
View this message in context: http://drools.46999.n3.nabble.com/Using-java-enums-in-guvnor-test-scenari...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months
Question about getObjects() on workspace with defeasible belief system
by Borris
I am trying the Defeasible belief system (it ties in pretty well with
some of how I want
to structure my project).
After fixing many typos, the rule behaviour seems to be what it should
for a defeasible
rule being correctly defeated (my clash spotter doesn't fire, which it
does if any
part of the defeasible chain is broken). Which is all jolly fun and good
and exciting.
But, my question.
I have a simple workspace dump based upon getting all objects (via
ksession.getObjects() )
and then doing my own tidy presentation. This still shows the defeated
fact as present.
So I know there is still record somewhere of the defeated fact, because
if the workspace
changed such that my defeater was retracted, then it needs to make the
fact visible again.
But I wasn't expecting to see it via getObjects(). Is that the intended
behaviour? If so,
is there a way to enquire whether a fact is in the "defeated state" or
not that I could
add to my tidy workspace dumper?
Thanks!
Borris
11 years, 5 months
Problem when I cleaning the production memory.
by braveheart85
Hello guys,
I have a very strange behaviour when i execute this fragment of code:
private void _clearKnowledge() {
try {
Collection<KnowledgePackage> knowledgePackages =
_knowledgeBase.getKnowledgePackages();
for (KnowledgePackage singlePackage : knowledgePackages) {
_log.debug("Removing knowledge in drools engine");
_log.debug("package name: " + singlePackage.getName());
_knowledgeBase.removeKnowledgePackage(singlePackage.getName());
}
} catch (NullPointerException e) {
// TODO An error about a missing package rarely occurs.
_log.warn("Drools Engine has tried to remove a missing knowledge
package.");
}
}
Sporadically the system raise this ugly exception:
Caused by: java.lang.NullPointerException
at
org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:252)
at
org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:459)
at
org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:1099)
at
org.drools.common.AbstractRuleBase.removePackage(AbstractRuleBase.java:1017)
at
org.drools.impl.KnowledgeBaseImpl.removeKnowledgePackage(KnowledgeBaseImpl.java:202)
at
org.titan.frontend.memory.drools.DroolsEngine._clearKnowledge(DroolsEngine.java:304)
I thought about timing issues, but each group of interaction with the engine
is protected with a synchronized method on the facade of the module. The
try-catch is the unique solution that I have found so far.
Thanks
Andrea
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-when-I-cleaning-the-production-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months
Activation-group doubt
by bjs
As far as i understand the activation group fires only one rules for a given
group.
But does it run once for each fact inserted or only just once.
for example i have activation group act1 with 3 rules: rule1,rule2,rule3 and
inserted 4 facts .
But the rule1 runs only once , i wanted rule1 to run for each of the 4 facts
inserted.
--
View this message in context: http://drools.46999.n3.nabble.com/Activation-group-doubt-tp4030388.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months
condition altered while unmarshalling a drl to guided rule
by Sumit Dhaniya
I created a guided rule and when I open it again some conditions which I
wrote using the --Text-- option from drop down are altered.
It seems the issue is only with unmarshalling because condition remains
unaltered in rdrl file until you save it again so everything is fine if you
change it every time you make any change to the rule or save it.
Below is the scenario to reproduce(use 6.1CR2) :-
1) Made a Maven-ized JAR containing the following classes:
package com.demo;
import java.util.List;
public class Foo {
private List myList;
public List getMyList() {
return myList;
}
public void setMyList( List myList ) {
this.myList = myList;
}
}
public class Bar {
private String myString;
public String getMyString() {
return myString;
}
public void setMyString( String myString ) {
this.myString = myString;
}
}
2) Uploaded JAR to the workbench's Artifact Repository
3) Added a project dependency on this artifact
4) Added an Import Suggestion for java.util.List
5) Created a new Guided Rule
6) Imported Foo,Bar and java.util.List (Config tab)
7) Created the following rule:
package org.mortgages;
import java.lang.Number;
import java.util.List;
import org.anstis.MyListClass;
rule "r1"
dialect "mvel"
when
$foo : Foo()
Bar : Bar( myString == $foo.myList.get(1))
then
end
8) Validate rule :- will be vaidated
9) Save and close rule
Now when rule will be opened again this get(1) will change to get moreover
while creating rule get(index) method is not specified in dropdown so
selected -- Text -- option to create the rule.
DRL remains in valid format until overwritten in another save.
--
View this message in context: http://drools.46999.n3.nabble.com/condition-altered-while-unmarshalling-a...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 5 months