public abstract class RulesetContext extends Object implements Serializable
//This is how one gets an instance of the RulesetContext passing the Ruleset name RulesetContext ctxt = engine.createRulesetContext("myProject","myRuleset"); // to add Business Objects that are required for the invocation, // use theadd(java.lang.Object)
method ctxt.add(object1); ctxt.add(object2); . . //If details of failed condition and satisfied condition is required then //Get the instance of EventFilter EventFilter filter = EventFilter.createEventFilter(); //Enable the collection of ConditionEventDetail for failed condition filter.enableCollectionOfConditionFailedStringEvents(true); //Enable the collection of ActionEventDetail for fired Evaluate/Execute Action filter.enableCollectionOfEvaluateActionStringEvents(true); //Set the filter to context. ctxt.setEventFilter(filter); // This is how one can invoke the Engine using this context // make sure to use the context returned by the Engine. ctxt = engine.invokeRuleset(ctxt); //Get the Event detail. Event Detail has all the String events of all the condition events and the action events. IEventDetails details = returnedRsContext.getEventDetails(); // To get the list of objects after they have been examined by the // Engine usegetReturnedFacts()
List facts = ctxt.getReturnedFacts(); //to reuse this object so that it is available afresh for subsequent invocations //useclear
ctxt.clear();
Modifier and Type | Class and Description |
---|---|
static class |
RulesetContext.BusinessLogLevel |
static class |
RulesetContext.EntityType
Contains a list of entities which can be invoked from the Rule Engine.
|
Modifier and Type | Field and Description |
---|---|
protected String |
abortMessage
message about execution abortion
|
protected Calendar |
calendar
instance of Calendar object
|
protected List |
clazzNameList
list to add className
|
protected String |
entityName |
protected RulesetContext.EntityType |
entityType |
protected IEventDetails |
eventDetails
instance of IEventDetail for this context
|
protected EventFilter |
eventFilter
instance of EventFilter associated with this context
|
protected List |
facts
List to store Facts
|
protected String |
id
id for this context
|
protected RulesetContext.BusinessLogLevel |
logLevel |
protected String |
projectName
name of Project
|
protected List |
returnedFacts
list to store returned Facts
|
protected String |
rulesetGUID |
protected String |
rulesetName
Ruleset name
|
protected boolean |
setInvocationDateAsSystemDate
this is used to set Invocation Date as System date
|
protected boolean |
wasAborted
boolean type to check whether execution was aborted or not
|
Modifier | Constructor and Description |
---|---|
protected |
RulesetContext()
Initializes a new instance of RulesetContext.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Object object)
Adds a fact that will be examined by the Rules Engine
|
void |
addAll(Collection objects)
Adds collection of Facts that will be examined by the Rules Engine
|
void |
clear()
Clears the existing Facts, Definition values that are set by the user,
the Definition values after the Ruleset execution and statistical
information.
|
abstract void |
clearFacts()
Clears the facts set on this context object.
|
String |
getAbortMessage()
Returns the message specified when the execution was aborted.
|
RulesetContext.BusinessLogLevel |
getBusinessLogLevel()
Returns the level of business logging to be done for this invocation.
|
ClassLoader |
getClassLoader()
Returns class loader configured to be used to load
Class when engine can not
load it from the input facts or engine class loader. |
String |
getEntityName()
Returns the name of the entity to be invoked using this
RulesetContext instance. |
RulesetContext.EntityType |
getEntityType()
Returns the entity type to be invoked using this
RulesetContext
instance. |
IEventDetails |
getEventDetails()
Returns the Event details of this context.
|
EventFilter |
getEventFilter()
Returns the event filter associated with this context.
|
String |
getId()
The Id is invocation specific value which is generated when you create
the context.
|
abstract String |
getInvocationId()
Returns the Id of the invocation.
|
String |
getProjectName()
Gets the name of the Project whose Ruleset needs to be invoked.
|
List |
getReturnedFacts()
Gets the facts after they have been examined by the Rules Engine.
|
String |
getRulesetName()
Gets the name of the Ruleset that needs to be invoked.
|
String |
getRulesetUID()
Returns the GUID of the Ruleset to be invoked.
|
abstract Calendar |
getSystemDate()
Returns systemdate for the Ruleset represented by this RulesetContext.
|
abstract Object |
getValueOfRulesetFunctionResult()
Returns the value of of the Ruleset function result.
|
abstract Object |
getValueOfVariableDefinition(AbstractDefinition definition)
Returns the value of the variable Definition after the invocation.
|
abstract boolean |
isFlowRuleset()
Returns true if the ruleset represented by this context object is a flow
ruleset
|
void |
setBusinessLogLevel(RulesetContext.BusinessLogLevel logLevel)
Sets the level of business logging to be done for this invocation.
|
void |
setClassLoader(ClassLoader classLoader)
Sets class loader to be used to load
Class when engine can not load
it from the input facts or engine class loader. |
void |
setEntity(RulesetContext.EntityType entityType,
String entityName)
Sets the entity to be invoked.
|
abstract void |
setEventFilter(EventFilter eventFilter)
Sets the event filter for this context.
|
abstract void |
setSystemDate(Calendar systemDate)
Sets the System date for the RulesetContext.
|
abstract void |
setValueForDefinition(AbstractDefinition definition,
Object value)
Sets the value for the Definition.
|
boolean |
wasExecutionAborted()
Returns true if the execution of the ruleset was aborted.
|
protected String projectName
protected String rulesetName
protected String rulesetGUID
protected boolean setInvocationDateAsSystemDate
protected Calendar calendar
protected List clazzNameList
protected IEventDetails eventDetails
protected EventFilter eventFilter
protected List facts
protected String id
protected List returnedFacts
protected RulesetContext.BusinessLogLevel logLevel
protected RulesetContext.EntityType entityType
protected String entityName
protected String abortMessage
protected boolean wasAborted
protected RulesetContext()
public void add(Object object)
object
- - fact to be added to enginepublic void addAll(Collection objects)
objects
- - collection of facts added to the enginepublic IEventDetails getEventDetails()
RuleEngine.invokeRuleset(RulesetContext)
will return an instance of IEventDetails class, which contains the event
related information that has not yet been switched off using
EventFilter
.public EventFilter getEventFilter()
public String getId()
public List getReturnedFacts()
add
method.public abstract void setEventFilter(EventFilter eventFilter)
eventFilter
- - EventFilter objectpublic void setBusinessLogLevel(RulesetContext.BusinessLogLevel logLevel)
getInvocationId()
. Please note that an invocation Id is
generated per ruleset invocation.
The Business Log Level, if set on the RulesetContext takes precedence
over the level set on the RuleEngineBean.
If the business logging is to be explicitly switched off, the level
#NO_BUSINESS_LOGGING
has to be set. Setting
null
as the BusinessLogLevelw ill not switch off the
business logging. The logging will still happen as set on the
RuleEngineBena environment entry businessloglevel.logLevel
- public RulesetContext.BusinessLogLevel getBusinessLogLevel()
getInvocationId()
. Pl note that an invocation Id is
generated per ruleset invocation.null
, if no
BusinessLogLevel is set.public void clear()
public String getProjectName()
public String getRulesetName()
public String getRulesetUID()
public void setEntity(RulesetContext.EntityType entityType, String entityName)
RulesetContext.EntityType
argument and the name of the entity is determined
by the entityName
argument. entityType
- - the type of the entity to be invokedentityName
- - the name of the entity to be invokedpublic RulesetContext.EntityType getEntityType()
RulesetContext
instance. If the entity type was not set using
setEntity(EntityType, String)
method call,
RulesetContext.EntityType.RULESET
is returned as the default choice.public String getEntityName()
RulesetContext
instance. If the entity name was not set using the
setEntity(EntityType, String)
method call, the name of the
ruleset is returned.public abstract Object getValueOfVariableDefinition(AbstractDefinition definition) throws IllegalArgumentException
definition
- the variable Definition whose value is to be returned.IllegalArgumentException
- if definition is null or
definition is not a variable Definition (i.e.,
definition.isAssignable() returns false).public abstract Object getValueOfRulesetFunctionResult()
null
value only if this method is called after invoking
the Ruleset. This will not be null
only if the Ruleset has a
Ruleset function signature and the result of this Ruleset function
signature is mapped to an expression that is to be evaluated by the
engine.public abstract void setValueForDefinition(AbstractDefinition definition, Object value) throws IllegalArgumentException
definition
- The AbstractDefinition object representing the Definition.value
- The object representing the value of the Definition.IllegalArgumentException
public abstract void setSystemDate(Calendar systemDate) throws IllegalArgumentException
systemDate
- The system date for the Ruleset.IllegalArgumentException
- if systemDate is null.public abstract Calendar getSystemDate()
public abstract void clearFacts()
public abstract boolean isFlowRuleset()
public boolean wasExecutionAborted()
RuleEngine.invokeRuleset(RulesetContext)
).
Note: This method is applicable only for flow-rulesets. Calling this
method on a context for a "rete" ruleset will always return
false.public String getAbortMessage()
public abstract String getInvocationId()
public final void setClassLoader(ClassLoader classLoader)
Class
when engine can not load
it from the input facts or engine class loader.classLoader
- public final ClassLoader getClassLoader()
Class
when engine can not
load it from the input facts or engine class loader.ClassLoader
Access Rights |
---|
SC | DC | Public Part | ACH |
---|---|---|---|
[sap.com] BRMS-FACADE
|
[sap.com] tc/brms/facade
|
api
|
BC-BMT-BRM-ENG
|
Copyright 2018 SAP AG Complete Copyright Notice