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
public class Event extends Item implements 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
CLIENT_ID_ATTRIBUTE
A constant for the name of the attribute that can be used to retrieve the current clientID.static String
HTTP_REQUEST_ATTRIBUTE
A constant for the name of the attribute that can be used to retrieve the current HTTP request.static String
HTTP_RESPONSE_ATTRIBUTE
A constant for the name of the attribute that can be used to retrieve the current HTTP response.static String
ITEM_TYPE
The Event ITEM_TYPE.
-
Constructor Summary
Constructors Constructor Description Event()
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ActionPostExecutor>
getActionPostExecutors()
Retrieves the action post executors for this event, if extra actions need to be executed after all Rule-triggered actions have been processedMap<String,Object>
getAttributes()
Retrieves the attributes.String
getEventType()
Retrieves the event type.Map<String,Object>
getFlattenedProperties()
Retrieves the flattened propertiesObject
getNestedProperty(String name)
Retrieves the value of the nested property identified by the specified name.Profile
getProfile()
Retrieves the profile.String
getProfileId()
Retrieves the profile identifier of the Profile associated with this eventMap<String,Object>
getProperties()
Retrieves the properties.Object
getProperty(String name)
Retrieves the value of the property identified by the specified name.Session
getSession()
Retrieves the session.String
getSessionId()
Retrieves the session identifier if available.Item
getSource()
Retrieves the source.Item
getTarget()
Retrieves the target.Date
getTimeStamp()
Retrieves the event time stampboolean
isPersistent()
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
setSource(Item source)
Sets the source.void
setTarget(Item target)
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 Detail
-
ITEM_TYPE
public static final String ITEM_TYPE
The Event ITEM_TYPE.
-
HTTP_REQUEST_ATTRIBUTE
public static final String HTTP_REQUEST_ATTRIBUTE
A constant for the name of the attribute that can be used to retrieve the current HTTP request.- See Also:
- Constant Field Values
-
HTTP_RESPONSE_ATTRIBUTE
public static final String HTTP_RESPONSE_ATTRIBUTE
A constant for the name of the attribute that can be used to retrieve the current HTTP response.- See Also:
- Constant Field Values
-
CLIENT_ID_ATTRIBUTE
public static final String CLIENT_ID_ATTRIBUTE
A constant for the name of the attribute that can be used to retrieve the current clientID.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
getSessionId
public String getSessionId()
Retrieves the session identifier if available.- Returns:
- the session identifier or
null
if unavailable
-
setSessionId
public void setSessionId(String sessionId)
Set the session id- Parameters:
sessionId
- the session id
-
getProfileId
public String getProfileId()
Retrieves the profile identifier of the Profile associated with this event- Returns:
- the profile id
-
setProfileId
public void setProfileId(String profileId)
Sets the profile id.- Parameters:
profileId
- the profile id
-
getEventType
public String getEventType()
Retrieves the event type.- Returns:
- the event type
-
setEventType
public void setEventType(String eventType)
Sets the event type- Parameters:
eventType
- the event type
-
getTimeStamp
public Date getTimeStamp()
Retrieves the event time stamp- Specified by:
getTimeStamp
in interfaceTimestampedItem
- Returns:
- the event time stamp
-
setTimeStamp
public void setTimeStamp(Date timeStamp)
- Parameters:
timeStamp
- set the time stamp
-
getProfile
public Profile getProfile()
Retrieves the profile.- Returns:
- the profile
-
setProfile
public void setProfile(Profile profile)
Sets the profile.- Parameters:
profile
- the profile
-
getSession
public Session getSession()
Retrieves the session.- Returns:
- the session
-
setSession
public void setSession(Session session)
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
public Map<String,Object> 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
public void setAttributes(Map<String,Object> attributes)
Sets the map of attribues- Parameters:
attributes
- the attributes map
-
setProperty
public void setProperty(String name, Object value)
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
public Object getProperty(String name)
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
public Object getNestedProperty(String name)
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
public Map<String,Object> getProperties()
Retrieves the properties.- Returns:
- the properties
-
setProperties
public void setProperties(Map<String,Object> properties)
Sets map of properties that will override existing field if it exists- Parameters:
properties
- Map of new Properties
-
getFlattenedProperties
public Map<String,Object> getFlattenedProperties()
Retrieves the flattened properties- Returns:
- the flattened properties.
-
setFlattenedProperties
public void setFlattenedProperties(Map<String,Object> flattenedProperties)
Set the flattened properties for current event- Parameters:
flattenedProperties
- the properties
-
getSource
public Item getSource()
Retrieves the source.- Returns:
- the source
-
setSource
public void setSource(Item source)
Sets the source.- Parameters:
source
- the source
-
getTarget
public Item getTarget()
Retrieves the target.- Returns:
- the target
-
setTarget
public void setTarget(Item target)
Sets the target.- Parameters:
target
- the target
-
getActionPostExecutors
public List<ActionPostExecutor> 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
public void setActionPostExecutors(List<ActionPostExecutor> actionPostExecutors)
Sets the action post executors.- Parameters:
actionPostExecutors
- the action post executors
-
-