Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-219

Accumulate over declared windows doesn't work

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • None
    • None
    • None
    • None
    • 2019 Week 35-37

    Description

      1- compliation error :

      declare Order
      @role(event)
      @timestamp (timestamp)
      @expires( 2m )
      end

      rule "3 successives BUY Orders of same Quote"
      when
      $q : Quote()
      $list : List( size == 3 ) from collect ( Order( orderType == OrderType.BUY , quote == $q.symbol )
      over window:length(3)
      from entry-point orderStream )
      then
      System.out.println(drools.getRule().getName());
      $q.setPrice($q.getPrice()+0.01);
      for ( Object $o : $list)

      { System.out.println("Retracting "+$o); delete($o); }
      end

      I am getting following compilation error with this rule, reproducer here [1]

      Caused by: java.lang.IllegalStateException: src/main/java/com/redhat/quotegame/processors/RulesFDF3DF171AA07357C5FA6AC5D133F4BE_rule___3_32successives_32BUY_32Orders_32of_32same_32Quote.java (37:94) : method accumulate in class org.drools.model.DSL cannot be applied to given types;
      required: org.drools.model.view.ViewItem<?>,org.drools.model.functions.accumulate.AccumulateFunction,org.drools.model.functions.accumulate.AccumulateFunction[]
      found: org.drools.model.functions.accumulate.AccumulateFunction
      reason: cannot infer type-variable(s) T

      2- runtime error :

      declare Order
      @role(event)
      @timestamp (timestamp)
      @expires( 2m )
      end

      rule "3 successive BUY Orders of the same Quote"
      when
      $q : Quote()
      $list : List( size == 3 ) from collect ( Order()
      over window:length(3)
      from entry-point orderStream )
      then
      System.out.println(drools.getRule().getName());
      $q.setPrice($q.getPrice()+0.01);
      for ( Object $o : $list){ System.out.println("Retracting "+$o); delete($o); }

      end

      Now, with this rule, I am getting the following runtime error, reproducer here [2]

      org.jboss.resteasy.spi.UnhandledException: java.lang.ClassCastException: org.drools.core.common.DefaultFactHandle cannot be cast to org.drools.core.common.EventFactHandle

      [1] - https://github.com/snoussi/kogito-cep-example/tree/BuildException
      [2] - https://github.com/snoussi/kogito-cep-example/tree/RuntimeException

      Attachments

        Issue Links

          Activity

            People

              mfusco@redhat.com Mario Fusco
              mfusco@redhat.com Mario Fusco
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: