[rules-users] drools queries: strange dependency

upalik upali at codegen.co.uk
Wed Apr 10 23:33:22 EDT 2013


This message was cross-posted to stack-exchange. If someone wants to answer
there, the URL is
http://stackoverflow.com/questions/15922343/drools-queries-strange-dependency
.
I'm somewhat new to Drools, and experienced this strange behavior during
writing a query.
To start with, the Hotel class here is a subclass of PlaceImpl, which
implements the interface Place. PlaceImpl itself is a subclass (via another
class) of OntologyClassImpl, where the method getClasses() is implemented in
the most trivial way: it returns an already existing java.util.Set of
objects. In short, getClasses() is accessible from both Place interface and
Hotel class.
My problem is this: The following query does not return any result even when
there are matching Hotels.
query "qryRomantic"     $e:   Hotel (classes contains
Semantics.AMB_Romantic)end
However, if I replace Hotel with Place, then the /query returns desired
results/, although the ONLY condition-setting rules are written for Hotel,
as follows. (This rule actually gets fired several times.)
rule "Set semantic class Romantic"no-loop    when        $hotel: Hotel( ...
conditions go here ... )    then        modify ($hotel){           
addToClasses(Semantics.AMB_Romantic)        }end
It does not end there.
if I add another query to the rule file, for exactly the opposite condition
as follows,
query "qryNonRomantic"     $e:   Hotel (classes not contains
Semantics.AMB_Romantic)end
then the /first query/ starts to return the desired results, /EVEN WHEN the
new query is not called at all/!
What am I doing wrong? I'd be really grateful for any pointers.



--
View this message in context: http://drools.46999.n3.nabble.com/drools-queries-strange-dependency-tp4023320.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130410/a56f2706/attachment.html 


More information about the rules-users mailing list