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

Implement xpath notation in drools constraints

    Details

    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 6.4.0.Final
    • Component/s: None
    • Labels:
      None

      Description

      It is required to allow an xpath notation in drools constraints like the following:

      Person( $pet : /pets ) 
      

      that is formally equivalent to the more verbose:

      Person( $pets : pets )
      $pet : Pet() from $pets
      

      It should be also possible to have conditions filtering the collection like in:

      Person( $pet : /pets[ age == 5 ] )
      

      corresponding to:

      Person( $pets : pets )
      $pet : Pet(age == 5) from $pets
      

      Of course also multiple indirections has to be allowed, so the following:

      Man( $toy : /wife/children/toys )
      

      will be equivalent to:

      $man: Man( $wife: wife )
      $child: Child() from $wife.children
      $toy: Toy() from $child.toys
      

      In this case the xpath notation will also allow to flatten the 2 from nodes in a single one that will internally flatten the collection of collections. Since it is necessary to distinguish the case when we want to iterate a collection from the case when we want to bind the collection as a whole it is possible to mix the collection iteration operator '/' and the simple dereferencing operator '.' as in:

      Man( $toys : /wife/children.toys )
      

      In this last case this pattern binds each List<Toy> for each child as a whole, so this is equivalent to:

      $man: Man( $wife: wife )
      Child( $toys: toys ) from $wife.children
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mfusco Mario Fusco
                  Reporter:
                  mfusco Mario Fusco
                • Votes:
                  1 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: