atg.targeting
Class RuleSetEvaluator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.targeting.RuleSetEvaluator
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class RuleSetEvaluator
extends GenericService

This service can be used to evaluate an arbitrary set of rules against different target objects. The rules are specified via the ruleSetService property. The testTarget method can be used to test if a specific target object satisfies the rules.

For example, suppose that we use a RuleSetService configured with the following rule set, which is meant to describe a subset of the user population:

<ruleset>
<accepts>
<rule op=eq>
<valueof target="gender">
<valueof constant="male">
</rule>
<rule op=lt>
<valueof target="age">
<valueof constant="30">
</rule>
</accepts>
</ruleset>
The testTarget method can then be used to test if various users are males under the age of 30. The target object tested against can be any bean which has the properties occuring in the target expressions in the rules - in this case, "gender" and "age." Typically, the target object will represent a DPS user, and will be either a atg.userprofiling.Profile or a atg.repository.RepositoryItem.

The optional sourceMap property, if provided, is used to resolve any bean expressions in the rules. If no such expressions occur in the rules, this property can be left null.

See Also:
RuleSetService, TargetingSourceMap

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
RuleSetEvaluator()
           
 
Method Summary
 atg.targeting.RuleSetService getRuleSetService()
          Returns the RuleSetService containing the rules to be evaluated.
 TargetingSourceMap getSourceMap()
          Returns the TargetingSourceMap to use when evaluating rules.
 void setRuleSetService(atg.targeting.RuleSetService pRuleSetService)
          Sets the RuleSetService containing the rules to be evaluated.
 void setSourceMap(TargetingSourceMap pSourceMap)
          Sets the TargetingSourceMap to use when evaluating rules.
 boolean testTarget(java.lang.Object pTarget)
          Evaluates the rules specified via the ruleSetService property against the target object.
 boolean testTarget(java.lang.Object pTarget, NameResolver pNameResolver)
          Evaluates the rules specified via the ruleSetService property against the target object.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

RuleSetEvaluator

public RuleSetEvaluator()
Method Detail

getRuleSetService

public atg.targeting.RuleSetService getRuleSetService()
Returns the RuleSetService containing the rules to be evaluated.


setRuleSetService

public void setRuleSetService(atg.targeting.RuleSetService pRuleSetService)
Sets the RuleSetService containing the rules to be evaluated.


getSourceMap

public TargetingSourceMap getSourceMap()
Returns the TargetingSourceMap to use when evaluating rules.


setSourceMap

public void setSourceMap(TargetingSourceMap pSourceMap)
Sets the TargetingSourceMap to use when evaluating rules.


testTarget

public boolean testTarget(java.lang.Object pTarget)
                   throws atg.targeting.rules.RuleSetException
Evaluates the rules specified via the ruleSetService property against the target object. Returns true if the target object satisfies the rules, false otherwise.

Throws:
atg.targeting.rules.RuleSetException - if an error is encountered while evaluating the rules

testTarget

public boolean testTarget(java.lang.Object pTarget,
                          NameResolver pNameResolver)
                   throws atg.targeting.rules.RuleSetException
Evaluates the rules specified via the ruleSetService property against the target object. Returns true if the target object satisfies the rules, false otherwise.

Parameters:
pTarget -
pNameResolver - name resolver to use if source map does not specify one
Throws:
atg.targeting.rules.RuleSetException - if an error is encountered while evaluating the rules