multi-tier decision application in drools server
by Yuri
Hi Everyone,
I am trying to use drools 5.5.0 to provide approval/denial for a case. The
best way to represent our business logic is through a workflow where the
user-inserted facts get processed in a particular step, and the RHS of the
rules in that step insert new facts for the next step in the flow, until,
at the end, a decision fact is generated. Looking at the Drools Expert
tutorial, this is very similar to the driver license application, except
that mine has a jbpm flow. As such, I have been using a stateless session
to get my rules to work.
Until recently, I have been working on this problem as a local drools
expert solution, referencing the rules engine and the rules package
directly. However, the final step was going to be to move this solution to
drools server so that the business logic could be accessed through a
RESTful interface. I assumed that the main functionality available in the
drools rules engine would remain in drools server. However, when I saw the
following post, I became concerned that perhaps the functionality I took
for granted in Drools Expert does not exist in Drools Server. The post was
recent and has not gotten a response, but if the response is indeed that
stateless sessions do not work with rule flows in drools server, I was
wondering if anyone had a suggestion for how I would tackle my workflow
problem. Is there another way in drools server (other than salience) to
get different sets of rules to execute in a particular order and come up
with an answer at the end of the work flow?
http://drools.46999.n3.nabble.com/Ruleflow-not-working-with-stateless-ses...
Best,
Yuri
PS. I have been able to reproduce the scenario described by the user in the
post above.
11 years, 10 months
ETA on drools 6?
by kurrent93
Hi
I'm curious, when will drools 6 be released?
Also, about Guvnor-NG. I understand this will be written in Errai. Will it
be possible to host/embed elements as can be done now with Guvnor?
I also understand you will use Git. Will Guvnor also support databases, eg,
postgresql?
Is there any developer documentation for the next Guvnor?
Thanks and regards,
Anton
--
View this message in context: http://drools.46999.n3.nabble.com/ETA-on-drools-6-tp4021695.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
solution equals and hashcode are never called.
by Michiel Vermandel
Hi,
I am still struggling to find why my simple unit test cannot be solved to a zero score solution.
It is easily to see the solution on sight and if I feed it with the prepared solution (in a custom solver phase) it "finds" the optimal solution right away.
I'm trying everything and try to review everything I have written.
It is during that review that I noticed that the equals and hashcode methods of my solution implementation class are never called.
Obviously the solutionEquals and solutionHashCode methods of my planning entity are never called either.
What should I conclude out of that?
Is this a crucial issue? If so, what should I check/change?
I am running Drools Planner 5.5.0.Final on java 1.7.0 on a Windows 7 64bit machine.
Thanks,
Michiel Vermandel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
11 years, 10 months
detecting score traps
by Michiel Vermandel
Hi,
Is there any deterministic way for detecting a score trap in Drools Planner?
I have read about the hill-climbing issue and the ways to reduce the possibility of this but I think it is still possible to encounter, right?
So it would be great to have some red-light flashing when it happens after all :-)
Thanks,
Michiel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
11 years, 10 months
can't copy files to guvnor using webdav
by Yuri
Hi Everyone,
I am having to move assets from one repository to another, and if WebDav
would work for me, I believe that it would be the easiest solution.
I have the default security setup that comes with guvnor 5.5.0 and JBoss AS
7, and I absolutely could not figure out any way to connect from Windows 7.
I was finally able to connect to webDav with BitKinex, however, I cannot
upload anything - I can download files just fine, but when I try to upload,
I get the following error on my server. Am I missing something?
Thanks,
Yuri
Error:
12:08:00,344 ERROR [org.drools.repository.RulesRepository]
(http--127.0.0.1-8080-7) Unable to load a module. :
javax.jcr.PathNotFoundException: *MyNewAsset.txt*
at org.apache.jackrabbit.core.NodeImpl$8.perform(NodeImpl.java:2135)
[jackrabbit-core-2.2.8.jar:2.2.8]
at org.apache.jackrabbit.core.NodeImpl$8.perform(NodeImpl.java:2129)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:200)
[jackrabbit-core-2.2.8.jar:2.2.8]
at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91)
[jackrabbit-core-2.2.8.jar:2.2.8]
at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2129)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.drools.repository.RulesRepository.loadModule(RulesRepository.java:435)
[guvnor-repository-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.repository.RulesRepository$Proxy$_$$_WeldClientProxy.loadModule(RulesRepository$Proxy$_$$_WeldClientProxy.java)
[guvnor-repository-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.files.WebDAVImpl.loadPackageFromRepository(WebDAVImpl.java:912)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.files.WebDAVImpl.getStoredObjectForReadOnlyPackages(WebDAVImpl.java:473)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.files.WebDAVImpl.getStoredObject(WebDAVImpl.java:409)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.guvnor.server.files.WebDAVImpl$Proxy$_$$_WeldClientProxy.getStoredObject(WebDAVImpl$Proxy$_$$_WeldClientProxy.java)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at net.sf.webdav.methods.DoPut.execute(DoPut.java:101)
[webdav-servlet-2.0.1.jar:]
at net.sf.webdav.WebDavServletBean.service(WebDavServletBean.java:129)
[webdav-servlet-2.0.1.jar:]
at
org.drools.guvnor.server.files.WebdavServlet.service(WebdavServlet.java:73)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
[weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
[solder-impl-3.1.1.Final.jar:3.1.1.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)
[solder-impl-3.1.1.Final.jar:3.1.1.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
[jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
[jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
[jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_35]
11 years, 10 months
Drools 5.4.0.FINAL and OSGI. Unable to instantiate service for Class 'org.drools.concurrent.ExecutorProvider'
by Per Sterner
Hello,
I have been using Drools 5.3.0.FINAL until now. I am upgrading my
running system with 5.4.0.FINAL. The bundles are all runing. I got some
error messages and tried to reduce the problem and created a simple bundle.
The code only inserts facts and after 20 facts I get the following error:
[ERROR] [System] - Exception in thread "Thread-8"
java.lang.ExceptionInInitializerError
[ERROR] [System] - at
org.drools.concurrent.ExecutorProviderFactory.getExecutorProvider(ExecutorProviderFactory.java:12)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint$ExecutorHolder.<clinit>(MvelConstraint.java:208)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint.jitEvaluator(MvelConstraint.java:199)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:164)
[ERROR] [System] - at
org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:124)
[ERROR] [System] - at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
[ERROR] [System] - at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
[ERROR] [System] - at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
[ERROR] [System] - at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:337)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:123)
[ERROR] [System] - at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:53)
[ERROR] [System] - at
de.pelle7.drools.test1.simpletest.SimpleTestDrools$1.run(SimpleTestDrools.java:74)
[ERROR] [System] - Caused by: java.lang.IllegalArgumentException: Unable
to instantiate service for Class 'org.drools.concurrent.ExecutorProvider'
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:162)
[ERROR] [System] - at
org.drools.concurrent.ExecutorProviderFactory$ExecutorProviderHolder.<clinit>(ExecutorProviderFactory.java:8)
[ERROR] [System] - ... 14 more
[ERROR] [System] - Caused by: java.lang.IllegalArgumentException: Unable
to instantiate 'org.drools.concurrent.ExecutorProviderImpl'
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.newInstance(ServiceRegistryImpl.java:213)
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.call(ServiceRegistryImpl.java:205)
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:160)
[ERROR] [System] - ... 15 more
[ERROR] [System] - Caused by: java.lang.ClassNotFoundException:
org.drools.concurrent.ExecutorProviderImpl
[ERROR] [System] - at
org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
[ERROR] [System] - at
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
[ERROR] [System] - at
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
[ERROR] [System] - at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
[ERROR] [System] - at java.lang.ClassLoader.loadClass(Unknown Source)
[ERROR] [System] - at java.lang.Class.forName0(Native Method)
[ERROR] [System] - at java.lang.Class.forName(Unknown Source)
[ERROR] [System] - at
org.drools.util.ServiceRegistryImpl$ReflectionInstantiator.newInstance(ServiceRegistryImpl.java:210)
[ERROR] [System] - ... 17 more
The Rule file:
package de.pelle7.drools.test1.users.rules.impl;
import de.pelle7.drools.test1.simpletest.*;
import org.jbpm.ruleflow.instance.*;
rule "Funny Rule #1"
dialect "java"
when
$testObject : TestObjectA( value == 0 ) from entry-point "my_entry"
then
System.err.println("New Item: " + $testObject);
retract($testObject);
end
If I change the line
--> $testObject : TestObjectA( value == 0 ) from entry-point "my_entry"
to
--> $testObject : TestObjectA( ) from entry-point "my_entry"
there is no problem.
In the java code i initialize a Drools Session programatically and add
one rule file:
package de.pelle7.drools.test1.simpletest;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactoryService;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderConfiguration;
import org.drools.builder.KnowledgeBuilderFactoryService;
import org.drools.builder.ResourceType;
import org.drools.definition.KnowledgePackage;
import org.drools.io.ResourceFactory;
import org.drools.io.ResourceFactoryService;
import org.drools.runtime.StatefulKnowledgeSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SimpleTestDrools {
public static final String DEFAULT_ENTRY = "my_entry";
private static Logger logger =
LoggerFactory.getLogger(SimpleTestDrools.class);
private StatefulKnowledgeSession droolsSession;
private KnowledgeBuilderFactoryService
droolsKnowledgeBuilderFactoryService;
private ResourceFactoryService droolsResourceFactoryService;
private KnowledgeBaseFactoryService droolsKnowledgeBaseFactoryService;
public static Logger getLogger() {
return logger;
}
public StatefulKnowledgeSession getDroolsSession() {
return droolsSession;
}
public void start() {
KnowledgeBuilder kbuilder =
getDroolsKnowledgeBuilderFactoryService().newKnowledgeBuilder();
KnowledgeBaseConfiguration config =
getDroolsKnowledgeBaseFactoryService().newKnowledgeBaseConfiguration();
//config.setOption( MBeansOption.ENABLED );
KnowledgeBase knowledgeBase =
getDroolsKnowledgeBaseFactoryService().newKnowledgeBase(config);
droolsSession = knowledgeBase.newStatefulKnowledgeSession();
LinkedList<URI> resourcesList = new LinkedList<URI>();
try {
resourcesList.add(
getClass().getResource("MyDrools.drl").toURI() );
addResources(droolsSession,
getDroolsKnowledgeBuilderFactoryService(),
resourcesList);
} catch (Exception e) {
e.printStackTrace();
}
new Thread() {
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
System.out.println("Go 1");
for (int i = 0; i< 1000; i++) {
System.out.println(i);
getDroolsSession().getWorkingMemoryEntryPoint(DEFAULT_ENTRY).insert(new
TestObjectA());
getDroolsSession().fireAllRules();
try {
Thread.sleep(1);
} catch (InterruptedException e) {
}
}
System.out.println("Go 2");
};
}.start();
System.err.println("wait");
//getDroolsSession().fireUntilHalt();
}
public static void addResources(
StatefulKnowledgeSession droolsSession,
KnowledgeBuilderFactoryService
droolsKnowledgeBuilderFactoryService,
List<URI> resources
) throws MyDroolsException {
getLogger().debug("Drools: Register: " + resources);
MyDroolsException exception = null;
KnowledgeBuilderConfiguration lnowledgeBuilderConfiguration =
droolsKnowledgeBuilderFactoryService.newKnowledgeBuilderConfiguration();
HashSet<URI> defects = new HashSet<URI>();
KnowledgeBuilder kbuilder = null;
while (true) {
URI uriError = null;
kbuilder =
droolsKnowledgeBuilderFactoryService.newKnowledgeBuilder(lnowledgeBuilderConfiguration);
try {
Iterator<URI> it = resources.iterator();
while (it.hasNext()) {
URI uri = (URI) it.next();
if (defects.contains(uri)) {
continue;
}
StringBuilder builder = new StringBuilder();
builder.append("Adding drools file '" +
uri.toString() + "'");
URL url = uri.toURL();
InputStream iStream = url.openStream();
ResourceType resourceType;
String path = uri.getPath().toLowerCase();
resourceType =
ResourceType.determineResourceType(path);
getLogger().debug(builder.toString());
kbuilder.add(ResourceFactory.newInputStreamResource(iStream), resourceType);
// Check the builder for errors
if (kbuilder.hasErrors()) {
uriError = uri;
//getLogger().error(kbuilder.getErrors().toString());
String errorMessage =
kbuilder.getErrors().toString();
kbuilder.getErrors().clear();
throw new MyDroolsException(errorMessage);
}
try {
iStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Throwable e) {
if (uriError != null) {
defects.add(uriError);
}
String msg = "Error in Resource '" + uriError + "'";
getLogger().error(msg);
e.printStackTrace();
if (exception != null) {
exception = new MyDroolsException(msg, exception);
} else {
exception = new MyDroolsException(msg);
}
exception = new MyDroolsException(e.getMessage(),
exception);
continue;
}
// All done!
break;
}
final Collection<KnowledgePackage> pkgs =
kbuilder.getKnowledgePackages();
droolsSession.getKnowledgeBase().addKnowledgePackages(pkgs);
if (exception != null) {
throw new MyDroolsException("Error while adding
resources!", exception);
}
}
public KnowledgeBuilderFactoryService
getDroolsKnowledgeBuilderFactoryService() {
return droolsKnowledgeBuilderFactoryService;
}
public void setDroolsKnowledgeBuilderFactoryService(
KnowledgeBuilderFactoryService
droolsKnowledgeBuilderFactoryService) {
this.droolsKnowledgeBuilderFactoryService =
droolsKnowledgeBuilderFactoryService;
}
public ResourceFactoryService getDroolsResourceFactoryService() {
return droolsResourceFactoryService;
}
public void setDroolsResourceFactoryService(
ResourceFactoryService droolsResourceFactoryService) {
this.droolsResourceFactoryService = droolsResourceFactoryService;
}
public KnowledgeBaseFactoryService
getDroolsKnowledgeBaseFactoryService() {
return droolsKnowledgeBaseFactoryService;
}
public void setDroolsKnowledgeBaseFactoryService(
KnowledgeBaseFactoryService
droolsKnowledgeBaseFactoryService) {
this.droolsKnowledgeBaseFactoryService =
droolsKnowledgeBaseFactoryService;
}
}
Some of the bundles in my runtime are:
39 ACTIVE org.drools.core_5.4.0.Final
66 ACTIVE org.drools.compiler_5.4.0.Final
78 ACTIVE org.drools.templates_5.4.0.Final
94 ACTIVE org.drools.internalapi_5.4.0.Final
136 ACTIVE org.drools.decisiontables_5.4.0.Final
189 ACTIVE org.drools.api_5.4.0.Final
191 ACTIVE org.mvel2_2.1.0.drools16
6 ACTIVE org.jbpm.flow.core_5.3.0.Final
13 ACTIVE org.jbpm.bpmn2_5.3.0.Final
71 ACTIVE org.jbpm.flow.builder_5.3.0.Final
142 ACTIVE org.jbpm.flow-persistence-jpa_5.3.0.FINAL
regards,
Per Sterner
11 years, 10 months
Implementation example
by André Fróes
Hello everyone. Is there anywhere I can get a full example of simplest
planner implementation, such as nqueens? (apart of example folder)
Thanks
11 years, 10 months
Drools Expert does not sort integers correctly
by John Smith
I am new to Drools and am trying to get the sample program to work. This
sample is given in the drools documentation
http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_....
This drool rule is expected to sort integers. I just changed the numbers
from what are given in the sample and they do not get sorted as expected.
Tried using drools version 5.5.0, 5.5.1 and the master 6.0.0, but got the
same wrong results.
Following is the main code:
package com.sample;
public class Example2 {
public static void main(String[] args) throws Exception {
Number[] numbers = new Number[] { wrap(5), wrap(6), wrap(4),
wrap(1), wrap(2) };
new RuleRunner().runRules(new String[] { "Example3.drl" }, numbers);
}
private static Integer wrap(int i) {
return new Integer(i);
}
}
The RuleRunner class is the same as given in the example and I do not think
I should give that here, since it will clutter the question. It simply
creates the KnowledgeBase, stateful session, inserts the facts as given in
the 'numbers' array above and then calls fireAllRules method on the session.
The rule file (Example3.drl) is:
rule "Rule 04"
dialect "mvel"
when
$number : Number()
not Number(intValue < $number.intValue)
then
System.out.println("Number found with value: " + $number.intValue());
retract($number);
end
The output I get is as follows:
Loading file: Example3.drl
Inserting fact: 5
Inserting fact: 6
Inserting fact: 4
Inserting fact: 1
Inserting fact: 2
Number found with value: 1
Number found with value: 4
Number found with value: 2
Number found with value: 5
Number found with value: 6
Not the correct expected ascending sorted order.
What might I be doing wrong? I cannot imagine that the drools rule engine
would be broken at this basic level.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Expert-does-not-sort-integers-co...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
Re: [rules-users] [BAD Bug] incorrect evaluation of LHS using Integer/Number intValue
by Wolfgang Laun
[Sorry - the previous email "escaped" before I was complete.]
This is a self-contained DRL demonstrating the erroneous handling of
a condition involving Integer.intValue (same: Number.intValue), not
and retract, which is meant to sort the integers. This fails with 5.5.0,
but works correctly with 5.4.0 and previous versions.
rule init
salience 9999
when
then
insert( Integer.valueOf( 10 ) );
insert( Integer.valueOf( 50 ) );
insert( Integer.valueOf( 60 ) );
insert( Integer.valueOf( 40 ) );
insert( Integer.valueOf( 20 ) );
end
rule "Rule 04"
when
$number : Integer( $i: intValue )
not Integer(intValue < $i)
then
System.out.println("Number found with value: " + $number.intValue());
retract($number);
end
>
> On 17/01/2013, Wolfgang Laun <wolfgang.laun(a)gmail.com> wrote:
>> This BAD bug was introduced on the way from 5.4.0 to 5.5.0 (and seems
>> to have sneaked into 6.0.0 as well).
>>
>> Only 5.4.0 and predecessors work as expected.
>>
>> Damage control? How far can 5.5.0 be trusted?
>>
>>
>> On 17/01/2013, John Smith <ffirstt.llastt(a)gmail.com> wrote:
>>> I am new to Drools and am trying to get the sample program to work. This
>>> sample is given in the drools documentation
>>> http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_....
>>> This drool rule is expected to sort integers. I just changed the numbers
>>> from what are given in the sample and they do not get sorted as
>>> expected.
>>> Tried using drools version 5.5.0, 5.5.1 and the master 6.0.0, but got
>>> the
>>> same wrong results.
>>>
>>> Following is the main code:
>>> package com.sample;
>>>
>>> public class Example2 {
>>> public static void main(String[] args) throws Exception {
>>> Number[] numbers = new Number[] { wrap(5), wrap(6), wrap(4),
>>> wrap(1), wrap(2) };
>>> new RuleRunner().runRules(new String[] { "Example3.drl" },
>>> numbers);
>>> }
>>>
>>> private static Integer wrap(int i) {
>>> return new Integer(i);
>>> }
>>> }
>>>
>>> The RuleRunner class is the same as given in the example and I do not
>>> think
>>> I should give that here, since it will clutter the question. It simply
>>> creates the KnowledgeBase, stateful session, inserts the facts as given
>>> in
>>> the 'numbers' array above and then calls fireAllRules method on the
>>> session.
>>>
>>> The rule file (Example3.drl) is:
>>>
>>>
>>> rule "Rule 04"
>>> dialect "mvel"
>>> when
>>> $number : Number()
>>> not Number(intValue < $number.intValue)
>>> then
>>> System.out.println("Number found with value: " +
>>> $number.intValue());
>>> retract($number);
>>> end
>>>
>>>
>>> The output I get is as follows:
>>> Loading file: Example3.drl
>>> Inserting fact: 5
>>> Inserting fact: 6
>>> Inserting fact: 4
>>> Inserting fact: 1
>>> Inserting fact: 2
>>> Number found with value: 1
>>> Number found with value: 4
>>> Number found with value: 2
>>> Number found with value: 5
>>> Number found with value: 6
>>>
>>> Not the correct expected ascending sorted order.
>>>
>>> What might I be doing wrong? I cannot imagine that the drools rule
>>> engine
>>> would be broken at this basic level.
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://drools.46999.n3.nabble.com/Drools-Expert-does-not-sort-integers-co...
>>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>
>
11 years, 10 months