Package org.apache.unomi.api
Class Event
java.lang.Object
org.apache.unomi.api.Item
org.apache.unomi.api.Event
- All Implemented Interfaces:
Serializable
,TimestampedItem
An event that can be processed and evaluated by the context server. Events can be triggered by clients following user actions or can also be issued internally in the context
server in response to another event. Conceptually, an event can be seen as a sentence, the event's type being the verb, the source the subject and the target the object.
Source and target can be any unomi item but are not limited to them. In particular, as long as they can be described using properties and unomi’s type mechanism and can be processed either natively or via extension plugins, source and target can represent just about anything.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
A constant for the name of the attribute that can be used to retrieve the current clientID.static final String
A constant for the name of the attribute that can be used to retrieve the current HTTP request.static final String
A constant for the name of the attribute that can be used to retrieve the current HTTP response.static final String
The Event ITEM_TYPE. -
Constructor Summary
ConstructorsConstructorDescriptionEvent()
Instantiates a new Event.Event
(String itemId, String eventType, Session session, Profile profile, String scope, Item source, Item target, Date timestamp) Instantiates a new Event.Event
(String itemId, String eventType, Session session, Profile profile, String scope, Item source, Item target, Map<String, Object> properties, Date timestamp, boolean persistent) Instantiates a new Event.Event
(String eventType, Session session, Profile profile, String scope, Item source, Item target, Date timestamp) Instantiates a new Event.Event
(String eventType, Session session, Profile profile, String scope, Item source, Item target, Map<String, Object> properties, Date timestamp, boolean persistent) Instantiates a new Event. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the action post executors for this event, if extra actions need to be executed after all Rule-triggered actions have been processedRetrieves the attributes.Retrieves the event type.Retrieves the flattened propertiesgetNestedProperty
(String name) Retrieves the value of the nested property identified by the specified name.Retrieves the profile.Retrieves the profile identifier of the Profile associated with this eventRetrieves the properties.getProperty
(String name) Retrieves the value of the property identified by the specified name.Retrieves the session.Retrieves the session identifier if available.Retrieves the source.Retrieves the target.Retrieves the event time stampboolean
Determines whether this Event needs to be persisted to the context server or not.void
setActionPostExecutors
(List<ActionPostExecutor> actionPostExecutors) Sets the action post executors.void
setAttributes
(Map<String, Object> attributes) Sets the map of attribuesvoid
setEventType
(String eventType) Sets the event typevoid
setFlattenedProperties
(Map<String, Object> flattenedProperties) Set the flattened properties for current eventvoid
setPersistent
(boolean persistent) Specifies if this Event needs to be persisted.void
setProfile
(Profile profile) Sets the profile.void
setProfileId
(String profileId) Sets the profile id.void
setProperties
(Map<String, Object> properties) Sets map of properties that will override existing field if it existsvoid
setProperty
(String name, Object value) Sets the property identified by the provided name to the specified value.void
setSession
(Session session) Sets the session.void
setSessionId
(String sessionId) Set the session idvoid
Sets the source.void
Sets the target.void
setTimeStamp
(Date timeStamp) Methods inherited from class org.apache.unomi.api.Item
equals, getItemId, getItemType, getItemType, getScope, getSystemMetadata, getVersion, hashCode, setItemId, setItemType, setScope, setSystemMetadata, setVersion
-
Field Details
-
ITEM_TYPE
The Event ITEM_TYPE. -
HTTP_REQUEST_ATTRIBUTE
A constant for the name of the attribute that can be used to retrieve the current HTTP request.- See Also:
-
HTTP_RESPONSE_ATTRIBUTE
A constant for the name of the attribute that can be used to retrieve the current HTTP response.- See Also:
-
CLIENT_ID_ATTRIBUTE
A constant for the name of the attribute that can be used to retrieve the current clientID.- See Also:
-
-
Constructor Details
-
Event
public Event()Instantiates a new Event. -
Event
public Event(String itemId, String eventType, Session session, Profile profile, String scope, Item source, Item target, Date timestamp) Instantiates a new Event.- Parameters:
itemId
- the event item id identifiereventType
- the event type identifiersession
- the session associated with the eventprofile
- the profile associated with the eventscope
- the scope from which the event is issuedsource
- the source of the eventtarget
- the target of the event if anytimestamp
- the timestamp associated with the event if provided
-
Event
public Event(String eventType, Session session, Profile profile, String scope, Item source, Item target, Date timestamp) Instantiates a new Event.- Parameters:
eventType
- the event type identifiersession
- the session associated with the eventprofile
- the profile associated with the eventscope
- the scope from which the event is issuedsource
- the source of the eventtarget
- the target of the event if anytimestamp
- the timestamp associated with the event if provided
-
Event
public Event(String eventType, Session session, Profile profile, String scope, Item source, Item target, Map<String, Object> properties, Date timestamp, boolean persistent) Instantiates a new Event.- Parameters:
eventType
- the event type identifiersession
- the session associated with the eventprofile
- the profile associated with the eventscope
- the scope from which the event is issuedsource
- the source of the eventtarget
- the target of the event if anyproperties
- the properties for this event if anytimestamp
- the timestamp associated with the event if providedpersistent
- specifies if the event needs to be persisted
-
Event
public Event(String itemId, String eventType, Session session, Profile profile, String scope, Item source, Item target, Map<String, Object> properties, Date timestamp, boolean persistent) Instantiates a new Event.- Parameters:
itemId
- the event item id identifiereventType
- the event type identifiersession
- the session associated with the eventprofile
- the profile associated with the eventscope
- the scope from which the event is issuedsource
- the source of the eventtarget
- the target of the event if anyproperties
- the properties for this event if anytimestamp
- the timestamp associated with the event if providedpersistent
- specifies if the event needs to be persisted
-
-
Method Details
-
getSessionId
Retrieves the session identifier if available.- Returns:
- the session identifier or
null
if unavailable
-
setSessionId
Set the session id- Parameters:
sessionId
- the session id
-
getProfileId
Retrieves the profile identifier of the Profile associated with this event- Returns:
- the profile id
-
setProfileId
Sets the profile id.- Parameters:
profileId
- the profile id
-
getEventType
Retrieves the event type.- Returns:
- the event type
-
setEventType
Sets the event type- Parameters:
eventType
- the event type
-
getTimeStamp
Retrieves the event time stamp- Specified by:
getTimeStamp
in interfaceTimestampedItem
- Returns:
- the event time stamp
-
setTimeStamp
- Parameters:
timeStamp
- set the time stamp
-
getProfile
Retrieves the profile.- Returns:
- the profile
-
setProfile
Sets the profile.- Parameters:
profile
- the profile
-
getSession
Retrieves the session.- Returns:
- the session
-
setSession
Sets the session.- Parameters:
session
- the session
-
isPersistent
public boolean isPersistent()Determines whether this Event needs to be persisted to the context server or not. Events that don't participate in building the user profile don't usually need to be persisted.- Returns:
true
if this Event needs to be persisted,false
otherwise
-
setPersistent
public void setPersistent(boolean persistent) Specifies if this Event needs to be persisted.- Parameters:
persistent
-true
if this Event needs to be persisted,false
otherwise
-
getAttributes
Retrieves the attributes. Attributes are not serializable, and can be used to provide additional contextual objects such as HTTP request or response objects, etc...- Returns:
- the attributes
-
setAttributes
Sets the map of attribues- Parameters:
attributes
- the attributes map
-
setProperty
Sets the property identified by the provided name to the specified value.- Parameters:
name
- the name of the property to be setvalue
- the value of the property
-
getProperty
Retrieves the value of the property identified by the specified name.- Parameters:
name
- the name of the property to be retrieved- Returns:
- the value of the property identified by the specified name
-
getNestedProperty
Retrieves the value of the nested property identified by the specified name.- Parameters:
name
- the name of the property to be retrieved, splited in the nested properties with "."- Returns:
- the value of the property identified by the specified name
-
getProperties
Retrieves the properties.- Returns:
- the properties
-
setProperties
Sets map of properties that will override existing field if it exists- Parameters:
properties
- Map of new Properties
-
getFlattenedProperties
Retrieves the flattened properties- Returns:
- the flattened properties.
-
setFlattenedProperties
Set the flattened properties for current event- Parameters:
flattenedProperties
- the properties
-
getSource
Retrieves the source.- Returns:
- the source
-
setSource
Sets the source.- Parameters:
source
- the source
-
getTarget
Retrieves the target.- Returns:
- the target
-
setTarget
Sets the target.- Parameters:
target
- the target
-
getActionPostExecutors
Retrieves the action post executors for this event, if extra actions need to be executed after all Rule-triggered actions have been processed- Returns:
- the action post executors
-
setActionPostExecutors
Sets the action post executors.- Parameters:
actionPostExecutors
- the action post executors
-