Inserting Facts from Json Format
by ihabo01
Hello to all,
I have the following simple rule:
declare FlatData
param1 : String
param2 : String
end
rule "Test"
when
a:FlatData(param1=="something")
then
a.setParam2("hi");
end
And I have the following code to load the rule:
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add(ResourceFactory.newFileResource("myRule.drl"),ResourceType.DRL);
KnowledgeBaseConfiguration kBaseConfig = KnowledgeBaseFactory
.newKnowledgeBaseConfiguration();
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(kBaseConfig);
kBase.addKnowledgePackages(kBuilder.getKnowledgePackages());
StatefulKnowledgeSession session = kBase.newStatefulKnowledgeSession();
session.fireAllRules();
And I have also the following object (in Json) that I would like to insert
as a fact just before firing the rules:
{"object":{" FlatData ":{"param1":"value1","param2":”value2”}}}}
How can I achieve that?
Many thanks in advance for your help
Ihab
--
View this message in context: http://drools.46999.n3.nabble.com/Inserting-Facts-from-Json-Format-tp3570...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
MySQL and Derby issues with Guvnor
by paco
I have changed the defualt Derby DB to MySQL DB for the JacRabbit in Guvnor.
I see this below exception when I try to up the JBOSS 5.0.1 AS and Guvnor.
I get the error when I execute the deployement server Jboss 5.0.1.
And a log file give me the following error:
Class path contains multiple SLF4J bindings.
........................
.........................
org.jboss.seam.servlet.SeamListener org.jboss.seam.InstantiationException:
Could not instantiate Seam component: repositoryConfiguration
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/MySQL-and-Derby-issues-with-Guvnor-tp40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Re: [rules-users] Logical insert and cyclic rules dependences
by zephyr
zephyr wrote
>
> I want to use "magick" of logical insert to keep dynamically changing
> inferred facts up to date. The problem are cyclic dependences:
>
> "a -> b" means "when a than insertLogical( new b()) end"
>
> a -> b
> b -> c
> c -> b
>
> when i insert "a" b and c are correctly inferred (they check equals so it
> doesnt loop)
> but when i remove a they persist, as they make they're rules active
> because ot the cycle
>
> is there a good way to remove such logical facts not supported by inserted
> data?
>
I thought maybe if next reference didnt increase the counter but instead
waited on some data structure, then after a fact and its implications are
removed those facts with counter 0 could see wheather there are any rules
still referencing them. As only one points at a time this should remove
cycles that stay after node is removed, but im not 100% shure it would work,
it can undo and insert again some facts [in my case its not that bad, but as
a general solution seems bad] and probably i would have to edit drools
files.
Hmm maybe there is some kind of better way to deal with this.
--
View this message in context: http://drools.46999.n3.nabble.com/Logical-insert-and-cyclic-rules-depende...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
DEPLOYMENTS Guvnor IN ERROR
by paco
I am using jboss-5.0.1 to deploy guvnor-distribution-5.4.0.Final.
However it does not work and when I read the log file, I find the following
error:
ERROR [org.jboss.system.server.profileservice.ProfileServiceBootstrap]
(main) Failed to load profile: Summary of incomplete deployments (SEE
PREVIOUS ERRORS FOR DETAILS).
I can not understand why this error.
Please suggest.
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/DEPLOYMENTS-Guvnor-IN-ERROR-tp4018482.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Performance issue
by Ini
Hi All,
I have written a code to check the properties of a bean using drools based
rules.
I have created the different rules file where different properties of the
bean will be checked.
The code i have written is a as below:
public static void check(Object details,String rule){
long methodStartTime=System.currentTimeMillis();
Resource resource = new ClassPathResource(RULE_CLASSPATH+rule);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
long startTime=System.currentTimeMillis();
kbuilder.add(resource, ResourceType.DRL );
long endTime=System.currentTimeMillis();
System.out.println("Time taken in add resource in milli seconds
is::"+(endTime-startTime));
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
}
StatelessKnowledgeSession ksession =
kbase.newStatelessKnowledgeSession();
ksession.execute(details);
long methodEndTime=System.currentTimeMillis();
System.out.println("Time taken in Method check in milli seconds
is::"+(methodEndTime-methodStartTime));
}
Here in the check method we have three parameters details this is the bean
whose properties need to be checked in rules file, rule this is the name of
rules file which contains all the rules.
Here the issue is that it takes around 4 seconds for the first time and 1
second for all consecutive requests, and 4 second looks too much time for
validating the rules file that has only 10 rules.
Please let me know we have some better way of doing it in drools
--
View this message in context: http://drools.46999.n3.nabble.com/Performance-issue-tp4017688.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Guvnor Help !!
by abhinay_agarwal
Hey,
I’ve been using GUVNOR for uploading JARS and creating rules using FACTS..
Now I thing I wanna know is - a rule which is GLOBAL AREA, can it be used
to fire rules which are there in some different package ?? (same facts may
be uploaded in both GLOBAL AREA and the PACKAGE !! .. if requirement asks
for it !!! )
Thanks,
Abhinay
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-Help-tp4018290.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
decision Tables - Operators - starts with/end with??
by gok45
Hi Guys,
Have been using Guvnor to create some decision tables and got a few
questions on the use of certain Operators in the Condition Columns - what
value do you put in for matches and sounds like?
Basically i want to create a condition where i can check starts with or end
with in relation to a string, is this possible using the perdefined
operators or how would i acheive this? so if i want to check "Hello" to see
if it starts with "He" - what value would put in the field?
Using Guvnor 5.2.0
Any help would be appreciated!
Gary
--
View this message in context: http://drools.46999.n3.nabble.com/decision-Tables-Operators-starts-with-e...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Possibly Broken drools-core-5.4.0.Final.jar?
by Darin Wilcox
Hello all,
I have an application that was written originally using Drools 5.3.1.Final
that works just fine. I wrote a JUnit test that runs through values
contained in a spreadsheet. Everything was working great. I updated the
application to use Drools 5.4.0.Final and then the test stopped working. I
have debugged the code and here is the exception thrown:
Exception executing consequence for rule "create vcmax" in
org.zoikks.drools: java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1283)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1209)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1442)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at
org.zoikks.drools.xlsx.SampleWorkflowXlsx.check(SampleWorkflowXlsx.java:103)
at
org.zoikks.drools.xlsx.SampleWorkflowXlsx.testSampleXlsxSheets(SampleWorkflowXlsx.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NullPointerException
at ConditionEvaluator0f64b1c63942476d80eb29d1cdffda28.evaluate(Unknown
Source)
at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:167)
at
org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:124)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:337)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:888)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:187)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:181)
at
org.zoikks.drools.Rule_create_vcmax_692832fd6e0547e09b6f632175df45ff.defaultConsequence(Rule_create_vcmax_692832fd6e0547e09b6f632175df45ff.java:7)
at
org.zoikks.drools.Rule_create_vcmax_692832fd6e0547e09b6f632175df45ffDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
org.zoikks.drools.Rule_create_vcmax_692832fd6e0547e09b6f632175df45ffDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1273)
... 26 more
This appears to be a race-condition occurring someplace within the app
because it executes find some times, yet other times a NPE is thrown. The
location where the exception is originating is new to Drools 5.4.0.Final so
there is nothing to compare against in previous versions. Has anyone else
seen this and/or does anyone know how to solve this problem?
I have attached code that is using Drools 5.4.0.Final. To successfully
re-produce the problem, place a breakpoint at
org.drools.rule.constraint.MvelConstraint.evaluate() [Line 167] and then
step through. The exception has been occurring continuously.
Thanks,
- Darin
12 years, 4 months