[rules-users] Guvnor and drools implementation - questions
Vincent Legendre
vincent.legendre at eurodecision.com
Tue Mar 8 17:37:11 EST 2011
> Yes i created rueles with guided editor and it's working with my
> attribute. is there a way to remove "empty", "entrySet", "keySet",
> "clone",... herited from Map. So i would have only the attribute i
> have defined?
Don't make the POJO extends Map, but containing a map.
>
> i have always used drl file instead of package. If i deploy a
> file.pkg, is there a way to know what's in it? If i deploy something,
> i just want to be able later to very that all is well what i think if
> i have a doubt (easy with drl file).
try this (the only trick is to compact the rules that comes from a
decision table into one main log line) :
public static void dumpKbContent(KnowledgeBase knowledgeBase) {
System.out.println("================ " + ruleSet + "
================");
// Dump content
for (KnowledgePackage p : knowledgeBase.getKnowledgePackages()) {
System.out.println("-o0o- Package " + p.getName() + " -o0o-");
System.out.println("Processes : ");
for (Process flow : p.getProcesses()) {
System.out.println(" - " + flow.getName());
}
System.out.println("Rules : ");
String lastRuleName = "";
for (Rule rule : p.getRules()) {
String ruleName = extractMainTableName(rule.getName());
if (!ruleName.equals(lastRuleName)) {
System.out.println(" - " + ruleName);
lastRuleName = ruleName;
}
}
System.out.println("-o0o- End Package " + p.getName() + "
-o0o-");
}
System.out.println("================ END " + ruleSet + "
================");
}
private static String extractMainTableName(String ruleName) {
// tables
Pattern p = Pattern.compile("(.*)_[0-9]+");
Matcher m = p.matcher(ruleName);
if (m.matches()) {
return m.group(1) + " ... table";
} else {
return ruleName;
}
}
More information about the rules-users
mailing list