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

DRL Dumper Not Printing the content of ConditionalBranch

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 7.0.0.Beta7
    • 6.4.0.Final
    • tools
    • None
    • Hide

      PackageDescr pkg = DescrFactory.newPackage()
      .name( "org.drools.compiler" )
      .newRule().name( "test" )
      .lhs()
      .pattern("Cheese").constraint( "type == \"stilton\"" ).end()
      .conditionalBranch()
      .condition().constraint("price < 10").end()
      .consequence().name("c1").end()
      .end()
      .pattern("Cheese").constraint( "type == \"cheddar\"" ).end()
      .conditionalBranch()
      .condition().constraint("price > 10").end()
      .consequence().name("c2").end()
      .end()
      .end()
      .rhs( "// do something" )
      .namedRhs( "c1", "// do something else\n" )
      .end()
      .getDescr();

      return new DrlDumper().dump( pkg );

      Show
      PackageDescr pkg = DescrFactory.newPackage() .name( "org.drools.compiler" ) .newRule().name( "test" ) .lhs() .pattern("Cheese").constraint( "type == \"stilton\"" ).end() .conditionalBranch() .condition().constraint("price < 10").end() .consequence().name("c1").end() .end() .pattern("Cheese").constraint( "type == \"cheddar\"" ).end() .conditionalBranch() .condition().constraint("price > 10").end() .consequence().name("c2").end() .end() .end() .rhs( "// do something" ) .namedRhs( "c1", "// do something else\n" ) .end() .getDescr(); return new DrlDumper().dump( pkg );
    • NEW
    • NEW

    Description

      While trying to use conditionalbranch api for handling multiple if-then blocks, the DRL dumper is not printing the content we have used for conditionalbranch. Please find the sample code below and the restuls

      Code

      PackageDescr pkg = DescrFactory.newPackage()
      .name( "org.drools.compiler" )
      .newRule().name( "test" )
      .lhs()
      .pattern("Cheese").constraint( "type == \"stilton\"" ).end()
      .conditionalBranch()
      .condition().constraint("price < 10").end()
      .consequence().name("c1").end()
      .end()
      .pattern("Cheese").constraint( "type == \"cheddar\"" ).end()
      .conditionalBranch()
      .condition().constraint("price > 10").end()
      .consequence().name("c2").end()
      .end()
      .end()
      .rhs( "// do something" )
      .namedRhs( "c1", "// do something else\n" )
      .end()
      .getDescr();

      return new DrlDumper().dump( pkg );

      Output

      package org.drools.compiler

      rule "test"
      when
      Cheese( type == "stilton" )

      Cheese( type == "cheddar" )

      then
      // do something
      then[c1]
      // do something else
      end

      In the above example the content "price < 10" and "price > 10" which we have used for conditionalBranch is not getting printed. On further investigation we found the drl.mvel template does not have the import org.drools.compiler.lang.descr.ConditionalBranchDescr.

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            siyadmhd Siyad Theyparambil Mohammed (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: