[rules-users] Fwd: Retrieving constraints based on a manual solution

Wolfgang Laun wolfgang.laun at gmail.com
Mon Jan 7 05:08:25 EST 2013


On 07/01/2013, Geoffrey De Smet <ge0ffrey.spam at gmail.com> wrote:
>>
>>           WorkingMemory workingMemory = ((DroolsScoreDirector)
>> scoreDirector).getWorkingMemory();
>>           Iterator<ConstraintOccurrence> it =
>> (Iterator<ConstraintOccurrence>) workingMemory
>>               .iterateObjects(new
>> ClassObjectFilter(ConstraintOccurrence.class));
>>           while (it.hasNext()) {
>>               //here you collect constraint occurrences and prepare your
>> report
>>           }
> That part isn't documented in the manual, but it works :)
>>
>> Hope this helps, for a complete example of the usage of this (internal!)
>> api see drools planner examples from Geoffrey on Git.
> Also look into "immovable entities" (see manual). You 'll need that if
> you want to combine scenario a and b.

Or do it in a rule just added (or activated) for this run, with a very
low salience, where you'd have full pattern matching capabilities for
selection, e.g., by running a query, etc.

This wouldn't need any internal API ;-)

-W
-W


More information about the rules-users mailing list