[jboss-jira] [JBoss JIRA] (DROOLS-1470) Match.getObjects() should also include accumulate's objects
Geoffrey De Smet (JIRA)
issues at jboss.org
Wed Mar 8 06:20:00 EST 2017
[ https://issues.jboss.org/browse/DROOLS-1470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Geoffrey De Smet updated DROOLS-1470:
-------------------------------------
Description:
Given this DRL:
{code}
global java.util.List list
rule R when
$t : CarType(id == \"roadster\")
accumulate(
$c : Car(type == $t);
$total : count($c)
)\
then
list.addAll(kcontext.getMatch().getObjects());
end
{code}
and then inserting the roadster type and 3 cars of that type:
{code}
CarType roadsterType = new CarType("roadster");
ksession.insert(roadsterType);
Car bmwZ4 = new Car("BMW Z4", roadsterType);
ksession.insert(bmwZ4);
Car lotusElise = new Car("Lotus Elise", roadsterType);
ksession.insert(lotusElise);
Car mazdaMx5 = new Car("Mazda MX-5", roadsterType);
ksession.insert(mazdaMx5);
{code}
then the Match.getObjects() (or getObjectsDeep()) should include every Car instance too.
Let's discuss. Maybe we need a new method getObjectsDeep() instead if we can't change getObjects() for backwards compatibility reasons.
was:More info coming once I 've created an isolated reproducer for this.
> Match.getObjects() should also include accumulate's objects
> -----------------------------------------------------------
>
> Key: DROOLS-1470
> URL: https://issues.jboss.org/browse/DROOLS-1470
> Project: Drools
> Issue Type: Enhancement
> Components: core engine
> Affects Versions: 7.0.0.Beta6
> Reporter: Geoffrey De Smet
> Assignee: Mario Fusco
>
> Given this DRL:
> {code}
> global java.util.List list
> rule R when
> $t : CarType(id == \"roadster\")
> accumulate(
> $c : Car(type == $t);
> $total : count($c)
> )\
> then
> list.addAll(kcontext.getMatch().getObjects());
> end
> {code}
> and then inserting the roadster type and 3 cars of that type:
> {code}
> CarType roadsterType = new CarType("roadster");
> ksession.insert(roadsterType);
> Car bmwZ4 = new Car("BMW Z4", roadsterType);
> ksession.insert(bmwZ4);
> Car lotusElise = new Car("Lotus Elise", roadsterType);
> ksession.insert(lotusElise);
> Car mazdaMx5 = new Car("Mazda MX-5", roadsterType);
> ksession.insert(mazdaMx5);
> {code}
> then the Match.getObjects() (or getObjectsDeep()) should include every Car instance too.
> Let's discuss. Maybe we need a new method getObjectsDeep() instead if we can't change getObjects() for backwards compatibility reasons.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the jboss-jira
mailing list