Complex DSL constraints to fact
by Sean Su
I do not know if anyone has run into the following scenario. If yes, what
is the solution.
We are following the Drools DSL instruction for "adding constraints to the
fact":
[when]There is a Cheese with=Cheese()
[when]- age is less than {age}=age<{age}
[when]- type is '{type}'=type=='{type}'
[when]- country equal to '{country}'=country=='{country}'
However, Our fact is more complicated than just any Cheese(). We want to
look for all cheeses that follow certain constraints and then count them.
So our first line which defines the fact would be something like this:
[when]There are at least {number} cheese=java.util.Collection(
size>{number} ) from collect ( Cheese())
[when]- age is less than {age}=age<{age}
[when]- type is '{type}'=type=='{type}'
[when]- country equal to '{country}'=country=='{country}'
I am hoping that the "additional" constraints defined after "-" will be
added to Cheese(). However, under Guvnor version 5.5, they are added into
the first (), in this case, it is the Collection (size>{number}).
To be more specific, when adding "age is less than {age}" after "There are
at least {number} cheese", the DRL generated becomes:
java.util.Collection( size>{number}, age<{age} ) from collect ( Cheese())
while what I want is:
java.util.Collection( size>{number} ) from collect ( Cheese(age<{age}))
Is this something Drools DSL and Guvnor can't support at all at this time?
or there is something I am not using correctly?
Thanks in advance.
Sean
12 years, 4 months
Drools Server fails starting when reading brl rules from Guvnor
by gfalco77
Hello Community,
I'm having trouble with the integration of Drools Camel Server and Guvnor..
Version 5.5.0
I've created a JAR which contains POJO and used it in Guvnor to create a BRL
rule (in the future will be created by not technical people)..
The problem is that when I start the drools server , it complains that it
cannot find the class Message defined in the Import of the Rules..
Below the configuration of the Knowledge-servics.xml
<drools:grid-node id="node1" />
<drools:resource-change-scanner id="res-scanner1" interval="15"
enabled="true" />
<drools:kbase id="kbase1" node="node1" />
<drools:kagent id="kagent1" kbase="kbase1" new-instance="false">
<drools:resources>
<drools:resource type="PKG"
source="http://localhost:8082/guvnor/org.drools.guvnor.Guvnor/package/<mypackage>/LATEST"
basic-authentication="enabled" username="admin"
password="admin" />
</drools:resources>
</drools:kagent>
<drools:ksession id="ksession1" type="stateless" kbase="kbase1"
node="node1" />
This is my rule in Guvnor
package mypackage
import mypackage.model.Message
rule "first"
dialect "mvel"
when
Message( text == "a" )
then
Message fact0 = new Message();
fact0.setText( "b" );
insert( fact0 );
end
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Server-fails-starting-when-readi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Persisted stateful sessions and knowledge base changes (revisited)
by dunnlow
I have an Drools 5.5. application that persists a stateful session to a
database. While it was running, I made some changes to my rules (via
Guvnor). When I restarted my application it was no longer able to reload
the persisted session:
*Caused by: java.lang.RuntimeException: Unable to load session snapshot at
org.drools.persistence.session.JPASessionMarshallingHelper.loadSnapshot(JPASessionMarshallingHelper.java:96)*
FYI, I do not use a KnowledgeAgent because I have a lot of events coming in
and I only want to load the knowledgebase changes when my application starts
up.
About two years ago, a discussion occurred on this topic
(https://community.jboss.org/message/628586#628586). Unfortunately, I
haven't seen much since but I am hoping that someone has concurred this
problem (elegantly or otherwise).
Is there a common way to solve this problem? Given a persisted session what
are the steps needed to migrate it to the new ruleset?
Thanks for any insight.
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Persisted-stateful-sessions-and-knowled...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Problem with PKG from guvnor
by calcacuervo
Hi Guys,
I am having a problem using Drools 5.5.
Basically, I have a ksession in stream mode.
I have a rule with an event, like this
when
myfact: EventA( main > 21 ) over window:length (1)
myfact2 : EventA( main <= 21 , this before myfact ) over window:length (2)
I also use a KnowledgeAgent and apply a changeset.
If I declare this rule directly from the changeset, as a Classpath resource,
with resource type DRL, it seems to work fine (the kbase compiles!).
But If I have the rule in a guvnor package, and I put the PKG link in my
changeset, I am getting an error:
Caused by: java.lang.NullPointerException
at
org.drools.base.evaluators.BeforeEvaluatorDefinition$BeforeEvaluator.getInterval(BeforeEvaluatorDefinition.java:268)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.rule.constraint.EvaluatorConstraint.getInterval(EvaluatorConstraint.java:100)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.reteoo.builder.BuildUtils.gatherTemporalRelationships(BuildUtils.java:326)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.reteoo.builder.BuildUtils.calculateTemporalDistance(BuildUtils.java:292)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:119)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:113)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:445)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
It seems that that getOperator() is null in this evaluation:
if ( this.getOperator().isNegated() ) {
I debugged a bit, and it seems the evaluator comes in serialized from
guvnor's package.But in case of getting directly the classpath resource, it
compiles the package and it gets the real operator ok (Operator = 'before')
Do you have any idea of why it could be happening? May I be doing something
wrong? Is this a bug in guvnor?
Thanks in advance!
Demian
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-with-PKG-from-guvnor-tp4025687....
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Using KnowledgeAgent with loadStatefulKnowledgeSession?
by dunnlow
Hello, I am using jBPM 5.4 with persistence and have long running processes
and make make changes to the knowledge base periodically (via drools guvnor
5.5). I use JPAKnowlegeService.loadStatefulKnowledgeSession(...) to retrieve
my existing knowledge session. When I make a change to the rule base (via
drools 5.5 guvnor) and then try to restart my application (and reload the
knowledgesession) I get an exception:
java.lang.RuntimeException: Unable to load session snapshot
at
org.drools.persistence.SessionMarshallingHelper.loadSnapshot(SessionMarshallingHelper.java:96)
.
.
Caused by: java.lang.NullPointerException
at
org.drools.common.Scheduler$activationTimerInputMarshaller.deserialize(Scheduler.java:230)
I am NOT currently using a KnowledgeAgent and it seems like it should be
able to help. I have read over the drools forum and this one and see a few
discussions on the topic (https://community.jboss.org/thread/172818) but
nothing concrete to put me on the right path.
The examples with knowledgeagent I have found assume that I am calling:
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Can someone please show/explain how I can reload an existing persisted
knowledgesession given changes in my knowledge base? (for example, can the
knowledgeagent and JPAKnowlegeService.loadStatefulKnowledgeSession be used
together? If not, do I load the existing statefulknowledgesession by some
other means?)
I am using Spring-based configuration. Thanks for any insight.
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Using-KnowledgeAgent-with-loadStatefulK...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Is drools the solution for my requirement.
by nitind
Hi,
We have 200 odd rules to be configured and wanted to know if drools can
be the optimum solutions. The rules are broadly classified into 2 categories
example 1 : We need to compare invoice no value in 10 documents and
if it matches perform A if it does not match perform B
The catch is the 10 different document may not
have the same Keyword i.e. Invoice no, instead it can Bill no, Invoice
number, Bill #, Inv etc.
example 2 : Search for Key word like Ferrari, BMW , if found need to
check if the individual is Authorized agent.
Question : Can the above be implement using Drools, second is it
worth the effort or just code if else in Java and get it done.
Thanks in advance.
Regards
Nitin
--
View this message in context: http://drools.46999.n3.nabble.com/Is-drools-the-solution-for-my-requireme...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Guvnor - more than one resource in changeset.xml
by rganesh84
I have 2 packages in Guvnor UI having different set of rule assets in it.
pkg1 -> UI rules
pkg2 -> Business rules
In the java application code base, is it mandatory to have 2 change set xmls
with different package contents?
[Java] // for UI rules
kagent.applyChangeSet(ResourceFactory.newClassPathResource("guvnor-tomcat-pkg1-changeset.xml"));
[/Java]
[Java] // for business rules
kagent.applyChangeSet(ResourceFactory.newClassPathResource("guvnor-tomcat-pkg2-changeset.xml"));
[/Java]
Can this be achieved having only one changeset holding multiple packaged
rules?
[change set]
<add>
<resource
source='http://server:8080/guvnor-tomcat/rest/packages/com.pkg1/source'
type='DRL' basicAuthentication="enabled" username="admin" password="admin"
/>
</add>
[/changeset]
If i add a resource to add tag, how do I call it in Java code?
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-more-than-one-resource-in-change...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Line breaks in DSLR
by Stefan
I have written a simple DSLR-rule with a rather long sentence in the
when-part:
-----------------------------------------------------------------
rule "NR3620"
when
tariff number of a position starts with "0301" and the duty measure
is one of "112", "122", "142", "141", "143" and code of condition is "M" and
customs value of position is less than the reference value of condition
then
Error F3620
end
-----------------------------------------------------------------
When I try to break up the sentence into serveral lines for better
readability I get an error. This does not word:
-----------------------------------------------------------------
rule "NR3620"
when
tariff number of a position starts with "0301" and
the duty measure is one of "112", "122", "142", "141", "143" and
code of condition is "M" and
customs value of position is less than the reference value of
condition
then
Error F3620
end
-----------------------------------------------------------------
Here is the corresponding expander (line breaks at the lhs of the 5th
when-clause are ok!):
-----------------------------------------------------------------
[when]condition code=condCode
[when]customs value=custValue
[when]reference value=condAmount
[when]less than=<=
[when]
tariff number of a position starts with {tariffNumberPrefix} and
the duty measure is one of {dutyMeasureCodes} and
code of condition is {conditionCode} and
{propPosition} of position is {comparator} the {propCondition} of condition
=
$measure: DutyMeasure(
tariffCode str[startsWith] {tariffNumberPrefix},
addCodeNumber in ({dutyMeasureCodes})
);
$condition: Condition(
condCode == {conditionCode}
)
$position: ImportPosition(
tariffNumber str[startsWith] {tariffNumberPrefix},
{propPosition} {comparator} $condition.{propCondition}
);
[then]
Error {code} = System.out.println("{code}");
-----------------------------------------------------------------
Any idea how to break up the long DSL-sentence into several lines?
Thx Stefan
--
View this message in context: http://drools.46999.n3.nabble.com/Line-breaks-in-DSLR-tp4025707.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
issue running Drools Expert 6.0 CR2 inside OSGi
by yelin66
I was able to have Drools Expert 5.3 running inside OSGi. However, the
bundles from 5.4/5.5 were having problem even to start inside the OSGi
container. I tried 6.0 CR2 recently, and encountered the following issue:
• Basically, my model class(es) failed to be loaded from the drools-core &
drools-compiler bundles, although the similar code worked in 5.3. I did some
investigation, and noticed that in 5.3 both drools-core & drools-compiler
have “DynamicImport-Package: *” in the bundle’s manifest file. I tried
manually adding “DynamicImport-Package: *” to the bundle’s manifest for 6.0
CR2, and that worked.
So what’s your suggestions on how to run 6.0 bundles inside OSGi? Would
appreciate your feedback.
--
View this message in context: http://drools.46999.n3.nabble.com/issue-running-Drools-Expert-6-0-CR2-ins...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
How Answers to community question Appear on more than one site
by Zahid Ahmed
Hi,
I also wanted to know that I replied on rules-users mailing list and now my answer is listed on http://www.marshut.com/ website instead of jboss community. Some answers get displayed at nabble.com.... Howcome some answers are visible on marshut and some on nabble. I just want to know is this a new technique to balance the load on community site.
Thanks and Best Regards,
Zahid Ahmed
12 years, 4 months