public interface Rule
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(javax.servlet.http.HttpServletRequest request,
RuleInstance ruleInstance,
AnonymousUser anonymousUser)
Returns
true if the user complies with the rule instance in
real time. |
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.
|
java.lang.String |
getFormHTML(RuleInstance ruleInstance,
java.util.Map<java.lang.String,java.lang.Object> context,
java.util.Map<java.lang.String,java.lang.String> values)
Returns the HTML code containing the form fields required to edit the
rule instance configuration, based on the context.
|
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.
|
java.lang.String |
getSummary(RuleInstance ruleInstance,
java.util.Locale locale)
Returns the rule instance's localized summary.
|
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. |
java.lang.String |
processRule(javax.portlet.PortletRequest portletRequest,
javax.portlet.PortletResponse portletResponse,
java.lang.String id,
java.util.Map<java.lang.String,java.lang.String> values)
Returns the result of evaluating the rule form fields in the context of
the request and response.
|
boolean |
supportsOfflineEvaluation()
Returns
true if the rule can be evaluated offline (without
the user request in real time). |
void activate()
void deActivate()
void deleteData(RuleInstance ruleInstance) throws com.liferay.portal.kernel.exception.PortalException
ruleInstance
- the rule instance with the stored configurationcom.liferay.portal.kernel.exception.PortalException
- if a portal exception occurredboolean evaluate(javax.servlet.http.HttpServletRequest request, RuleInstance ruleInstance, AnonymousUser anonymousUser) throws java.lang.Exception
true
if the user complies with the rule instance in
real time. The evaluation is completed correctly after the user makes a
request.request
- the servlet request of the userruleInstance
- the rule instance with stored configurationanonymousUser
- the user who evaluates the ruletrue
if the user complies with the rule instance in
real time; false
otherwisejava.lang.Exception
- if an exception occurredboolean evaluate(java.util.Map<java.lang.String,java.lang.Object> context, RuleInstance ruleInstance, AnonymousUser anonymousUser)
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 supportsOfflineEvaluation()
). A context map can be
optionally passed with some context variables.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
otherwisevoid 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
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 occurredlong getCacheTime()
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.java.lang.String getDescription(java.util.Locale locale)
locale
- the language localejava.lang.String getFormHTML(RuleInstance ruleInstance, java.util.Map<java.lang.String,java.lang.Object> context, java.util.Map<java.lang.String,java.lang.String> values)
ruleInstance
- the rule instance with stored configurationcontext
- the map defining the form evaluation contextvalues
- the values configured by users for the current rule
instance based on the form controls from the HTML. This will be
used when there is an error and the form is reloaded.java.lang.String getIcon()
java.lang.String getName(java.util.Locale locale)
locale
- the language localejava.lang.String getRuleCategoryKey()
java.lang.String getRuleKey()
java.lang.String getShortDescription(java.util.Locale locale)
locale
- the language localejava.lang.String getSummary(RuleInstance ruleInstance, java.util.Locale locale)
ruleInstance
- the rule instance with stored configurationlocale
- the language localevoid importData(com.liferay.exportimport.kernel.lar.PortletDataContext portletDataContext, UserSegment userSegment, RuleInstance ruleInstance) throws java.lang.Exception
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 occurredboolean isInstantiable()
true
if the rule can be used more than once with
different values for a user segment.true
if the rule can be used more than once;
false
otherwiseboolean isVisible()
true
if the rule is visible.true
if the rule is visible; false
otherwisejava.lang.String processRule(javax.portlet.PortletRequest portletRequest, javax.portlet.PortletResponse portletResponse, java.lang.String id, java.util.Map<java.lang.String,java.lang.String> values) throws InvalidRuleException
portletRequest
- the request from which to get the request
parametersportletResponse
- the response to receive the render parametersid
- the identifier that differentiates between rule instances of
the same type of an instantiable rulevalues
- the values configured by users for the current rule
instance based on the form controls from the HTMLInvalidRuleException
- if an invalid rule exception occurredboolean supportsOfflineEvaluation()
true
if the rule can be evaluated offline (without
the user request in real time). If this is set to true
, the
method evaluate(Map, RuleInstance, AnonymousUser)
should be
implemented.true
if the rule can be evaluated offline;
false
otherwise.