I have following specific requirement to be implemented in Drools. Don't know how to do this. If anyone know give me a direction.
In my project drool rules are associated into a java class . Rules are defined as string list filed in the class. I have list of these class objects and I need to execute rules of these classes. I used following code to add rules. Imagine "Test" class has the rules.
for (Test test : testList) {
List<String> rules = test.getRules();
if (rules != null) {
for (String rule : rules) {
System.out.println("Added Rule...");
knowledgeBuilder.add(ResourceFactory.newByteArrayResource(rule.getBytes()), ResourceType.DRL);
}
}
}
as facts "Test" object list and other required objects are added. Rules are executing without an issue. Now i need to get specific "Test" object which the rule succeed. Does anybody have an idea how to do this ? I think there should be a mechanism to combine Test object with rule, but don't know how to do that. Can any one help ?
Thanks in advance .