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

Extraneous parentheses generated by Guided Rule editor

    XMLWordPrintable

Details

    • 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.
    • User Experience
    • Hide

      Enter rule using DRL editor and not Guided Rule editor

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

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              manstis@redhat.com Michael Anstis
              rh-ee-jomarko Jozef Marko
              Jozef Marko Jozef Marko
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: