Drools Queries with relation to the LHS and RHS syntax of the rule
by Dibya
I have the below two requirement for Drools implementation.
1. To use a java method(with single argument) of my application class in the
'LHS' of the rule .
2. To pass the object set in 'RHS' of the rule back to my application.
Is it possible to implement point 1 and point 2 as below ?
Example :
Application class is defined as :
//Class for getting various types from my application
package application.custom;
public class Project
{
public string getStringValue(String name) {
<Logic of the application>
return ;
}
}
//Class 2 for setting the rule result
package application.customresults;
public class ProjectResults
{
public void setResult(String name) {
<Logic of the application>
}}
===========================================================================
Drl file like :
package application.rules
#I shall set the object 'projRes' in my appl using setGlobal
global application.customresults.ProjectResults projRes ;
import application.custom.Project;
rule "project-1.option1"
when
$proj : application.custom.Project();
eval ($proj.getStringValue("Drools") .equals ("ABC")) # Logic specific to my
application
then
#Requirement is to set and make use of the object 'projRes' in my
application
modify (projRes) {projRes.setResult("Drools project"); }
end
rule "project-1.option2"
when
$proj : application.custom.Project();
$projRes : application.customresults.ProjectResults();
eval ($proj.getStringValue("Java") .equals ("DEF")) # Logic specific to my
application
then
#Requirement is to set and make use of the object 'projRes' in my
application
modify (projRes) {projRes.setResult("Java project");
}
end
Please let me know if the above way of writing the drl would suffice both
the requirements (or) is there a better way to implement it.
Thanks
Dibya
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Queries-with-relation-to-the-LHS...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 11 months
Drools 4.0.7 compatible with Jboss 3.2.7
by Dibya Ranjan
Thanks for the update.
Would like to know if Drools version 4.0.7 is compatible with J-boss version
3.2.7.
/BR
Dibya
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Drools5-2-2-integration-with-scala2-9-0...
> Sent from the Drools: User forum mailing list archive at Nabble.com.
>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 7 Aug 2011 14:33:25 +0200
> From: Dibya Ranjan <dibya.tcs(a)gmail.com>
> Subject: [rules-users] Regd Drools compatibility with Jboss version
> To: rules-users(a)lists.jboss.org
> Message-ID:
> <CAK=+3B9m73RKWQB951Ze1Ca-rpFbB+a+gds4aHVmaGNB4TZ+Vg(a)mail.gmail.com
> >
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi
>
> We have a requirement to implement Drools in an application ,which is
> hosting the application server in Jboss with version as 3.2.7.
>
> It further uses java 1.4 version with the application being build and
> deployed with Ant 1.6.2.
>
> Could anyone help me in providing the Drools version that is compatible
> with
> above .
>
> --
> With Warm Regards
>
> Dibya Ranjan
> -
> *******************************************
>
14 years, 11 months
Rule o
by DroolersEye
Hi,
Some one can help me,
I want to use Rule object...I noticed Rule interface available in two
packages ...which one to be used...
"org.drools.definitions.rule" or "org.drools.rule"
please some one can advise us...
thanks,
-----
with kind regards,
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-o-tp3243667p3243667.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 11 months
Lock-on-active and ruleflow-group
by bitter
I have three rules:
rule "First rule"
salience 20
ruleflow-group "rfs_1"
lock-on-active true
when
$c: Car(color == "red")
then
$c.setPrice(1);
update($c);
end
rule "Second rule"
salience 25
ruleflow-group "rfs_1"
lock-on-active true
when
$c: Car(size == "small")
then
$c.setPrice(2);
update($c);
end
rule "Second step"
salience 40
ruleflow-group "rfs_2"
lock-on-active true
when
$c: Car()
then
System.out.println($c);
end
I have class, for example Car, which has three prioperties: color, size,
price.
I insert into session fact-Car("red", "small"), next start process, and
execute rules.
After that, price value is 1. I thought that "Second rule" should be fired
only because it has bigger salience but it is exactly the opposite. Could
anyone explain me why first rule was executed/fired and what can I do to
fire only "Second rule" (without invoking "First rule").
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Lock-on-active-and-ruleflow-group-tp323...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 11 months
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, 11 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, 11 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, 11 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, 11 months