use of org.drools.verifier.components.ObjectType in project drools by kiegroup.
the class VerifierDataMapsTest method testSaveVerifierComponentAndGetForAllComponentTypes.
@Test
public void testSaveVerifierComponentAndGetForAllComponentTypes() {
RulePackage rulePackage = VerifierComponentMockFactory.createPackage1();
saveVerifierComponentAndGet(rulePackage);
VerifierRule rule = VerifierComponentMockFactory.createRule1();
saveVerifierComponentAndGet(rule);
Pattern pattern = VerifierComponentMockFactory.createPattern1();
saveVerifierComponentAndGet(pattern);
saveVerifierComponentAndGet(new InlineEvalDescr(pattern));
saveVerifierComponentAndGet(new ObjectType(new PackageDescr("testPackage1")));
saveVerifierComponentAndGet(new RuleOperatorDescr(new AndDescr(), rule, OperatorDescrType.AND));
saveVerifierComponentAndGet(new PatternOperatorDescr(pattern, OperatorDescrType.AND));
saveVerifierComponentAndGet(new SubPattern(pattern, 0));
saveVerifierComponentAndGet(new ReturnValueFieldDescr(pattern));
saveVerifierComponentAndGet(new SubRule(rule, 0));
saveVerifierComponentAndGet(new TextConsequence(rule));
saveVerifierComponentAndGet(new PatternVariable(rule));
saveVerifierComponentAndGet(new VerifierAccessorDescr(rule));
saveVerifierComponentAndGet(new VerifierAccumulateDescr(pattern));
saveVerifierComponentAndGet(new VerifierCollectDescr(pattern));
saveVerifierComponentAndGet(new RuleEval(rule));
saveVerifierComponentAndGet(new VerifierFieldAccessDescr(rule));
saveVerifierComponentAndGet(new VerifierFromDescr(pattern));
saveVerifierComponentAndGet(new VerifierMethodAccessDescr(rule));
saveVerifierComponentAndGet(new PatternEval(pattern));
}
use of org.drools.verifier.components.ObjectType in project drools by kiegroup.
the class VerifierDataMapsTest method saveVerifierComponentAndGet.
private void saveVerifierComponentAndGet(Field field) {
VerifierData data = VerifierReportFactory.newVerifierData();
ObjectType objectType = new ObjectType(new PackageDescr("testPackage1"));
field.setObjectTypePath(objectType.getPath());
data.add(objectType);
data.add(field);
Collection<VerifierComponent> all = data.getAll();
assertEquals(2, all.size());
assertTrue(all.contains(objectType));
assertTrue(all.contains(field));
Collection<VerifierComponent> fields = data.getAll(field.getVerifierComponentType());
assertEquals(1, fields.size());
assertEquals(field, fields.toArray()[0]);
VerifierComponent field2 = data.getVerifierObject(field.getVerifierComponentType(), field.getPath());
assertNotNull(field2);
assertEquals(field, field2);
Collection<VerifierComponent> objectTypes = data.getAll(objectType.getVerifierComponentType());
assertEquals(1, objectTypes.size());
assertEquals(objectType, objectTypes.toArray()[0]);
VerifierComponent objectType2 = data.getVerifierObject(objectType.getVerifierComponentType(), objectType.getPath());
assertNotNull(objectType2);
assertEquals(objectType, objectType2);
}
use of org.drools.verifier.components.ObjectType in project drools by kiegroup.
the class ComponentsReportVisitor method visitField.
public static String visitField(String sourceFolder, Field field, VerifierReport result) {
VerifierData data = result.getVerifierData();
ObjectType objectType = data.getVerifierObject(VerifierComponentType.OBJECT_TYPE, field.getObjectTypePath());
Collection<VerifierRule> rules = data.getRulesByFieldPath(field.getPath());
Map<String, Object> map = new HashMap<String, Object>();
map.put("sourceFolder", sourceFolder);
map.put("ruleFolder", UrlFactory.RULE_FOLDER);
map.put("objectTypeFolder", UrlFactory.OBJECT_TYPE_FOLDER);
map.put("fieldFolder", UrlFactory.FIELD_FOLDER);
map.put("field", field);
map.put("objectType", objectType);
map.put("rules", rules);
if (field.getFieldType() == Field.DOUBLE || field.getFieldType() == Field.DATE || field.getFieldType() == Field.INT) {
Collection<MissingRange> causes = result.getRangeCheckCausesByFieldPath(field.getPath());
Collection<Restriction> restrictions = data.getRestrictionsByFieldPath(field.getPath());
map.put("ranges", "Ranges:" + MissingRangesReportVisitor.visitRanges(UrlFactory.PREVIOUS_FOLDER, restrictions, causes));
} else {
map.put("ranges", "");
}
String myTemplate = readFile("field.htm");
return String.valueOf(TemplateRuntime.eval(myTemplate, map));
}
use of org.drools.verifier.components.ObjectType in project drools by kiegroup.
the class HTMLReportWriter method writeReport.
public void writeReport(OutputStream out, VerifierReport result) throws IOException {
zout = new ZipOutputStream(out);
VerifierData data = result.getVerifierData();
// Base files
// index.htm
writeToFile(UrlFactory.SOURCE_FOLDER + File.separator + UrlFactory.HTML_FILE_INDEX, formPage(UrlFactory.THIS_FOLDER, ComponentsReportVisitor.visitObjectTypeCollection(UrlFactory.THIS_FOLDER, data.<ObjectType>getAll(VerifierComponentType.OBJECT_TYPE))));
// packages.htm
writeToFile(UrlFactory.SOURCE_FOLDER + File.separator + UrlFactory.HTML_FILE_PACKAGES, formPage(UrlFactory.THIS_FOLDER, ComponentsReportVisitor.visitRulePackageCollection(UrlFactory.THIS_FOLDER, data.<RulePackage>getAll(VerifierComponentType.RULE_PACKAGE))));
// Rules
String ruleFolder = UrlFactory.SOURCE_FOLDER + File.separator + UrlFactory.RULE_FOLDER;
for (VerifierRule rule : data.<VerifierRule>getAll(VerifierComponentType.RULE)) {
writeToFile(ruleFolder + File.separator + rule.getPath() + ".htm", formPage(UrlFactory.PREVIOUS_FOLDER, ComponentsReportVisitor.visitRule(UrlFactory.PREVIOUS_FOLDER, rule, data)));
}
// ObjectTypes
String objectTypeFolder = UrlFactory.SOURCE_FOLDER + File.separator + UrlFactory.OBJECT_TYPE_FOLDER;
for (ObjectType objectType : data.<ObjectType>getAll(VerifierComponentType.OBJECT_TYPE)) {
writeToFile(objectTypeFolder + File.separator + objectType.getPath() + ".htm", formPage(UrlFactory.PREVIOUS_FOLDER, ComponentsReportVisitor.visitObjectType(UrlFactory.PREVIOUS_FOLDER, objectType, data)));
}
// Fields
String fieldFolder = UrlFactory.SOURCE_FOLDER + File.separator + UrlFactory.FIELD_FOLDER;
for (Field field : data.<Field>getAll(VerifierComponentType.FIELD)) {
writeToFile(fieldFolder + File.separator + field.getPath() + ".htm", formPage(UrlFactory.PREVIOUS_FOLDER, ComponentsReportVisitor.visitField(UrlFactory.PREVIOUS_FOLDER, field, result)));
}
// Verifier messages
writeMessages(result);
// css files
String cssFolder = UrlFactory.SOURCE_FOLDER + File.separator + UrlFactory.CSS_FOLDER;
writeToFile(cssFolder + File.separator + UrlFactory.CSS_BASIC, ComponentsReportVisitor.getCss(UrlFactory.CSS_BASIC));
// Image files
String imagesFolder = UrlFactory.SOURCE_FOLDER + File.separator + UrlFactory.IMAGES_FOLDER;
copyFile(imagesFolder, "hdrlogo_drools50px.gif");
copyFile(imagesFolder, "jbossrules_hdrbkg_blue.gif");
zout.close();
}
Aggregations