import org.drools.verifier.report.components.Severity;
public class ComponentsReportModeller extends ReportModeller {
public static void writeHTML(String path, VerifierResult result) {
VerifierData data = result.getVerifierData();
// Source folder
File sourceFolder = new File(path + UrlFactory.SOURCE_FOLDER);
sourceFolder.mkdir();
// Base files
// index.htm
writeToFile(path + UrlFactory.SOURCE_FOLDER + File.separator
+ UrlFactory.HTML_FILE_INDEX, formPage(UrlFactory.THIS_FOLDER,
ComponentsReportVisitor.visitObjectTypeCollection(
UrlFactory.THIS_FOLDER, data.getAllObjectTypes())));
// packages.htm
writeToFile(path + UrlFactory.SOURCE_FOLDER + File.separator
+ UrlFactory.HTML_FILE_PACKAGES, formPage(
UrlFactory.THIS_FOLDER, ComponentsReportVisitor
.visitRulePackageCollection(UrlFactory.THIS_FOLDER,
data.getAllRulePackages())));
// Rules
String ruleFolder = path + UrlFactory.SOURCE_FOLDER + File.separator
+ UrlFactory.RULE_FOLDER;
File rulesFolder = new File(ruleFolder);
rulesFolder.mkdir();
for (VerifierRule rule : data.getAllRules()) {
writeToFile(ruleFolder + File.separator + rule.getId() + ".htm",
formPage(UrlFactory.PREVIOUS_FOLDER,
ComponentsReportVisitor.visitRule(
UrlFactory.PREVIOUS_FOLDER, rule, data)));
}
// ObjectTypes
String objectTypeFolder = path + UrlFactory.SOURCE_FOLDER
+ File.separator + UrlFactory.OBJECT_TYPE_FOLDER;
File objectTypesFolder = new File(objectTypeFolder);
objectTypesFolder.mkdir();
for (ObjectType objectType : data.getAllObjectTypes()) {
writeToFile(objectTypeFolder + File.separator + objectType.getId()
+ ".htm", formPage(UrlFactory.PREVIOUS_FOLDER,
ComponentsReportVisitor.visitObjectType(
UrlFactory.PREVIOUS_FOLDER, objectType, data)));
}
// Fields
String fieldFolder = path + UrlFactory.SOURCE_FOLDER + File.separator
+ UrlFactory.FIELD_FOLDER;
File fieldsFolder = new File(fieldFolder);
fieldsFolder.mkdir();
for (Field field : data.getAllFields()) {
writeToFile(fieldFolder + File.separator + field.getId() + ".htm",
formPage(UrlFactory.PREVIOUS_FOLDER,
ComponentsReportVisitor.visitField(
UrlFactory.PREVIOUS_FOLDER, field, result)));
}