Package org.drools.verifier.dao

Examples of org.drools.verifier.dao.VerifierData


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)));
    }
View Full Code Here


      e.printStackTrace();
    }
  }

  private static void writeMessages(String path, VerifierResult result) {
    VerifierData data = result.getVerifierData();

    String errors = VerifierMessagesVisitor
        .visitVerifierMessagesCollection(
            Severity.ERROR.getTuple(),
            result.getBySeverity(Severity.ERROR),
View Full Code Here

    return String.valueOf(TemplateRuntime.eval(myTemplate, map));
  }

  public static String visitField(String sourceFolder, Field field,
      VerifierResult result) {
    VerifierData data = result.getVerifierData();
    ObjectType objectType = data.getObjectTypeById(field.getObjectTypeId());
    Collection<VerifierRule> rules = data.getRulesByFieldId(field.getId());

    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.FieldType.DOUBLE
        || field.getFieldType() == Field.FieldType.DATE
        || field.getFieldType() == Field.FieldType.INT) {
      Collection<RangeCheckCause> causes = result
          .getRangeCheckCausesByFieldId(field.getId());
      Collection<Restriction> restrictions = data
          .getRestrictionsByFieldId(field.getId());
      map.put("ranges", "Ranges:"
          + MissingRangesReportVisitor.visitRanges(
              UrlFactory.PREVIOUS_FOLDER, restrictions, causes));
    } else {
View Full Code Here

TOP

Related Classes of org.drools.verifier.dao.VerifierData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.