Designer: How to assign/map attributes inside complex objects?
by xmithj
The *Editor for Data Assignments* allows to map a *From Object* to *To
Object*. Very nice! However attributes inside complex objects are not shown
preventing me from map to them. Let me clarify:
My *To Object* represents a *Person* object and has two attributes: *name*
and *surname*.
These 2 attributes are of type String and public (exposed through getters
and setters). But the* Editor for Data Assignments* only shows the *Person*
object (doesn't show its attributes), preventing me from map my * From
Object* to Person.surname.
I also tried to bypass the *Editor for Data Assignments* by writing directly
into the *Assignments* property something similar to this:
recordedName -> Person.surname
but I get an exception when building the package.
Is there any work around to achieve these type of assignment? Will this
functionality be built in Designer's *Editor for Data Assignments* future
release?
Thanks for help.
--
View this message in context: http://drools.46999.n3.nabble.com/Designer-How-to-assign-map-attributes-i...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Trouble using || operator and after evaluator in constraints in 5.4.0.Final
by abr
Hi everyone,
I've tried to go from Drools 5.3.0.Final to 5.4.0.Final and some strange
errors appeared on constraints using the after evaluator and the ||
operator.
For instance, considering these 2 objects :
public class MyObject {
private Date myDate;
public MyObject(Date myDate) {
super();
this.myDate = myDate;
}
public Date getMyDate() {
return myDate;
}
public void setMyDate(Date myDate) {
this.myDate = myDate;
}
}
public class MyObjectList {
private List<MyObject> myObjectList;
public MyObjectList() {
super();
this.myObjectList = new ArrayList<MyObject>();
}
public List<MyObject> getMyObjectList() {
return myObjectList;
}
public void setMyObjectList(List<MyObject> myObjectList) {
this.myObjectList = myObjectList;
}
public void addObject(MyObject myObject) {
this.myObjectList.add(myObject);
}
}
This rule:
rule "Sample rule"
when
CurrentDate( $now: now )
$list: MyObjectList()
$obj: MyObject(
this memberOf $list,
( myDate == null ||
myDate after[ 5d ] $now ) )
then
System.out.println( "Sample rule activated" );
end
Provokes the following error:
Unable to Analyse Expression $list contains this && ( myDate == null ||
after0.evaluate( myDate, $now ) ):
[Error: unable to resolve method using strict-mode:
com.sample.MyObject.after0()]
[Near : {... ( myDate == null || after0.evaluate( myDate, $now ....}]
^ : [Rule name='Sample rule']
This worked very well in Drools 5.3.0.Final.
The strangest thing about this issue is that, if I change the || into a &&,
compilation works correctly!
Is there some configuration specific to Drools 5.4.0.Final that I've missed
in the release notes?
Thanks in advance for your help.
Best,
Alexis
--
View this message in context: http://drools.46999.n3.nabble.com/Trouble-using-operator-and-after-evalua...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
How to trigger update when modifying a list attribute?
by Paulo Reis
Hi guys,
I'm having the follow issue: I have an object that contains a list. The object is inserted on the memory but not the list, so I want to do something like this:
when
$obj: Object()
eval($obj.hasInList("item"))
then
$obj.replaceInList("item", "replacement");
end
How do I trigger the update for $obj? I've tried to add Java Beans support but that didn't help, neither @watch nor @PropertyChangeSupport on java class.
Im watching the debug but don't see the object being modified and I've rules that were triggered that shouldn't be because the value was already changed.
Inserting the list on the working memory won't help me, as I need to search like this:
when
$obj: Object()
eval($obj.hasInList("item item1 item2 item3"))
then
$obj.replaceInList("item item1 item2 item3", "singleItem")
end
The example above search for several items (each one is a list element), so I need to replace them all for a single element.
Any thoughts?
Thanks in advance.
Paulo Reis
casmeiron(a)gmail.com
12 years, 4 months
Re: [rules-users] Rule flows in Drools planner configuration?
by Garf
spinjala wrote
>
> Is it possible to have a rule flow file that defines a set of rules
> (constraints) but executed in the order per the defined ruleflow.? I dont
> see any example doing that so I was wondering if it is possible at all to
> have the constraints defined with a rule flow file instead of single .drl
> file?
>
I guess that the challenge here is that a rule flow file awaits
startProcess() to be fired.
Planner's DroolsScoreDirector.calculateScore() only calls fireAllRules().
Jon
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-flows-in-Drools-planner-configurat...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Decision Table Management Process
by dme1
Hi,
I am looking for the best approach to manage decision tables within Drools,
essentially the hand-off process between developers and Business Analysts.
There are 2 ways to create and maintain Decision Tables in Drools
1. Use the XLS based decision tables. This requires developers to create the
initial XLS file with sample data, and work with the BAs to fill in the
actual requirements. On an ongoing basis if BAs require to maintain rules in
XLS based decision tables, they have to download the the existing XLS file,
update the rules using Excel - prettify as required for grouping etc.,
upload back to Guvnor and then test the rules.
2. Use the Guided Decision Table feature. This feature is available only in
Guvnor, and any tables created in Guvnor cannot be opened and maintained in
Eclipse (atleast not easily as at this time you are essentially looking at
updating XML files). So developers have to create/update rules in Guvnor as
well as BAs use the same tools to update/maintain rules in Guvnor.
Are there any other/better options available to create/manage decision
tables and co-ordinate the efforts between development (who prefer to use
Eclipse based tooling) and BAs (who would benefit from the richer features
available in Guvnor).
Thanks,
dme
--
View this message in context: http://drools.46999.n3.nabble.com/Decision-Table-Management-Process-tp401...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
<otherwise> in Excel Decision Table
by dme1
Hi,
How do I use <otherwise> in Decision Tables created using Eclipse (Excel
Spreadsheets). I have created a rule where I have provided "<otherwise>" as
a criteria but its been taken as the value of the parameter instead of
creating a separate rule with the "not" clause. I am providing the
screenshot of the decision table as well as the rules generated by Drools.
I would much appreciate if someone can advise on how I can use <otherwise>
in my rules.
http://drools.46999.n3.nabble.com/file/n4019162/droolsdt.jpg
Drools conversion to ".drl" below (Rule Flight_Type_Rules_15 shows
<otherwise> being used as parameter valUE):
DRL is :: package com.test.BasicDTRules;
//generated from Decision Table
import java.util.Date;
import com.test.Flight;
// rule values at C11, header at C6
rule "Flight Type Rules_11"
when
flight : Flight(flightNumber >= "0001", flightNumber <= "1000",
airlineCode == "BA")
then
flight.setFlightType("SH");
flight.setValid(true);
System.out.println("Row 1");
end
// rule values at C12, header at C6
rule "Flight Type Rules_12"
when
flight : Flight(flightNumber >= "0001", flightNumber <= "1000",
airlineCode == "AA")
then
flight.setFlightType("SH");
flight.setValid(true);
System.out.println("Row 2");
end
// rule values at C13, header at C6
rule "Flight Type Rules_13"
when
flight : Flight(flightNumber >= "1001", flightNumber <= "2500",
airlineCode == "VG")
then
flight.setFlightType("LH");
flight.setValid(true);
System.out.println("Row 3");
end
// rule values at C14, header at C6
rule "Flight Type Rules_14"
when
flight : Flight(flightNumber >= "1001", flightNumber <= "2500",
airlineCode == "AA")
then
flight.setFlightType("550");
flight.setValid(true);
System.out.println("Row 4");
end
// rule values at C15, header at C6
rule "Flight Type Rules_15"
when
flight : Flight(flightNumber >= "2501", flightNumber <= "9999",
airlineCode == "<otherwise>")
then
flight.setFlightType("Invalid");
flight.setValid(false);
System.out.println("Row 5");
end
Thanks,
dme
--
View this message in context: http://drools.46999.n3.nabble.com/otherwise-in-Excel-Decision-Table-tp401...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months