Drools Workbench - Data Model API 6.2.0.Final

org.drools.workbench.models.datamodel.rule
Class RuleModel

java.lang.Object
  extended by org.drools.workbench.models.datamodel.rule.RuleModel
All Implemented Interfaces:
HasImports, HasPackageName

public class RuleModel
extends Object
implements HasImports, HasPackageName


Field Summary
 RuleAttribute[] attributes
           
 IPattern[] lhs
           
 RuleMetadata[] metadataList
           
 String modelVersion
           
 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).
 String parentName
           
 IAction[] rhs
           
 
Constructor Summary
RuleModel()
           
 
Method Summary
 void addAttribute(RuleAttribute attribute)
           
 void addLhsItem(IPattern pat)
           
 void addLhsItem(IPattern pat, boolean append)
           
 void addLhsItem(IPattern pat, int position)
           
 void addMetadata(RuleMetadata metadata)
          Add metaData
 void addRhsItem(IAction action)
           
 void addRhsItem(IAction action, boolean append)
           
 void addRhsItem(IAction action, int position)
           
 boolean equals(Object o)
           
 List<String> getAllLHSVariables()
          This will get a list of all LHS bound variables, including bound fields..
 List<String> getAllRHSVariables()
          This will get a list of all RHS bound variables.
 List<String> getAllVariables()
          This will get a list of all bound variables (LHS and RHS), including bound fields..
 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).
 List<String> getFieldBinding(FieldConstraint f)
           
 String getFieldBinding(FieldConstraint fc, String var)
           
 Imports getImports()
           
 String getLHSBindingType(String var)
          Get the data-type associated with the binding
 FactPattern getLHSBoundFact(String var)
          This will return the FactPattern that a variable is bound Eto.
 List<String> getLHSBoundFacts()
          This will return a List of all FactPattern bindings
 SingleFieldConstraint getLHSBoundField(String var)
          This will return the FieldConstraint that a variable is bound to.
 FactPattern getLHSParentFactPatternForBinding(String var)
          This will return the FactPattern that a variable is bound to.
 RuleMetadata getMetaData(String attributeName)
          Locate metadata element
 String getPackageName()
           
 ActionInsertFact getRHSBoundFact(String var)
          This will return the ActionInsertFact that a variable is bound to.
 List<String> getRHSBoundFacts()
          This will return a List of all ActionInsertFact bindings
 boolean hasDSLSentences()
          Returns true if any DSLSentences are used.
 int hashCode()
           
 boolean isBoundFactUsed(String binding)
           
 boolean isNegated()
          Is the Rule to be negated, i.e.
 boolean isVariableNameUsed(String s)
          Checks to see if a variable is used or not, includes fields as well as facts.
 void moveLhsItemDown(int itemIndex)
           
 void moveLhsItemUp(int itemIndex)
           
 void moveRhsItemDown(int itemIndex)
           
 void moveRhsItemUp(int itemIndex)
           
 void removeAttribute(int idx)
           
 boolean removeLhsItem(int idx)
           
 void removeMetadata(int idx)
           
 void removeRhsItem(int idx)
           
 void setImports(Imports imports)
           
 void setNegated(boolean isNegated)
          Set whether the Rule is to be negated
 void setPackageName(String packageName)
           
 boolean updateMetadata(RuleMetadata target)
          Update metaData element if it exists or add it otherwise
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

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

attributes

public RuleAttribute[] attributes

metadataList

public RuleMetadata[] metadataList

lhs

public IPattern[] lhs

rhs

public IAction[] rhs
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

getFieldBinding

public String getFieldBinding(FieldConstraint fc,
                              String var)

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..


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..


getFieldBinding

public List<String> getFieldBinding(FieldConstraint f)

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 Imports getImports()
Specified by:
getImports in interface HasImports

setImports

public void setImports(Imports imports)
Specified by:
setImports in interface HasImports

getPackageName

public String getPackageName()
Specified by:
getPackageName in interface HasPackageName

setPackageName

public void setPackageName(String packageName)
Specified by:
setPackageName in interface HasPackageName

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

Drools Workbench - Data Model API 6.2.0.Final

Copyright © 2001-2015 JBoss by Red Hat. All Rights Reserved.