예제: 비즈니스 규칙 언어의 루트 구조 재정의

새 루트 노드 구현의 예로 BQL(Business Query Language)에 대한 루트 노드를 추가할 수 있습니다. 또한 루트 노드 변환기를 제공해야 합니다.

더 이상 사용되지 않는 기능:

더 이상 사용되지 않음 아이콘 사용자 정의 비즈니스 규칙 언어에 대한 지원이 V8.8.1에서 더 이상 사용되지 않습니다. 이 기능은 제품의 향후 릴리스에서 제거됩니다. 마이그레이션 세부사항은 더 이상 사용되지 않는 기능을 참조하십시오.

추상 구문에 대한 새 루트 노드를 제공하려면 즉, 완전히 새로운 규칙 언어를 작성하려면 특정 루트 노드 변환기를 제공해야 합니다.

루트 노드 변환기는 IlrRuleStatement 인스턴스를 작성하고 서브 노드에서 context.processNode를 호출하여 구조를 완성하는 역할을 합니다.

예를 들어, 다음과 같이 BQL(Business Query Language)의 루트 노드(T-class-rule)를 구현합니다.

public static class ClassRuleNodeTranslator implements IlrNodeTranslator
{
  public IlrStatement process(IlrSyntaxTree.Node node,
                              IlrTranslationContext context) {
    // BQL generates one rule
    IlrRuleStatement rule = new IlrRuleStatement(node);
    IlrIntermediateForm iform = context.getIntermediateForm();
    iform.setRuleStatement(rule);
    
    // Binding is implicit in BQL
    IlrConcept ruleQueryConcept = 
                context.getVocabulary().getConcept("bql.RuleQuery");
    rule.addConditionStatement(new IlrSimpleBindingStatement(node, 
                                      "ruleQuery", ruleQueryConcept));
    
    // Process class condition
    IlrSyntaxTree.Node classCondNode = node.getSubNode("class-condition");

    // Process the condition part
    context.setCurrentRulePart(IlrTranslationContext.CONDITIONS_PART);
    IlrConditionStatement condStmt = 
           (IlrConditionStatement) context.processNode(classCondNode);
    if (condStmt != null)
      rule.addConditionStatement(condStmt);
      
    // Process the action part
    context.setCurrentRulePart(IlrTranslationContext.ACTIONS_PART);

    IlrSyntaxTree.Node actionsNode = node.getSubNode("actions");
    if (actionsNode != null)
    {
      IlrActionStatement actionStmt = 
        (IlrActionStatement) context.processNode(actionsNode);
      if (actionStmt != null)
        rule.addActionStatement(actionStmt);
    }      
    return rule;
  }
}