Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-1548

Order of statements described in rule action part does not keep after model generation in executable model.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.10.0.GA
    • 7.5.0.GA, 7.5.1.GA, 7.6.0.GA, 7.7.0.GA, 7.7.1.GA, 7.8.0.GA, 7.8.1.GA, 7.9.0.GA
    • BRE
    • False
    • False
    • +
    • Undefined
    • Hide
      1. Extract reproducer.
        $ unzip reproducer_model_compiler_14a.zip
        $ cd reproducer_model_compiler_14a
        
      2. Build and execute the rule with executable model disabled.
        $ mvn clean compile exec:exec -DgenerateModel=NO
            :
            :
        ***** start
        ***** Action of rule14a
        $model = ABC A180, count = 1           <----- as expected
        $manufacturer = ABC, totalCount = 1    <----- as expected
        ***** end
            :
            :
        
      3. Build and execute the rule with executable model enabled.
        $ mvn clean compile exec:exec -DgenerateModel=YES
            :
            :
        ***** start
        ***** Action of rule14a
        $model = ABC A180, count = 0           <----- unexpected result
        $manufacturer = ABC, totalCount = 0    <----- unexpected result
        ***** end
            :
            :
        
      Show
      Extract reproducer. $ unzip reproducer_model_compiler_14a.zip $ cd reproducer_model_compiler_14a Build and execute the rule with executable model disabled. $ mvn clean compile exec:exec -DgenerateModel=NO : : ***** start ***** Action of rule14a $model = ABC A180, count = 1 <----- as expected $manufacturer = ABC, totalCount = 1 <----- as expected ***** end : : Build and execute the rule with executable model enabled. $ mvn clean compile exec:exec -DgenerateModel=YES : : ***** start ***** Action of rule14a $model = ABC A180, count = 0 <----- unexpected result $manufacturer = ABC, totalCount = 0 <----- unexpected result ***** end : :
    • 2020 Week 52-03 (from Dec 21)

      Building a rule written in MVEL dialect like (*1) in executable rule model, the order of the statements described in action (then) part of the rule changes after model generation like (*2). The generated code looks like that all statements outside the modify blocks come first, followed by all statements inside the modify blocks, and finally update statements for the modified properties are called together. The original order of the statements in action part should keep after model generation.

      (*1)

      package com.example.reproducer
      
      dialect "mvel"
      
      rule "rule14a"
          when
              $manufacturer : Manufacturer()
              $model : Model( manufacturer == $manufacturer )
              $car : Car( model == $model )
          then
              System.out.println("***** Action of rule14a");
              modify($model) {
                  count = $model.count + 1
              }
              System.out.println("$model = " + $model + ", count = " + $model.count);
              modify($manufacturer) {
                  totalCount = $manufacturer.totalCount + 1
              }
              System.out.println("$manufacturer = " + $manufacturer + ", totalCount = " + $manufacturer.totalCount);
      end
      

      (*2) LambdaConsequence<hash>.java generated from the action (then) part of the rule.

          @Override()
          public void execute(org.drools.model.Drools drools, com.example.reproducer.Model $model, com.example.reproducer.Manufacturer $manufacturer) throws java.lang.Exception {
              System.out.println("***** Action of rule14a");
              System.out.println("$model = " + $model + ", count = " + $model.getCount());
              System.out.println("$manufacturer = " + $manufacturer + ", totalCount = " + $manufacturer.getTotalCount());
              $model.setCount($model.getCount() + 1);
              $manufacturer.setTotalCount($manufacturer.getTotalCount() + 1);
              drools.update($model, mask_$model);
              drools.update($manufacturer, mask_$manufacturer);
          }
      

              lmolteni@redhat.com Luca Molteni
              rhn-support-myoshida Masato Yoshida
              Daniel Rosa Daniel Rosa
              Daniel Rosa Daniel Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: