ilog.rules.dt.model.helper

Class IlrDTHelper

  • java.lang.Object
    • ilog.rules.dt.model.helper.IlrDTHelper
  • All Implemented Interfaces:
    ilog.rules.dt.model.IlrDTProperties


    public class IlrDTHelper
    extends java.lang.Object
    implements ilog.rules.dt.model.IlrDTProperties
    IlrDTHelper provides helper methods used to manipulate a DT.
    • Constructor Detail

      • IlrDTHelper

        public IlrDTHelper()
    • Method Detail

      • isTree

        public static boolean isTree(IlrDTModel dtModel)
        Tests if the model is a decision tree or a decision table.
        Parameters:
        dtModel - The DT model to test.
        Returns:
        If the model is a decision tree, true is returned. If the model is a decision table, false is returned.
      • getOtherwiseItemCount

        public static int getOtherwiseItemCount(IlrDTPartition partition)
        Gets the number of Otherwise items in a partition.
        Parameters:
        partition - The partition to test.
      • containsOtherwise

        public static boolean containsOtherwise(IlrDTPartition partition)
        Tests if a partition contains an otherwise expression.
        Parameters:
        partition - The partition to test.
        Returns:
        If a partition contains an otherwise expression, true is returned.
      • createPartitionItemAt

        public static IlrDTPartitionItem createPartitionItemAt(IlrDTModel dtModel,
                                               int row,
                                               int column)
        Creates a partition item and fills it with the default expression of its definition if no partition item exist at a specific row and column.
        Returns:
        The new partition item.
        See Also:
        getPartitionItem(IlrDTModel, int, int)
      • getDefinition

        public static IlrDTDefinition getDefinition(IlrDTModel dtModel,
                                    int columnIndex)
        Returns the definition in a specific column. Note that the action definition index starts after the partition definitions.
        Returns:
        The definition at columnIndex.
      • getExpressionHandler

        public static IlrDTExpressionHandler getExpressionHandler(IlrDTModel dtModel,
                                                  int rowIndex,
                                                  int columnIndex)
        Returns the expression handler at row/column, a partition item or an action, depending on the column. May be null.
        Returns:
        The expression handler at row/column, a partition item or an action, depending on the column. May be null.
      • getRuleText

        public static java.lang.String getRuleText(IlrDTController controller,
                                   IlrDTActionSet as)
        Returns the BAL text of a row in a decision table or the action node of a decision tree represented by the given ActionSet for the DT represented by its controller.
        Parameters:
        controller - the DT Controller representing the Decision Table or the Decision Tree
        as - the action set representing the Row or the Action Node
        Returns:
        a BAL representation of the action set in the DT locale
      • getRuleHTMLText

        public static java.lang.String getRuleHTMLText(IlrDTController controller,
                                       IlrDTActionSet as,
                                       boolean includeComment)
        Return an HTML representation of the rule corresponding of the given Action Set
        Parameters:
        controller -
        as - the action set representing the Row or the Action Node
        Returns:
        an HTML string of the BAL rule or null if the rule has syntactic errors
      • getHTMLTable

        public static java.lang.String getHTMLTable(IlrDTController controller,
                                    boolean showEmptyRow,
                                    boolean includeCSS,
                                    boolean inlineStyle)
        Deprecated. inlineStyle option has no effect
        This method computes an HTML table representation of the given Decision Table Model.
        Parameters:
        controller -
        showEmptyRow -
        includeCSS -
        inlineStyle -
        Returns:
        an HTML string of the whole table styled with CSS
      • getHTMLTable

        public static java.lang.String getHTMLTable(IlrDTController controller,
                                    boolean showEmptyRow,
                                    boolean includeCSS)
        Computes an HTML table representation of the given decision table model.
        Parameters:
        controller - The DT controller.
        showEmptyRow - Set to true to print empty rows.
        includeCSS - Set to true to include CSS definitions in the generated HTML.
        Returns:
        An HTML string containing the whole table styled with CSS.
      • getHTMLTable

        public static java.lang.String getHTMLTable(IlrDTController controller)
        Computes an HTML table representation of the given decision table model.
        Parameters:
        controller - The DT controller.
        Returns:
        An HTML string containing the whole table styled with CSS.
      • getPreconditionHTMLText

        public static java.lang.String getPreconditionHTMLText(IlrDTController controller)
        This method returns the HTML of the preconditions of the given DT represented by its controller. Note that the text of the preconditions is returned if the preconditions cannot be interpreted without syntax errors.
        Parameters:
        controller - the DT Controller representing the DT for which we would like to have the preconditions
        Returns:
        an HTML text of the precondition or the text of the preconditions if the text has syntax error.
      • getPreconditionsText

        public static java.lang.String getPreconditionsText(IlrDTModel dtModel)
        Returns the precondition of the dtModel.
        Parameters:
        dtModel - The DT model to get the preconditions from.
        Returns:
        The precondition of the dtModel.
      • setPreconditionsText

        public static void setPreconditionsText(IlrDTModel dtModel,
                                java.lang.String text)
        Changes the guard condition of the IlrDTModel.
        Parameters:
        dtModel - The DT model to set the preconditions text.
        text - The new precondition of the model.
      • createDTController

        public static IlrDTController createDTController(IlrDTRuleElement dtRuleElement,
                                         IlrDTEnvironment dtEnvironment)
        This method is a helper to create a DTController from a given DTRuleElement, a DT environment. The created DT Model associated to this controller is "minimal". Minimal in this context means that the created DT Model has only 1 Condition Definition, 1 Action Definition, a Root Partition with an empty Condition and 1 ActionSet with 1 Action.
        Parameters:
        dtRuleElement - the DTRuleElement represented the Decision Table or Tree.
        dtEnvironment - the environment in which the controller is built
        Returns:
        a newly created DTController
      • createDTController

        public static IlrDTController createDTController(IlrDTRuleElement dtRuleElement,
                                         IlrDTEnvironment dtEnvironment,
                                         org.w3c.dom.Node dom)
        This method is a helper to create a DTController from a given DTRuleElement, a DT environment and a content given as a DOM fragment. This method will instantiate a DT Model and will apply checking that are enabled for this model (Overlap, Gap...).
        Parameters:
        dtRuleElement - the DTRuleElement represented the Decision Table or Tree.
        dtEnvironment - the environment in which the controller is built
        dom - the root element of the DOM representing the content of the Decision Table or Tree. If null, the DT model will stay empty.
        Returns:
        a newly created DTController
      • createDTController

        public static IlrDTController createDTController(IlrDTRuleElement dtRuleElement,
                                         IlrDTEnvironment dtEnvironment,
                                         java.io.Reader content)
        This method is a helper to create a DTController from a given DTRuleElement, an environment and a content given as Reader. This method will instantiate a DT Model and will apply checking that are enabled for this model (Overlap, Gap...).
        Parameters:
        dtRuleElement - the DTRuleElement represented the Decision Table or Tree.
        dtEnvironment - the environment in which the controller is built
        content - a reader that contains the XML of the Decision Table or Tree content. If null, the DT model will stay empty. The root node of the XML fragment is supposed to be <DT>.
        Returns:
        a newly created DTController or null if XML cannot be read.
      • createDTController

        public static IlrDTController createDTController(IlrDTRuleElement dtRuleElement,
                                         IlrDTEnvironment dtEnvironment,
                                         java.io.Reader content,
                                         boolean check,
                                         java.util.Collection errors)
        This method is a helper to create a DTController from a given DTRuleElement, a DT environment and a content given as a Reader. This method will instantiate a DT Model. If check is set to true, this method will apply checking that are enabled for this model (Overlap, Gap...) and return errors on the provided error collection if any. If an exception occurs during the load or the checking, an empty DT model is returned an error is created, logged and returned to the provided error collection if any.
        Parameters:
        dtRuleElement - the DTRuleElement represented the Decision Table or Tree.
        dtEnvironment - the environment in which the controller is built
        content - a reader that contains the XML of the Decision Table or Tree content. If null, the DT model will stay empty. The root node of the XML fragment is supposed to be <DT>.
        check - if true, the model is checked after beeing load.
        errors - if not null, errors are collected and added to this collection
        Returns:
        a newly created DTController or null if XML cannot be read.
      • createDTController

        public static IlrDTController createDTController(IlrDTRuleElement dtRuleElement,
                                         IlrDTEnvironment dtEnvironment,
                                         org.w3c.dom.Node dom,
                                         boolean check,
                                         java.util.Collection errors)
        This method is a helper to create a DTController from a given DTRuleElement, a DT environment and a content given as a DOM fragment. This method will instantiate a DT Model. If check is set to true, this method will apply checking that are enabled for this model (Overlap, Gap...) and return errors on the provided error collection if any. If an exception occurs during the load or the checking, an empty DT model is returned an error is created, logged and returned to the provided error collection if any. Note that if check is false, default checkers of this model are disabled.
        Parameters:
        dtRuleElement - the DTRuleElement represented the Decision Table or Tree.
        dtEnvironment - the environment in which the controller is built
        dom - the root element of the DOM representing the content of the Decision Table or Tree. If null, the DT model will stay empty.
        check - if true, the model is checked after being load.
        errors - if not null and check is true, errors are collected and added to this collection
        Returns:
        a newly created DTController
      • getXML

        public static org.w3c.dom.Node getXML(IlrDTController dtController)
        Creates an XML serialization of the model. The node root tag of the XML produced is <DT>
        Parameters:
        dtController - The dt controller.
        Returns:
        The node root tag
      • getIRLCode

        public static java.lang.String getIRLCode(IlrDTController dtController,
                                  java.util.Collection errors)
        Converts the given DT Model represented by its controller into IRL code.
        Parameters:
        dtController - The DT controller representing the DT Model.
        errors - If provided, translation errors may be reported in this list
        Returns:
        A string containing the IRL representation of the DT model.
      • hasInvalidDefinitions

        public static boolean hasInvalidDefinitions(IlrDTModel dtModel,
                                    boolean checkOverriddenExpressions)
        This method returns whether the given DT has some invalid definition expressions. A definition expression is invalid if it has some syntactic errors. If such errors exist on a DT, some functionalities can be forbidden, such as conversion to a different locale for instance.
        Parameters:
        dtModel -
        checkOverriddenExpressions - if true, definition of condition overriding their column are also checked.
        Returns:
        true if one of the expression definition of the given model is invalid.

© Copyright IBM Corp. 1987, 2017