public abstract class BaseRule extends java.lang.Object implements Rule
| Constructor and Description |
|---|
BaseRule() |
| Modifier and Type | Method and Description |
|---|---|
void |
activate()
Does processing when the rule is installed.
|
void |
deActivate()
Does processing when the rule is uninstalled.
|
void |
deleteData(RuleInstance ruleInstance)
Removes any additional data added by this rule when the rule instance is
removed.
|
boolean |
evaluate(java.util.Map<java.lang.String,java.lang.Object> context,
RuleInstance ruleInstance,
com.liferay.content.targeting.anonymous.users.model.AnonymousUser anonymousUser)
Returns
true if the user complies with the rule instance in
an offline mode. |
void |
exportData(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext,
com.liferay.portal.kernel.xml.Element userSegmentElement,
UserSegment userSegment,
com.liferay.portal.kernel.xml.Element ruleInstanceElement,
RuleInstance ruleInstance)
Exports any additional data added by this rule when the rule instance is
exported.
|
long |
getCacheTime()
Returns the time in milliseconds that the evaluation of this rule can be
cached.
|
java.lang.String |
getDescription(java.util.Locale locale)
Returns the rule's localized description.
|
protected java.lang.String |
getExportImportErrorMessage(UserSegment userSegment,
RuleInstance ruleInstance,
java.lang.String missingReferenceClassName,
java.lang.String missingReferenceId,
java.lang.String action) |
java.lang.String |
getIcon()
Returns the Font Awesome CSS class for the rule icon.
|
java.lang.String |
getName(java.util.Locale locale)
Returns the rule's localized name.
|
java.lang.String |
getRuleCategoryKey()
Returns the key that identifies the category of the rule.
|
java.lang.String |
getRuleKey()
Returns the key that identifies the rule.
|
java.lang.String |
getShortDescription(java.util.Locale locale)
Returns the rule's localized short description.
|
void |
importData(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext,
UserSegment userSegment,
RuleInstance ruleInstance)
Imports any additional data added by this rule when the rule instance is
imported.
|
boolean |
isInstantiable()
Returns
true if the rule can be used more than once with
different values for a user segment. |
boolean |
isVisible()
Returns
true if the rule is visible. |
boolean |
supportsOfflineEvaluation()
Returns
true if the rule can be evaluated offline (without
the user request in real time). |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitevaluate, getFormHTML, getSummary, processRulepublic void activate()
Rulepublic void deActivate()
RuledeActivate in interface Rulepublic void deleteData(RuleInstance ruleInstance) throws com.liferay.portal.kernel.exception.PortalException
RuledeleteData in interface RuleruleInstance - the rule instance with the stored configurationcom.liferay.portal.kernel.exception.PortalException - if a portal exception occurredpublic boolean evaluate(java.util.Map<java.lang.String,java.lang.Object> context,
RuleInstance ruleInstance,
com.liferay.content.targeting.anonymous.users.model.AnonymousUser anonymousUser)
Ruletrue if the user complies with the rule instance in
an offline mode. The evaluation is completed without having a user
request. This will only be called if the rule supports offline evaluation
(see method Rule.supportsOfflineEvaluation()). A context map can be
optionally passed with some context variables.evaluate in interface Rulecontext - a map of objects that can be used to evaluate the rule
instanceruleInstance - the rule instance with stored configurationanonymousUser - the user who evaluates the ruletrue if the user complies with the rule instance in
an offline mode; false otherwisepublic void exportData(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext,
com.liferay.portal.kernel.xml.Element userSegmentElement,
UserSegment userSegment,
com.liferay.portal.kernel.xml.Element ruleInstanceElement,
RuleInstance ruleInstance)
throws java.lang.Exception
RuleexportData in interface RuleportletDataContext - the context of the data exportuserSegmentElement - the element with the user segment export datauserSegment - the user segment containing the rule instanceruleInstanceElement - the element with the rule instance export
dataruleInstance - the rule instance with stored configurationjava.lang.Exception - if an exception occurredpublic long getCacheTime()
RuleAge rule can be cached at least 1
day and a Geolocation rule could be cached 5 minutes. This
value can be configurable by adding a custom configuration to your
component. A value of 0 means that the evaluation can not be
cached.getCacheTime in interface Rulepublic java.lang.String getDescription(java.util.Locale locale)
RulegetDescription in interface Rulelocale - the language localepublic java.lang.String getIcon()
RulegetIcon in interface Rulepublic java.lang.String getName(java.util.Locale locale)
Rulepublic java.lang.String getRuleCategoryKey()
RulegetRuleCategoryKey in interface Rulepublic java.lang.String getRuleKey()
RulegetRuleKey in interface Rulepublic java.lang.String getShortDescription(java.util.Locale locale)
RulegetShortDescription in interface Rulelocale - the language localepublic void importData(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext,
UserSegment userSegment,
RuleInstance ruleInstance)
throws java.lang.Exception
RuleimportData in interface RuleportletDataContext - the context of the data importuserSegment - the user segment containing the rule instanceruleInstance - the rule instance with stored configurationjava.lang.Exception - if an exception occurredpublic boolean isInstantiable()
Ruletrue if the rule can be used more than once with
different values for a user segment.isInstantiable in interface Ruletrue if the rule can be used more than once;
false otherwisepublic boolean isVisible()
Ruletrue if the rule is visible.public boolean supportsOfflineEvaluation()
Ruletrue if the rule can be evaluated offline (without
the user request in real time). If this is set to true, the
method Rule.evaluate(Map, RuleInstance, AnonymousUser) should be
implemented.supportsOfflineEvaluation in interface Ruletrue if the rule can be evaluated offline;
false otherwise.protected java.lang.String getExportImportErrorMessage(UserSegment userSegment, RuleInstance ruleInstance, java.lang.String missingReferenceClassName, java.lang.String missingReferenceId, java.lang.String action)