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,
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, wait
evaluate, getFormHTML, getSummary, processRule
public void activate()
Rule
public void deActivate()
Rule
deActivate
in interface Rule
public void deleteData(RuleInstance ruleInstance) throws com.liferay.portal.kernel.exception.PortalException
Rule
deleteData
in interface Rule
ruleInstance
- 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, AnonymousUser anonymousUser)
Rule
true
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 Rule
context
- 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
Rule
exportData
in interface Rule
portletDataContext
- 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()
Rule
Age
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 Rule
public java.lang.String getDescription(java.util.Locale locale)
Rule
getDescription
in interface Rule
locale
- the language localepublic java.lang.String getIcon()
Rule
getIcon
in interface Rule
public java.lang.String getName(java.util.Locale locale)
Rule
public java.lang.String getRuleCategoryKey()
Rule
getRuleCategoryKey
in interface Rule
public java.lang.String getRuleKey()
Rule
getRuleKey
in interface Rule
public java.lang.String getShortDescription(java.util.Locale locale)
Rule
getShortDescription
in interface Rule
locale
- the language localepublic void importData(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext, UserSegment userSegment, RuleInstance ruleInstance) throws java.lang.Exception
Rule
importData
in interface Rule
portletDataContext
- 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()
Rule
true
if the rule can be used more than once with
different values for a user segment.isInstantiable
in interface Rule
true
if the rule can be used more than once;
false
otherwisepublic boolean isVisible()
Rule
true
if the rule is visible.public boolean supportsOfflineEvaluation()
Rule
true
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 Rule
true
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)