Problem sharing declarative model between two packages
by Al
I would like to be able to share a declarative model between two packages.
When I attempt to do this by creating my model in Guvnor's Global Area and
then importing it into each package, I find that instances of the declared
types that are created by rules in one package are not recognized by rules
in the other package.
For example, suppose I create a model in the global area with a declared
type:
declare MyType
field1: String
end
I then import this model into packages "p1" and "p2". I add the following
rule into package "p1":
rule "create it"
when
eval(true)
then
MyType m = new MyType();
insert(m);
end
and I add the following rule into package "p2":
rule "find it"
when
$m : MyType()
then
System.out.println("found it");
end
At runtime, the "create it" rule fires and inserts a "MyType" object.
However, the "find it" rule never fires.
If I add a WorkingMemoryEventListener and look at exactly what is being
inserted, I can see that the "create it" rule is inserting an instance of
p1.MyType. I assume that the "find it" rule is looking for an instance of
p2.MyType and that is why it never fires.
Is there a different way to accomplish this? Or, are declarative models
simply not intended to be shared across packages?
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-sharing-declarative-model-betwe...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Custom Form with DSL
by bhochhi
I were able to launch the custom form in DSL, however the rule condition is
not mapped to corresponding DRL. I don't know if this is a bug or just
something is missing. my DSL mapping looks like this:
[when]
my dsl is "{varName:CF:MyFactType.fieldName}" =
System.out.println("{varName}")
I have working set created then configured custom form for fieldName. All
things working but rule is not validating. When I check drl source, I found
the mapping is not taking place, its still displaying DSL expression in DRL
source instead of displaying:
System.out.println("values from cf")
Any ideas? I have tried this in guvnor 5.4.0.final and 5.5.beta1
--
View this message in context: http://drools.46999.n3.nabble.com/Custom-Form-with-DSL-tp4020207.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Building our own UI for Drools
by kapokfly
Due to some reasons (for example, build a consistent UI within our own
application, easier to work with our own meta data, don't want SSO etc), we
are considering to build our own UI to generate Drools rule file basing on
the user input via the UI , has anyone tried this before? Is there any
library shipped within Drools Gunvor can be used to be easier to work with
Drools rule syntax?
Thanks,
Ivan
-----
Ivan, your Panda, forever
--
View this message in context: http://drools.46999.n3.nabble.com/Building-our-own-UI-for-Drools-tp350884...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Best practice to use heap memory effectively
by mohan
Hi ,
I want to keep events valid for 24 hour period. Per day I’m getting over
1000K events & insert into session. I saw that heap usage increase
drastically because of this. What is the best practice to handle such a
situation? Do I need to choose some caching mechanism?
Meantime I’m using “Statefulknowledge” session and use single session to
cater each event & never call session.dispose(). Will there be any impact?
I’m using Drool 5.1.1, jboss-5.1.0.GA, jre 1.6.0_33
Thanks.
Mohan
--
View this message in context: http://drools.46999.n3.nabble.com/Best-practice-to-use-heap-memory-effect...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Re: [rules-users] JITting error with 5.5.0.CR1
by paulk_asert
I should have added that the script still completes successfully, it is only
the JIT optimization that is having problems and only when some threshold is
reached causing an attempt at performing the optimization - as per
descriptions I have read earlier. The problem is that I thought there was a
fix already in place for this problem if I read the earlier posts correctly
but perhaps I do not know how to enable it.
paulk_asert wrote
> When I run this Groovy script using drools 5.5.0.CR1 with numAnimals = 8
> and numLegs = 120, it works fine. If I set numAnimals = 17 and numLegs =
> 1020 then it fails with a JITting error. I saw a bunch of Jira issues
> related to JITting issues but no open ones seemed to match exactly.
>
> @GrabResolver('https://repository.jboss.org/nexus/content/groups/public-jboss/')
> @Grab('org.drools:knowledge-api:5.5.0.CR1')
> @Grab('org.drools:drools-compiler:5.5.0.CR1')
> @Grab('org.drools:drools-core:5.5.0.CR1')
> @Grab('com.sun.xml.bind:jaxb-xjc:2.2.5.jboss-1')
> @GrabExclude('com.github.relaxng:relaxngDatatype')
> @GrabResolver('http://repo2.maven.org/maven2/')
> @Grab('org.mvel#mvel2;2.1.2.Final')
> @Grab('org.slf4j#slf4j-simple;1.6.4')
> import groovy.transform.Immutable
> import static org.drools.KnowledgeBaseFactory.newKnowledgeBase
> import static
> org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder
> import static org.drools.builder.ResourceType.DRL
> import static org.drools.io.ResourceFactory.newReaderResource
>
> def numAnimals = 8
> def numLegs = 120
> def kbuilder = newKnowledgeBuilder()
> def drl = '''
> dialect "mvel"
> rule "deduce animal counts"
> when
> $crane : Crane( )
> $centipede : Centipede( )
> $tortoise : Tortoise(
> quantity + $crane.quantity + $centipede.quantity == ''' + numAnimals
> + ''',
> quantity * numLegs + $crane.quantity * $crane.numLegs +
> $centipede.quantity * $centipede.numLegs == ''' + numLegs + '''
> )
> then
> System.out.println( "Cranes " + $crane.getQuantity() )
> System.out.println( "Tortoises " + $tortoise.getQuantity() )
> System.out.println( "Centipedes " + $centipede.getQuantity() )
> end
> '''
> kbuilder.add(newReaderResource(new StringReader(drl)), DRL)
> def kbase = newKnowledgeBase()
> kbase.addKnowledgePackages(kbuilder.knowledgePackages)
> def ksession = kbase.newStatefulKnowledgeSession()
>
> (numAnimals + 1).times { n ->
> if (numLegs.intdiv(Crane.numLegs) >= n) {
> ksession.insert(new Crane(n))
> }
> if (numLegs.intdiv(Tortoise.numLegs) >= n) {
> ksession.insert(new Tortoise(n))
> }
> if (numLegs.intdiv(Centipede.numLegs) >= n) {
> ksession.insert(new Centipede(n))
> }
> }
>
> ksession.fireAllRules()
> ksession.dispose()
>
> @Immutable
> class Crane {
> static int numLegs = 2
> int quantity
> }
>
> @Immutable
> class Tortoise {
> static int numLegs = 4
> int quantity
> }
>
> @Immutable
> class Centipede {
> static int numLegs = 100
> int quantity
> }
>
> Here is the error message:
>
> Exception in thread "Thread-1" java.lang.RuntimeException: Exception
> jitting: quantity + $crane.quantity + $centipede.quantity == 17 &&
> quantity * numLegs + $crane.quantity * $crane.numLegs +
> $centipede.quantity * $centipede.numLegs == 1020
> at
> org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:275)
> at
> org.drools.rule.constraint.MvelConstraint.access$200(MvelConstraint.java:51)
> at
> org.drools.rule.constraint.MvelConstraint$ConditionJitter.run(MvelConstraint.java:250)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)
> Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Error
> writing method evaluate
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator.newInstance(ClassGenerator.java:200)
> at
> org.drools.rule.constraint.ASMConditionEvaluatorJitter.jitEvaluator(ASMConditionEvaluatorJitter.java:53)
> at
> org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:273)
> ... 5 more
> Caused by: java.lang.RuntimeException: Error writing method evaluate
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator$MethodDescr.write(ClassGenerator.java:881)
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator.generateBytecode(ClassGenerator.java:128)
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator.generateClass(ClassGenerator.java:144)
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator.newInstance(ClassGenerator.java:198)
> ... 7 more
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
> at org.mvel2.asm.Frame.merge(Frame.java:1373)
> at org.mvel2.asm.Frame.merge(Frame.java:1329)
> at org.mvel2.asm.MethodWriter.visitMaxs(MethodWriter.java:1282)
> at
> org.drools.rule.builder.dialect.asm.ClassGenerator$MethodDescr.write(ClassGenerator.java:879)
> ... 10 more
>
> Is this a known issue?
>
> Thanks, Paul.
--
View this message in context: http://drools.46999.n3.nabble.com/JITting-error-with-5-5-0-CR1-tp4020565p...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Drools Guvnor API information?
by Vikas Hazrati
Hi,
I am looking at using Guvnor for our project where users would be creating
rules using our UI. For this i need to add / modify rule or any asset for
that matter using an api.
Unfortunately, i could not find enough documentation to suggest the best way
to use the REST api, which I guess is provided by Guvnor. Could someone let
me know the location of where i can get some information for this api. I
also see that the issue GUVNOR-1080
(https://issues.jboss.org/browse/GUVNOR-1080) is marked resolved so the api
should exist right? or that we cannot access it remotely until we have the
Atom Pub Interface done?
Help appreciated .
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Guvnor-API-inf...
Sent from the Drools - User mailing list archive at Nabble.com.
12 years
How can I nested rules
by leonardo_josue
Hi everybody, I hope some of you can tell me if I can do something with my
problem.
I have a table in a DB with medical information from too many patients. This
information was captured in paper and after put into the table. The
questions have a sequence, and a few answers depend of other answers, for
example:
P1. Age:____
P2. Gander: 1: Female, 2: Male
--> if P1 >= 12 and P2 = 1 then go to p3, else go to p5
P3. How many times have you been pregnant? 0, 1, 2, 3, 4, 5, ______
--> if number > 1 go to P3 else P5
P4. How many babes were born alive? 0, 1, 2, 3, 4, 5, _______
P5. Do you smoke? 1: no, 2: yes
In the table I have something like this:
mysql> SELECT * FROM table;
|id||P1|P2|P3|P4|P5|STATUS
------------------------------
|1|34|1|3|2|1|NULL
|2|10|1|3|2|1|NULL
|3|21|2|1|1|1|NULL
|4|66|1|0|1|1|NULL
|5|14|2|NULL|NULL|1|NULL
|6|09|1|NULL|NULL|1|NULL
I try to set STATUS = "OK" when information was consistent, i.e.
ID = 2. A girl of 10 years hardly been pregnant 3 times
ID = 3. A man can't get pregnant or abort
ID = 4. A woman can't abort if the number of times she has become pregnant
is zero
I'll try to use Drools to do something like this.
rule "Age and gender women"
no-loop
when
p : Person(p1 >= 12 && p2 = 1)
then
//execute rule "Pregnant"
end
rule "Pregnant"
no-loop
when
p : Person(p3 > 1)
then
//execute rule "Aborts"
end
rule "Pregnant"
no-loop
when
p : Person(p4 <= P3)
then
//it's ok
p.Status = 'OK'
end
Is this possible??? I read than you can't nested rules, but I want to know
if exist some way to do. Since now my thanks for any help.
Best regards.
Leo.
--
View this message in context: http://drools.46999.n3.nabble.com/How-can-I-nested-rules-tp4020488.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Calling queries or collect() from functions
by Miguel Paraz
Hi,
I have a rule like:
rule "Rule1"
when
$fact: Fact1()
$allFacts: ArrayList() from collect(Fact1())
then
insert(new Fact2($allFacts.size()));
end
I want to compute $allFacts inside a function since I will use it across
different rules.
This doesn't work because it is not valid Java syntax:
function int size() {
ArrayList a = ArrayList() from collect(InQueuePredicate());
return a.size();
}
Could I put this in a named query, and call it from a function?
Thanks!
Miguel
12 years