Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1470

Match.getObjects() should also include accumulate's objects

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 7.0.0.Beta8
    • 7.0.0.Beta6
    • core engine
    • None
    • NEW
    • NEW

      Given this DRL:

      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
      

      and then inserting the roadster type and 3 cars of that type:

              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);
      

      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.

            mfusco@redhat.com Mario Fusco
            gdesmet@redhat.com Geoffrey De Smet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: