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

scala case class, Option field and mvel : unable to resolve method using strict-mode

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 5.3.1.Final, 5.3.2.Final, 5.4.0.Final
    • Fix Version/s: 5.5.0.Beta1
    • Component/s: drools-compiler
    • Labels:
      None
    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      with a cast operation such as :
      address.get.town becomes ((Address)address.get).town
      But this is not satisfactory.

      Show
      with a cast operation such as : address.get.town becomes ((Address)address.get).town But this is not satisfactory.

      Description

      case class Address(street:String, town:String, country:String)
      case class Home(someone:Someone, address:Option[Address])

      rule "Who live at London"
      when
      $someone:Someone($name:name)
      Home(someone == $someone, address.isDefined, address.get.town == "London")
      then
      insert(new InformationRequest($someone, $name+" lives in London"))
      end

      address.get is seen as a java.lang.Object, not an "Address". The reported error is :

      $ sbt run
      [info] Loading project definition from /home/dcr/dev-new/scala-drools-dummy-project/project
      [info] Set current project to ScalaDroolsDummyProject (in build file:/home/dcr/dev-new/scala-drools-dummy-project/)
      [info] Running dummy.Dummy
      Unable to Analyse Expression address.get.town:
      [Error: unable to resolve method using strict-mode: java.lang.Object.town()]
      [Near :

      {... address.get.town ....}

      ]
      ^
      [Line: 61, Column: 49] : [Rule name='Who live at London']

      Although I've set mvel strict to false :

      System.setProperty("drools.dialect.mvel.strict", "false")

        Attachments

          Activity

            People

            Assignee:
            mfusco Mario Fusco
            Reporter:
            dacr Crosson David (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: