Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-3517

Combining custom operators with OR results in compile error

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Hide

      Trying to compile the following code:

      package test.rulez
      
      declare GN
      gNo : Double
      end
      
      
      declare t547147
      c547148 : String
      c547149 : String
      end
      
      declare Tra48
      gNo : Double
      postCode : String
      name : String
      cnt : String
      end
      
      
      rule "r548695.1"
      no-loop true
      dialect "mvel"
      when
      gnId : GN()
      la : t547147( )
      v1717 : Tra48( gnId.gNo==gNo , name F_str[startsWith] la.c547148 || postCode F_str[contains] la.c547149 )
      then
      System.out.println("Rule r548695.1 fired");
      end 
      

      results in the following error:

      Unable to Analyse Expression gnId.gNo == gNo && ( F_str0.evaluate( name, la.c547148 ) || F_str1.evaluate( postCode, la.c547149 ) ):
      [Error: unable to resolve method using strict-mode: test.rulez.Tra48.F_str0()]
      [Near :

      {... nId.gNo == gNo && ( F_str0.evaluate( name, la.c547 ....}

      ]
      ^ : [Rule name='r548695.1']

      Exception in thread "main" java.lang.IllegalArgumentException: Could not parse knowledge.
      at testfordrools.TestForDrools.main(TestForDrools.java:45)

      On the contrary, by replacing || with && in the above rule file as follows:

      package test.rulez
      
      declare GN
      gNo : Double
      end
      
      
      declare t547147
      c547148 : String
      c547149 : String
      end
      
      declare Tra48
      gNo : Double
      postCode : String
      name : String
      cnt : String
      end
      
      
      
      rule "r548695.1"
      no-loop true
      dialect "mvel"
      when
      gnId : GN()
      la : t547147( )
      v1717 : Tra48( gnId.gNo==gNo , name F_str[startsWith] la.c547148 && postCode F_str[contains] la.c547149 )
      then
      System.out.println("Rule r548695.1 fired");
      end 
      

      no errors are produced and the expected result (i.e. "Rule r548695.1 fired") is printed.

      Show
      Trying to compile the following code: package test.rulez declare GN gNo : Double end declare t547147 c547148 : String c547149 : String end declare Tra48 gNo : Double postCode : String name : String cnt : String end rule "r548695.1" no-loop true dialect "mvel" when gnId : GN() la : t547147( ) v1717 : Tra48( gnId.gNo==gNo , name F_str[startsWith] la.c547148 || postCode F_str[contains] la.c547149 ) then System.out.println("Rule r548695.1 fired"); end results in the following error: Unable to Analyse Expression gnId.gNo == gNo && ( F_str0.evaluate( name, la.c547148 ) || F_str1.evaluate( postCode, la.c547149 ) ): [Error: unable to resolve method using strict-mode: test.rulez.Tra48.F_str0()] [Near : {... nId.gNo == gNo && ( F_str0.evaluate( name, la.c547 ....} ] ^ : [Rule name='r548695.1'] Exception in thread "main" java.lang.IllegalArgumentException: Could not parse knowledge. at testfordrools.TestForDrools.main(TestForDrools.java:45) On the contrary, by replacing || with && in the above rule file as follows: package test.rulez declare GN gNo : Double end declare t547147 c547148 : String c547149 : String end declare Tra48 gNo : Double postCode : String name : String cnt : String end rule "r548695.1" no-loop true dialect "mvel" when gnId : GN() la : t547147( ) v1717 : Tra48( gnId.gNo==gNo , name F_str[startsWith] la.c547148 && postCode F_str[contains] la.c547149 ) then System.out.println("Rule r548695.1 fired"); end no errors are produced and the expected result (i.e. "Rule r548695.1 fired") is printed.
    • Compatibility/Configuration

    Description

      I recently migrated from Drools.5.0.1 to Drools.5.4.0 and I am having issues when combining constraints with OR when custom operators are involved.

      For example, the following rule:

      rule "r548695.1"
      no-loop true
      dialect "mvel"
      when
      gnId : GN()
      la : t547147( )
      v1717 : Tra48( gnId.gNo==gNo , name F_str[startsWith] la.c547148 || postCode F_str[contains] la.c547149 )
      then
      System.out.println("Rule r548695.1 fired");
      end

      results in the following exception:

      Unable to Analyse Expression gnId.gNo == gNo && ( F_str0.evaluate( name, la.c547148 ) || F_str1.evaluate( postCode, la.c547149 ) ):
      [Error: unable to resolve method using strict-mode: my.package.rulez.Tra48.F_str0()]
      [Near :

      {... gNo == gNo && ( F_str0.evaluate( name, la.c54 ....}

      ]
      ^ : [Rule name='r548695.1']

      Please note, that the same rule using AND (&&) between the custom operators compiles OK.

      The above rule had not problem whatsoever in Drools.5.0.1.

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            rouvas Stathis Rouvas (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

            Dates

              Created:
              Updated:
              Resolved:
              Archived:

              PagerDuty