Drools verifier - redundancy detection
by bitter
I would like to use drools-verifier to detect redundancy in my drl files. But
drools-verifier can not detect redundancy even in simple drl. Maybe I do
something wrong ;/.
*Simple drl file:*
rule "rule 1"
when
$person: Person(age==16, name=="Anna")
then
retract($person);
end
rule "rule 4"
when
$person: Person(age==16, name=="Anna")
then
retract($person);
end
*And my test:*
@Test
public void verifyRules() {
//given
VerifierBuilder vbuilder = VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vbuilder.newVerifier();
verifier.addResourcesToVerify(new
ClassPathResource("qualityVerification.drl", getClass()), ResourceType.DRL);
if (verifier.hasErrors()) {
for(VerifierError ve : verifier.getErrors()) {
System.out.println(ve.getMessage());
}
throw new RuntimeException("ERRORS ");
}
//when
verifier.fireAnalysis();
//then
VerifierReport report = verifier.getResult();
System.out.println(">>>>>>>>> ERRORS: ");
for(VerifierMessageBase vmb : report.getBySeverity(Severity.ERROR)) {
System.out.println(vmb + ". Type: " + vmb.getMessageType());
}
System.out.println(">>>>>>>>> WARNINGS: ");
for(VerifierMessageBase vmb : report.getBySeverity(Severity.WARNING)) {
System.out.println(vmb + ". Type: " + vmb.getMessageType());
}
System.out.println(">>>>>>>>> NOTES: ");
for(VerifierMessageBase vmb : report.getBySeverity(Severity.NOTE)) {
System.out.println(vmb + ". Type: " + vmb.getMessageType());
}
System.out.println(">>>>>>>>> MISSING RANGE: ");
for(MissingRange mr : report.getRangeCheckCauses()) {
System.out.println(mr);
}
}
*OUTPUT:*
>>>>>>>>> ERRORS:
>>>>>>>>> WARNINGS:
Warning id = 0:
faulty : LiteralRestriction from rule [rule 4] value '== Anna'
Rule base covers == Anna, but it is missing != Anna
Cause trace:
. Type: MISSING_EQUALITY
Warning id = 1:
faulty : LiteralRestriction from rule [rule 4] value '== 16'
Rule base covers == 16, but it is missing != 16
Cause trace:
. Type: MISSING_EQUALITY
Warning id = 2:
faulty : LiteralRestriction from rule [rule 1] value '== Anna'
Rule base covers == Anna, but it is missing != Anna
Cause trace:
. Type: MISSING_EQUALITY
Warning id = 3:
faulty : LiteralRestriction from rule [rule 1] value '== 16'
Rule base covers == 16, but it is missing != 16
Cause trace:
. Type: MISSING_EQUALITY
>>>>>>>>> NOTES:
>>>>>>>>> MISSING RANGE:
Gap: (Field 'age' from object type 'Person') Operator = '<' 16 from rule:
[rule 4]
Gap: (Field 'age' from object type 'Person') Operator = '>' 16 from rule:
[rule 4]
Gap: (Field 'age' from object type 'Person') Operator = '<' 16 from rule:
[rule 1]
Gap: (Field 'age' from object type 'Person') Operator = '>' 16 from rule:
[rule 1]
Is it a bug or I do something wrong?
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-verifier-redundancy-detection-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
KnowledgeRuntimeLogger file logger
by bitter
I registered file KnowledgeRuntimeLogger (logging output will be similar to
that generated by the registered WorkingMemoryEventListener) and trying to
analize output xml.
Here is output content:
<object-stream>
<org.drools.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>check education - nvq [1]</activationId>
<rule>check education - nvq</rule>
<declarations>$creditApplication=CreditApplication{scoringResult=0,
clientAge=27, clientEducation=NVQ}(1)</declarations>
</org.drools.audit.event.ActivationLogEvent>
<org.drools.audit.event.ObjectLogEvent>
<type>1</type>
<factId>1</factId>
<objectToString>CreditApplication{scoringResult=0, clientAge=27,
clientEducation=NVQ}</objectToString>
</org.drools.audit.event.ObjectLogEvent>
<org.drools.audit.event.ActivationLogEvent>
<type>6</type>
<activationId>check education - nvq [1]</activationId>
<rule>check education - nvq</rule>
<declarations>$creditApplication=CreditApplication{scoringResult=0,
clientAge=27, clientEducation=NVQ}(1)</declarations>
</org.drools.audit.event.ActivationLogEvent>
<org.drools.audit.event.ActivationLogEvent>
<type>7</type>
<activationId>check education - nvq [1]</activationId>
<rule>check education - nvq</rule>
<declarations>$creditApplication=CreditApplication{scoringResult=20,
clientAge=27, clientEducation=NVQ}(1)</declarations>
</org.drools.audit.event.ActivationLogEvent>
</object-stream>
Could anyone explain me why ACTIVATION_CREATED ( type 4) event is logged
before INSERT( type 1) event?
--
View this message in context: http://drools.46999.n3.nabble.com/KnowledgeRuntimeLogger-file-logger-tp40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
Classnotfound exception on POJO model upload in guvnor
by mpgong
Hello,
I'm trying to use Guvnor but when i upload my POJO models that my DRL needs
i get a classnotfoundexception even though i uploaded the jar that has the
class in it first.
So i basically upload a jar that provides some common classes,utilities,
that have no dependencies other than on the core java libs. This jar
uploads fine. I then upload my model jar that contains my facts and other
classess that the DRL needs and it complains that it can't find the class
from the first common jar even though i uploaded it first and it is loaded
without errors.
How do i load all of my jars so that they are available in Guvnor to use
such as in creating a test scenario? It looks like the jars are upload but
i get the error, i can also build the package but i'm worried it won't work
when i try to use it in my app. Any ideas or insight to this issue.
I'm using drools.5.3.0 final.
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Classnotfound-exception-on-POJO-model-u...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
Plugging custom verification rules into Guvnor
by Joe Ammann
Hi all
coming from another thread [1], Wolfgang pointed me to the Guvnor/Drools
verifier. I am looking now for ways to implement my own verification
rules into Guvnor.
Ideally, I would like to be able to hook into 2 places in Guvnor with
custom rules (maybe these are going actually through the same code path
in Guvnor)
1) When editing BRLs (or other business oriented asset types) and
selecting "Source -> Verify"
2) When doing "Run Analysis" on a package in QA Menu
I searched the documentation and had a quick look at the source of
Guvnor, but wasn't able to quickly find the way to achieve this. Any
pointers?
--
CU, Joe
[1] http://lists.jboss.org/pipermail/rules-users/2012-May/026518.html
13 years, 10 months
Exception on at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300) drools 5.0.1
by Joana Lopes
Hi There,
I'm new to drools and i'm having a problem with a rule which has an OR:
/* Rule 25_OFF
--------------------------------------------------------------------------------
*/
rule "25_OFF"
when
$p1:InferenceFactValue( param!=null, param.parameterName == "sonar_8_cm",
$v1:param.valueFloat >= 10 ) or
$p2:InferenceFactValue( param!=null, param.parameterName == "sonar_8_cm",
$v2:param.valueFloat >= 10 )
then
InferenceUtils.log( LogLevel.DEBUG, InferenceUtils.DROOLS_RULE, "Global
Clock: " + InferenceDateUtils.dateString( globalClock, false ), true, false
);
InferenceUtils.log( LogLevel.DEBUG, InferenceUtils.DROOLS_RULE,
"\t\tRegra 25_OFF " + "25", true, false );
InferenceFactValue[] params = {$p1, $p2};
RuleFire.addEndAlarm( inferenceAgent, droolsEngine, "AlarmPackage",
"25", "25", params, globalClock );
end
No errors in knowledge builder
What happens is:
org.drools.runtime.rule.ConsequenceException: java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:943)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:885)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1086)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:660)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:627)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:183)
at
pt.holos.dva.agents.inference.process.DroolsInferenceEngine.fireAllRules(DroolsInferenceEngine.java:644)
at
pt.holos.dva.agents.inference.process.DroolsInferenceEngine.receiveDataFromBuffer(DroolsInferenceEngine.java:342)
at
pt.holos.dva.agents.inference.process.BufferedDataReceiver.sendDataToDrools(BufferedDataReceiver.java:454)
at
pt.holos.dva.agents.inference.process.BufferedDataReceiver.run(BufferedDataReceiver.java:68)
Caused by: java.lang.NullPointerException
at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300)
at
AlarmPackage.Rule_25_OFF_0ConsequenceInvoker.evaluate(Rule_25_OFF_0ConsequenceInvoker.java:15)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:934)
... 9 more
I've tried to see the source code and the declaration
in org.drools.reteoo.LeftTuple.get(LeftTuple.java:300) is null. Can you
give me some pointers please?
Thank you,
Joana P Lopes
--
LinkedIn - http://pt.linkedin.com/in/joanpl
My Bla Bla Bla: http://joanpl.blogspot.com
.......................................................
The intuitive mind is a sacred gift and the rational mind is a faithful
servant. We have created a society that honors the servant and has
forgotten the gift. Albert Einstein.
"Doubt is not a pleasant condition, but certainty is absurd."
Voltaire
13 years, 10 months
Building Guvnor from source
by anchi
Hi!
I'm trying to build Guvnor from source. I have followed instructions listed
here:
https://github.com/droolsjbpm/droolsjbpm-build-bootstrap/blob/master/READ...
I am able to start the application. After clicking on URL in Development
Mode tab, Guvnor app starts to load but after a few seconds becomes
unresponsive and I get an OutOfMemoryException:
[org.drools.guvnor.Guvnor] Out of memory; to increase the amount of memory,
use the -Xmx flag at startup (java -Xmx128M ...)
I have increased VM memory, however, no matter how much memory I give, it
always throws this exception.
I get this output in the console:
WARN 17-05 16:14:26,525
(RulesRepositoryManager.java:createRulesRepository:65) Creating
RulesRepository with default username.
INFO 17-05 16:14:26,530 (RulesRepositoryConfigurator.java:getInstance:46)
Creating an instance of the RulesRepositoryConfigurator.
WARN 17-05 16:14:30,598
(RulesRepositoryManager.java:createRulesRepository:65) Creating
RulesRepository with default username.
WARN 17-05 16:14:31,764
(RulesRepositoryManager.java:createRulesRepository:65) Creating
RulesRepository with default username.
Any suggestions?
--
View this message in context: http://drools.46999.n3.nabble.com/Building-Guvnor-from-source-tp3999132.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
Displaying BPM node names across lines (easy)
by drdaveg
I can't seem to find this on the site and know I have done it - how do you
wrap a node name in a ruleflow or BPMN graph so it displays on multiple
lines?
I would like "This is a really long process name that I would like to be be
wrapped on multiple lines"
to appear as
This is a really long
process name that
I would like to be be
wrapped on multiple lines
via adding in special characters to the process name. Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Displaying-BPM-node-names-across-lines-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months
Guvnor REST API and XLS decision tables
by anchi
Hi!
I'm wondering how does Guvnor REST api handle Excel decision tables? I'm
using 5.3.1.Final version.
It seems that when I use url for binary e.g.
/http://{guvnor_url}/rest/packages/package_name/assets/excel_table_name/binary/
, I get a source (.xls) file.
And when I use source url e.g.
/http://{guvnor_url}/rest/packages/package_name/assets/excel_table_name/source/
, I get a binary file.
Is this some bug or is it really expected to work this way?
Also, when I try to build binary file (which I get using source url:) )
using knowledge builder I'm getting exceptions, I have tried it in two ways:
1. kbuilder.add(urlResource, ResourceType.DTABLE);
Exception in thread "main"
org.drools.template.parser.DecisionTableParseException: An error occurred
opening the workbook. It is possible that the encoding of the document did
not match the encoding of the reader.
at
org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:90)
at
org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:89)
at
org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:68)
at
org.drools.decisiontable.DecisionTableProviderImpl.compileStream(DecisionTableProviderImpl.java:38)
at
org.drools.decisiontable.DecisionTableProviderImpl.loadFromInputStream(DecisionTableProviderImpl.java:21)
at
org.drools.compiler.DecisionTableFactory.loadFromInputStream(DecisionTableFactory.java:18)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:613)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
at Main.main(Main.java:101)
Caused by: jxl.read.biff.BiffException: Unable to recognize OLE stream
at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:116)
at jxl.read.biff.File.<init>(File.java:127)
at jxl.Workbook.getWorkbook(Workbook.java:268)
at
org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:75)
... 8 more
2. kbuilder.add(urlResource, ResourceType.DRL);
java.lang.IndexOutOfBoundsException: Index: 693, Size: 693
at java.util.ArrayList.get(ArrayList.java:352)
at org.antlr.runtime.CommonTokenStream.LT(CommonTokenStream.java:103)
at org.drools.lang.ParserHelper.reportError(ParserHelper.java:386)
at org.drools.lang.DRLParser.compilationUnit(DRLParser.java:182)
at org.drools.compiler.DrlParser.compile(DrlParser.java:225)
at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:394)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:586)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
at Main.main(Main.java:101)
Exception in thread "main" java.lang.RuntimeException:
org.drools.compiler.DroolsParserException: Unexpected exception raised while
parsing. This is a bug. Please contact the Development team :
Index: 693, Size: 693
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:692)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
at Main.main(Main.java:101)
Caused by: org.drools.compiler.DroolsParserException: Unexpected exception
raised while parsing. This is a bug. Please contact the Development team :
Index: 693, Size: 693
at org.drools.compiler.DrlParser.compile(DrlParser.java:242)
at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:394)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:586)
... 2 more
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-REST-API-and-XLS-decision-tables...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 10 months