Class EventDto

java.lang.Object
com.qfs.snl.dtos.EventDto
All Implemented Interfaces:
ISentinelEvent, ILocatedResource, ISiteLocated, IIdentifiable, Serializable

public class EventDto extends Object implements ISentinelEvent, Serializable
The data transfer object for an event.
Author:
ActiveViam
See Also:
  • Constructor Details Link icon

    • EventDto Link icon

      public EventDto(long monitorId, String site, Map<String,String> updatedResource, long timestamp, Double previousStatus, Double status, List<StateDto> states)
      Constructor for unpersisted event.

      This does not include the event id since it is not yet defined.

      Parameters:
      monitorId - id of the related monitor
      site - the site where the event lives
      updatedResource - the concerned resource
      timestamp - datetime (in ms) of the event
      previousStatus - the preivous current monitoring status
      status - current monitoring status
      states - states of the monitoring at the time of the timestamp
    • EventDto Link icon

      public EventDto(long id, String site, long monitorId, Map<String,String> updatedResource, long timestamp, Double previousStatus, Double status, List<StateDto> states)
      Full constructor.
      Parameters:
      id - unique id of the event
      site - the site where the event lives
      monitorId - id of the related monitor
      updatedResource - the concerned resource
      timestamp - datetime (in ms) of the event
      previousStatus - the preivous current monitoring status
      status - current monitoring status
      states - states of the monitoring at the time of the timestamp
    • EventDto Link icon

      public EventDto(ISentinelEvent event)
      Constructor.
      Parameters:
      event - ISentinelEvent used to generate this Dto.
    • EventDto Link icon

      public EventDto()
      Constructor.
  • Method Details Link icon

    • getId Link icon

      public long getId()
      Description copied from interface: IIdentifiable
      Gets the resource id.
      Specified by:
      getId in interface IIdentifiable
      Returns:
      the id
    • setId Link icon

      public void setId(long id)
      Sets the event unique id.
    • getSite Link icon

      public String getSite()
      Description copied from interface: ISiteLocated
      Gets the site where the element is located.
      Specified by:
      getSite in interface ISiteLocated
      Returns:
      the site
    • setSite Link icon

      public void setSite(String site)
      Sets the agent site.
    • getMonitorId Link icon

      public long getMonitorId()
      Description copied from interface: ISentinelEvent
      Return the id of the monitor that produced the event.
      Specified by:
      getMonitorId in interface ISentinelEvent
      Returns:
      the id of the monitor
    • setMonitorId Link icon

      public void setMonitorId(long monitorId)
      Sets the id of the underlying monitor.
    • getUpdatedResource Link icon

      public Map<String,String> getUpdatedResource()
      Description copied from interface: ISentinelEvent
      Gets a string representation of the updated resource.

      This does support a null value. It will be considered as a valid representation, meaning that all event with a null resource are considered as updates on the same resource.

      Specified by:
      getUpdatedResource in interface ISentinelEvent
      Returns:
      the updated resource
    • setUpdatedResource Link icon

      public void setUpdatedResource(Map<String,String> updatedResource)
      Sets the list of data that are reported as updated through this event.
    • getTimestamp Link icon

      public long getTimestamp()
      Description copied from interface: ISentinelEvent
      Return the timestamp in milliseconds when the action occurred.
      Specified by:
      getTimestamp in interface ISentinelEvent
      Returns:
      the timestamp in milliseconds
    • setTimestamp Link icon

      public void setTimestamp(long timestamp)
      Sets the time of this event.
      Parameters:
      timestamp - date time in milliseconds
    • getPreviousStatus Link icon

      public Double getPreviousStatus()
      Description copied from interface: ISentinelEvent
      Return the previous status of this event If null it means that the state has started.
      Specified by:
      getPreviousStatus in interface ISentinelEvent
      Returns:
      the previous status of the event
    • setPreviousStatus Link icon

      public void setPreviousStatus(Double previousStatus)
      Sets the previous state of the event.
    • getStatus Link icon

      public Double getStatus()
      Description copied from interface: ISentinelEvent
      Return the status of this event If null it means that the state has ended.
      Specified by:
      getStatus in interface ISentinelEvent
      Returns:
      the status of the event
    • setStatus Link icon

      public void setStatus(Double status)
      Sets the current status.
    • getStates Link icon

      public List<? extends ISentinelState> getStates()
      Description copied from interface: ISentinelEvent
      Gets the state of the event.
      Specified by:
      getStates in interface ISentinelEvent
      Returns:
      the list of states representing the event state
    • setStates Link icon

      public void setStates(List<StateDto> states)
      Sets the list of states reported through this event.
    • addSentinelState Link icon

      public void addSentinelState(String stateId, String caption, Double value, String formattedValue)
      Adds a state to the event.
      Parameters:
      stateId - list of states unique id
      caption - list of caption
      value - raw value
      formattedValue - formatted value
    • hashCode Link icon

      public int hashCode()

      Cache the hashcode for performance reasons, as this object is supposed to be immutable

      Overrides:
      hashCode in class Object
    • hashCode Link icon

      public static int hashCode(ISentinelEvent event)
      Compute the hashcode of the given ISentinelEvent.
      Parameters:
      event - an ActiveMonitor event
      Returns:
      the hashcode for the given object
    • equals Link icon

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals Link icon

      public static boolean equals(ISentinelEvent event, Object obj)
      Tests the equality between a ISentinelEvent and an object.

      Two events are equals if they concern the same monitor (id + site) and the same resource, at the same time. They must represent the same transition resulting in the same states.
      This is consistent for an append-only resource.

      Parameters:
      event - the reference event
      obj - the object to test
      Returns:
      true for equality
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • toString Link icon

      public static String toString(ISentinelEvent event)
      Generates String representation of the given ISentinelEvent.
      Parameters:
      event - ISentinelEvent to describe
      Returns:
      string representation of the given event