Class RuleModel

  • All Implemented Interfaces:
    org.kie.soup.project.datamodel.imports.HasImports, org.kie.soup.project.datamodel.packages.HasPackageName

    public class RuleModel
    extends Object
    implements org.kie.soup.project.datamodel.imports.HasImports, org.kie.soup.project.datamodel.packages.HasPackageName
    • Field Detail

      • name

        public String name
        This name is generally not used - the asset name or the file name is preferred (ie it could get out of sync with the name of the file it is in).
      • parentName

        public String parentName
      • modelVersion

        public String modelVersion
    • Constructor Detail

      • RuleModel

        public RuleModel()
    • Method Detail

      • getLHSBoundFacts

        public List<String> getLHSBoundFacts()
        This will return a List of all FactPattern bindings
        Returns:
        The bindings or an empty list if no bindings are found.
      • getLHSBoundFact

        public FactPattern getLHSBoundFact​(String var)
        This will return the FactPattern that a variable is bound Eto.
        Parameters:
        var - The bound fact variable (NOT bound field).
        Returns:
        null or the FactPattern found.
      • getLHSBoundField

        public SingleFieldConstraint getLHSBoundField​(String var)
        This will return the FieldConstraint that a variable is bound to.
        Parameters:
        var - The bound field variable (NOT bound fact).
        Returns:
        null or the FieldConstraint found.
      • getLHSBindingType

        public String getLHSBindingType​(String var)
        Get the data-type associated with the binding
        Parameters:
        var -
        Returns:
        The data-type, or null if the binding could not be found
      • getRHSBoundFacts

        public List<String> getRHSBoundFacts()
        This will return a List of all ActionInsertFact bindings
        Returns:
        The bindings or an empty list if no bindings are found.
      • getRHSBoundFact

        public ActionInsertFact getRHSBoundFact​(String var)
        This will return the ActionInsertFact that a variable is bound to.
        Parameters:
        var - The bound fact variable (NOT bound field).
        Returns:
        null or the ActionInsertFact found.
      • getLHSParentFactPatternForBinding

        public FactPattern getLHSParentFactPatternForBinding​(String var)
        This will return the FactPattern that a variable is bound to. If the variable is bound to a FieldConstraint the parent FactPattern will be returned.
        Parameters:
        var - The variable binding
        Returns:
        null or the FactPattern found.
      • getAllLHSVariables

        public List<String> getAllLHSVariables()
        This will get a list of all LHS bound variables, including bound fields..
      • getLHSPatternVariables

        public List<String> getLHSPatternVariables()
        This will get a list of all LHS bound variables, excluding bound fields
      • getLHSVariables

        public List<String> getLHSVariables​(boolean includePatterns,
                                            boolean includeFields)
      • getAllRHSVariables

        public List<String> getAllRHSVariables()
        This will get a list of all RHS bound variables.
      • getAllVariables

        public List<String> getAllVariables()
        This will get a list of all bound variables (LHS and RHS), including bound fields..
      • removeLhsItem

        public boolean removeLhsItem​(int idx)
        Parameters:
        idx - Remove this index from the LHS. returns false if it was NOT allowed to remove this item (ie it is used on the RHS).
      • isBoundFactUsed

        public boolean isBoundFactUsed​(String binding)
        Parameters:
        binding - The name of the LHS fact binding.
        Returns:
        Returns true if the specified binding is used on the RHS.
      • addLhsItem

        public void addLhsItem​(IPattern pat)
      • addLhsItem

        public void addLhsItem​(IPattern pat,
                               boolean append)
      • addLhsItem

        public void addLhsItem​(IPattern pat,
                               int position)
      • moveLhsItemDown

        public void moveLhsItemDown​(int itemIndex)
      • moveLhsItemUp

        public void moveLhsItemUp​(int itemIndex)
      • moveRhsItemDown

        public void moveRhsItemDown​(int itemIndex)
      • moveRhsItemUp

        public void moveRhsItemUp​(int itemIndex)
      • addRhsItem

        public void addRhsItem​(IAction action)
      • addRhsItem

        public void addRhsItem​(IAction action,
                               boolean append)
      • addRhsItem

        public void addRhsItem​(IAction action,
                               int position)
      • removeRhsItem

        public void removeRhsItem​(int idx)
      • addAttribute

        public void addAttribute​(RuleAttribute attribute)
      • removeAttribute

        public void removeAttribute​(int idx)
      • addMetadata

        public void addMetadata​(RuleMetadata metadata)
        Add metaData
        Parameters:
        metadata -
      • removeMetadata

        public void removeMetadata​(int idx)
      • getMetaData

        public RuleMetadata getMetaData​(String attributeName)
        Locate metadata element
        Parameters:
        attributeName - - value to look for
        Returns:
        null if not found
      • updateMetadata

        public boolean updateMetadata​(RuleMetadata target)
        Update metaData element if it exists or add it otherwise
        Parameters:
        target -
        Returns:
        true on update of existing element false on added of element
      • getBoundVariablesInScope

        public List<String> getBoundVariablesInScope​(BaseSingleFieldConstraint con)
        This uses a deceptively simple algorithm to determine what bound variables are in scope for a given constraint (including connectives). Does not take into account globals.
      • isVariableNameUsed

        public boolean isVariableNameUsed​(String s)
        Checks to see if a variable is used or not, includes fields as well as facts.
      • hasDSLSentences

        public boolean hasDSLSentences()
        Returns true if any DSLSentences are used.
      • isNegated

        public boolean isNegated()
        Is the Rule to be negated, i.e. "not ( PatternX, PatternY... )"
        Returns:
      • setNegated

        public void setNegated​(boolean isNegated)
        Set whether the Rule is to be negated
        Parameters:
        isNegated -
      • getImports

        public org.kie.soup.project.datamodel.imports.Imports getImports()
        Specified by:
        getImports in interface org.kie.soup.project.datamodel.imports.HasImports
      • setImports

        public void setImports​(org.kie.soup.project.datamodel.imports.Imports imports)
        Specified by:
        setImports in interface org.kie.soup.project.datamodel.imports.HasImports
      • getPackageName

        public String getPackageName()
        Specified by:
        getPackageName in interface org.kie.soup.project.datamodel.packages.HasPackageName
      • setPackageName

        public void setPackageName​(String packageName)
        Specified by:
        setPackageName in interface org.kie.soup.project.datamodel.packages.HasPackageName
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object