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
13 years, 8 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.
13 years, 8 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.
13 years, 8 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***
13 years, 8 months
unable to build expression for 'constraint' null': java.lang.NullPointerException with bpmn processes
by sumatheja
Hi All,
I've a set of bmpn2 processes. When I try to compile them locally,
its compiles fine. But when I upload them to the Guvnor and try to build
the package, I get the below mentioned error for *each and every process*.
*unable to build expression for 'constraint' null':
java.lang.NullPointerException*
I tried validating each process using the jbpm designer and they show no
errors. Can someone help me with this. Thanks in advance.
--
cheers
Sumatheja Dasararaju
13 years, 8 months
Drools & jBPM Workshops : June : WDC NYC
by Mark Proctor
Only a week to go, and spaces are filling up fast. If you want to go,
register ASAP.
http://blog.athico.com/2012/06/drools-jbpm-workshops-june-wdc-nyc.html
----pasted from url---
JBoss BRMS (Drools and jBPM) Workshops
Drools 5, the upstream for JBoss BRMS, is a Business Logic integration
Platform, and provides a unified and integrated platform for Rules,
Workflow and Event Processing. It's been designed from the ground up so
that each aspect is a first class citizen, with no compromises. Drools
may be easily used with jBPM, a flexible business process management suite.
Want to learn more?
Join us for one of two complimentary full day, hands-on workshop on
Drools and jBPM, where we will cover:
* The ecosystem that encompasses the Drools open source project and
the JBoss BRMS
* Benefits of rules systems, business workflows, and specific challenges
* The history of rules systems, where they are going, and the current
state of the art
* Various features of the BRMS via a hands on demo
* BPMN 2.0 and the future of Business Process Management
Be prepared to work hands-on with the tools, meet the team behind the
engine, and have your questions answered. This event will give you
unparalleled access to industry-recognized leaders in the rules community.
There are two dates to choose from:
* Tuesday, June 19 2012 in New York City
<http://app.engage.redhat.com/e/er?s=1795&lid=1384&elq=d3d6d783acbc4c7382b...>
* Thursday, June 21, 2012 (Government focus) in Washington DC
<http://app.engage.redhat.com/e/er?s=1795&lid=5482&elq=d3d6d783acbc4c7382b...>
Speakers:
Jim Tyrrell
<http://app.engage.redhat.com/e/er?s=1795&lid=5483&elq=d3d6d783acbc4c7382b...>,
Principle JBoss Solution Architect, Red Hat
Mark Proctor
<http://app.engage.redhat.com/e/er?s=1795&lid=5483&elq=d3d6d783acbc4c7382b...>,
Drools Project Lead and Founder, Red Hat
Edson Tirelli
<http://app.engage.redhat.com/e/er?s=1795&lid=5483&elq=d3d6d783acbc4c7382b...>,
Senior Software Engineer, Red Hat
Kris Verlaenen
<http://app.engage.redhat.com/e/er?s=1795&lid=5483&elq=d3d6d783acbc4c7382b...>,
jBPM Lead Engineer, Red Hat
Prakash Aradhya
<http://app.engage.redhat.com/e/er?s=1795&lid=5483&elq=d3d6d783acbc4c7382b...>,
Senior Product Manager, Red Hat
/*Attendees are responsible for bringing their own laptop to this event.
Please make sure your laptop has the ability to copy files from a USB,
which will provide the software for the hands-on sessions, and have JDK
1.6 already installed./
Register now as space is limited. We look forward to seeing you there!
13 years, 8 months
get new errors caused by KnowledgeBuilder.add()
by Sandeep Bandela
Hi,
I have rules (drl format strings) stored in a database column in a schema
like MyRules(rule_id integer, name text, rule text, enabled boolean ... )
I query the db to get them and iterate over the rows and add using
KnowledgeBuilder.add() using String.getBytes. (I dont want to move to
guvnor as of now)
some rules might have compilation errors, hence the
KnowledgeBuilder.hasErrors() is set to true.
those will not be added to the package by the PackageBuilder.
My problem is to log the error causing rule_id and the error message.
KnowledgeBuilderErrors dosent expose the internal errors list so that I
could see if any new errors are in the arraylist from the last time error
seen time and log them.
But only solution i could think of is using the low level api of using
DrlParser to pre-parse it to check for errors+log and add to the kBuilder
if its not failed.
is there any elegant way to do this?
I am using drools-5.2.0.final
--
Regards,
Sandeep Bandela.
13 years, 9 months
Unification with logical or question
by bdolbeare
Can someone explain to me why these two rules behave differently? I expected
that the second rule would produce the same output as the first but it seems
to ignore the first half of the logical or expression. Is this because the
unification happens before the null checks occur?
declare Foo
name : String
item : Item
end
declare Item
id : long
end
rule "insert stuff"
when
then
Item item1 = new Item(1);
Foo foo1 = new Foo("foo1", item1);
insert(foo1);
Foo foo3 = new Foo("foo3", null);
insert(foo3);
end
rule "Unification Test Rule"
when
f : Foo ( item != null, $item := item )
f2 : (
Foo ( item == null )
or Foo ( $item := item )
)
then
System.out.println(String.format("%s Fired:\n\tFoo: %s\n\t%s",
kcontext.getRule().getName(), f, f2));
end
rule "Unification Test Rule 2"
salience -10
when
f : Foo ( item != null, $item := item )
f2 : Foo ( ( item == null ) || ( item != null && $item := item ) )
then
System.out.println(String.format("%s Fired:\n\tFoo: %s\n\t%s",
kcontext.getRule().getName(), f, f2));
end
Unification Test Rule Fired:
Foo: Foo( name=foo1, item=Item( id=1 ) )
Foo( name=foo3, item=null )
Unification Test Rule Fired:
Foo: Foo( name=foo1, item=Item( id=1 ) )
Foo( name=foo1, item=Item( id=1 ) )
Unification Test Rule 2 Fired:
Foo: Foo( name=foo1, item=Item( id=1 ) )
Foo( name=foo1, item=Item( id=1 ) )
--
View this message in context: http://drools.46999.n3.nabble.com/Unification-with-logical-or-question-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 9 months