<br>> So the question is it a bug or a feature? :)<br><br> Well, there are no bugs, only features! ;)<br> But we still should change the feature to properly match the spec semantics of "not". :) Can you please open a ticket and attach your test case bellow? Should be an easy fix. <br>
<br> Thanks,<br> Edson<br><br><div class="gmail_quote">2010/1/12 Taras Svirskyi <span dir="ltr"><<a href="mailto:stware@gmail.com">stware@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
I don't know exactly is it a bug or am I doing something wrong.<br>
Consider following example.<br>
There are nodes that are connected into directed graph. Each node has<br>
special collection of attributes. Under some conditions attributes<br>
should be propagated along the edges in the graph.<br>
<br>
Lets model this with following code.<br>
<br>
/******* propagation rules **********************/<br>
package com.test.collection;<br>
<br>
rule "move child"<br>
when<br>
c : Child()<br>
s : CNode( children contains c)<br>
l : Link( src == s,<br>
t : target && target.children not contains c )<br>
then<br>
System.out.println("adding "+c+" from "+s+" to "+t);<br>
t.addChild(c);<br>
update(t);<br>
end<br>
<br>
<br>
/** Child.java (represent special attributes of a node) *******/<br>
package com.test.collection;<br>
<br>
public class Child {<br>
private String name;<br>
public Child(String name){<br>
<a href="http://this.name" target="_blank">this.name</a> = name;<br>
}<br>
public String getName() {<br>
return name;<br>
}<br>
@Override<br>
public String toString() {<br>
return "child("+name+")";<br>
}<br>
}<br>
<br>
/********* CNode.java - nodes of a graph *************/<br>
package com.test.collection;<br>
<br>
import java.util.HashSet;<br>
import java.util.Set;<br>
<br>
public class CNode {<br>
private Set<Child> children;<br>
<br>
public CNode() {<br>
this.children = new HashSet<Child>();<br>
}<br>
<br>
public Set<Child> getChildren() {<br>
return children;<br>
}<br>
<br>
public void addChild(Child ch){<br>
children.add(ch);<br>
}<br>
<br>
@Override<br>
public String toString() {<br>
return "Node{children="+children+"}";<br>
}<br>
}<br>
<br>
/**** Link.java - edges of a graph *******/<br>
package com.test.collection;<br>
<br>
public class Link {<br>
private CNode src;<br>
private CNode target;<br>
<br>
public Link(CNode src, CNode target) {<br>
this.src = src;<br>
this.target = target;<br>
}<br>
<br>
public CNode getSrc() {<br>
return src;<br>
}<br>
<br>
public CNode getTarget() {<br>
return target;<br>
}<br>
}<br>
<br>
/********************* populate session with facts **********/<br>
Child c0 = new Child("x");<br>
Child c1 = new Child("y");<br>
Child c2 = new Child("z");<br>
<br>
CNode src = new CNode();<br>
src.addChild(c0);<br>
src.addChild(c1);<br>
<br>
CNode target = new CNode();<br>
target.addChild(c0);<br>
<br>
Link link = new Link(src,target);<br>
<br>
// populate with facts<br>
ksession.insert(c0);<br>
ksession.insert(c1);<br>
ksession.insert(c2);<br>
ksession.insert(link);<br>
ksession.insert(src);<br>
ksession.insert(target);<br>
<br>
/****************************************************************/<br>
So with all that code listed below I've got following output from rules:<br>
--<br>
adding child(x) from Node{children=[child(x), child(y)]} to<br>
Node{children=[child(x)]}<br>
--<br>
That means that 'not contains' operator actually works as 'contains'<br>
one. Still when I changed it to older operator 'excludes' everything<br>
goes right printing out.<br>
---<br>
adding child(y) from Node{children=[child(y), child(x)]} to<br>
Node{children=[child(x)]}<br>
---<br>
<br>
I've noticed that rewriting rule in form of simple statements also fix<br>
issue.<br>
<br>
rule "move child"<br>
when<br>
c : Child()<br>
s : CNode( children contains c)<br>
t : CNode( children not contains c )<br>
l : Link( src == s, target == t)<br>
then<br>
System.out.println("adding "+c+" from "+s+" to "+t);<br>
t.addChild(c);<br>
update(t);<br>
end<br>
<br>
So the question is it a bug or a feature? :)<br>
<br>
regards,<br>
Taras<br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>