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 String
ITEM_TYPE
The 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.Condition
getCondition()
Retrieves the condition that, when satisfied, triggers the rule.List<String>
getLinkedItems()
Retrieves the linked items.int
getPriority()
Retrieves the priority in case this Rule needs to be executed before other ones when similar conditions match.boolean
isRaiseEventOnlyOnce()
Determines whether the event raised when the rule is triggered should only be raised onceboolean
isRaiseEventOnlyOnceForProfile()
Determines whether the event raised when the rule is triggered should only be raised once perProfile
.boolean
isRaiseEventOnlyOnceForSession()
Determines whether the event raised when the rule is triggered should only be raised once perSession
.void
setActions(List<Action> actions)
Sets the actions to be performed when this rule triggers.void
setCondition(Condition condition)
Sets the condition that, when satisfied, triggers the rule..void
setLinkedItems(List<String> linkedItems)
Sets the linked items.void
setPriority(int priority)
Sets the priority in case this Rule needs to be executed before other ones when similar conditions match.void
setRaiseEventOnlyOnce(boolean raiseEventOnlyOnce)
Specifies whether the event raised when the rule is triggered should only be raised once perEvent
.void
setRaiseEventOnlyOnceForProfile(boolean raiseEventOnlyOnceForProfile)
Specifies whether the event raised when the rule is triggered should only be raised once perProfile
.void
setRaiseEventOnlyOnceForSession(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:
true
if the rule-triggered event should only be raised once per profile,false
otherwise
-
isRaiseEventOnlyOnce
public boolean isRaiseEventOnlyOnce()
Determines whether the event raised when the rule is triggered should only be raised once- Returns:
true
if 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
-true
if the rule-triggered event should only be raised once per profile,false
otherwise
-
isRaiseEventOnlyOnceForSession
public boolean isRaiseEventOnlyOnceForSession()
Determines whether the event raised when the rule is triggered should only be raised once perSession
.- Returns:
true
if the rule-triggered event should only be raised once per session,false
otherwise
-
setRaiseEventOnlyOnceForSession
public void setRaiseEventOnlyOnceForSession(boolean raiseEventOnlyOnceForSession)
Specifies whether the event raised when the rule is triggered should only be raised once perSession
.- Parameters:
raiseEventOnlyOnceForSession
-true
if the rule-triggered event should only be raised once per session,false
otherwise
-
setRaiseEventOnlyOnce
public void setRaiseEventOnlyOnce(boolean raiseEventOnlyOnce)
Specifies whether the event raised when the rule is triggered should only be raised once perEvent
.- Parameters:
raiseEventOnlyOnce
-true
if the rule-triggered event should only be raised once per event,false
otherwise
-
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
-
-