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

Extraneous parentheses generated by Guided Rule editor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 7.0.0.GA
    • Decision Central
    • RHDM 7.0.0.GA on Oracle JDK 1.8.0_172 on Mac OSX 10.13.5

    • User Experience
    • Hide

      Enter rule using DRL editor and not Guided Rule editor

      Show
      Enter rule using DRL editor and not Guided Rule editor
    • Hide

      Start RHDM
      Browse to http://localhost:8080/decision-central
      Log in using the appropriate credentials
      Select Menu -> Projects
      Press the “Import Project” button
      Enter the URL “https://github.com/rlucente-se-jboss/myrepo.git
      Select “RHDM Demo” and press the “Ok” button
      Wait until all six items are indexed in the project
      Press “Create New Asset” then select “Guided Rule”
      In the “Create new Guided Rule” dialog, set the “Guided Rule” field to “SpecialHandlingGuidedRule”
      Press “Ok+”

      To the right of “WHEN”, press “+”
      Select “Order ...” and press “+ Ok”

      Click the phrase “There is an Order”
      In the dialog “Modify constraints for Order”, set “Variable name” to “$o”

      Click the phrase “There is an Order”
      In the dialog “Modify constraints for Order”, press the “Expression editor” button
      Click on “Choose...” to the right of “not bound” and select “orderlines”
      Click on “Choose...” to the right of “orderlines.” and select “size()”
      Click on “--- please choose ---“ and select “greater than”
      Click on the pencil icon to the right of “greater than” and press “Literal value”
      Leave the value “0” as is

      Add another “WHEN” condition by clicking the “+” sign to the right of the first condition

      In the dialog, select “From Accumulate...”

      Click on “click to add pattern...” above the line “From Accumulate”
      For “choose fact type”, select “Number”

      Click “There is a Number” and click on “Expression editor”

      To the right of “not bound”, select “intValue()”

      Click on “--- please choose ---“, select “greater than”

      click the pencil icon to the right of “greater than” and select “Literal value”
      Change the value “0” to the right of “greater than” to “100”

      Click on “click to add pattern...”
      Click the “From” button in the dialog
      To the right of “From”, click “Choose...” and select “$o”
      Click “Choose...” and select “orderlines”

      Click on “(click to add patterns...)” and for “choose fact type” select “OrderLine”

      Click on “There is an OrderLine”, and for “Add restriction to a field”, select “quantity”
      Click on “quantity” and set “Variable name” to “$q”

      Click on “--- please choose ---“ and select “greater than”
      Click on the pencil icon to the right of “greater than” and select “Literal value”
      Leave the value “0” unchanged

      In the box to the right of “Function”, enter “sum($q)”

      If you click on “Source” in the sub-menu headings, you’ll see the following source:

      package com.redhat.rhdm.demo;

      import java.lang.Number;

      rule "SpecialHandlingGuidedRule"
      dialect "mvel"
      when
      $o : Order( orderlines.size() > 0 )
      Number( intValue() > 100 ) from accumulate ( (OrderLine( $q : quantity > 0 ) from $o.orderlines)
      ,
      sum($q))
      then
      end

      Clicking the “Validate” button at the top of the page will result in a validation error. The reason for the error are extraneous parentheses in the condition:

      Number( intValue() > 100) from accumulate( (OrderLine($q : quantity > 0) from $o.orderlines), sum($q))

      The Guided Rule editor is not correctly generating DRL.

      Show
      Start RHDM Browse to http://localhost:8080/decision-central Log in using the appropriate credentials Select Menu -> Projects Press the “Import Project” button Enter the URL “ https://github.com/rlucente-se-jboss/myrepo.git ” Select “RHDM Demo” and press the “Ok” button Wait until all six items are indexed in the project Press “Create New Asset” then select “Guided Rule” In the “Create new Guided Rule” dialog, set the “Guided Rule” field to “SpecialHandlingGuidedRule” Press “Ok+” To the right of “WHEN”, press “+” Select “Order ...” and press “+ Ok” Click the phrase “There is an Order” In the dialog “Modify constraints for Order”, set “Variable name” to “$o” Click the phrase “There is an Order” In the dialog “Modify constraints for Order”, press the “Expression editor” button Click on “Choose...” to the right of “not bound” and select “orderlines” Click on “Choose...” to the right of “orderlines.” and select “size()” Click on “--- please choose ---“ and select “greater than” Click on the pencil icon to the right of “greater than” and press “Literal value” Leave the value “0” as is Add another “WHEN” condition by clicking the “+” sign to the right of the first condition In the dialog, select “From Accumulate...” Click on “click to add pattern...” above the line “From Accumulate” For “choose fact type”, select “Number” Click “There is a Number” and click on “Expression editor” To the right of “not bound”, select “intValue()” Click on “--- please choose ---“, select “greater than” click the pencil icon to the right of “greater than” and select “Literal value” Change the value “0” to the right of “greater than” to “100” Click on “click to add pattern...” Click the “From” button in the dialog To the right of “From”, click “Choose...” and select “$o” Click “Choose...” and select “orderlines” Click on “(click to add patterns...)” and for “choose fact type” select “OrderLine” Click on “There is an OrderLine”, and for “Add restriction to a field”, select “quantity” Click on “quantity” and set “Variable name” to “$q” Click on “--- please choose ---“ and select “greater than” Click on the pencil icon to the right of “greater than” and select “Literal value” Leave the value “0” unchanged In the box to the right of “Function”, enter “sum($q)” If you click on “Source” in the sub-menu headings, you’ll see the following source: package com.redhat.rhdm.demo; import java.lang.Number; rule "SpecialHandlingGuidedRule" dialect "mvel" when $o : Order( orderlines.size() > 0 ) Number( intValue() > 100 ) from accumulate ( (OrderLine( $q : quantity > 0 ) from $o.orderlines) , sum($q)) then end Clicking the “Validate” button at the top of the page will result in a validation error. The reason for the error are extraneous parentheses in the condition: Number( intValue() > 100) from accumulate( (OrderLine($q : quantity > 0) from $o.orderlines), sum($q)) The Guided Rule editor is not correctly generating DRL.

      The Guided Rule editor inserts extraneous parentheses in the generated DRL around the phrase "(OrderLine : quantity > 0) from $o.orderlines)" as shown below:

      package com.redhat.rhdm.demo;

      import java.lang.Number;

      rule "SpecialHandlingGuidedRule"
      dialect "mvel"
      when
      $o : Order( orderlines.size() > 0 )
      Number( intValue() > 100 ) from accumulate ( (OrderLine( $q : quantity > 0 ) from $o.orderlines)
      ,
      sum($q))
      then
      end

      This above DRL will fail to validate. If the extraneous parentheses are removed, as shown below, then the DRL is valid.

      package com.redhat.rhdm.demo;

      import java.lang.Number;

      rule "Assign Special Handling for Large Orders"
      dialect "mvel"
      when
      $o : Order( orderlines.size() > 0 )
      Number( intValue() > 100 )
      from accumulate (OrderLine( $q : quantity > 0 ) from $o.orderlines, sum($q))
      then
      $o.setIsSpecial( true )
      end

              manstis@redhat.com Michael Anstis
              rlucente-se-jboss Richard Lucente
              Jozef Marko Jozef Marko (Inactive)
              Jozef Marko Jozef Marko (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: