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
public class Rule extends MetadataItem
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 usingisRaiseEventOnlyOnceForProfile()andisRaiseEventOnlyOnceForSession(). 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 thegetPriority()property.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringITEM_TYPEThe Rule ITEM_TYPE.-
Fields inherited from class org.apache.unomi.api.MetadataItem
metadata
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Action>getActions()Retrieves the actions to be performed when this rule triggers.ConditiongetCondition()Retrieves the condition that, when satisfied, triggers the rule.List<String>getLinkedItems()Retrieves the linked items.intgetPriority()Retrieves the priority in case this Rule needs to be executed before other ones when similar conditions match.booleanisRaiseEventOnlyOnce()Determines whether the event raised when the rule is triggered should only be raised oncebooleanisRaiseEventOnlyOnceForProfile()Determines whether the event raised when the rule is triggered should only be raised once perProfile.booleanisRaiseEventOnlyOnceForSession()Determines 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, setMetadata
-
Methods inherited from class org.apache.unomi.api.Item
equals, getItemId, getItemType, getItemType, getSystemMetadata, getVersion, hashCode, setItemId, setItemType, setScope, setSystemMetadata, setVersion
-
-
-
-
Field Detail
-
ITEM_TYPE
public static final String ITEM_TYPE
The Rule ITEM_TYPE.
-
-
Method Detail
-
getCondition
public Condition getCondition()
Retrieves the condition that, when satisfied, triggers the rule.- Returns:
- the condition that, when satisfied, triggers the rule.
-
setCondition
public void setCondition(Condition condition)
Sets the condition that, when satisfied, triggers the rule..- Parameters:
condition- the condition that, when satisfied, triggers the rule.
-
getActions
public List<Action> getActions()
Retrieves the actions to be performed when this rule triggers.- Returns:
- the actions to be performed when this rule triggers
-
setActions
public void setActions(List<Action> actions)
Sets the actions to be performed when this rule triggers.- Parameters:
actions- the actions to be performed when this rule triggers
-
getLinkedItems
public List<String> getLinkedItems()
Retrieves the linked items.- Returns:
- the linked items
-
setLinkedItems
public void setLinkedItems(List<String> linkedItems)
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
-
-