Calling a method in when part
by Sumeet Karawal
Hi,
I have a requirement where there is a customized Java class having a method
that returns some value.
like:
getValueBoolean("Some String")
{ //some calculation
// returns a boolean value
}
The default getters and setters are not being used in the Application. The
value that is being returned by the method needs to be checked in the .drl
file.
There are different Java classes with these kind of methods. Where the
string and integer value is also returned. I have gone through the
documentation for Drools-Expert but have only found the implementation for
the method in the consequence part, i.e., the then part.
This is how I tried:
importing the class
in when
binding the a variable to the Class name suppose $c
eval ($c.getValueBoolean("abc"))
then
System.out.println("the value is true")
It didn't work this way.
I tried by another way like :
creating a function in the .drl itself that calls the method of that class
and returns a value
then calling this drl function in the when part and carrying on.
It would be very helpful if some body could let me know how to do this in
the .drl.
Thanks & Regards,
Sumeet Karawal
Mailto: sumeet.karawal(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
14 years, 5 months
How to update facts in Script task (RuleFlow)
by joeyoungkc
Hi,
I'm trying to update the facts before a flowgroup and after a script
task(written in java). I was thinking of calling update(myFact) inside the
script task, but how do I call it?
Do I need to press in the session to the parameter map and call
session.update(FactHandle handle, Object object)??
--------------------------------------------------
StatefulKnowledgeSession session = getKnowledgeAgent("abc")
.getKnowledgeBase().newStatefulKnowledgeSession();
Map<String, Object> parameterMap = new HashMap<String,
Object>();
parameterMap.put("myFact",myFact);
session.insert(myFact);
session.startProcess("rruleflow", parameterMap);
session.fireAllRules();
--------------------------------------------------
I'm new to drool, please help!
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-update-facts-in-Script-task-Rule...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
How to rethrow Exceptions from Drools 5 functions
by Matthew Erler
I would like to write a utility function that works with java.text.SimpleDateFormat and several more date-related Java classes. The classes can throw Exceptions that the function caller should know about. Is it possible for a function to be declared such that it can throw any Exception back to the caller?
14 years, 5 months
How to deal with Set inside another Set?
by joeyoungkc
I have three classes
Master()
private Set<Header> Headers;
----------------------------
Header()
private Set<Line> Lines;
----------------------------
Line()
private String name;
----------------------------
Master() is the facts. In my spreadsheet I would like to check the line
name == "abc". How do I do that.
Here is what I got but it cause type mismatched error!! please help.
Master()
$h: Headers
$L : $h.Lines
m: Line(<generated by condition header>) from $L
Please help!!
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-deal-with-Set-inside-another-Set...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months