public class DynamicContentTargeter extends GenericService implements Targeter, atg.targeting.RepositoryTargeter, atg.targeting.ContentHistoryManager, atg.targeting.PCCEditableComponent, atg.targeting.overrides.TargetingObjectsFactory<atg.targeting.RuleBasedRepositoryTargeter>
It is like RuleBasedRepositoryTargeter in that it performs rule-based targeting over a Repository, but it adds a number of additional features including "rule breaks" (the ability to cascade through multiple rulesets and stop when any one of them returns content) and the ability to say that this targeter should suppress repository items that have already been seen during this session.
To keep the UI manageable, DynamicContentTargeters generally specify a restricted subset of rules that are easy to parse and easy to display and edit in a graphical user interface. This restriction is enforced only at the GUI level, not in the targeter implementation, but if you construct a DynamicContentTargeter by hand whose rules don't fit the expected pattern, the UI will be unable to cope with it. Caveat emptor.
Targeter,
RuleBasedRepositoryTargeter,
ContentHistoryManager,
ContentHistory| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
protected java.lang.String |
mContentHistoryPath
Nucleus component path that points to ContentHistory object
|
protected java.lang.String |
mDescription
Description of this targeter's behavior for use in a GUI
|
protected int |
mImpressionLimit
How many times can this targeter show each time in a session?
|
protected boolean |
mImpressionLimitPerTargeter
Are impression limits local to this targeter, or global?
|
protected java.util.Map<java.lang.String,java.lang.String> |
mOverriddenRulesets
Definition of all overridden rulesets
|
protected atg.targeting.overrides.MultisiteOverrideContainer<atg.targeting.RuleBasedRepositoryTargeter> |
mOverriddenTargeters
Container for overridden targeters
|
protected Repository |
mRepository
The repository from which to select items
|
protected java.lang.String |
mRepositoryViewName
The name of the repository view from which to select items
|
protected StringList |
mRulesets
Definitions of all the rulesets used by this targeter
|
protected StringList |
mRuleStrings
Array of strings representing an anglicized version of the rules
|
protected java.lang.String |
mSortBy
The criteria used to sort results in this targeter
|
protected SortDirectives |
mSortDirectives
The SortDirectives object that corresponds to mSortBy
|
protected atg.targeting.RuleBasedRepositoryTargeter[] |
mTargeters
The set of RuleBasedRepositoryTargeters to use for targeting
|
SERVICE_INFO_KEYNO_MAX_NUMBER, NO_START_INDEXDEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS| Constructor and Description |
|---|
DynamicContentTargeter() |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object[] |
atMost(int pMaxNumber,
java.lang.Object[] pItems)
Return at most N items from an array.
|
static SortDirectives |
buildSortDirectives(java.lang.String pSortBy)
Build a SortDirectives object from a
|
atg.targeting.RuleBasedRepositoryTargeter[] |
buildTargeters(Repository pRepository,
java.lang.String pRepositoryViewName,
StringList pRulesets,
SortDirectives pSortDirectives)
Build an array of targeters from an array of rule specifications.
|
atg.targeting.RuleBasedRepositoryTargeter[] |
convertRuleSetsToTargetingObjects(java.lang.String[] pRuleSets)
Converts rulesets (an array of string) to targeters (array of
RuleBasedRepositoryTargeter) |
int |
countContentShown(NameResolver pNameResolver,
RepositoryItem pItem)
Query how many times some repository item has been shown in this session.
|
static atg.nucleus.ConfigurationState |
createTargeterConfiguration()
Return a configuration object describing a new, uninitialized
instance of DynamicContentTargeter.
|
void |
doStartService()
Start this dynamic content targeting service.
|
void |
doStopService()
Stop this dynamic content targeting service.
|
protected java.lang.Object[] |
filter(NameResolver pNameResolver,
java.lang.Object[] pItems)
Filter an array of items to remove any that have reached their
impression limit.
|
Targeter[] |
findSiteTargeters(java.lang.String pSiteId) |
atg.targeting.ContentHistory |
getContentHistory(NameResolver pNameResolver)
Get the content history object associated with this targeter in
a given name context.
|
java.lang.Object |
getContentHistoryContext()
Get the correct context in which to record content history information
|
java.lang.String |
getContentHistoryPath()
Get the path to use when looking up the content history object
|
java.lang.String |
getDescription()
Get this targeter's description
|
java.lang.String[] |
getDisplayRuleStrings()
Get the display form of the rule strings.
|
java.lang.String[] |
getDisplayRuleStrings(DynamoHttpServletRequest pRequest)
Get the display form of the rule strings using the context of
the given request.
|
java.lang.String[] |
getDisplayRuleStringsUsingCurrentRequest()
Get the display form of the rule strings using the context of
the current request.
|
int |
getImpressionLimit()
Get the maximum number of times this targeter can return the same item
|
ApplicationLogging |
getLogger()
Get the object that performs application logging on our behalf.
|
int |
getNumRulesets()
Return the number of rulesets used by this targeter
|
java.util.Map<java.lang.String,java.lang.String> |
getOverriddenRulesets()
Gets a map of overridden rulesetss.
|
Repository |
getRepository()
Get the repository from which to select items
|
RepositoryView |
getRepositoryView()
Get the repositoryView from which to select items
|
java.lang.String |
getRepositoryViewName()
Get the name of the repository view from which to select items
|
StringList |
getRulesets()
Get the definitions for all rulesets used by this targeter
|
StringList |
getRuleStrings()
Get the StringList representing the rules used by this targeter.
|
java.util.Map<java.lang.String,java.lang.String> |
getSiteRulesets()
Deprecated.
There are other override types besides site override, so API doesn't correspond
to existent override model.
Method
getOverriddenRulesets() should be used instead. |
java.lang.String |
getSortBy()
Get the criteria used to sort results in this targeter.
|
Targeter[] |
getTargeters() |
boolean |
isContentShown(NameResolver pNameResolver,
RepositoryItem pItem)
Query whether some repository item has been shown in this session.
|
boolean |
isImpressionLimitPerTargeter()
Query whether impression limits are per-targeter or global.
|
boolean |
isLoggingDebug()
This method returns whether or not an debug log event should be
broadcast.
|
boolean |
isLoggingError()
This method returns whether or not an error log event should be
broadcast.
|
boolean |
isLoggingInfo()
This method returns whether or not an info log event should be
broadcast.
|
boolean |
isLoggingWarning()
This method returns whether or not an warning log event should be
broadcast.
|
void |
logDebug(java.lang.String pMessage)
Logs an debug event with the specified message
|
void |
logDebug(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an debug event with the specified message and Throwable
|
void |
logDebug(java.lang.Throwable pThrowable)
Logs an debug event with the specified Throwable
|
void |
logError(java.lang.String pMessage)
Logs an error event with the specified message
|
void |
logError(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an error event with the specified message and Throwable
|
void |
logError(java.lang.Throwable pThrowable)
Logs an error event with the specified Throwable
|
void |
logInfo(java.lang.String pMessage)
Logs an info event with the specified message
|
void |
logInfo(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an info event with the specified message and Throwable
|
void |
logInfo(java.lang.Throwable pThrowable)
Logs an info event with the specified Throwable
|
void |
logWarning(java.lang.String pMessage)
Logs an warning event with the specified message
|
void |
logWarning(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an warning event with the specified message and Throwable
|
void |
logWarning(java.lang.Throwable pThrowable)
Logs an warning event with the specified Throwable
|
void |
registerContentShown(NameResolver pNameResolver,
RepositoryItem pItem)
Register the fact that some repository item was shown in this session.
|
void |
setContentHistoryPath(java.lang.String pContentHistoryPath)
Set the component path of the object used to record what content
items have been displayed from each repository.
|
void |
setDescription(java.lang.String pDescription)
Set this targeter's description
|
void |
setImpressionLimit(int pImpressionLimit)
Set the maximum number of times this targeter can return the same item
|
void |
setImpressionLimitPerTargeter(boolean pImpressionLimitPerTargeter)
Specify whether impression limits are per-targeter, or global.
|
void |
setLogger(ApplicationLogging pLogger)
Set the object that performs application logging on our behalf.
|
void |
setLoggingDebug(boolean pLogging)
Sets whether or not debug log events should be logged.
|
void |
setLoggingError(boolean pLogging)
Sets whether or not error log events should be logged.
|
void |
setLoggingInfo(boolean pLogging)
Sets whether or not info log events should be logged.
|
void |
setLoggingWarning(boolean pLogging)
Sets whether or not warning log events should be logged.
|
void |
setOverriddenRulesets(java.util.Map<java.lang.String,java.lang.String> pOverriddenRulesets)
Sets a map of overridden rulesets.
|
void |
setRepository(Repository pRepository)
Set the repository from which to select items
|
void |
setRepositoryViewName(java.lang.String pRepositoryViewName)
Set the name of the repository view from which to select items
|
void |
setRulesets(StringList pRulesets)
Set the definitions for all rulesets used by this targeter
|
void |
setRuleStrings(StringList pRuleStrings)
Set the StringList representing the rules used by this targeter.
|
void |
setSiteRulesets(java.util.Map<java.lang.String,java.lang.String> pSiteReulsets)
Deprecated.
There are other override types besides site override, so API doesn't correspond
to existent override model.
Method
setOverriddenRulesets(java.util.Map<java.lang.String, java.lang.String>) should be used instead. |
void |
setSortBy(java.lang.String pSortBy)
Set the criteria used to sort results in this targeter.
|
void |
start()
Prepare this targeter for use.
|
void |
stop()
Mark this targeter inactive and clear its internal list of sub-targeters.
|
java.lang.Object[] |
target(NameResolver pNameResolver)
Performs a targeting operation, returning an array of "target"
objects.
|
java.lang.Object[] |
target(NameResolver pNameResolver,
int pMaxNumber)
Performs a targeting operation, returning an array of "target" objects
containing at most pMaxNumber entries.
|
java.lang.Object[] |
target(NameResolver pNameResolver,
int pStartIndex,
int pMaxNumber)
Performs a targeting operation, returning an array of "target"
objects, beginning at the starting index of the entire result set, and
containing at most pMaxNumber elements.
|
protected void |
updateTargeters(boolean pCreate)
Rebuild all targeters.
|
protected void |
zapTargeters()
Zap all targeters to indicate that this object needs to be reinitialized.
|
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingTrace, isRunning, logTrace, logTrace, logTrace, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingTrace, setNucleus, setServiceInfo, startService, stopServicevlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarningpublic static java.lang.String CLASS_VERSION
protected Repository mRepository
protected java.lang.String mRepositoryViewName
protected StringList mRulesets
protected StringList mRuleStrings
protected java.lang.String mSortBy
protected SortDirectives mSortDirectives
protected atg.targeting.RuleBasedRepositoryTargeter[] mTargeters
protected int mImpressionLimit
protected boolean mImpressionLimitPerTargeter
protected java.lang.String mDescription
protected java.lang.String mContentHistoryPath
protected java.util.Map<java.lang.String,java.lang.String> mOverriddenRulesets
protected atg.targeting.overrides.MultisiteOverrideContainer<atg.targeting.RuleBasedRepositoryTargeter> mOverriddenTargeters
public void setRepository(Repository pRepository) throws atg.targeting.TargetingException
atg.targeting.TargetingExceptionpublic Repository getRepository()
getRepository in interface atg.targeting.RepositoryTargeterpublic void setRepositoryViewName(java.lang.String pRepositoryViewName)
throws atg.targeting.TargetingException
atg.targeting.TargetingExceptionpublic java.lang.String getRepositoryViewName()
public RepositoryView getRepositoryView() throws RepositoryException
getRepositoryView in interface atg.targeting.RepositoryTargeterRepositoryExceptionpublic void setRulesets(StringList pRulesets) throws atg.targeting.TargetingException
pRulesets - A StringList, each of whose elements is a complete ruleset as
defined in the targeting documentation for Dynamo, including
the <ruleset> and </ruleset> tags.
These rulesets should not include sorting directives since they will be overridden by any sort criteria specified in the targeter's sortBy property.
atg.targeting.TargetingExceptionpublic StringList getRulesets()
public void setRuleStrings(StringList pRuleStrings)
public StringList getRuleStrings()
public java.lang.String[] getDisplayRuleStrings()
public java.lang.String[] getDisplayRuleStringsUsingCurrentRequest()
public java.lang.String[] getDisplayRuleStrings(DynamoHttpServletRequest pRequest)
pRequest - the request context to use. May be null.public int getNumRulesets()
public void setSortBy(java.lang.String pSortBy)
throws atg.targeting.TargetingException
pSortBy - The stringified version of a set of targeter sorting rules.
This should be a string of the form:
<sortby>
<sortbyvalue value=property [dir=direction]>
...
</sortby>
Note that the value may not use the src= attribute to incorporate another set of sort criteria by reference.
atg.targeting.TargetingExceptionpublic java.lang.String getSortBy()
<sortby>
<sortbyvalue value=property [dir=direction]>
...
</sortby>
public void setImpressionLimit(int pImpressionLimit)
public int getImpressionLimit()
public void setContentHistoryPath(java.lang.String pContentHistoryPath)
public java.lang.String getContentHistoryPath()
public void setImpressionLimitPerTargeter(boolean pImpressionLimitPerTargeter)
If a per-targeter limit is used, then impressionLimit will only count impressions that come from this targeter. If a global limit is used, then impressionLimit will count impressions from any similarly configured targeter. .
public boolean isImpressionLimitPerTargeter()
public void setDescription(java.lang.String pDescription)
public java.lang.String getDescription()
public void setLogger(ApplicationLogging pLogger)
public ApplicationLogging getLogger()
@Deprecated
public void setSiteRulesets(java.util.Map<java.lang.String,java.lang.String> pSiteReulsets)
throws atg.targeting.TargetingException
setOverriddenRulesets(java.util.Map<java.lang.String, java.lang.String>) should be used instead.TargetingException@Deprecated public java.util.Map<java.lang.String,java.lang.String> getSiteRulesets()
getOverriddenRulesets() should be used instead.public void setOverriddenRulesets(java.util.Map<java.lang.String,java.lang.String> pOverriddenRulesets)
throws atg.targeting.TargetingException
TargetingExceptionpublic java.util.Map<java.lang.String,java.lang.String> getOverriddenRulesets()
public java.lang.Object[] target(NameResolver pNameResolver) throws atg.targeting.TargetingException
Returns null if no items are found matching the targeting criteria.
This method automatically cascades down rulesets. If a ruleset returns no suitable items or if all items returned have passed their impression limits, then the targeting operation will automatically try subsequent rulesets. It returns null only after all rulesets have been exhausted.
public java.lang.Object[] target(NameResolver pNameResolver, int pMaxNumber) throws atg.targeting.TargetingException
Returns null if no items are found matching the targeting criteria.
This method automatically cascades down rulesets. If a ruleset returns no suitable items or if all items returned have passed their impression limits, then the targeting operation will automatically try subsequent rulesets. It returns null only after all rulesets have been exhausted.
public java.lang.Object[] target(NameResolver pNameResolver, int pStartIndex, int pMaxNumber) throws atg.targeting.TargetingException
This method performs cascading differently from the other target methods of this class. In particular, it does not use impression limits to trigger cascading behavior.
Rulesets are tried in turn until one of them produces a non-empty set of items. That set is then filtered by impression limit, and the result is immediately returned.
If the filtering process removes all items from the initial result set this method immediately returns null, where the other targeting methods would automatically try the next available ruleset. Keep this difference in mind when deciding which form of target to call.
target in interface TargeterpStartIndex - the starting index; must be >= 0pMaxNumber - the maximum number of elements to return; if -1, the entire
result set starting at index pStartIndex will be retrievedTargetingException - if a problem was encountered during the
targeting operationpublic void registerContentShown(NameResolver pNameResolver, RepositoryItem pItem)
registerContentShown in interface atg.targeting.ContentHistoryManagerpublic boolean isContentShown(NameResolver pNameResolver, RepositoryItem pItem)
isContentShown in interface atg.targeting.ContentHistoryManagerpublic int countContentShown(NameResolver pNameResolver, RepositoryItem pItem)
countContentShown in interface atg.targeting.ContentHistoryManagerpublic void doStartService()
throws ServiceException
doStartService in class GenericServiceServiceException - if the Service had a problem starting uppublic void doStopService()
doStopService in class GenericServicepublic void start()
throws atg.targeting.TargetingException
This allows the object to be instantiated either as a Nucleus component or stand-alone. For example, one could instantiate a DynamicContentTargeter as follows:
DynamicContentTargeter t = new DynamicContentTargeter(); t.setRepository(...); t.setRepositoryViewName(...); t.setRulesets(...); t.start();
TargetingException - if the object had a problem starting uppublic void stop()
public atg.targeting.ContentHistory getContentHistory(NameResolver pNameResolver)
public java.lang.Object getContentHistoryContext()
protected void updateTargeters(boolean pCreate)
throws atg.targeting.TargetingException
atg.targeting.TargetingExceptionprotected void zapTargeters()
public Targeter[] getTargeters()
public Targeter[] findSiteTargeters(java.lang.String pSiteId)
protected java.lang.Object[] filter(NameResolver pNameResolver, java.lang.Object[] pItems)
pNameResolver - An object (usually an HTTP request) used to find the session-scoped
ContentHistory object.pItems - An array of RepositoryItems to filter.protected java.lang.Object[] atMost(int pMaxNumber,
java.lang.Object[] pItems)
public atg.targeting.RuleBasedRepositoryTargeter[] buildTargeters(Repository pRepository, java.lang.String pRepositoryViewName, StringList pRulesets, SortDirectives pSortDirectives) throws atg.targeting.TargetingException
pRepository - The repository from which these targeters will select contentpRepositoryViewName - The repository view from which these targeters will select contentpRulesets - An array of strings specifying rulesets. These rulesets should
not include sorting directives since they will be overridden by
pSortDirectives.pSortDirectives - Sorting directives these targeters will use to sort results.TargetingException - if anything goes wrong when creating the targeters. In cases
where the error involved unparseable rule specifications or other
ruleset-related problems, the rootCause of the TargetingException
will contain the original exception.public atg.targeting.RuleBasedRepositoryTargeter[] convertRuleSetsToTargetingObjects(java.lang.String[] pRuleSets)
throws atg.targeting.TargetingException
RuleBasedRepositoryTargeter)convertRuleSetsToTargetingObjects in interface atg.targeting.overrides.TargetingObjectsFactory<atg.targeting.RuleBasedRepositoryTargeter>array - of string representations of targetersRuleBasedRepositoryTargeteratg.targeting.TargetingExceptionpublic static SortDirectives buildSortDirectives(java.lang.String pSortBy) throws atg.targeting.TargetingException
atg.targeting.TargetingExceptionpublic boolean isLoggingInfo()
GenericServiceisLoggingInfo in interface atg.core.logging.LoggingisLoggingInfo in interface ApplicationLoggingisLoggingInfo in class GenericServicepublic void setLoggingInfo(boolean pLogging)
GenericServicesetLoggingInfo in interface atg.core.logging.LoggingsetLoggingInfo in interface ApplicationLoggingsetLoggingInfo in class GenericServicepublic boolean isLoggingWarning()
GenericServiceisLoggingWarning in interface atg.core.logging.LoggingisLoggingWarning in interface ApplicationLoggingisLoggingWarning in class GenericServicepublic void setLoggingWarning(boolean pLogging)
GenericServicesetLoggingWarning in interface atg.core.logging.LoggingsetLoggingWarning in interface ApplicationLoggingsetLoggingWarning in class GenericServicepublic boolean isLoggingError()
GenericServiceisLoggingError in interface atg.core.logging.LoggingisLoggingError in interface ApplicationLoggingisLoggingError in class GenericServicepublic void setLoggingError(boolean pLogging)
GenericServicesetLoggingError in interface atg.core.logging.LoggingsetLoggingError in interface ApplicationLoggingsetLoggingError in class GenericServicepublic boolean isLoggingDebug()
GenericServiceisLoggingDebug in interface atg.core.logging.LoggingisLoggingDebug in interface ApplicationLoggingisLoggingDebug in class GenericServicepublic void setLoggingDebug(boolean pLogging)
GenericServicesetLoggingDebug in interface atg.core.logging.LoggingsetLoggingDebug in interface ApplicationLoggingsetLoggingDebug in class GenericServicepublic void logInfo(java.lang.String pMessage)
GenericServicelogInfo in interface atg.core.logging.LogginglogInfo in interface ApplicationLogginglogInfo in class GenericServicepublic void logInfo(java.lang.Throwable pThrowable)
GenericServicelogInfo in interface atg.core.logging.LogginglogInfo in interface ApplicationLogginglogInfo in class GenericServicepublic void logInfo(java.lang.String pMessage,
java.lang.Throwable pThrowable)
GenericServicelogInfo in interface atg.core.logging.LogginglogInfo in interface ApplicationLogginglogInfo in class GenericServicepublic void logWarning(java.lang.String pMessage)
GenericServicelogWarning in interface atg.core.logging.LogginglogWarning in interface ApplicationLogginglogWarning in class GenericServicepublic void logWarning(java.lang.Throwable pThrowable)
GenericServicelogWarning in interface atg.core.logging.LogginglogWarning in interface ApplicationLogginglogWarning in class GenericServicepublic void logWarning(java.lang.String pMessage,
java.lang.Throwable pThrowable)
GenericServicelogWarning in interface atg.core.logging.LogginglogWarning in interface ApplicationLogginglogWarning in class GenericServicepublic void logError(java.lang.String pMessage)
GenericServicelogError in interface atg.core.logging.LogginglogError in interface ApplicationLogginglogError in class GenericServicepublic void logError(java.lang.Throwable pThrowable)
GenericServicelogError in interface atg.core.logging.LogginglogError in interface ApplicationLogginglogError in class GenericServicepublic void logError(java.lang.String pMessage,
java.lang.Throwable pThrowable)
GenericServicelogError in interface atg.core.logging.LogginglogError in interface ApplicationLogginglogError in class GenericServicepublic void logDebug(java.lang.String pMessage)
GenericServicelogDebug in interface atg.core.logging.LogginglogDebug in interface ApplicationLogginglogDebug in class GenericServicepublic void logDebug(java.lang.Throwable pThrowable)
GenericServicelogDebug in interface atg.core.logging.LogginglogDebug in interface ApplicationLogginglogDebug in class GenericServicepublic void logDebug(java.lang.String pMessage,
java.lang.Throwable pThrowable)
GenericServicelogDebug in interface atg.core.logging.LogginglogDebug in interface ApplicationLogginglogDebug in class GenericServicepublic static atg.nucleus.ConfigurationState createTargeterConfiguration()
throws java.beans.IntrospectionException
java.beans.IntrospectionException - If any error occurs while creating the configuration.