Class Dimension

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>, UnnamedComponent, ExpressionContext, VariableScope

public class Dimension extends UnnamedRuleComponent<Dimension> implements ExpressionContext
A Dimension defines a top-level ANDed term in the condition part of every rule in a decision table. A Dimension contains
  • an Expression
  • a BucketSet, or a reference to a datamodel BucketSet
  • a table of DimensionNodes. For the last Dimension, the table contains a node per rule in the sheet.
The Expression's value can be quantized using the BucketSet. One way to think of a rule sheet is a multi-dimensional cube whose cells are addressed by a bucket in each dimension and contain actions.

Dimensions are ordered by their position in the DimensionTable of the containing RuleSheet.

See Also:
  • Method Details

    • getPrivateBucketSetProperty

      public DictionaryProperty<BucketSet> getPrivateBucketSetProperty()
      Get PrivateBucketSet Property.
      Returns:
      DictionaryProperty of type BucketSet
    • getExpressionProperty

      public DictionaryProperty<Expression> getExpressionProperty()
      Get Expression Property.
      Returns:
      DictionaryProperty of type Expression
    • getSharedBucketSetProperty

      public ChoosableProperty getSharedBucketSetProperty()
      Get SharedBucketSet Property.
      Returns:
      ChoosableProperty
    • getDimensionNodeTableProperty

      @Deprecated public TableProperty<DimensionNode> getDimensionNodeTableProperty()
      Get DimensionNodeTable Property.
      Returns:
      DimensionNode Table
    • getExpression

      public Expression getExpression()
      get Expression of the dimension.
    • getValueProperty

      public Expression.ExpressionValueProperty getValueProperty()
    • getValue

      public String getValue()
    • setValue

      public void setValue(String v)
    • getValueOptions

      public String[] getValueOptions()
    • getResultTypeID

      public DOID getResultTypeID()
    • getMutableVariableOptions

      public String[] getMutableVariableOptions()
    • getFunctionOptions

      public String[] getFunctionOptions()
    • getConstructorOptions

      public String[] getConstructorOptions()
    • getOperatorOptions

      public String[] getOperatorOptions()
    • getImmutableVariableOptions

      public String[] getImmutableVariableOptions()
    • setShowVariables

      public void setShowVariables(boolean showVariables)
    • getBucketSet

      public BucketSet getBucketSet()
      Get BucketSet of the dimension. If #setSharedBucketSet has been called with a non-null argument, that argument is returned if it still exists (has not been deleted). If #setSharedBucketSet has been called with a null argument, the private bucketset is returned.
      Returns:
      BucketSet of the Dimension
    • isBucketSetShared

      public boolean isBucketSetShared()
      Is the BucketSet shared
      Returns:
      boolean flag
    • setSharedBucketSet

      public void setSharedBucketSet(BucketSet bucketSet)
      Set SharedBucketSet and BucketSet shared flag Null bucketSet clears shared flag.
      Parameters:
      bucketSet -
    • setSharedBucketSetByAlias

      public void setSharedBucketSetByAlias(String alias)
    • getSharedBucketSetOptions

      public String[] getSharedBucketSetOptions()
    • getSharedBucketSetSelected

      public int getSharedBucketSetSelected()
    • setDefaultBucketSet

      public void setDefaultBucketSet()
      Set default bucketset based on expression. This also sets the shared BucketSet associated with the expression, if any.
    • getDimensionNodeTable

      public DimensionNodeTable getDimensionNodeTable()
      Get DimensionNodeTable
      Returns:
      DimensionNodeTable of DimensionNodes in this Dimension
    • merge

      public void merge() throws SDKException
      Merge all DimensionNodes in this Dimension so that no node has a sibling. In an ordered rulesheet, this may decrease the number rules in the sheet, and may create invalid DTActionNodes if conflicting actions parameter values are merged.
      Throws:
      SDKException
    • span

      public void span()
      Span all consecutive DimensionNodes in this Dimension with same buckets.
    • canSpan

      public boolean canSpan()
      Test whether (nodes in) this dimension can be spanned.
    • split

      public void split() throws SDKException
      Split the Dimension in the same way split(true)
      Throws:
      SDKException
    • split

      public void split(boolean expanded) throws SDKException
      Split the Dimension such that each sibling group has all values in the bucketset. This split method never splits existing dimension nodes. Use splitExisting if that that is the desired behavior. if expanded is false, then for each sibling group, only one Dimension Node is added and this new node contains all of the previously unrepresented buckets. if expanded is true, then for each sibling group, one Dimension Node is added for each previously unrepresented bucket for subsequent rows in the DimensionTable, a "don't care" is added for each new node in this Dimension. These Dimensions must then be split if one wishes to have a rule combinations of buckets.
      Throws:
      SDKException
    • unspan

      public void unspan()
      Unspan all nodes in this dimension. Afterward, all nodes in this dimension have at most one child.
    • canUnspan

      public boolean canUnspan()
      Test whether (nodes in) this dimension can be unspanned.
    • getPropertyNames

      public String[] getPropertyNames()
      Specified by:
      getPropertyNames in interface UnnamedComponent
      Overrides:
      getPropertyNames in class UnnamedRuleComponent<Dimension>
      Returns:
      Array of property names available.
    • getStoredPropertyNames

      public String[] getStoredPropertyNames()
      Overrides:
      getStoredPropertyNames in class UnnamedRuleComponent<Dimension>
      Returns:
      Array of property names which are persisted in the order in which they appear in the schema.
    • validate

      public void validate(List<SDKException> errors, List<SDKWarning> warnings)
      Validate dimension. Validate the expression, local bucketset, and dimension nodes. Not all nodes can be set to "don't care" unless the bucketset is a LOV with no otherwise bucket and not boolean.

      Type check of bucketset and expression datatype via expression typecheck TODO: Need better error message for this case.

      Overrides:
      validate in class DictionaryComponent<Dimension>
      Parameters:
      errors -
      warnings -
      See Also:
    • put

      public Object put(String key, Object value)
      Description copied from class: DictionaryComponent
      Generic property setter. Throws runtime exceptions for incorrect arguments. Please see the specific bean class for a list of properties, their types, and permissible values.

      A put() with either null key or null value throws a NullPointerException.

      A put() with a key that is not a String throws a ClassCastException

      A put() of a value that is not of the correct type for the key throws a ClassCastException.

      Bean properties which have no set() method are read only, and cannot be modified using the put(). Attempting to do so throws a runtime IllegalArgumentException. PROP_ID, and PROP_*_SELECTED are always read only.

      Specified by:
      put in interface Map<String,Object>
      Overrides:
      put in class UnnamedRuleComponent<Dimension>
      Parameters:
      key - the key of the property to set
      value - the value of the named property to set
      Returns:
      the previous value of the property
    • get

      public Object get(Object key)
      Description copied from class: DictionaryComponent
      Generic property getter.

      Please see the specific bean class for a list of properties.

      Specified by:
      get in interface Map<String,Object>
      Overrides:
      get in class UnnamedRuleComponent<Dimension>
      Parameters:
      key - a String containing the property name to be fetched.
      Returns:
      the value corresponding to the key: a String, String[], DictionaryComponent, DictionaryComponentTable, etc.
    • inScopeVariables

      public List<ScopedVariable> inScopeVariables(boolean includeAggregates, VariableScope.ExprLocation loc)
      Description copied from class: RuleComponent
      By default, pass the request to the container
      Specified by:
      inScopeVariables in interface VariableScope
      Overrides:
      inScopeVariables in class RuleComponent<Dimension>
    • getMatchTypeIDs

      public DOID[] getMatchTypeIDs(Expression e)
      A Dimension Expression's type is unconstrained. TODO this could be improved to allow only bucketset compatible types
      Specified by:
      getMatchTypeIDs in interface ExpressionContext
    • getMatchOp

      public String getMatchOp(Expression e)
      The semantics of "match" is "=="
      Specified by:
      getMatchOp in interface ExpressionContext
    • isValueRequired

      public boolean isValueRequired(Expression e)
      Description copied from interface: ExpressionContext
      A child calls this method in the parent to see if it must have a value != ""
      Specified by:
      isValueRequired in interface ExpressionContext