1

I want to be able to check if at least one element from a list of string elements (see $el.getTags()) is contained in a list (tagService.getAvailableTags($el.getName()) using a Drools rule. I'm using a helper method for the check: CollectionUtils.containsValuesFromList(subList, targetList, checkAllValues).

For now I'm using below rule definition:

rule "Check at least one tag is set"
when
   $el: Element()
   $tags : tagService.getTags($el.getName())
   $errors : ValidationErrors()
   $condition: CollectionUtils.containsValueFromList($el.getTags(), $tags, true)
then
   $errors.addError( $el, "el", "At least one tag should be set!");
end

Could it be possible to check if at least one sub list element is contained in a list, without using any helper method? Thanks.

4

1 回答 1

1
rule "Check at least one tag is set"
when
$el: Element()
$tags : tagService.getTags($el.getName())
$errors : ValidationErrors()
//  $condition: CollectionUtils.containsValueFromList($el.getTags(), $tags, true)
Element( Tags in ($tags) )
then
$errors.addError( $el, "el", "At least one tag should be set!");
end
于 2013-09-11T13:48:29.473 回答