private boolean checkCondition(TemplateContext context, ITemplateGenerator generator)
      throws GenerationFailureException {
    if (baseRuleCondition == null) {
      return true;
    }

    try {
      return (Boolean)
          QueryMethodGenerated.invoke(
              myConditionMethodName,
              generator.getGeneratorSessionContext(),
              new ReductionRuleQueryContext(context, ruleNode, generator),
              ruleNode.getModel(),
              true);
    } catch (ClassNotFoundException e) {
      String msg =
          String.format(
              "cannot find condition method '%s' : evaluate to FALSE", myConditionMethodName);
      generator.getLogger().warning(baseRuleCondition, msg);
    } catch (NoSuchMethodException e) {
      String msg =
          String.format(
              "cannot find condition method '%s' : evaluate to FALSE", myConditionMethodName);
      generator.getLogger().warning(baseRuleCondition, msg);
    } catch (Throwable t) {
      generator.getLogger().handleException(t);
      String msg =
          String.format("error executing condition '%s', see exception", myConditionMethodName);
      generator.getLogger().error(baseRuleCondition, msg);
      throw new GenerationFailureException(t);
    }
    return false;
  }
Beispiel #2
0
 private boolean reportErrorIfStrict(String msg) {
   ITemplateGenerator generator = myEnv.getGenerator();
   if (generator.isStrict()) {
     generator
         .getLogger()
         .error(myRule.getRuleNode(), String.format("Strict generation mode failure: %s", msg));
     return false;
   } else {
     generator.getLogger().warning(myRule.getRuleNode(), msg);
     return true;
   }
 }