[rules-users] Not possible to directly access the property

bradypt paul.brady at airnz.co.nz
Sun Feb 19 15:53:14 EST 2012


I'm a Drools novice but am doing a regular refactor which is causing a
problem for our existing rulebase.

Before my refactor, I had an interface Itinerary that had a getRules()
method. getRules() returned a simple POJO that had a getDestination method.

My Drools rule looked like:
rule "NZSF Accommodation - With infants" salience 101
  activation-group "NZSF Accommodation"
  when
    itinerary : Itinerary( rules.destination memberOf
travelServicesFeatures.accommodationDestinations )
    eval(isOnlineBookingAllowed(itinerary) == false)
  then
    TravelService travelService = addTravelService(travelServices,
TravelService.Type.ACCOMMODATION);
    travelService.appendVariant(ResourceType.TEXT, "phone");
    travelService.setNull(ResourceType.URL, true);
    Airport destination = itinerary.getRules().getDestination();
    travelService.setArguments(ResourceType.TEXT, new
ResourceRefImpl("City." + destination.getCode()));
end

All was working fine.

My refactor is simply to move Rules.getDestination() to the Itinerary
interface so I changed my rule to:

rule "NZSF Accommodation - With infants" salience 101
  activation-group "NZSF Accommodation"
  when
    itinerary : Itinerary( destination memberOf
travelServicesFeatures.accommodationDestinations )
    eval(isOnlineBookingAllowed(itinerary) == false)
  then ...

Now I get:
java.lang.RuntimeException: Errors in rules: Not possible to directly access
the property 'accommodationDestinations' of declaration
'travelServicesFeatures' since it is not a pattern : [Rule name='NZSF
Accommodation - With infants']
Unable to create restriction '[QualifiedIndentifierRestr: memberOf
travelServicesFeatures.accommodationDestinations ]' for field 'destination'
in the rule 'NZSF Accommodation - With infants' : [Rule name='NZSF
Accommodation - With infants']

Any help greatly appreciated!

--
View this message in context: http://drools.46999.n3.nabble.com/Not-possible-to-directly-access-the-property-tp3758865p3758865.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list