Package org.apache.unomi.api.rules
Class Rule
java.lang.Object
org.apache.unomi.api.Item
org.apache.unomi.api.MetadataItem
org.apache.unomi.api.rules.Rule
- All Implemented Interfaces:
Serializable
A conditional set of actions to be executed in response to incoming events. Triggering of rules is guarded by a condition: the rule is only triggered if the associated
condition (
getCondition()) is satisfied. Once a rule triggers, a list of actions (getActions() can be performed as consequences.
When rules trigger, a specific event is raised so that other parts of unomi can react to it accordingly. We can control how that event should be raised using
isRaiseEventOnlyOnceForProfile() and isRaiseEventOnlyOnceForSession().
We could also specify a priority for our rule in case it needs to be executed before other ones when similar conditions match. This is accomplished using the
getPriority() property.- See Also:
-
Field Summary
FieldsFields inherited from class org.apache.unomi.api.MetadataItem
metadata -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the actions to be performed when this rule triggers.Retrieves the condition that, when satisfied, triggers the rule.Retrieves the linked items.intRetrieves the priority in case this Rule needs to be executed before other ones when similar conditions match.booleanDetermines whether the event raised when the rule is triggered should only be raised oncebooleanDetermines whether the event raised when the rule is triggered should only be raised once perProfile.booleanDetermines whether the event raised when the rule is triggered should only be raised once perSession.voidsetActions(List<Action> actions) Sets the actions to be performed when this rule triggers.voidsetCondition(Condition condition) Sets the condition that, when satisfied, triggers the rule..voidsetLinkedItems(List<String> linkedItems) Sets the linked items.voidsetPriority(int priority) Sets the priority in case this Rule needs to be executed before other ones when similar conditions match.voidsetRaiseEventOnlyOnce(boolean raiseEventOnlyOnce) Specifies whether the event raised when the rule is triggered should only be raised once perEvent.voidsetRaiseEventOnlyOnceForProfile(boolean raiseEventOnlyOnceForProfile) Specifies whether the event raised when the rule is triggered should only be raised once perProfile.voidsetRaiseEventOnlyOnceForSession(boolean raiseEventOnlyOnceForSession) Specifies whether the event raised when the rule is triggered should only be raised once perSession.Methods inherited from class org.apache.unomi.api.MetadataItem
getMetadata, getScope, setMetadataMethods inherited from class org.apache.unomi.api.Item
equals, getItemId, getItemType, getItemType, getSystemMetadata, getVersion, hashCode, setItemId, setItemType, setScope, setSystemMetadata, setVersion
-
Field Details
-
ITEM_TYPE
The Rule ITEM_TYPE.
-
-
Constructor Details
-
Rule
public Rule()Instantiates a new Rule. -
Rule
Instantiates a new Rule with the specifiedMetadata.- Parameters:
metadata- the metadata
-
-
Method Details
-
getCondition
Retrieves the condition that, when satisfied, triggers the rule.- Returns:
- the condition that, when satisfied, triggers the rule.
-
setCondition
Sets the condition that, when satisfied, triggers the rule..- Parameters:
condition- the condition that, when satisfied, triggers the rule.
-
getActions
Retrieves the actions to be performed when this rule triggers.- Returns:
- the actions to be performed when this rule triggers
-
setActions
Sets the actions to be performed when this rule triggers.- Parameters:
actions- the actions to be performed when this rule triggers
-
getLinkedItems
Retrieves the linked items.- Returns:
- the linked items
-
setLinkedItems
Sets the linked items.- Parameters:
linkedItems- the linked items
-
isRaiseEventOnlyOnceForProfile
public boolean isRaiseEventOnlyOnceForProfile()Determines whether the event raised when the rule is triggered should only be raised once perProfile.- Returns:
trueif the rule-triggered event should only be raised once per profile,falseotherwise
-
isRaiseEventOnlyOnce
public boolean isRaiseEventOnlyOnce()Determines whether the event raised when the rule is triggered should only be raised once- Returns:
trueif the rule-triggered event should only be raised once per profile
-
setRaiseEventOnlyOnceForProfile
public void setRaiseEventOnlyOnceForProfile(boolean raiseEventOnlyOnceForProfile) Specifies whether the event raised when the rule is triggered should only be raised once perProfile.- Parameters:
raiseEventOnlyOnceForProfile-trueif the rule-triggered event should only be raised once per profile,falseotherwise
-
isRaiseEventOnlyOnceForSession
public boolean isRaiseEventOnlyOnceForSession()Determines whether the event raised when the rule is triggered should only be raised once perSession.- Returns:
trueif the rule-triggered event should only be raised once per session,falseotherwise
-
setRaiseEventOnlyOnceForSession
public void setRaiseEventOnlyOnceForSession(boolean raiseEventOnlyOnceForSession) Specifies whether the event raised when the rule is triggered should only be raised once perSession.- Parameters:
raiseEventOnlyOnceForSession-trueif the rule-triggered event should only be raised once per session,falseotherwise
-
setRaiseEventOnlyOnce
public void setRaiseEventOnlyOnce(boolean raiseEventOnlyOnce) Specifies whether the event raised when the rule is triggered should only be raised once perEvent.- Parameters:
raiseEventOnlyOnce-trueif the rule-triggered event should only be raised once per event,falseotherwise
-
getPriority
public int getPriority()Retrieves the priority in case this Rule needs to be executed before other ones when similar conditions match.- Returns:
- the priority
-
setPriority
public void setPriority(int priority) Sets the priority in case this Rule needs to be executed before other ones when similar conditions match.- Parameters:
priority- the priority
-