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:
  • Field Details

    • ITEM_TYPE

      public static final String ITEM_TYPE
      The Event ITEM_TYPE.
      See Also:
    • 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:
    • 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:
    • 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:
  • 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 identifier
      eventType - the event type identifier
      session - the session associated with the event
      profile - the profile associated with the event
      scope - the scope from which the event is issued
      source - the source of the event
      target - the target of the event if any
      timestamp - 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 identifier
      session - the session associated with the event
      profile - the profile associated with the event
      scope - the scope from which the event is issued
      source - the source of the event
      target - the target of the event if any
      timestamp - 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 identifier
      session - the session associated with the event
      profile - the profile associated with the event
      scope - the scope from which the event is issued
      source - the source of the event
      target - the target of the event if any
      properties - the properties for this event if any
      timestamp - the timestamp associated with the event if provided
      persistent - 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 identifier
      eventType - the event type identifier
      session - the session associated with the event
      profile - the profile associated with the event
      scope - the scope from which the event is issued
      source - the source of the event
      target - the target of the event if any
      properties - the properties for this event if any
      timestamp - the timestamp associated with the event if provided
      persistent - specifies if the event needs to be persisted
  • Method Details

    • 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 interface TimestampedItem
      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 set
      value - 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