Here's how I'd address this issue. I haven't compiled or run this but I hope it communicates the idea.

rule "Every mother and father produce a child"
        no-loop
        when
                $mother : Mother(  )
                $father : Father(  )
                not Child( mother = $mother, father = $father )
        then
                Child child = new Child($mother.getId() + "-" + 
$father.getId());
                child.setMother($mother);
                child.setFather($father);
                insertLogical( child );
end

rule "Every child gets his/her father's first and last name"
        no-loop
        when
                $father : Father( $first: first, $last: last )
                $child : Child( father == $father,
                               first != $first,
                                last != last )
        then
                $child.setFirst($first);
                $child.setLast($last);
                update($child);
end

rule "Every child gets his/her mother's middle name"
        no-loop
        when
                $mother : Mother( $middle: middle )
$child : Child( mother == $mother, middle != middle )
        then
                $child.setMiddle($middle);
                update($child);
end


_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to