Search in sources :

Example 6 with Restriction

use of org.drools.verifier.components.Restriction 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));
}
Also used : ObjectType(org.drools.verifier.components.ObjectType) Restriction(org.drools.verifier.components.Restriction) MissingRange(org.drools.verifier.report.components.MissingRange) VerifierData(org.drools.verifier.data.VerifierData) HashMap(java.util.HashMap) VerifierRule(org.drools.verifier.components.VerifierRule)

Aggregations

Restriction (org.drools.verifier.components.Restriction)6 ArrayList (java.util.ArrayList)3 Pattern (org.drools.verifier.components.Pattern)3 VerifierRule (org.drools.verifier.components.VerifierRule)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)2 LiteralRestriction (org.drools.verifier.components.LiteralRestriction)2 NumberRestriction (org.drools.verifier.components.NumberRestriction)2 SubPattern (org.drools.verifier.components.SubPattern)2 SubRule (org.drools.verifier.components.SubRule)2 VerifierData (org.drools.verifier.data.VerifierData)2 MissingRange (org.drools.verifier.report.components.MissingRange)2 Solvers (org.drools.verifier.solver.Solvers)2 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 DrlParser (org.drools.compiler.compiler.DrlParser)1 PatternDescr (org.drools.compiler.lang.descr.PatternDescr)1 Field (org.drools.verifier.components.Field)1 ObjectType (org.drools.verifier.components.ObjectType)1