[jboss-jira] [JBoss JIRA] (DROOLS-664) Implement xpath notation in drools constraints
Mario Fusco (JIRA)
issues at jboss.org
Wed Dec 10 11:49:39 EST 2014
Mario Fusco created DROOLS-664:
----------------------------------
Summary: Implement xpath notation in drools constraints
Key: DROOLS-664
URL: https://issues.jboss.org/browse/DROOLS-664
Project: Drools
Issue Type: Feature Request
Reporter: Mario Fusco
Assignee: Mario Fusco
It is required to allow an xpath notation in drools constraints like the following:
{code}
Person( $pet : /pets )
{code}
that is formally equivalent to the more verbose:
{code}
Person( $pets : pets )
$pet : Pet() from $pets
{code}
It should be also possible to have conditions filtering the collection like in:
{code}
Person( $pet : /pets[ age == 5 ] )
{code}
corresponding to:
{code}
Person( $pets : pets )
$pet : Pet(age == 5) from $pets
{code}
Of course also multiple indirections has to be allowed, so the following:
{code}
Man( $toy : /wife/children/toys )
{code}
will be equivalent to:
{code}
$man: Man( $wife: wife )
$child: Child() from $wife.children
$toy: Toy() from $child.toys
{code}
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:
{code}
Man( $toys : /wife/children.toys )
{code}
In this last case this pattern binds each List<Toy> for each child as a whole, so this is equivalent to:
{code}
$man: Man( $wife: wife )
Child( $toys: toys ) from $wife.children
{code}
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
More information about the jboss-jira
mailing list