doubt regarding FORALL and contains operator...
by Sudhir M
Hi ALL,
We are using drools 4.0.7 for one of our projects. We encountered some
issues which I thought are strange.
1. When using FORALL on an entity for which we haven't asserted any of the
instances in the working memory the rule always fires. I thought this rule
should be evaluted to true only if all the asserted instances satisfy the
condition and if we don't insert any of the instances in the working memory
it should no fire the rule. Is this the expected behaviour or am I wrong?
ex: rule "rule1"
when
forall (
Vehicle( model == "bmw" )
)
then
System.out.println("in forall");end
2. When using 'contains' operator on array or collection of strings its
working fine. But when we use it for an array of primitive type double it
gives a classcastexception . Is auto boxing not supported? May be this is
fine as it mentioned in the documentation that it works only on Objects. I
tried using the array of Double objects, here it doesn't throw an excpetion
but the rule wasn't firing. The behaviour was same even if I use a
collection of Double objects. Is this a bug or am I missing something?
ex:
using Array
rule "OrderArray"
when
Order(valueArray contains 0)
then
System.out.println("OrderArray");
end.
using Collection
rule "OrderList"
when
Order(valueList contains 0)
then
System.out.println("OrderList");
end.
May be for collections I can write it as below
rule "OrderList"
when
$order : Order( $val:valueList)
Double(doubleValue ==0) from $val
then
System.out.println("OrderList");
end. but this working but not intuitive as these rules were maintained
later by a business user it will be easy for him if we contains and also if
we can directly use array instead of collections it would be a great as
current BOM uses arrays everywhere.
Thanks,
sudhir.
15 years, 10 months
Nested Objects
by Ashish Soni
Hi All ,
I have a Object which contains "*n" *number or different object basically a
graph of object , Now if i have a rules on nested object do i need to insert
each object separately for rule execution or is there a way drools engine
can recognize the object graph and fire rules to corresponding objects.
Regards,
Ashish
15 years, 10 months
Iterating two collection in LHS
by techy
Hello,
Please help me to implement following rule in drool. I could not find a way
to iterate two collection using accumulate or collect in LHS.
public Male{
int age;
//other fields
}
public Female{
int age;
//other fields
}
public City{
private List<Male> maleList;
private List<Female> femaleList;
}
#Rule to get all Male whose age != any of female's
rule "Get Unlucky Male"
when
city : City()
maleList : ArrayList() from collect ( Male( his age = any of
Female's age from city.femaleList ) from city.maleList)
//consequence
end
--
View this message in context: http://www.nabble.com/Iterating-two-collection-in-LHS-tp21796713p21796713...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 10 months
RE: [rules-users] Parsing XML using Drools
by Anstis, Michael (M.)
I am not sure on what you are trying to achieve.
Drools is a Rule Engine and not a XML parser; the nearest I could find
to what you are reporting ("I know XML Streaming is possible in Drools")
is the following.
http://netzooid.com/blog/2007/03/16/sxc-simple-xml-compiler-jaxb-runtime
-streaming-xpath-implementation-and-more/
Can you enlighten me with your knowledge of XML Streaming in Drools?
________________________________
From: Gupta, Ankit (Ankit) [mailto:gupta11@avaya.com]
Sent: 29 January 2009 10:04
To: Anstis, Michael (M.)
Subject: RE: [rules-users] Parsing XML using Drools
Hi Mike,
Thanks for prompt reply ,
Actually right now I am streaming the xml
<BenchmarkResultsFor>
<Benchmark>DataProcessing</Benchmark>
<Workload>1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16</Workload>
<Memory>4, 4, 4, 8, 8, 12, 12, 16, 24, 24, 24, 24, 24, 24,
24, 24</Memory>
</BenchmarkResultsFor>
here we are using apache math api for interpolation
public MemoryBenchmarkResult(String name, double[] x, double[]
y) {
this.hostFunction = name;
// Create the interpolation function
SplineInterpolator i1 = new SplineInterpolator();
this.workload = x;
this.memory = y;
this.interpolator = i1.interpolate(this.workload, this.memory);
}
here we are passing the values of X Axis (Workload) and we get
the values of Y Axis (Memory ). Reading or Streaming of this XML are
doing using SAX .
This thing I want to do with Drools ...... as I know XML
Streaming is possible in Drools .
Regards
Ankit
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Anstis,
Michael (M.)
Sent: Thursday, January 29, 2009 2:48 PM
To: Rules Users List
Subject: RE: [rules-users] Parsing XML using Drools
It is not clear how you want to use the XML?
If the XML represents Facts then you could use a worker Fact and
"FROM" to deserialise them and make them available to WM. For example:-
rule "get some XML facts"
when
$w : Worker()
Cheese( ) from $w.getCheesesFromXML();
then
//Do something with cheese
end
Obviously the XML need not be true serialised objects (in a JAXB
sense) but simply the properties that "getCheeseFromXML" rehydrates.
Drools is not exposing any of the XML libraries; they are merely
used by your code. The above would be (partially) equivalent to:-
Worker w = new Worker();
List<Cheese> cheeses = w.getCheesesFromXML();
for(Cheese c : cheeses) {
wm.insert(c);
}
rule "Cheese pre-loaded"
when
Cheese( )
then
//Do something with cheese
end
Partially equivalent as you could retract Cheese( ) in the
second way which would affect truth maintenance whereas the first way
would (I believe) not.
With kind regards,
Mike
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Gupta, Ankit
(Ankit)
Sent: 29 January 2009 07:22
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Parsing XML using Drools
Hi All,
How can we read and parse a XML file using
drools ?
Does Drools support the SAX or DOM parsing .
Regards
Ankit
15 years, 10 months
yasu quick rules migration to Drools
by Mark Proctor
Anyone had any experience in migrating from yasu quick rules to Drools,
particularly interested in how you migrated yasu rules and the contents
of their rule repository.
Mark
15 years, 10 months
How to setup Foreach node?
by Cristiano Gavião
Hi, I would like to know how can I setup a ForEach composite.
I setup two variables on accountProcess.rf properties (main flow
diagram). One is the Account class, and other is a
java.util.Collection<Account>.
I fill the variable and collection expression on the ForEach node
with those variables. But Im still getting these errors:
ForEach node 'Every Account' [8] has no collection expression.
ForEach node 'Every Account' [8] has no variable name.
Im missing something or I did something wrong?
ah, I almost forget.... When I have a ForEach node on a flows diagram,
the layout isn't saved. I mean, if I close the diagram and open It
again, the ForEach node will be on a different place.
thanks in advance
_________________________
Cristiano V. Gavião
"Tudo vale a pena se a alma não é pequena..." Fernando Pessoa
15 years, 10 months
RuleFlow question
by Steven Williams
Hi guys,
I am playing with the OrderExample in drools-examples and was wondering how
I get access in my rules to the parameters that are sent to startProcess?
e.g.
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("order", order);
parameters.put("orderId", order.getOrderId());
parameters.put("email", emailTextField.getText());
ProcessInstance processInstance =
ksession.startProcess("org.drools.examples.process.ruleset.RuleSetExample",
parameters);
I have access to the ProcessInstance but there doesn't seem to be any clear
path to the parameters.
thanks
Steve
15 years, 10 months
Globals
by Femke De Backere
Hi!
I'm trying to set a global for my ruleflow in Drools 5 M5.
Patient patient = new Patient();
ksession.setGlobal("patient", patient);
But I always get the following error:
"Could not find variable scope for variable patient when trying to
execute Work Item Human Task
Continuing without setting parameter."
Does anyone know what I'm doing wrong?
Thx!
Femke
15 years, 10 months
How to associate Actors to one Swimlane ?
by Cristiano Gavião
Hi,
I was looking at Flows Diagram properties and I could see the
'swinlanes' property. In the human task properties I could see the
properties 'swimlane' and 'actorId'.
And I could see that on class org.drools.task.TaskServiceSession
there are a addUser() and addGroup() methods, but there isn't any
relationship between those classes....
I would like to understand how will Drools Flow treat the relationship
betweem Users, Group and Swimlanes.
Is the swinlane a conceptual thing mapped by the Group class? And how
can Drools Flows knows the Potencial Owner of a process?
thanks for your help
ps. Im building a little swing example application for testing the
flows and human tasks capabilities (connecting to flows server, open a
session, fire some process, etc). After I've it done and if you guys
wanted I could share it. How is the best way to do that?
Cristiano
15 years, 10 months
How can i achieve below in Guvnor or Drools
by Ashish Soni
Hi All ,
I am not sure if below structure is supported in Drools 5 or Guvnor or is
there is any way we can achieve this -
We want to create packages structure like below under the packages panel ,
as of now every package comes under the packages tab but how can we have a
multiple package root element with different names -
As per the below there are parent default rules and function which may or
may not be applicable to states ( child's ) and then each child also have
their own rules and functions
Countries
USA
- Default Rules
- Default functions
- MA
- Rules
- Functions
--
--
-Arizona
- Rules
- Functions
-NY
- Rules
- Functions
United Kingdom
- Default Rules
- Default functions
- State 1
- Rules
- Functions
--
--
-State 2
- Rules
- Functions
-State 3
- Rules
- Functions
Please suggest.
Regards,
Ashish Soni
15 years, 10 months