Class DefaultDroolsRuleActionContext
- java.lang.Object
-
- de.hybris.platform.droolsruleengineservices.compiler.impl.DefaultDroolsRuleActionContext
-
- All Implemented Interfaces:
RuleActionContext
public class DefaultDroolsRuleActionContext extends java.lang.Object implements RuleActionContext
Default implementation ofRuleActionContextfor the drools rule engine.
-
-
Constructor Summary
Constructors Constructor Description DefaultDroolsRuleActionContext(java.util.Map<java.lang.String,java.lang.Object> variables, java.lang.Object helper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.drools.core.spi.KnowledgeHelpercheckAndGetRuleContext(java.lang.Object ruleContext)protected <T> java.util.Set<T>evaluateValues(java.lang.Class<T> type, java.util.List<T> values, java.lang.String... path)protected <T> java.util.Set<T>evaluateValues(java.lang.Class<T> type, java.util.Set<T> values, java.lang.String... path)protected <T> java.util.Set<T>findValues(java.lang.Class<T> type, java.lang.String... path)CartRAOgetCartRao()Get cart RAOjava.lang.ObjectgetDelegate()Returns a rule engine specific context object.java.lang.StringgetMetaData(java.lang.String key)Returns the rule's meta-data for the given key (ornull).java.lang.ObjectgetParameter(java.lang.String parameterName)Returns parameter of the running rule by it name or null if not found.<T> TgetParameter(java.lang.String parameterName, java.lang.Class<T> type)Returns parameter of the running rule by it name and type or throwsIllegalArgumentExceptionotherwise.java.util.Map<java.lang.String,java.lang.Object>getParameters()Returns parameters of the running rule.RuleEngineResultRAOgetRuleEngineResultRao()Get rule engine result RAOjava.util.Map<java.lang.String,java.lang.Object>getRuleMetadata()get rule metadatajava.lang.StringgetRuleName()Get the name of the rulejava.util.Optional<java.lang.String>getRulesModuleName()Get the name of the rules module.<T> TgetValue(java.lang.Class<T> type)Returns the value for a specific type from the default variables container.<T> TgetValue(java.lang.Class<T> type, java.lang.String... path)Returns the value for a specific type and variables container.<T> java.util.Set<T>getValues(java.lang.Class<T> type)Returns the values for a specific type from the default variables container.<T> java.util.Set<T>getValues(java.lang.Class<T> type, java.lang.String... path)Returns the values for a specific type and variables container.java.util.Map<java.lang.String,java.lang.Object>getVariables()voidhalt()Stops evaluation of following rulesvoidinsertFacts(java.lang.Object... facts)Insert the facts in an array to a contextvoidinsertFacts(java.util.Collection facts)Insert the facts in a collection to a contextvoidscheduleForUpdate(java.lang.Object... facts)schedules the given facts for an update.voidsetParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)Sets parameters to the running rulevoidupdateFacts(java.lang.Object... facts)Update the facts in a contextvoidupdateScheduledFacts()updates any previously scheduled facts (seeRuleActionContext.scheduleForUpdate(Object...)
-
-
-
Method Detail
-
getVariables
public java.util.Map<java.lang.String,java.lang.Object> getVariables()
-
getDelegate
public java.lang.Object getDelegate()
Description copied from interface:RuleActionContextReturns a rule engine specific context object.- Specified by:
getDelegatein interfaceRuleActionContext
-
getMetaData
public java.lang.String getMetaData(java.lang.String key)
Description copied from interface:RuleActionContextReturns the rule's meta-data for the given key (ornull). CallstoString()on the meta-data object.- Specified by:
getMetaDatain interfaceRuleActionContext- Returns:
- the string representation of the meta-data (or null)
-
getValue
public <T> T getValue(java.lang.Class<T> type)
Description copied from interface:RuleActionContextReturns the value for a specific type from the default variables container. If more than one value is found, the first one is returned.- Specified by:
getValuein interfaceRuleActionContext- Parameters:
type- - the type- Returns:
- the value or null if no value is found for the given type
-
scheduleForUpdate
public void scheduleForUpdate(java.lang.Object... facts)
Description copied from interface:RuleActionContextschedules the given facts for an update. Note: The actual fact update is invoked viaRuleActionContext.updateScheduledFacts()- Specified by:
scheduleForUpdatein interfaceRuleActionContext- Parameters:
facts- the facts to schedule for update
-
getValues
public <T> java.util.Set<T> getValues(java.lang.Class<T> type)
Description copied from interface:RuleActionContextReturns the values for a specific type from the default variables container.- Specified by:
getValuesin interfaceRuleActionContext- Parameters:
type- - the type- Returns:
- the values or an empty set if no value is found for the given type
-
getValue
public <T> T getValue(java.lang.Class<T> type, java.lang.String... path)Description copied from interface:RuleActionContextReturns the value for a specific type and variables container. If more than one value is found, the first one is returned.- Specified by:
getValuein interfaceRuleActionContext- Parameters:
type- - the typepath- - the path for the variables container- Returns:
- the value or null if no value is found for the given type
-
getValues
public <T> java.util.Set<T> getValues(java.lang.Class<T> type, java.lang.String... path)Description copied from interface:RuleActionContextReturns the values for a specific type and variables container.- Specified by:
getValuesin interfaceRuleActionContext- Parameters:
type- - the typepath- - the path for the variables container- Returns:
- the values or an empty set if no value is found for the given type
-
insertFacts
public void insertFacts(java.lang.Object... facts)
Description copied from interface:RuleActionContextInsert the facts in an array to a context- Specified by:
insertFactsin interfaceRuleActionContext- Parameters:
facts- - the array of facts
-
updateScheduledFacts
public void updateScheduledFacts()
Description copied from interface:RuleActionContextupdates any previously scheduled facts (seeRuleActionContext.scheduleForUpdate(Object...)- Specified by:
updateScheduledFactsin interfaceRuleActionContext
-
updateFacts
public void updateFacts(java.lang.Object... facts)
Description copied from interface:RuleActionContextUpdate the facts in a context- Specified by:
updateFactsin interfaceRuleActionContext- Parameters:
facts- - the array of facts
-
insertFacts
public void insertFacts(java.util.Collection facts)
Description copied from interface:RuleActionContextInsert the facts in a collection to a context- Specified by:
insertFactsin interfaceRuleActionContext- Parameters:
facts- - the collection of facts
-
findValues
protected <T> java.util.Set<T> findValues(java.lang.Class<T> type, java.lang.String... path)
-
evaluateValues
protected <T> java.util.Set<T> evaluateValues(java.lang.Class<T> type, java.util.List<T> values, java.lang.String... path)
-
evaluateValues
protected <T> java.util.Set<T> evaluateValues(java.lang.Class<T> type, java.util.Set<T> values, java.lang.String... path)
-
getCartRao
public CartRAO getCartRao()
Description copied from interface:RuleActionContextGet cart RAO- Specified by:
getCartRaoin interfaceRuleActionContext
-
getRuleEngineResultRao
public RuleEngineResultRAO getRuleEngineResultRao()
Description copied from interface:RuleActionContextGet rule engine result RAO- Specified by:
getRuleEngineResultRaoin interfaceRuleActionContext
-
getRuleName
public java.lang.String getRuleName()
Description copied from interface:RuleActionContextGet the name of the rule- Specified by:
getRuleNamein interfaceRuleActionContext
-
getRulesModuleName
public java.util.Optional<java.lang.String> getRulesModuleName()
Description copied from interface:RuleActionContextGet the name of the rules module.- Specified by:
getRulesModuleNamein interfaceRuleActionContext
-
getRuleMetadata
public java.util.Map<java.lang.String,java.lang.Object> getRuleMetadata()
Description copied from interface:RuleActionContextget rule metadata- Specified by:
getRuleMetadatain interfaceRuleActionContext
-
checkAndGetRuleContext
protected org.drools.core.spi.KnowledgeHelper checkAndGetRuleContext(java.lang.Object ruleContext)
-
getParameters
public java.util.Map<java.lang.String,java.lang.Object> getParameters()
Description copied from interface:RuleActionContextReturns parameters of the running rule.- Specified by:
getParametersin interfaceRuleActionContext
-
getParameter
public java.lang.Object getParameter(java.lang.String parameterName)
Description copied from interface:RuleActionContextReturns parameter of the running rule by it name or null if not found.- Specified by:
getParameterin interfaceRuleActionContext
-
getParameter
public <T> T getParameter(java.lang.String parameterName, java.lang.Class<T> type)Description copied from interface:RuleActionContextReturns parameter of the running rule by it name and type or throwsIllegalArgumentExceptionotherwise.- Specified by:
getParameterin interfaceRuleActionContext
-
setParameters
public void setParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
Description copied from interface:RuleActionContextSets parameters to the running rule- Specified by:
setParametersin interfaceRuleActionContext- Parameters:
parameters- - map of named objects, creating the execution context for an action
-
halt
public void halt()
Description copied from interface:RuleActionContextStops evaluation of following rules- Specified by:
haltin interfaceRuleActionContext
-
-