BigDecimal comparison
by devan.vanreenen@gmail.com
Hi there,
Please assist.
I have an object MaxCap that has a single property capAmount of type
BigDecimal.
The BigDecimal is negative
when the rule is
MaxCap( capAmount.doubleValue < 0.00 ) it doesnt fire, which I expect it
should but when the rule is
MaxCap( capAmount.doubleValue > 0.00 ) then the rules fires, so the rule
recognises my negative number as a positive one.
Any help would be appreciated.
Thanks
Devan
--
View this message in context: http://drools.46999.n3.nabble.com/BigDecimal-comparison-tp4017841.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 6 months
Else condition in drl file
by learner
Hi,
I have a scenario like
if(value == 200){
// then do something
}else if(value == 100){
// then do something
}else{
value = 0
}
I created drl with 3 rules
Rule 1 : value equal 200
Rule 2 : value equal 100
Rule 3 : value not equal to 100 or 200(ie by value!=200 & value!=100 ).
Is there a way by which I can simplify the condition in rule 3.
--
View this message in context: http://drools.46999.n3.nabble.com/Else-condition-in-drl-file-tp4017903.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 6 months
Managing Sets of Rules
by tlee
Hi,
Are there any guidelines or recommendations for how best to isolate
different groups of rules? For example, I'm using decision tables to do
some (initially) simple inter-system value mappings/translation. The
generated rules look like this:
Decision Table 1:
rule "mapCountry"
salience 65496
when
String(toString == 'SRI LANKA')
then
result.put('countryCode', 'apac.sri-lanka');
drools.halt();
end
I will have other decision tables that also match against String values.
If I want to isolate these decision tables so that only one set of the rules
fire when calling 'execute' on the knowledge session, should I put them in
different knowledge bases? Or is there another way? Or am I going about
this the wrong way all together?
Many Thanks,
Tim.
--
View this message in context: http://drools.46999.n3.nabble.com/Managing-Sets-of-Rules-tp4017898.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 6 months
how to declare an identifier and use it?
by vysrinivas
Hi,
Requirement:
i have a function which will return a value. Say for example String
getInfo().
In header level, i have a tag called as TType. possible values in this tag
are Online/offline.
In line level, i have a validation which should be executed based on TType.
if i get TType = online, line level validation has to be executed.
if i get TType = offline, then line level validation has to be skipped. No
validation should happen.
Solution:
I have to call getInfo() function in linelevel <java:condition> so that it
will return me the TType value.
based on TType, validation will happen / can be skipped.
Issue:
As i am declaring given below.
<rule name="12_Line_Validation">
<parameter identifier="THeader">
<java:class>THeaderType</java:class>
</parameter>
<parameter identifier="TReqLine">
<java:class>TLineType</java:class>
</parameter>
<java:condition>
getQType(TReqHeader) != null
|| !getInfo(TReqHeader).equals("Online")
</java:condition>
<java:condition>
getOffType(TReqLine).equals("Local")
</java:condition>
As show above, i am having two java conditions.
1. it will verify whether TType is online / offline.
2. it will verify whether offtype is Local or not
when i test with valid data, it never perform above validations. it just
skip both the validations irrespective whether TType is online/ offline.
Suggestion:
Can anyone let me know what might be the issue?
1. Is it that i am having both header and line program calls in one rule?
2. is it that i cannot use header value in line level validation?
work around:
is there any work around as given below
can i declare a variable/identifier in line and invoke the method and have
the return value in the declared identifier?
<parameter identifier="TType">
<java:method>getInfo(TReqHeader)</java:method>
</parameter>
so that i can use this TType within the line <java:condition>.
Please verify and suggest possible way to fix this issue.
let me know if you need any other info.
--
View this message in context: http://drools.46999.n3.nabble.com/how-to-declare-an-identifier-and-use-it...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 6 months
Using 'from {x}.field' in DSL
by Sandjaja, Dominik
I have the following Drools DSL "sentence":
[when]The field {field} in the module {module} contains value
{value}=$a : {module} ( {field} != null)
String( this.equalsIgnoreCase("{value}") ) from $a.{field}
where the `field` is a `Set` of Strings.
Now, if I have two of these sentences in one rule, it obviously won't
work as the variable `$a` occurs twice. So I wanted to improve the rule
to make the variable, well, variable:
[when]The field {field} in the module {module} contains value
{value} as {a}={a} : {module} ( {field} != null)
String( this.equalsIgnoreCase("{value}") ) from {a}.{field}
This doesn't work, I can't use the part `{a}.`, that breaks.
So, my questions are: Is there either a way to rewrite the rules or a
way to allow the `{variable}.` notation to work? Alternatively, is there
a `contains` operator which works case insensitive?
Thanks in advance
Dominik
12 years, 6 months
Solving Conflict Resolution on values of the facts - Help
by Daniel Souza
Hi..
Can anyone suggest me how can I solve conflict resolution on values of the
facts? It seems so simple but I have no idea in mind. The restriction is we
don't know how many facts will be inserted, it could be one fact, 3 facts or
more.
My problem is: If my application suggested me 1 or * Persons() as best
person, I have a conflict resolution and the rules to solve this conflict
should be evaluate the best properties (values) of the facts.
I don't know how to create rules to work with an amount of facts that I
can't know and after to solve conflict resolution between values.
The sample facts below show what I want to express as conflict resolution.
Supose that I have a POJO
Person():
atribute name;
atribute experience;
atribue age;
atribute sugestedPerson;
getters and setters;
end Person
*The declared rule is not explict. I can't express rule as:*
rule "best experience"
when
$person : Person ( experience > 200 )
then
$person.suggestedPerson = true;
end
or
rule "best experience"
salience 100
when
$person1 : Person ( $exp1 : experience )
$person2 : Person ( $exp2 : experience )
$person3 : Person ( $exp3 : experience )
eval( $exp1 > $exp2 && $exp1 > $exp3)
then
$person1.suggestedPerson = true;
end
My knowledge Base was Built.. and 3 Persons facts was inserted into.. (*The
problem is: - WE DON'T KNOW HOW MANY PERSONS WILL BE INSERTED IN THE
KNOWLEDGE BASE*)
Person { name = Jhon, experience = 200, age = 35, suggestedPerson = false }
Person { name = Daniel, experience = 251, age = 27, suggestedPerson = false
}
Person { name = Julia, experience = 219, age = 31, suggestedPerson = false }
Now I has 3 Persons and I want to sugest just the Person with the best
experience, or if all persons has the same experience indicate the older
person. What Can I do?
In this Case the sugested person is: /Person { name = Daniel, experience =
251, age = 27, sugestedPerson = *true* }/
If all person facts has the same experience and was inserted:
Person { name = Jhon, experience = 200, age = 35, sugestedPerson = false }
Person { name = Daniel, experience = 200, age = 27, sugestedPerson = false }
Person { name = Julia, experience = 200, age = 31, sugestedPerson = false }
In this Case the sugested person is: /Person { name = Jhon, experience =
200, age = 35, sugestedPerson = *true* }/
*A sample rule will be helpfull*
Daniel Souza - Brazil
--
View this message in context: http://drools.46999.n3.nabble.com/Solving-Conflict-Resolution-on-values-o...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 6 months
Guvnor 5.4 Eclipse Setup
by JeffM
I am posting to USER, rather than the DEV list since the rules for the DEV
list imply that I should only post there if I am intending to make code
changes.
I have Eclipse Indigo with the EGIT, m2e, and GWT plugins and am using 5.4.x
from Github as my source. I have followed the instructions
https://github.com/droolsjbpm/droolsjbpm-build-bootstrap/blob/master/READ...
here for setting up my environment. I can build the project with Maven
outside of Eclipse, but my goal is to run a server within Eclipse so that I
can do run-time debugging. However, my Eclipse environment is not
successfully building everything and I was wondering if I could get some
direction. All three java errors occur in the guvnor-webapp-soa project and
are as follows.
1) *"ApplicationProperties cannot be resolved*" in
SOAServicesNewAssetMenuViewImpl.java, line 183
2) "*The field Artifact.uuid is not visibl*e" in
AssetEditorActionToolbar.java, line 467
3) "*The field Artifact.uuid is not visible*" in
PackageEditorActionToolbar.java line 399.
Thanks for your help,
Jeff
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-5-4-Eclipse-Setup-tp4017825.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 6 months
Firing the rules in a sequence for all the items in an ArrayList.
by Amal Gupta
Hello,
I am new to Java and Drools and have a doubt regarding the sequence of rules' execution as stated below :-
Scenario:- I have a scenario wherein I have to apply multiple rules on multiple columns coming in a file. To simulate that I created a 2-D array as follows
String[][] data = {
{"1791","8459625","78458745","20120610","20120610" },
{"1792","8459623","78458745","20120610","20120610" },
{"1793","8459624","78458745","20120610","20120610" },
{"17944","8459626","78458745","20120610","20120610"}
};
Here each column of corresponds to a member for the following class
public class DailyPLC {
private String Id; // This value will correspond to data[i][0]
private String productCode; // This value will correspond to data[i][1]
private String customerCode; // This value will correspond to data[i][2]
private String date1; // This value will correspond to data[i][3]
private String date2; // This value will correspond to data[i][4]
private int rowNumber; // The row number to keep a track of row for which the record exists
/*Getters and Setters defined for each of them*/
}
I have to perform checks on each of the columns, and the intent is to create all the rules that I need for the entire array and save it in a single drl file. Also, at the execution time, all the rules should be applied - either at once or sequentially - to all the rows of the data.
Approach:- I tried the following
1. Created an ArrayList
ArrayList<DailyPLC> alPLCArrayList = new ArrayList<DailyPLC>();
2. Iterated over the data and stored each row into a field of the object of DailyPLC class.
3. For every iteration, added the object into the array list.
alPLCArrayList.add(plcToday); // The plcToday is the object of the DailyPLC class
4. When executing the rules, I am adding all the items of the ArrayList one by one and adding into the Knowledge Session.
for(DailyPLC d : alPLCArrayList)
{
ksession.insert(d);
}
Problem Faced :- The problem that I faced is that when I do FireAllRules, the rule only validates the last record. The intent is that it should traverse the list and give a result for all the members of the list.
Have I missed something here?
Please assist. Let me know in case you need any more information
Thanks in Advance,
Amal Gupta
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are not
to copy, disclose, or distribute this e-mail or its contents to any other person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken
every reasonable precaution to minimize this risk, but is not liable for any damage
you may sustain as a result of any virus in this e-mail. You should carry out your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
12 years, 6 months